problems with WHOI NetCDF files

Henrique Barbosa hmjbarbosa at GMAIL.COM
Mon Oct 30 10:49:35 EST 2006


Hi All,

I am trying to open NetCDF files from WHOI (Woods Hole Oceanographic
Institution)
with monthly analysis of sensible and latent oceanic heat fluxes.
Since I have tried for a few days without success, I decided to write
to the list.
By the way, this data can be found here:

http://oaflux.whoi.edu/index.html
ftp://ftp.whoi.edu/pub/science/oaflux/data/monthly/lhsh_oaflux_1981.nc.gz

The initial problem was that when I tried to open any of the files I
got the following error:

ga-> sdfopen lhsh_oaflux_1981.nc
Scanning self-describing file:  lhsh_oaflux_1981.nc
SDF file has no discernable X coordinate.

By the error, I assumed WHOI netCDF does not conform with COARDS
conventions, therefore, I wrote a simple ctl to use with xdfopen:

dset ^lhsh_oaflux_1981.nc
xdef lon  360 linear   0.5 1.0
ydef lat  130 linear -64.5 1.0
tdef time  12 linear 0z1jan81 1mo

Now I can open the file, but grads is not unpacking the data and
the plotted fields are completely wrong. However, a look
in the output of ncdump:

netcdf lhsh_oaflux_1981 {
dimensions:
        time = UNLIMITED ; // (12 currently)
        lat = 130 ;
        lon = 360 ;

variables:
        float lon(lon) ;
                lon:long_name = "longitude" ;
                lon:units = "degrees" ;
                lon:range = "0.5 to 359.5" ;
        float lat(lat) ;
                lat:long_name = "latitude" ;
                lat:units = "degrees" ;
                lat:range = "64.5S to 64.5N" ;
        long time(time) ;
                time:units = "month" ;
                time:comment = "Year 1981" ;
        short lhtfl(time, lat, lon) ;
                lhtfl:comments = "monthly mean surface latent heat flux" ;
                lhtfl:units = "W/m^2" ;
                lhtfl:scale_factor = 0.1 ;
                lhtfl:missing_value = 32766. ;
        short shtfl(time, lat, lon) ;
                shtfl:comment = "monthly mean surface sensible heat flux" ;
                shtfl:units = "W/m^2" ;
                shtfl:scale_factor = 0.1 ;
                shtfl:missing_value = 32766. ;
(...)

shows that  both variables shtfl and lhtfl have an attribute
named scale_factor... but grads is not using it. Does anyone
have a clue what the problem might be?

In the mean time I gave up using xdfopen and wrote a full ctl to use
with standard open command:

dset ^lhsh_oaflux_1981.nc
dtype netcdf
undef 32766.
title WHOI Monthly analysis of Ocean Latent/Sensible Heat Flux
xdef 360 linear   0.5 1.0
ydef 130 linear -64.5 1.0
zdef   1 levels 1000
tdef  12 linear 0z1jan81 1mo
unpack scale_factor
vars 2
lhtfl=>lhtfl 0 t,y,x monthly mean surface latent heat flux (W/m2)
shtfl=>shtfl 0 t,y,x monthly mean surface latent heat flux (W/m2)
endvars

With this ctl and I can open the file and show the data ALMOST
properly. Fields look right but the values are not
multiplied by the scale_factor:

ga-> open lhsh.ctl
Scanning description file:  lhsh.ctl
Warning : Missing offset attribute name in unpack record
Data file lhsh_oaflux_1981.nc is open as file 1
LON set to 0 360
LAT set to -64.5 64.5
LEV set to 1000 1000
Time values set: 1981:1:1:0 1981:1:1:0
ga-> display lhtfl
Contouring: -3500 to 0 interval 500
ga->

I mean, latent heat flux should be around -350W/m2 and not 3500.
How come grads was able to convert the 'short' data to real but
is not applying the scale_factor? Querying the file gives me:

ga-> q file
File 1 : WHOI Monthly analysis of Ocean Latent/Sensible Heat Flux
  Descriptor: lhsh.ctl
  Binary: lhsh_oaflux_1981.nc
  Type = Gridded
  Xsize = 360  Ysize = 130  Zsize = 1  Tsize = 12
  Number of Variables = 2
    lhtfl 0 -103 monthly mean surface latent heat flux (W/m2)
    shtfl 0 -103 monthly mean surface latent heat flux (W/m2)

Which is very strange.... what does -103 means?

Even thou the file is now usable (i just need to multiply by 0.1 by hand),
I would really like to have the CTL telling grads how to do that automatically.

Thanks,
Henrique



More information about the gradsusr mailing list