Sure, just loose the [i] and it will work.<div><br></div><div>ref= where(ref.lt.45, FillValue, ref)</div><div><br></div><div>Maria<br><br>On Wednesday, November 25, 2015, Tim Melino <<a href="mailto:melino33@gmail.com">melino33@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Is it possible to do something like this on each member of the array:<div><br></div><div> ref[i] = where(ref[i].lt.45,FillValue,ref[i])<br></div><div><br></div><div>Then sum up the values?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 25, 2015 at 4:17 PM, Tim Melino <span dir="ltr"><<a href="javascript:_e(%7B%7D,'cvml','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">Hi Maria, <div><br></div><div>Each file is a single time I am trying to read in the first scan level so I think the answer to your question is yes. Here is the variable summary for the field I am reading: </div><div><br></div><div><div>Variable: ref</div><div>Type: float</div><div>Total Size: 161604 bytes</div><div> 40401 values</div><div>Number of Dimensions: 2</div><div>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[y0 | 201] x [x0 | 201]</div><div>Coordinates: </div><div> y0: [-100..100]</div><div> x0: [-100..100]</div><div>Number Of Attributes: 10</div><div> grid_mapping :<span style="white-space:pre-wrap">        </span>grid_mapping_0</div><div> coordinates :<span style="white-space:pre-wrap">        </span>lon0 lat0</div><div> units :<span style="white-space:pre-wrap">        </span>dBZ</div><div> long_name :<span style="white-space:pre-wrap">        </span>radar_reflectivity</div><div> standard_name :<span style="white-space:pre-wrap">        </span>REF</div><div> valid_max :<span style="white-space:pre-wrap">        </span>47.81145</div><div> valid_min :<span style="white-space:pre-wrap">        </span>-25.57751</div><div> time :<span style="white-space:pre-wrap">        </span>1427402261</div><div> z0 :<span style="white-space:pre-wrap">        </span> 1</div><div> _FillValue :<span style="white-space:pre-wrap">        </span>-9999</div></div><div><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 25, 2015 at 1:50 PM, Maria Gehne - NOAA Affiliate <span dir="ltr"><<a href="javascript:_e(%7B%7D,'cvml','maria.gehne@noaa.gov');" target="_blank">maria.gehne@noaa.gov</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">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"><div><div>On Wed, Nov 25, 2015 at 3:51 AM, Tim Melino <span dir="ltr"><<a href="javascript:_e(%7B%7D,'cvml','melino33@gmail.com');" target="_blank">melino33@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><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><font color="#888888"><span><font color="#888888"><div>-Tim</div></font></span></font></span></div>
<br></div><br></div>
</div><br></div>
<br></div></div>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="javascript:_e(%7B%7D,'cvml','ncl-talk@ucar.edu');" target="_blank">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>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</blockquote></div>