<div dir="ltr"><div><div><div><div>Hi Guigma,<br></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>begin<br>; X1 = (/0,1,0,0,1,1,1,1,1,0,0,1,0,1,1,1,1,0,0,1,0/) ; orignal <br> 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<br><br> X2 = new(dimsizes(X1),integer)<br><br> do n=0,dimsizes(X1)-1<br> if(n.eq.0)<br> if(X1(n).eq.1.and.X1(n+1).eq.0)<br> X2(n) = 0<br> else<br> X2(n) = X1(n)<br> end if<br> end if<br><br> if(n.gt.0.and.n.lt.dimsizes(X1)-1)<br> if(X1(n).eq.1)<br> if(X1(n-1).eq.0.and.X1(n+1).eq.0)<br> X2(n) = 0<br> else<br> X2(n) = X1(n)<br> end if<br> else<br> X2(n) = X1(n)<br> end if<br><br> end if<br><br> if(n.eq.dimsizes(X1)-1)<br> if(X1(n).eq.1.and.X1(n-1).eq.1)<br> X2(n) = X1(n)<br> else<br> X2(n) = 0<br> end if<br> end if<br> end do<br> print(X1+" ... "+X2)<br><br>end<br><br><br></div>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><br></div>Cheers,<br></div>Rashed<br><div><div><br><br><div><br><br><br><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 24, 2018 at 6:44 AM, 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>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></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></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,<wbr>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,<wbr>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></div><div>Kindest regards<br><pre><strong></strong><br></pre><br><div><br></div><div><br></div><div class="m_-12244688286929487ydp2124e450signature">-----------------------------<br>GUIGMA</div></div>
<div><br></div><div><br></div><div>
</div><div id="m_-12244688286929487yahoo_quoted_2361277437" class="m_-12244688286929487yahoo_quoted">
<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 href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:
</div>
<div><br></div>
<div><br></div>
<div><div id="m_-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/<wbr>Document/Functions/Built-in/<wbr>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/<wbr>Document/Functions/Built-in/<wbr>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 = <strong>dim_numrun_n</strong> (T10, <b>0</b>, 0) ; (ntim,nlat,mlon)
r1 = <strong>dim_numrun_n</strong> (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_-12244688286929487yiv0687598992gmail_extra"><br clear="none"><div class="m_-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_-12244688286929487yiv0687598992gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-12244688286929487yiv0687598992yqt6827108155" id="m_-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_-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><br>______________________________<wbr>_________________<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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>