[ncl-talk] Vector subscripting (Resending this email. Please respond)
Dennis Shea
shea at ucar.edu
Wed May 9 17:37:05 MDT 2018
[1] There is no indication that you sent any previous email with this topic.
[2] I am not clear on what is desired. Maybe:
ntim = 10000
klev = 50
nrad = 75
data = random_uniform(0, 500, (/ntim,klev,nrad/) ) ; dimension #: (0,
1, 2)
data at _FillValue = -999.0
data!0 = "time"
data!1 = "level"
data!2 = "radii"
rmin = 100.
rmax = 250.
data_rmin = where(data.lt.rmin, data, data at _FillValue)
data_rmax = where(data.gt.rmax, data, data at _FillValue)
data_rmnx = where(data.lt.rmin .or. data.gt.rmax, data at _FillValue, data)
copy_VarMeta(data, data_rmin)
copy_VarMeta(data, data_rmax)
copy_VarMeta(data, data_rmnx)
ndim = 2 ; radii dimension
data_avg_rmin = dim_avg_n_Wrap(data_rmin, ndim)
data_avg_rmin at long_name = "Average of all radii < "+rmin
printVarSummary(data_avg_rmin)
printMinMax(data_avg_rmin,0)
print("---")
data_avg_rmax = dim_avg_n_Wrap(data_rmax, ndim)
data_avg_rmax at long_name = "Average of all radii > "+rmax
printVarSummary(data_avg_rmax)
printMinMax(data_avg_rmax,0)
print("---")
data_avg_rmnx = dim_avg_n_Wrap(data_rmnx, ndim)
data_avg_rmnx at long_name = "Average of all values between rmin= "+rmin+"
and rmax="+rmax
printVarSummary(data_avg_rmnx)
printMinMax(data_avg_rmnx,0)
print("---")
++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++
Note that *clarity is best* but you could avoid the creation of a temporary
array via:
data_avg_rmin = dim_avg_n_Wrap(where(data.lt.rmin, data, data at _FillValue),
ndim)
etc
On Wed, May 9, 2018 at 8:23 AM, Prashanth Bhalachandran <
prashanth.bhalachandran at gmail.com> wrote:
> Dear NCL’ers,
> I have a 3 dimensional variable say M (time x level x radius). Now, I know
> the certain radius RMW at each level (RMW is a function of level) . For
> each time, I’d to average the variable within the radius RMW at each
> height. I want to avoid loops, so I need to use vector subscripting. How do
> I do this averaging?
>
> If RMW was a fixed number like 30, then I’d have simply done a
> dim_avg_n_Wrap( M (:,:,1:30), 2).
>
> Can someone help me out with this?
>
> Thank you,
> Prashanth
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180509/408b9694/attachment.html>
More information about the ncl-talk
mailing list