[ncl-talk] Array subsetting

Dennis Shea shea at ucar.edu
Thu Oct 24 11:55:39 MDT 2019


You can not directly check for _FillValue. Specifically:  k2.ne.k2 at _FillValue
will not do the correct test.
You must use a function. eg: in fortran:*   ieee_is_nan(*x)

In NCL: *ismissing
<http://www.ncl.ucar.edu/Document/Functions/Built-in/ismissing.shtml> *...
please read the documentation


Try replacing:
      ifa = where(k2.ne.k2 at _FillValue,diag(:,k2),diag at _FillValue)
with
      ifa = where(*.not.ismissing*(k2), diag(:,k2), diag at _FillValue)

On Thu, Oct 24, 2019 at 10:37 AM Laura Fowler via ncl-talk <
ncl-talk at ucar.edu> wrote:

> Hello:
>
> I have the following arrays:
>
> Variable: diag
>
> Type: float
>
> Total Size: 1297613240 bytes
>
>             324403310 values
>
> Number of Dimensions: 2
>
> Dimensions and sizes: [nCells | 5898242] x [nVertLevels | 55]
>
> Coordinates:
>
> Number Of Attributes: 3
>
>   _FillValue : 9.96921e+36
>
>   long_name : Ice-friendly aerosol number concentration
>
>   units : nb kg^{-1}
>
>
>
> Variable: k2
>
> Type: integer
>
> Total Size: 23592968 bytes
>
>             5898242 values
>
> Number of Dimensions: 1
>
> Dimensions and sizes: [nCells | 5898242]
>
> Coordinates:
>
> Number Of Attributes: 1
>
>   _FillValue : 0
>
>
> where nCells is the horizontal dimension and nVertLevels is the number of
> vertical levels. you can think of k2 as the index for the base of a
> convective cloud with a missing value set to zero. I would like to build an
> array nifa which contains the value of diag at k2, such that:
>
>
> nifa(iCell) = diag(:,k2(iCell)) for iCell varying between 0 and nCells-1.
>
>
>
> I tried to use the function "where" but this did not work. I get the
> following:
>
> nifa = where(k2.ne.k2 at _FillValue,diag(:,k2),diag at _FillValue)
>
>
> fatal:NclMalloc Failed:[errno=12]
>
> Segmentation fault (core dumped)
>
>
>
> I am not sure why this is not working. I also tried the ismissing function
> but this did not work either. Any suggestions?
>
>
> Thanks,
>
> Laura
>
>
>
> --
>
> !-------------------------------------------------------------------------------------------------------------
> Laura D. Fowler
>
> Mesoscale and Microscale Meteorology Division (MMM)
> National Center for Atmospheric Research
> P.O. Box 3000, Boulder CO 80307-3000
>
> e-mail: laura at ucar.edu
> phone: 303-497-1628
>
>
> !-------------------------------------------------------------------------------------------------------------
> _______________________________________________
> 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/20191024/2383fd3a/attachment.html>


More information about the ncl-talk mailing list