Re: setting missing values

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue, 10 Jun 2008 21:20:40 -0600

Andrea is on the right track. If x(lev,lat,lon)

        work = x(lat|:,lon|:,lev|:)
       dsum = dim_sum( work )
       dnum = dim_num( work.ne.0)

Here is a 'trick'

        dnum@_FillValue = 0

         davg = dsum/dnum

For graphics reason only, change the _FillValue to something other than 0

         davg@_FillValue = 1e20
 

Andrea Hahmann wrote:
> James
>
> Instead of using "dim_avg" you can use "dim_sum" and then count the
> number of points that are not zero with the function "num". Something
> like avg = sum(matrix)/num(not zero)
>
> Andrea
>
> James Correia wrote:
>> Hi NCL-ers,
>>
>> I have a 3D variable (vertical level, lat, lon). I am taking an
>> average (using dim_avg) over space but want to exclude those grid
>> points which have zeros in the whole column. I know I can set them to
>> missing, but what is the best way to set those columns to missing (I
>> do not want to simply set all zeros to missing, only those grid
>> points where the whole column is zero).
>>
>> Not sure if I can use the mask function for this.
>> Thanks for any insight.
>>
>>
>>
>>
>>
>> --
>> James Correia Jr.
>> Post Doc
>> Climate Physics Group, PNNL
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk_at_ucar.edu
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jun 10 2008 - 21:20:40 MDT

This archive was generated by hypermail 2.2.0 : Wed Jun 11 2008 - 13:31:20 MDT