[ncl-talk] first index in the sequence,

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Sat May 6 18:17:09 MDT 2017


Here is an ordinary run finder.

  x = (/ 2.1, 3.2, 4.3, -999, -999, 7.6, 8.7, 9.8 /)
  x at _FillValue = -999.0

  n                   = dimsizes (x)
  prev_missing        = new (n, logical)

  valid               = .not. ismissing (x)
  prev_missing(0)     = True
  prev_missing(1:n-1) = .not. valid(0:n-2)

  start_mask          = valid .and. prev_missing
  start_indices       = ind (start_mask)
  start_values        = x(start_indices)

--Dave


On Sat, May 6, 2017 at 3:51 PM, Xi Chang <xi.chang01 at gmail.com> wrote:

> Dear Karin,
>
> I meant multiple first index in the sequence. Your example is only work
> for the
> first index in the first sequence. The values -999 separated each sequence.
> Can you suggest me something?
>
> Xi
>
> On Sat, May 6, 2017 at 8:25 AM, Karin Meier-Fleischer <
> meier-fleischer at dkrz.de> wrote:
>
>> Hi Xi,
>>
>> I think you want to do something like
>>
>> x=(/2.1, 3.2, 4.3, -999, -999, 7.6, 8.7, 9.8/)
>> x at _FillValue=-999
>>
>>
>> first_index = x(0)
>> print(x(0))
>>
>> Bye,
>> Karin
>>
>>
>> Am 05.05.2017 um 17:48 schrieb Xi Chang <xi.chang01 at gmail.com>:
>>
>> Dear NCL,
>>
>> Could you suggest me how to get the first index in the sequence?
>> for instance:
>>
>> x=(/2.1, 3.2, 4.3, -999, -999, 7.6, 8.7, 9.8/)
>> x at _FillValue=-999
>>
>> the first index in the sequence will be
>> (0) 2.1 and
>> (5) 7.6
>>
>> I do appreaciate for your help.
>>
>> Best,
>> Xi
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170506/53aff719/attachment.html 


More information about the ncl-talk mailing list