<div dir="ltr"><div><br></div><div>I think your condition (b) would be the only condition that is needed, since if condition b is true then condition "a" must be true. So, it appears that you do not need condition "a".</div><div>For example, if 80% of grid points for a given time and region has precipitation values greater than zero, then for that particular time and region area average value will always be above zero.</div><div><br></div><div>So I modified your script (see attached) and added a loop to find out those time steps:</div><div><br></div><div>; condition b:<br><br> dims = dimsizes(rain_region)<br> ntime = dims(0)<br> tot_point = dims(1)*dims(2)*1.<br> ids_valid = new(ntime,integer)<br> req_perc = 80. ; 40.<br><br> do n=0,ntime-1<br> tmp_rain = rain_region(n,:,:)<br> oneD = ndtooned(tmp_rain)<br> npnts = 1.*dimsizes(ind(oneD.gt.0))<br> perc = 100.*(npnts/tot_point)<br><br> if(perc.gt.req_perc)then<br> ids_valid(n) = n<br> else<br> print(n+ " ... pertange of grid points is less than 80% = > "+perc)<br> end if<br> delete([/tmp_rain,oneD,npnts,perc/])<br> end do<br><br> if(.not.all(ismissing(ids_valid)))then<br> n_thres = ids_valid(ind(.not.ismissing(ids_valid)))<br> else<br> print(" No valid time step for the specified condition: Exiting")<br> exit<br> end if</div><div><br></div><div><br></div><div>You need to play with the variable
req_perc = 80., by changing to lower values such 40. or anything else to see how it works. In your data file no time step would satisfy the 80% condition.</div><div>hope that helps.<br></div><div>
</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br> </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 9, 2019 at 9:20 AM Lyndz <<a href="mailto:olagueralyndonmark429@gmail.com">olagueralyndonmark429@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div dir="ltr" class="gmail-m_1447874627762431068gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi,</div><div dir="ltr"><br></div><div dir="ltr">This includes all time steps. But, in the file that I sent, I want to <b>count the number of gridpoints in each time step</b> with rainfall above 0. I have to include this in the time filter. Specifically, these two conditions: the area averaged rainfall is > 0 <b><i>and</i></b> at least 80% of the total gridpoints have rainfall > 0.</div><div dir="ltr"><br></div><div>Over the region I specified (rain_region), it has 40 x 30 x 10 (ntim x nlat x nlon).</div><div>The above command you gave results to 5830.</div><div>I can get a similar result by just doing this: <span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0);font-family:Menlo;font-size:11px">a = num(rain_region.gt.0)</span></div>
<div dir="ltr"><div><br></div><div>Sincerely,</div></div></div></div></div></div></div></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 10, 2019 at 12:02 AM Rashed Mahmood <<a href="mailto:rashidcomsis@gmail.com" target="_blank">rashidcomsis@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Yes, there can be several ways of counting grid points with rainfall above 0:</div><div><br></div><div>e.g. say your variable name is "precp"</div><div><br></div><div>oneD = ndtooned(precip)</div><div><br></div><div> nVal = dimsizes(ind(oneD.gt.0))</div><div><br></div><div>nVal is the number of time precip is greater than 0. Does this makes sense, let me know if does not.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 9, 2019 at 11:36 AM Lyndz via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr" class="gmail-m_1447874627762431068gmail-m_-4812331830161380845gmail-m_5494544575195008608gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Dear NCL experts, </div><div><br></div><div>I would like to filter the dates in a NetCDF file when the following conditions are met:</div><div>(a) Area averaged rainfall is greater than 0.</div><div><br></div><div>Area:</div><div> latS = 12.5</div> latN = 20.0<br> lonL = 120.0<br> lonR = 122.5</div><div dir="ltr"><br><div>(b) At least 80% of the grid points within the specified area satisfies (a).</div><div><br></div><div>Attached in this email is the script that I am currently working on.</div><div>The sample data can be accessed here:</div><div><a href="https://www.dropbox.com/s/spfnwb4rhwjo90o/aphro_1979_AMJ.nc?dl=0" target="_blank">https://www.dropbox.com/s/spfnwb4rhwjo90o/aphro_1979_AMJ.nc?dl=0</a><br></div><div><br></div><div><br></div><div><b>[Problem]</b></div><div>I was able to do the condition (a) but is there a way to count the number of grid points with rainfall above 0 over the specified region? How can I add this as another condition for the date filter?</div><div><br></div><div>The time filter is like this:</div><div><br></div><div> rain_threshold = 0<br> rain_aave=wgt_areaave_Wrap(rain_region,1.0,1.0,0)<br> printVarSummary(rain_aave)<br> n_thres = ind(rain_aave .gt. rain_threshold) ;time indices<br> print(n_thres)<br> print("=====")<br></div><div><br></div><div>I'll appreciate any guidance about this. </div><div><br></div><div>Sincerely,</div><div>Lyndz</div><div><br></div><div><br></div><div><br></div></div></div></div></div></div></div></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto: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></blockquote></div>
</blockquote></div>
</blockquote></div>