[ncl-talk] Fwd: Sequences of values

Rashed Mahmood rashidcomsis at gmail.com
Tue Mar 27 11:09:36 MDT 2018


Are you sure there is no error message? when I run your script I get this
error message:

fatal:Subscript out of range, error in subscript #0
fatal:An error occurred reading wakato
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 89 in file
IND1_ERA_1_1_Tn_4d.ncl

I am using NCL 6.4 and if you are not already using 6.4 then you should
consider upgrading to 6.4.

Reason for error:

Line 89 is:

mmm:=wakato(ind(.not.ismissing(wakato)))

and the error message is caused by "wakato" which is missing due to your
conditional statements in previous lines.

So to check this I added an if statement (see in the attached script) to
see if "wakato" is always missing or not, and it seems that it is missing,
here is part of the output message I get:

 Copyright (C) 1995-2017 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 6.4.0
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.
(0)     missing ...
(0)     missing ...
(0)     missing ...
(0)     missing ...
(0)     missing ...
(0)     missing ...
(0)     missing ...
(0)     missing ...
(0)     missing ...
(0)     missing ...
(0)     missing ...
(0)     missing ...
(0)     missing ...
(0)     missing ...
.... so on


It would be better if you can check carefully the logic for each
conditional statement and the output from it, to see if that is what you
want.

Note that as I had mentioned in my first message that I would not be able
to test the code for 3D data sets since this requires lots of time to get
the conditional statements right, and I am quite busy these days.
I hope this gives you start.

By the way, please consider making the script read easy, your script had no
indentation, and no loop structure, which makes it difficult to understand
which loop ends where especially when there are many nested loops.

Cheers,
Rashed














On Tue, Mar 27, 2018 at 12:51 AM, Kiswendsida Hyacinthe GUIGMA <
karongseba at gmail.com> wrote:

> please find data in this link : ERA-I_1_1_1979-2017_Tmax_Tmin_NTA.nc
> <https://drive.google.com/open?id=1semO2FGV60dLKjHha1oNG607zvlKA8Uf>
>
> ERA-I_1_1_1979-2017_Tmax_Tmin_NTA.nc
>
> <https://drive.google.com/open?id=1semO2FGV60dLKjHha1oNG607zvlKA8Uf>
>
>
> Actually there isn't any error message. It just kills the script and shows
> up this message:"killed".
>
>
> -----------------------------
> GUIGMA
>
>
> On Monday, 26 March 2018, 23:09:03 GMT+1, Rashed Mahmood <
> rashidcomsis at gmail.com> wrote:
>
>
> Sorry I meant to send it to ncl-talk. here it is:
> ---------- Forwarded message ----------
> From: *Rashed Mahmood* <rashidcomsis at gmail.com>
> Date: Mon, Mar 26, 2018 at 3:02 PM
> Subject: Re: [ncl-talk] Sequences of values
> To: Kiswendsida Hyacinthe GUIGMA <karongseba at gmail.com>
>
>
> That's too many loops! ...I can not test without data set, what error
> messages you get when you run this?
>
> On Mon, Mar 26, 2018 at 1:20 PM, Kiswendsida Hyacinthe GUIGMA <
> karongseba at gmail.com> wrote:
>
> Please find attached an example of a code.
> 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
>
> Kindest regards
>
> -----------------------------
> GUIGMA
>
>
> On Monday, 26 March 2018, 20:40:32 GMT+1, Rashed Mahmood <
> rashidcomsis at gmail.com> wrote:
>
>
> How does your script look like? and what is the size of input data?
>
> On Mon, Mar 26, 2018 at 8:45 AM, Kiswendsida Hyacinthe GUIGMA <
> karongseba at gmail.com> wrote:
>
> Hi Rashed and everyone,
> Thank you for your suggestion.
> 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.
>
> Best
>
>
> -----------------------------
> GUIGMA
>
>
> On Saturday, 24 March 2018, 18:30:38 GMT, Rashed Mahmood <
> rashidcomsis at gmail.com> wrote:
>
>
> Hi Guigma,
> 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.
> begin
> ;  X1 = (/0,1,0,0,1,1,1,1,1,0,0,1,0,1, 1,1,1,0,0,1,0/) ; orignal
>    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
>
>
>    X2 = new(dimsizes(X1),integer)
>
>  do n=0,dimsizes(X1)-1
>      if(n.eq.0)
>        if(X1(n).eq.1.and.X1(n+1).eq. 0)
>          X2(n) = 0
>         else
>          X2(n) = X1(n)
>        end if
>      end if
>
>     if(n.gt.0.and.n.lt.dimsizes( X1)-1)
>       if(X1(n).eq.1)
>          if(X1(n-1).eq.0.and.X1(n+1). eq.0)
>             X2(n) = 0
>           else
>             X2(n) = X1(n)
>          end if
>        else
>           X2(n) = X1(n)
>       end if
>
>     end if
>
>     if(n.eq.dimsizes(X1)-1)
>       if(X1(n).eq.1.and.X1(n-1).eq. 1)
>         X2(n) = X1(n)
>        else
>         X2(n) = 0
>       end if
>     end if
>  end do
>     print(X1+" ... "+X2)
>
> end
>
>
> 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.
>
> Cheers,
> Rashed
>
>
>
>
>
>
>
> On Sat, Mar 24, 2018 at 6:44 AM, Kiswendsida Hyacinthe GUIGMA <
> karongseba at gmail.com> wrote:
>
> 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
> <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
> <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
> <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
>
> ______________________________ _________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/ mailman/listinfo/ncl-talk
> <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180327/ad6c1a5a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IND1_ERA_1_1_Tn_4d.ncl
Type: application/octet-stream
Size: 3745 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180327/ad6c1a5a/attachment.obj>


More information about the ncl-talk mailing list