Re: Where function inserting missing values. Why?

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Tue Oct 20 2009 - 11:21:10 MDT

Bridget,

I suspect that you have missing values in the first argument to the
where function. From the documentation:

   "If any elements of condtnl_expr are missing (i.e. equal
   to condtnl_array@_FillValue), then the corresponding
   elements of the return array become missing values equal
   to the missing value of whatever type is returned."

For debugging, I recommend that you assign "condtnl_expr" to a named
NCL variable, and print the counts of true, false, and missing for that.

Dave Allured
CU/CIRES Climate Diagnostics Center (CDC)
http://cires.colorado.edu/science/centers/cdc/
NOAA/ESRL/PSD, Climate Analysis Branch (CAB)
*** http://www.esrl.noaa.gov/psd/psd1/ ***
NOTICE: NEW PSD1/CAB WEBSITE ADDRESS AS OF 2009-OCT-14
PRODUCT AND DATA CONSUMERS PLEASE TAKE NOTE

Bridget Thrasher wrote:
> I am doing the following in a loop:
>
> mon_avg_obs(m,:,:) = where(mon_avg_obs(m,:,:).eq.0, -2222,
> mon_avg_obs(m,:,:))
> factors(a*12+m,:,:) = data_all(a*12+m,:,:)/mon_avg_20c(m,:,:)
> print("1. "+num(ismissing(factors(a*12+m,:,:))))
> factors(a*12+m,:,:) = where(.not.ismissing(mon_avg_obs(m,:,:)),
> dvar(a*12+m,:,:)/mon_avg_obs(m,:,:), factors(a*12+m,:,:))
> print("2. "+num(ismissing(factors(a*12+m,:,:))))
> factors(a*12+m,:,:) =
> where(.not.ismissing(mon_avg_obs(m,:,:)).and.mon_avg_obs(m,:,:).eq.-2222,
> 0., factors(a*12+m,:,:))
> print("3. "+num(ismissing(factors(a*12+m,:,:))))
>
>
> The output on the screen says:
> (0) 1. 0
> (0) 2. 0
> (0) 3. 11753
>
> Why is the last where statement inserting a fill value? I've tried it
> with and without the .not.ismissing() part, as well as some other
> things, but all yield the same result.
>
> -Bridget
>
>
> --
> Bridget Thrasher, PhD
> Postdoctoral Researcher
> Climate Central
> www.climatecentral.org <http://www.climatecentral.org>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Oct 20 11:21:15 2009

This archive was generated by hypermail 2.1.8 : Thu Oct 22 2009 - 13:09:30 MDT