Re: Where function inserting missing values. Why?

From: Bridget Thrasher <bthrasher_at_nyahnyahspammersnyahnyah>
Date: Tue Oct 20 2009 - 16:03:30 MDT

It is only missing values now because of the way you wrote your test where
statement. If you look back at my original post, you will see that it is not
missing values until the final where statement. The arrays data_all and
mon_avg_20c are both complete at all grid points and times. The arrays dvar
and mon_avg_obs contain missing values in cells over oceans.

I originally did have the first 2 where statements combined. However, your
solution will not create the correct output for all land points because it
will use the incorrect data sets to calculate the value for land cells that
have a monthly average obs value of 0 instead of setting those cells to 0,
which is what I'm trying to do in the final where statement that is causing
the problem.

-Bridget

On Tue, Oct 20, 2009 at 2:48 PM, Wei Huang <huangwei@ucar.edu> wrote:

> Bridget,
> Here, clearly that you missing values of factors, matches mon_avg_obs.
>
> So, you may want to change the whole paragraph:
>
> 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,:,:))))
>
> printVarSummary(mon_avg_obs)
> printMinMax(mon_avg_obs,True)
> printVarSummary(factors(a*12+m,:,:))
> printMinMax(factors(a*12+m,:,:),True)
> print("debug:
> "+num(.not.ismissing(mon_avg_obs(m,:,:)).and.(mon_avg_obs(m,:,:).eq.-2222)))
>
> 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,:,:))))
>
>
> to:
>
> factors(a*12+m,:,:) = where(ismissing(mon_avg_obs(m,:,:))
> .or. mon_avg_obs(m,:,:) .le. 0., \
>
> data_all(a*12+m,:,:)/mon_avg_20c(m,:,:), \
>
> dvar(a*12+m,:,:)/mon_avg_obs(m,:,:))
>
> Then check with:
>
> print("3. "+num(ismissing(factors(a*12+m,:,:))))
> printVarSummary(factors(a*12+m,:,:))
> printMinMax(factors(a*12+m,:,:),True)
>
>
> Wei Huang
> huangwei@ucar.edu
> VETS/CISL
> National Center for Atmospheric Research
> P.O. Box 3000 (1850 Table Mesa Dr.)
> Boulder, CO 80307-3000 USA
> (303) 497-8924
>
>
>
>
>
>
>

-- 
Bridget Thrasher, PhD
Postdoctoral Researcher
Climate Central
www.climatecentral.org

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Oct 20 16:03:33 2009

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