[ncl-talk] Sequences of values

Kiswendsida Hyacinthe GUIGMA karongseba at gmail.com
Sat Mar 24 07:44:08 MDT 2018


Thank you for your reply and for your help. Actually, before to post my question, I tried to make a use of dim_numrun_n but it didn't solve my problem.
You misunderstood a bit my [1]. I said that I successfully did that... So it is OK for that. 
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:X1=(/0,1,0,0,1,1,1,1,1,0,0,1,0,1,1,1,1,0,0,1,0,/) ==========> X2= (/0,0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,/).In other words it is to replace all "isolated" 1s by 0.
Kindest regards




-----------------------------
GUIGMA 

    On Friday, 23 March 2018, 22:17:11 GMT, Dennis Shea <shea at ucar.edu> wrote:  
 
 Sorry, I'm I am not looking at any code.

   tcrit = 30.

   f  = addfile(...)
  T = f->T                  ; (time,lat,lon)


[1] "setting values below the threshold to _FillValue" is simple.

https://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml

   Tcrit = where(T.ge.tcrit, T, T at _FillValue)
   copy_VarMeta(T, Tcrit)
===========
[2] You do not need to do [1]

Maybe you could use the following function:

=========
http://www.ncl.ucar.edu/Document/Functions/Built-in/dim_numrun_n.shtml
***Look at the examples***
=========

  T10= where(T.ge.tcrit,1, 0)  
  T10 at long_name = "Exceed=1; No=0"
  copy_VarCoords(T, T10)
  printVarSummary(T10)
 r0 = dim_numrun_n (T10, 0, 0)  ; (ntim,nlat,mlon)
 r1 = dim_numrun_n (T10, 1, 0)  

 copy_VarCoords(T, r0)
 copy_VarCoords(T, r1)

;---Pick one grid point to see what is happening

  LAT = ..
  LON = ..
  print(T(:,{LAT},{LON})+"  "+Tcrit(:,{LAT},{LON})+"  "+T10(:,{LAT},{LON}) \
                        +"  "r0(:,{LAT},{LON})+"   "+r1(:,{LAT},{LON})    

On Fri, Mar 23, 2018 at 3:29 PM, Kiswendsida Hyacinthe GUIGMA <karongseba at gmail.com> wrote:

Dear NCL users,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.
Please find attached my data and my code.

Regards

-----------------------------
GUIGMA
______________________________ _________________
ncl-talk mailing list
ncl-talk at ucar.edu
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/ mailman/listinfo/ncl-talk



  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180324/98c03580/attachment.html>


More information about the ncl-talk mailing list