[ncl-talk] Fwd: Adding Up Files
Tim Melino
melino33 at gmail.com
Wed Nov 25 03:51:12 MST 2015
Hi,
I am trying to add up reflectivity values from a bunch of netcdf radar data
but I can't quite get it to work. I have 75 files to loop over and I am
trying to add to the total each iteration. I have attached the code below.
If anyone has any ideas how to put this together correctly that would be
great!
;========================
; get list of all files and open as "one big file"
;========================
fils = systemfunc ("ls ./grids/ncf*.nc") ; file paths
a = addfiles (fils, "r")
ListSetType (a, "cat") ; concatenate (=default)
type = "png"
wks = gsn_open_wks(type, "radar")
; Set some Basic Plot options
res = True
res at gsnDraw = False ; do not draw the plot
res at gsnFrame = False ; do not advance the frame
pltres = True
pltres at NoTitles = True
pltres at CommonTitle = True
pltres at PlotTitle = "Radar Reflectivity DbZ"
pltres at PanelPlot = True
pltres at FramePlot = False
; Set the Colormap
gsn_define_colormap(wks,"WhBlGrYeRe")
FillValue = 0
lat = a[0]->lat0(:,:)
lon = a[0]->lon0(:,:)
total = 75
i = 0
do while(i.le.total)
;print (i)
if ( i .gt. 0 ) then
ref_save = a[i]->REF(0,0,:,:)
ref_save = where(ref_save.lt.45,FillValue,ref_save)
ref_tot = ref_tot + ref_save
;print (ref_save)
else
ref_tot = a[i]->REF(0,0,:,:)
ref_tot = where(ref_tot.lt.45,FillValue,ref_tot)
end if
i=i+1
end do
Thanks in advance!
-Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151125/3441c926/attachment.html
More information about the ncl-talk
mailing list