Hi all,
I realized I hadn't included the Ferret list on this reply.
To complete this thread, Dan was able to use NCO and change all
of the string-typed attributes to character type. This needs to
include the global attributes, which Ferret reads and stores as
it's initializing the file. Once that change was made, the file
can be used as always by Ferret.
-ansley
On 8/1/2018 5:19 PM, Ansley C. Manke
wrote:
Hi Dan,
We've recently run into this ourselves. It's the "string" type
attributes, and Ferret has always been set up to only read
attributes of type "char" These are two different calls in the
various libraries (C, java, python) that people use to write
netCDF files. There has recently been a discussion going on in
the CF conventions world about this, as there is a lot of software
out there that doesn't handle string attributes. It looks as
though the standard will recommend the use of "char" type for this
reason, but these files are being made and so we're looking into
dealing with this. We have an idea of what needs to be done to
catch Ferret up to this style of file.
Ferret will open your file and read data correctly, but it will
just skip these attributes. Right now it doesn't handle these
files all that well. In your example, it'll be missing the units
for the coordinates and so won't set up the grid to work with
those coordinates, and won't label plots correctly with the units
and titles of variables.
There are a couple of workarounds:
The first is to use Ferret to assign some of the attributes. In
the Ferret session, you could assign the units and titles to the
coordinates and variables. This is an imperfect solution and
requires you to use ncdump and do all of this by hand. It's also
an imperfect solution. For instance you would need to redefine the
coordinate axes in order to account for the coordinate bounds
variables. Here's how that would go:
yes? use m2.nc
yes? define axis/units="degrees_north" lat
yes? set axis/units="degrees_east" lon
yes? set var/units=units = "degrees"/title="Sea surface
height phaselag due to non equilibrium ocean tide at m2
frequency" phase
Or, you could make a copy of it that will work perfectly, by
running it through a full ncdump and ncgen. ncgen will write
these problematic attributes into the new file using a call which
makes them into char type:
% ncdump m2.nc > m2.cdl
% ncgen -o m2_new.nc m2.cdl
Your grid is big, but only
2-dimensional, so this might be a good interim answer for you,
though some datasets might be quite large. Another possibility
might be to use NCO to change the attributes. I have not tried
that.
Ansley
On 8/1/2018 4:36 PM, Yu, Hao-Cheng wrote:
Dear ferret user
I try to read netcdf from aviso.
When I try to read with ferret 7.4, it shows
NetCDF: Not a valid data type or _FillValue type mismatch
(OPeNDAP/netCDF Error code -45)
is this a CDF file ?
Anyone encounter this before?
ncdump shows the following
netcdf m2 {
dimensions:
lat = 2881 ;
lon = 5760 ;
nv = 2 ;
variables:
float lat(lat) ;
string lat:long_name = "latitude" ;
string lat:units = "degrees_north" ;
string lat:bounds = "lat_bnds" ;
string lat:axis = "Y" ;
lat:valid_min = -90. ;
lat:valid_max = 90. ;
float lat_bnds(lat, nv) ;
string lat_bnds:comment = "latitude values
at the north and south bounds of each pixel." ;
string lat_bnds:units = "degrees_north" ;
float lon(lon) ;
string lon:long_name = "longitude" ;
string lon:units = "degrees_east" ;
string lon:bounds = "lon_bnds" ;
string lon:axis = "X" ;
lon:valid_min = 0. ;
lon:valid_max = 360. ;
float lon_bnds(lon, nv) ;
string lon_bnds:comment = "longitude values
at the west and east bounds of each pixel." ;
string lon_bnds:units = "degrees_north" ;
int nv(nv) ;
string nv:comment = "Vertex" ;
string nv:units = "1" ;
int crs ;
string crs:grid_mapping_name =
"latitude_longitude" ;
crs:semi_major_axis = 6371000. ;
crs:inverse_flattening = 0 ;
float phase(lat, lon) ;
phase:_FillValue = 1.844674e+19f ;
string phase:units = "degrees" ;
string phase:long_name = "Sea surface height
phaselag due to non equilibrium ocean tide at m2 frequency "
;
string phase:grid_mapping = "crs" ;
Dan
|