[ncl-talk] Binning multilevel MODIS data using bin_sum
Alan Brammer
abrammer at albany.edu
Tue May 3 07:15:53 MDT 2016
I’ve had weird issues with bin_sum() and looping over arrays in the past.
My solution has usually been to pass a temporary variable to bin_sum() then set your GBIN array to that temp variable.
e.g. unchanged lines omitted for brevity.
do nf=0,nfil-1
do lev=0,nlev-1
….
tmp_var = GBIN(lev,:,:) ;; This could be defined outside of loop and just reset to zero for each loop.
tmp_var = 0
tmp_ct = toint(tmp_var) ;; as above doesn’t need to be redefined each loop just set to 0 each time.
bin_sum(tmp_var, tmp_ct, ,lon,lat , ndtooned(lon2d),ndtooned(lat2d),ndtooned(x) )
GBIN(lev,:,:) = tmp_var
GKNT(lev,:,:) = tmp_ct
…
end
Alan
##############################
Alan Brammer,
Post-Doc Researcher
Department of Atmospheric and Environmental Sciences,
University at Albany, State University of New York, Albany, NY, 12222
abrammer at albany.edu
##############################
> On 3 May 2016, at 04:43, AJILESH PP <ajileshparolla at gmail.com> wrote:
>
> Hi all, I modified the loop, but still I'm getting same data values on all 20 levels. Can anybody please tell me where I went wrong?
>
> On Sat, 23 Apr 2016 at 02:41 AJILESH PP <ajileshparolla at gmail.com <mailto:ajileshparolla at gmail.com>> wrote:
> Hi,
> Thank You for the prompt reply. Sorry for the mistake, Now loop is working output has 20 levels, but all the levels have the same data values (all levels are same).
>
> On Thu, 21 Apr 2016 at 20:56 Rick Brownrigg <brownrig at ucar.edu <mailto:brownrig at ucar.edu>> wrote:
> Hi,
>
> I'm not totally sure, but I wonder if "level" in this line should be "lev"?
>
>
> bin_sum(GBIN(level,:,:),GKNT(level,:,:),lon,lat \
>
> In any case, a few strategic print() statements on your indexing variables will show where/when thing go arwy.
>
> HTH...
> Rick
>
>
> On Thu, Apr 21, 2016 at 7:10 AM, AJILESH PP <ajileshparolla at gmail.com <mailto:ajileshparolla at gmail.com>> wrote:
> Dear all
> I want to bin MODIS level 2 products for a period of time. I modified an example script given in ncl HDF examples and it is giving me only output of a single level, where the desired output is for 20 levels. I tried to add a level loop and level dimension also as shown in the script below.
> --------------------------------------
> GBIN = new ( (/nlev,nlat,mlon/), float )
> GKNT = new ( (/nlev,nlat,mlon/), integer )
>
> snip
>
> do nf=0,nfil-1
> do lev=0,nlev-1
> print(nf+" "+fili(nf))
> f = addfile(diri+fili(nf), "r")
> ; read data
> x = short2flt_hdf( f->$vNam$ )
> lat2d1 = f->Latitude
> lon2d1 = f->Longitude
> lat2d = conform(x,lat2d1,(/1,2/))
> lon2d = conform(x,lon2d1,(/1,2/))
> level = (/1000,950,920,850,700,620,500,400,300,250,200,100,150,100,70,50,30,20,10,5/)
> x!0 = "level"
> x&level = level
> nx = product(dimsizes(x))
> bin_sum(GBIN(level,:,:),GKNT(level,:,:),lon,lat \
> ,ndtooned(lon2d),ndtooned(lat2d),ndtooned(x) )
> printVarSummary(x)
> ---------------------------------------
> but it is giving this error:
> fatal:Subscript out of range, error in subscript #0
> fatal:An error occurred reading GBIN
>
> Can anybody help me to resolve this issue?
> Please find my script and data as follows
> Data: MOD07_L2.A2012166.0*.hdf
> Script: bin.ncl
>
> Any help would be appreciated
> Thank You!
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
> _______________________________________________
> 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/20160503/d5820785/attachment.html
More information about the ncl-talk
mailing list