Re: help with Replacing missing value in an array with zeros

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Fri, 18 Jul 2008 11:56:55 -0600

Hi Erik,

dim_avg ignores all data that is set to _FillValue, as you can see here:

ncl 0> a = (/1,2,3,4,5,-999/)
ncl 1> a@_FillValue = -999
ncl 2> print(dim_avg(a))
(0) 3

So I don't know that you want to replace all the _FillValue data with 0's.

Second, the ind documentation states that the input array must be
1-dimensional, and you are inputting a 3-dimensional array. That is what
the "fatal:Number of dimensions in parameter (0) of (ind) is (3), (1)
dimensions were expected" error message means. Continuing with the
interactive ncl from above:
ncl 3> a(ind(ismissing(a))) = 0
ncl 4> print(a)

Variable: a
Type: integer
Total Size: 24 bytes
             6 values
Number of Dimensions: 1
Dimensions and sizes: [6]
Coordinates:
Number Of Attributes: 1
   _FillValue : -999
(0) 1
(1) 2
(2) 3
(3) 4
(4) 5
(5) 0

Adam

Erik Noble wrote:
> Dear NCL,
> I was testing the ind and ismissing functions out in command line
> mode on my data to exclude the fill value when I do an average of the
> data (using dim_avg) . I followed examples #1 and #2 at
> http://www.ncl.ucar.edu/Document/Functions/Built-in/ind.shtml
> The ncl ind function page does not explain why i might be getting the
> error that i am getting. Could I have some help resolving this?
>
> Thank you for your time.
> -Erik
>
>
> ncl 15> printVarSummary(r)
>
>
> Variable: r
> Type: float
> Total Size: 60099840 bytes
> 15024960 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 240] x [lat | 222] x [lon | 282]
> Coordinates:
> time: [2006090100..2006093021]
> lat: [-20.125..35.125]
> lon: [-35.125..35.125]
> Number Of Attributes: 4
> lonFlip : longitude coordinate variable has been reordered via lonFlip
> long_name : merged microwave precipitation
> units : mm/hr
> _FillValue : -9999
> ncl 16> r@_FillValue = -9999
> ncl 17> r(ind(ismissing(r))) = 0
> fatal:Number of dimensions in parameter (0) of (ind) is (3), (1)
> dimensions were expected
> fatal:Execute: Error occurred at or near line 12
>
> ncl 18> ir =ind(.not.ismissing(r))
> fatal:Number of dimensions in parameter (0) of (ind) is (3), (1)
> dimensions were expected
> fatal:Execute: Error occurred at or near line 14
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jul 18 2008 - 11:56:55 MDT

This archive was generated by hypermail 2.2.0 : Mon Jul 21 2008 - 14:41:34 MDT