# Re: Where function inserting missing values. Why?

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Tue Oct 20 2009 - 15:10:43 MDT

Bridget,

Can change the 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(mon_avg_obs(m,:,:) .le. 0., 0.,
data_all(a*12+m,:,:)/mon_avg_20c(m,:,:))
print("0. "+num(ismissing(mon_avg_20c(m,:,:))))
print("1. "+num(ismissing(mon_avg_obs(m,:,:))))
print("2. "+num(ismissing(data_all(a*12+m,:,:))))
print("3. "+num(ismissing(factors(a*12+m,:,:))))

printVarSummary(mon_avg_20c)
printMinMax(mon_avg_20c,True)
printVarSummary(mon_avg_obs)
printMinMax(mon_avg_obs,True)
printVarSummary(data_all(a*12+m,:,:))
printMinMax(data_all(a*12+m,:,:),True)
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

On Oct 20, 2009, at 2:57 PM, Bridget Thrasher wrote:

> OK, here's what I'm printing now:
>
> 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,:,:))))
>
> With the result being:
>
> (0) 1. 0
> (0) 2. 0
>
>
> Variable: mon_avg_obs
> Type: float
> Total Size: 790608 bytes
> 197652 values
> Number of Dimensions: 3
> Dimensions and sizes: [month | 12] x [lat | 91] x [lon | 181]
> Coordinates:
> month: [0..11]
> lat: [ -90.. 90]
> lon: [ 0.. 360]
> Number Of Attributes: 3
> info : function clmMonLLT: contributed.ncl
> time_op_ncl : Climatology: 50 years
> _FillValue : 1e+20
> (0)
> (0) min=-2222 max=41.1583
>
>
> Variable: factors (subsection)
> Type: float
> Total Size: 65884 bytes
> 16471 values
> Number of Dimensions: 2
> Dimensions and sizes: [lat | 91] x [lon | 181]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : 1e+20
> (0)
> (0) min=0 max=14.1053
> (0) debug: 2
> (0) 3. 11753
>
>
> I still don't see what's wrong. Am I missing something glaring?
>
> -Bridget
>
>
> On Tue, Oct 20, 2009 at 1:02 PM, Dennis Shea <shea@ucar.edu> wrote:
> On topics like this, it is a good idea to include a printVarSummary
> as suggested by Wei. Specifically,
>
> printVarSummary( mon_avg_obs )
> printMinMax( mon_avg_obs, True ) ; contributed.ncl
>
> before you do any of the operations indicated below. The information
> can be quite useful.
>
> Also,
>
> printVarSummary( factors(a*12+m,:,:) )
> printMinMax(factors(a*12+m,:,:), true)
>
> ---
> The one thing different with the last 'where' is the .and.
>
> ... where( .not.ismissing(mon_avg_obs(m,:,:)) .and.
> mon_avg_obs(m,:,:).eq.-2222,...)
>
> print("debug: "+num( .not.ismissing(mon_avg_obs(m,:,:)) .and.
> mon_avg_obs(m,:,:).eq.-2222) )
>
>
>
>
>
>
>
>
> _______________________________________________
> 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 15:10:44 2009

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