[ncl-talk] where function

Laura Fowler laura at ucar.edu
Thu Jun 7 11:48:22 MDT 2018


Hi Dennis:

Of course, that makes complete sense. Not sure what I was thinking
here. I was further wondering. If I were to put lw_aqua_3 and
lw_aqua_7 in one array, like:

lw(0,:,:) = lw_aqua_3
lw(1,:,:) = lw_aqua_7
and then

lw_sum = dim_sum_n_Wrap(lw,0).

Would this be the same as using the where function and ismissing? This
may be a simpler way to do this?

Thanks for your quick reply on my 1st e-mail,
Laura




On Thu, Jun 7, 2018 at 11:30 AM, Dennis Shea <shea at ucar.edu> wrote:
> In many [?all?] languages, you can not directly test for NaN [if (x.eq.Nan)]
> You must use a function.
>
> NCL is similar in the way it treats _FillValue. You can not use: if
> (x.eq.x at _FillValue)
>
> NCL *requires* the user to use the ismissing function to test for _FillValue
>
> https://www.ncl.ucar.edu/Document/Functions/Built-in/ismissing.shtml
>
> q = where(ismissing(x) .and. .not.ismissing(y), a, b)
>
> HTH
>
>
> On Thu, Jun 7, 2018 at 11:14 AM, Laura Fowler <laura at ucar.edu> wrote:
>>
>> Hello:
>>
>> I am trying to make a composite of 2 cloud layers using the where
>> function but that does not seem to work. I am attaching the plots
>> test.layers_3.pdf and test.layers_7.pdf which are monthly mean values
>> of the liquid water paths for the lower cloud layer and the upper
>> cloud layer. Both data include missing values (green), but the liquid
>> water path for the upper cloud layer contains a lot more missing data
>> than the lower cloud layer.
>>
>> I would like to make a composite of the two layers. So first, I used
>> the where function as below:
>>
>> lw = where(lw_aqua_3.ne.lw_aqua_3 at _FillValue .and.
>> lw_aqua_7.ne.lw_aqua_7 at _FillValue, \
>>                    lw_aqua_3+lw_aqua_7,lw_aqua_3 at _FillValue)
>>
>> where lw_aqua_3 and lw_aqua_7 are the liquid water paths for the lower
>> and upper cloud layers, respectively. The plot
>> test1.add_layers.pdf show the "total" liquid water path.
>>
>>
>> What I can't seem to be able to do is to fill the missing value of lw
>> with lw_aqua_3 where lw_aqua_7 is actually missing and vice versa. So
>> I did:
>>
>> ;lw2 = where(lw_aqua_3.ne.lw_aqua_3 at _FillValue .and.
>> lw_aqua_7.eq.lw_aqua_7 at _FillValue, \
>>                       lw_aqua_3,lw)
>>
>> but that does not work as the plot of lw2 (test1.add_layers.pdf) is
>> the same as the plot for lw (since lw is missing where lw_aqua_3 is
>> not missing). I also tried to use ismissing but that does not work
>> since lw and lw2 are a two dimensional array.
>>
>>
>> Is there a simpler way to compute that kind of composite?
>>
>> 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
>>
>



-- 
!-------------------------------------------------------------------------------------------------------------
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

!-------------------------------------------------------------------------------------------------------------


More information about the ncl-talk mailing list