<div dir="ltr">Sorry I meant to send it to ncl-talk. here it is:<br><div><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Rashed Mahmood</b> <span dir="ltr"><<a href="mailto:rashidcomsis@gmail.com">rashidcomsis@gmail.com</a>></span><br>Date: Mon, Mar 26, 2018 at 3:02 PM<br>Subject: Re: [ncl-talk] Sequences of values<br>To: Kiswendsida Hyacinthe GUIGMA <<a href="mailto:karongseba@gmail.com">karongseba@gmail.com</a>><br><br><br><div dir="ltr">That's too many loops! ...I can not test without data set, what error messages you get when you run this?<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 26, 2018 at 1:20 PM, Kiswendsida Hyacinthe GUIGMA <span dir="ltr"><<a href="mailto:karongseba@gmail.com" target="_blank">karongseba@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><div style="font-family:verdana,helvetica,sans-serif;font-size:16px"><div><div>Please find attached an example of a code. </div><div>My data spans 0 to 35N and 20W to 50E with resolution in both directions of 1*1. It is too big to be uploaded in NCL_talk<br></div><div><br></div><div>Kindest regards<br></div><div><br></div><div class="m_1897331985444617648m_3166969670626823163ydp1275d4d9signature">-----------------------------<br>GUIGMA</div></div>
<div><br></div><div><br></div>
<div id="m_1897331985444617648m_3166969670626823163yahoo_quoted_2571667525" class="m_1897331985444617648m_3166969670626823163yahoo_quoted">
<div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#26282a"><span>
<div>
On Monday, 26 March 2018, 20:40:32 GMT+1, Rashed Mahmood <<a href="mailto:rashidcomsis@gmail.com" target="_blank">rashidcomsis@gmail.com</a>> wrote:
</div>
<div><br></div>
<div><br></div>
</span><div><div id="m_1897331985444617648m_3166969670626823163yiv5187759884"><div><span><div dir="ltr">How does your script look like? and what is the size of input data?<br clear="none"></div></span><div class="m_1897331985444617648m_3166969670626823163yiv5187759884yqt1965475992" id="m_1897331985444617648m_3166969670626823163yiv5187759884yqt40086"><div class="m_1897331985444617648m_3166969670626823163yiv5187759884gmail_extra"><br clear="none"><div class="m_1897331985444617648m_3166969670626823163yiv5187759884gmail_quote"><span>On Mon, Mar 26, 2018 at 8:45 AM, Kiswendsida Hyacinthe GUIGMA <span dir="ltr"><<a rel="nofollow" shape="rect" href="mailto:karongseba@gmail.com" target="_blank">karongseba@gmail.com</a>></span> wrote:<br clear="none"></span><blockquote class="m_1897331985444617648m_3166969670626823163yiv5187759884gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:verdana,helvetica,sans-serif;font-size:16px"><span><div>Hi Rashed and everyone,</div><div>Thank you for your suggestion.</div><div>I also had the idea of using many loops. It works perfectly for no large data. But when it comes to apply it to a 3D data covering half of the Africa domain, it slows down the execution and ends up killing the process. That's why I was thinking that there exist an other way to do that using not as much iterations.</div><div><br clear="none"></div><div>Best<br clear="none"><div><br clear="none"></div><div><br clear="none"></div><div class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683ydpdd8a04cfsignature">-----------------------------<br clear="none">GUIGMA</div></div></span><div><div class="m_1897331985444617648m_3166969670626823163yiv5187759884h5">
<div><br clear="none"></div><div><br clear="none"></div>
<div class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yahoo_quoted" id="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yahoo_quoted_3048719941">
<div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#26282a"><span>
<div>
On Saturday, 24 March 2018, 18:30:38 GMT, Rashed Mahmood <<a rel="nofollow" shape="rect" href="mailto:rashidcomsis@gmail.com" target="_blank">rashidcomsis@gmail.com</a>> wrote:
</div>
<div><br clear="none"></div>
<div><br clear="none"></div>
</span><div><div id="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430"><div><div dir="ltr"><div><div><div><span><div>Hi Guigma,<br clear="none"></div>For 1 dimensional series you can use the following. however, you would need to adapt this to your 3D data sets through loops/ind function and need to do TESTING, this is a very time consuming process.<br clear="none">begin<br clear="none">; X1 = (/0,1,0,0,1,1,1,1,1,0,0,1,0,1, 1,1,1,0,0,1,0/) ; orignal <br clear="none"></span> X1 = (/0,1,0,0,1,1,1,1,1,0,0,1,0,1, 1,1,1,0,0,1,0,1,1,0,0,1,0,1,0, 1,1/) ; for testing<div><div class="m_1897331985444617648h5"><br clear="none"><br clear="none"> X2 = new(dimsizes(X1),integer)<br clear="none"><br clear="none"> do n=0,dimsizes(X1)-1<br clear="none"> if(n.eq.0)<br clear="none"> if(X1(n).eq.1.and.X1(n+1).eq. 0)<br clear="none"> X2(n) = 0<br clear="none"> else<br clear="none"> X2(n) = X1(n)<br clear="none"> end if<br clear="none"> end if<br clear="none"><br clear="none"> if(n.gt.0.and.n.lt.dimsizes( X1)-1)<br clear="none"> if(X1(n).eq.1)<br clear="none"> if(X1(n-1).eq.0.and.X1(n+1). eq.0)<br clear="none"> X2(n) = 0<br clear="none"> else<br clear="none"> X2(n) = X1(n)<br clear="none"> end if<br clear="none"> else<br clear="none"> X2(n) = X1(n)<br clear="none"> end if<br clear="none"><br clear="none"> end if<br clear="none"><br clear="none"> if(n.eq.dimsizes(X1)-1)<br clear="none"> if(X1(n).eq.1.and.X1(n-1).eq. 1)<br clear="none"> X2(n) = X1(n)<br clear="none"> else<br clear="none"> X2(n) = 0<br clear="none"> end if<br clear="none"> end if<br clear="none"> end do<br clear="none"> print(X1+" ... "+X2)<br clear="none"><br clear="none">end<br clear="none"><br clear="none"><br clear="none"></div></div></div><div><div class="m_1897331985444617648h5">Note I have NOT tested it as much one should so I would let you to test and find out if that is what you are looking for.<br clear="none"><br clear="none"></div></div></div>Cheers,<br clear="none"></div>Rashed<br clear="none"><div><div><br clear="none"><br clear="none"><div><br clear="none"><br clear="none"><br clear="none"><br clear="none"></div></div></div></div><div><div class="m_1897331985444617648h5"><div class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430gmail_extra"><br clear="none"><div class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430gmail_quote">On Sat, Mar 24, 2018 at 6:44 AM, Kiswendsida Hyacinthe GUIGMA <span dir="ltr"><<a rel="nofollow" shape="rect" href="mailto:karongseba@gmail.com" target="_blank">karongseba@gmail.com</a>></span> wrote:<br clear="none"><blockquote class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430yqt3038823429" id="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430yqt43503"><div><div style="font-family:verdana,helvetica,sans-serif;font-size:16px"><div>Thank you for your reply and for your help. </div><div>Actually, before to post my question, I tried to make a use of dim_numrun_n but it didn't solve my problem.</div><div><br clear="none"></div><div>You misunderstood a bit my [1]. I said that I successfully did that... So it is OK for that.</div><div> </div><div><br clear="none"></div><div>For [2] , what the dim_numrun_n function allows is just to do a count. What me I'd rather like is to set to _FillValue (or to 0 if use of where function) all values that are not in a sequence of at least 04 days. As an example I would like to have something as follows:</div><div>X1=(/0,1,0,0,1,1,1,1,1,0,0,1, 0,1,1,1,1,0,0,1,0,/) ==========> X2= (/0,<b>0</b>,0,0,1,1,1,1,1,0,0,<b>0</b>,0,1, 1,1,1,0,0,<b>0</b>,0,/).</div><div>In other words it is to replace all "isolated" 1s by 0.</div><div><br clear="none"></div><div>Kindest regards<br clear="none"><pre><b></b><br clear="none"></pre><br clear="none"><div><br clear="none"></div><div><br clear="none"></div><div class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430m_-12244688286929487ydp2124e450signature">-----------------------------<br clear="none">GUIGMA</div></div>
<div><br clear="none"></div><div><br clear="none"></div><div>
</div><div class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430m_-12244688286929487yahoo_quoted" id="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430m_-12244688286929487yahoo_quoted_2361277437">
<div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#26282a">
<div>
On Friday, 23 March 2018, 22:17:11 GMT, Dennis Shea <<a rel="nofollow" shape="rect" href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:
</div>
<div><br clear="none"></div>
<div><br clear="none"></div>
<div><div id="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430m_-12244688286929487yiv0687598992"><div><div dir="ltr"><div><div><div><div><div><div><div><div>Sorry, I'm I am not looking at any code.<br clear="none"></div><div><br clear="none"></div> tcrit = 30.<br clear="none"><br clear="none"></div> f = addfile(...)<br clear="none"></div> T = f->T ; (time,lat,lon)<br clear="none"><br clear="none"><br clear="none">[1] "setting
values below the threshold to _FillValue" is simple.<br clear="none"><br clear="none"><a rel="nofollow" shape="rect" href="https://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml" target="_blank">https://www.ncl.ucar.edu/ Document/Functions/Built-in/ where.shtml</a><br clear="none"><br clear="none"></div> Tcrit = where(T.ge.tcrit, T, T@_FillValue)<br clear="none"></div> copy_VarMeta(T, Tcrit)<br clear="none">===========<br clear="none"></div><div>[2] You do not need to do [1]<br clear="none"><br clear="none"></div><div>Maybe you could use the following function:<br clear="none"><br clear="none"></div><div>=========<br clear="none"><div><a rel="nofollow" shape="rect" href="http://www.ncl.ucar.edu/Document/Functions/Built-in/dim_numrun_n.shtml" target="_blank">http://www.ncl.ucar.edu/ Document/Functions/Built-in/ dim_numrun_n.shtml</a><br clear="none"></div><b>***Look at the examples***</b><br clear="none">=========<br clear="none"><br clear="none"></div> T10= where(T.ge.tcrit,1, 0) <br clear="none"></div><div> T10@long_name = "Exceed=1; No=0"<br clear="none"></div> copy_VarCoords(T, T10)<br clear="none"></div> printVarSummary(T10)<br clear="none"><div><div><pre> r0 = <b>dim_numrun_n</b> (T10, <b>0</b>, 0) ; (ntim,nlat,mlon)
r1 = <b>dim_numrun_n</b> (T10, <b>1</b>, 0)
<br clear="none"> copy_VarCoords(T, r0)<br clear="none"> copy_VarCoords(T, r1)<br clear="none"><br clear="none"></pre><pre>;---Pick one grid point to see what is happening<br clear="none"><br clear="none"></pre><pre> LAT = ..<br clear="none"> LON = ..<br clear="none"> print(T(:,{LAT},{LON})+" "+Tcrit(:,{LAT},{LON})+" "+T10(:,{LAT},{LON}) \<br clear="none"> +" "r0(:,{LAT},{LON})+" "+r1(:,{LAT},{LON})</pre><div><div> <br clear="none"></div></div></div></div></div><div class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430m_-12244688286929487yiv0687598992gmail_extra"><br clear="none"><div class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430m_-12244688286929487yiv0687598992gmail_quote">On Fri, Mar 23, 2018 at 3:29 PM, Kiswendsida Hyacinthe GUIGMA <span dir="ltr"><<a rel="nofollow" shape="rect" href="mailto:karongseba@gmail.com" target="_blank">karongseba@gmail.com</a>></span> wrote:<br clear="none"><blockquote class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430m_-12244688286929487yiv0687598992gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430m_-12244688286929487yiv0687598992yqt6827108155" id="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430m_-12244688286929487yiv0687598992yqt42772"><div><div style="font-family:verdana,helvetica,sans-serif;font-size:16px"><div style="font-family:verdana,helvetica,sans-serif;font-size:16px"><div style="font-family:verdana,helvetica,sans-serif;font-size:16px"><div><div>Dear NCL users,</div><div>I have 3D (time,lat,lon) array of
temperature from which I would like to keep only sequences (consecutive
days) exceeding a certain threshold. This consist concretely in setting
values below the threshold to _FillValue. The length of sequence is
set to 4. So far, have been able to set to _FillValu only individual
days that exceed the threshold. Then I would be pleased if you could
provide me with a method to also set to _FillValue values that are not
into sequences of at least 04 days.</div><div><br clear="none"></div><div>Please find attached my data and my code.<br clear="none"></div><div><br clear="none"></div>Regards<div><br clear="none"></div><div><br clear="none"></div><div class="m_1897331985444617648m_3166969670626823163yiv5187759884m_6032098021478253683yiv0791746430m_-12244688286929487yiv0687598992m_7026875322926614417ydp786f0203signature">-----------------------------<br clear="none">GUIGMA</div></div></div></div></div></div></div><br clear="none">______________________________ _________________<br clear="none">
ncl-talk mailing list<br clear="none">
<a rel="nofollow" shape="rect" href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br clear="none">
List instructions, subscriber options, unsubscribe:<br clear="none">
<a rel="nofollow" shape="rect" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/ mailman/listinfo/ncl-talk</a><br clear="none">
<br clear="none"></blockquote></div><br clear="none"></div></div></div></div>
</div>
</div></div></div></div><br clear="none">______________________________ _________________<br clear="none">
ncl-talk mailing list<br clear="none">
<a rel="nofollow" shape="rect" href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br clear="none">
List instructions, subscriber options, unsubscribe:<br clear="none">
<a rel="nofollow" shape="rect" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/ mailman/listinfo/ncl-talk</a><br clear="none">
<br clear="none"></blockquote></div><br clear="none"></div></div></div></div></div></div>
</div>
</div></div></div></div></div></blockquote></div><br clear="none"></div></div></div></div></div>
</div>
</div></div></div></blockquote></div><br></div>
</div></div></div><br></div></div>