<div dir="ltr">Hi Tim,<div><br></div><div>what are the dimensions of REF in each file? Are you really trying to read only the first level/time (or whatever the first two dimensions are)?</div><div><br></div><div>I would get rid of the loop entirely. Join the files instead of concatenating, that gives you an extra dimension. And then you can just sum over the first dimension. So:</div><div><br></div><div>ref = a[:]-><span style="font-size:13px">REF(0,0,:,:)   ; now ref is 75 x nlat x nlon</span></div><div class="gmail_extra"><br></div><div class="gmail_extra">ref_tot = dim_sum_n_Wrap(ref,0)   ; sums over the first dimension and keeps meta-data</div><div class="gmail_extra"><br></div><div class="gmail_extra">Hop this helps,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Maria</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 25, 2015 at 3:51 AM, Tim Melino <span dir="ltr"><<a href="mailto:melino33@gmail.com" target="_blank">melino33@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">Hi, <div><br></div><div>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!</div><div><br></div><div><div>  ;========================</div><div>  ; get list of all files and open as "one big file"</div><div>  ;========================                             </div><div>   fils = systemfunc ("ls ./grids/ncf*.nc") ; file paths</div><div>   a    = addfiles (fils, "r")   </div><div>   ListSetType (a, "cat")        ; concatenate (=default)</div><div><br></div><div>  type = "png"</div><div>  wks = gsn_open_wks(type, "radar")</div><div><br></div><div>; Set some Basic Plot options</div><div>  res = True</div><div>  res@gsnDraw      =  False                   ; do not draw the plot</div><div>  res@gsnFrame     =  False                   ; do not advance the frame</div><div>  pltres = True</div><div>  pltres@NoTitles = True</div><div>  pltres@CommonTitle = True</div><div>  pltres@PlotTitle = "Radar Reflectivity DbZ"</div><div>  pltres@PanelPlot = True</div><div>  pltres@FramePlot = False</div><div> </div><div>; Set the Colormap  </div><div>  gsn_define_colormap(wks,"WhBlGrYeRe")</div><div>    FillValue = 0    </div><div>    lat  = a[0]->lat0(:,:)</div><div>    lon  = a[0]->lon0(:,:)</div><div><br></div><div>   total = 75</div><div>   i = 0</div><div>   do while(i.le.total)</div><div>      ;print (i)</div><div>      if ( i .gt. 0 ) then</div><div>      ref_save = a[i]->REF(0,0,:,:) </div><div>      ref_save = where(ref_save.lt.45,FillValue,ref_save)</div><div>      ref_tot = ref_tot + ref_save</div><div>      ;print (ref_save)</div><div>      else </div><div>       ref_tot = a[i]->REF(0,0,:,:)     </div><div>       ref_tot = where(ref_tot.lt.45,FillValue,ref_tot)</div><div>      end if</div><div><br></div><div>   i=i+1</div><div>   end do</div></div><div><br></div><div><br></div><div><br></div><div><br></div><div>Thanks in advance! </div><span class="HOEnZb"><font color="#888888"><span><font color="#888888"><div>-Tim</div></font></span></font></span></div>
<br></div><br></div>
</div><br></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div></div>