Re: about missing value in nc file and avg function

From: Dennis Shea (shea AT XXXXXX)
Date: Mon Jun 14 2004 - 08:24:15 MDT


>ncl-talkHi aLL:
> Today I met a problem when i use NCL .
> In my NCL programm to creat a nc file.
> I wrote as follows:
>..............
>..............
> RAIN@_FillValue = 251.
>
> print(RAIN)
>
> outfile = addfile("rain_98_big.nc","c")
> outfile->RAIN = RAIN
> end
>------------------------------------------------------------------------
>Then it is printed on computer monitor :
> 1, 0.5, 0, 0, 0, 0.3, 0.5, 0.3, 0, 0, 0, 0, 0, 0, 0, 0, 0.4, 1, 1.4, 0.8,
> 0.1, 0, 0, 0, 0.1, 0.3, 0.3, 0.6, 5.3, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 8.3, 6.3, 8.3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0.6, 1.3, 0.8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0.1, 0.1, 0.1,
> 251., 251., 251., 0, 0, 0,251.,251.,251.,251., 0, 0, 0,..................
>
>
>But, when I open the .nc file, it is as follows:
>..........
>............
> RAIN:_FillValue = 251.f
>==============================
>
> 1, 0.5, 0, 0, 0, 0.3, 0.5, 0.3, 0, 0, 0, 0, 0, 0, 0, 0, 0.4, 1, 1.4, 0.8,
> 0.1, 0, 0, 0, 0.1, 0.3, 0.3, 0.6, 5.3, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 8.3, 6.3, 8.3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0.6, 1.3, 0.8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0.1, 0.1, 0.1,
> _, _, _, 0, 0, 0, _, _, _, _, 0, 0, 0, _, 0, 0, 0,
.................................
>====================================
> You see the 251. is not displayed as it should be. why?

+++++++++++++
I speculate that you "opened the .nc file" you used
     ncdump -v RAIN rain_98_big.nc
     
ncdump is a Unidata (creator of netCDF) utility.
To save space, it prints _ to indicate _FillValue.
Nothing is wrong.

Incidently, ncdump is not part of NCL.
++++++++++++++

+++++++++++++
>
> Then I will make average for the array in "this" nc file I created.
> So i wrote
>--------------------------------
> rainave = avg(RAIN)
>--------------------------------
> but when I run the NCL script.
> I got these warnings.
>
>warning:avg: Entire input array contains missing values, can't compute average
[snip]
>warning:avg: Entire input array contains missing values, can't compute average
>-----------------------------------------------------------------------
>I don't know why?
>could you help me?
>Thanks a lot!

+++++++++++++++++++
I do not know why either. avg works fine.

ncl 0> x = (/-10., 251, 10./)
ncl 1> x@_FillValue = 251.
ncl 2> xAvg = avg(x) ; should be 0.
ncl 3> print (xAvg)

Variable: xAvg
Type: float
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
Number Of Attributes: 1
  _FillValue : 251
(0) 0
+++++++++++++++++++++++

I speculate that you tried to create the file but had
and error. Then you recreated the file.

Conceptually that works fine. However, sometimes environment
variables have been set that require the user to
explicitly delete an existing netCDF file before
recreating the file.

This can also be done within the NCL script:

     system ("/bin/rm rain_98_big.nc") ; remove any pre-existing file
     outfile = addfile("rain_98_big.nc","c")
     
good luck

_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk



This archive was generated by hypermail 2b29 : Fri Jun 25 2004 - 15:17:38 MDT