Project

General

Profile

Linear level interpolation metadata missing

Added by Jay Su over 3 years ago

Hello,

I am using intlevel to do linear level interpolation but many metadata of the vertical level variable are missing.

Original:
double lev(lev) ;
lev:long_name = "vertical level" ;
lev:units = "layer" ;
lev:positive = "down" ;
lev:coordinate = "eta" ;
lev:standard_name = "model_layers" ;
lev:vmax = 1.e+15f ;
lev:vmin = -1.e+15f ;
lev:valid_range = -1.e+15f, 1.e+15f ;

After:
double lev(lev) ;
lev:long_name = "vertical level" ;
lev:units = "layer" ;
lev:axis = "Z" ;

Do we have an option to keep the original attributes?

Thanks,


Replies (7)

RE: Linear level interpolation metadata missing - Added by Karin Meier-Fleischer over 3 years ago

Hi Jay,

the attributes are deleted because they are not CF-convention conform or due to the fact that you've interpolated the coordinate variable. See https://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/ch04s03.html.

You can add the attributes you want with the setattribute operator, see https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf#subsection.2.6.1

-Karin

RE: Linear level interpolation metadata missing - Added by Jay Su over 3 years ago

Thank you Karin,

Do you mean coordinate variable should not have vmax/vmin/valid_range attributes?

How about positive and standard_name?

Adding attributes back manually is tedious and unnecessarily costs extra resources for the servers and users.

Remember CF convention is never mandatory, though it's nice to follow. In the meanwhile, removing the original attributes is usually, if not always, a bad idea. Data providers and service providers would like to preserve metadata as much as possible. Please at least provide an option in the future versions.

RE: Linear level interpolation metadata missing - Added by Brendan DeTracey over 3 years ago

From the first paragraph of the CDO manual.

The NetCDF attributes should follow the GDT, COARDS or CF Conventions.

If you create your netcdf with enough header padding:
--netcdf_hdr_pad, --hdr_pad, --header_pad <nbr>    
      Pad NetCDF output header with nbr bytes.
then you can alter attributes without rewriting the entire file. I do not think CDO can edit a file(not create a new output file), but I know NCO can.

RE: Linear level interpolation metadata missing - Added by Karin Meier-Fleischer over 3 years ago

For CDO it is mandatory to follow GDT, COARDS or CF.

We know that some users would like to retain all attributes, but that is not possible yet, and sometimes it does not make sense.

See CDO User guide

Introduction

NetCDF datasets are only supported for the classic data model and arrays up to 4 dimensions.
These dimensions should only be used by the horizontal and vertical grid and the time.
The NetCDF attributes should follow the GDT, COARDS or CF Conventions.

RE: Linear level interpolation metadata missing - Added by Jay Su over 3 years ago

Thanks Brendan and Karin,

Please help me understand CF convention in this case.

Do you mean coordinate variable should not have vmax/vmin/valid_range attributes?

How about positive and standard_name?

RE: Linear level interpolation metadata missing - Added by Jay Su over 3 years ago

Waiting for your reply.

Original:
double lev(lev) ;
lev:long_name = "vertical level" ;
lev:units = "layer" ;
lev:positive = "down" ;
lev:coordinate = "eta" ;
lev:standard_name = "model_layers" ;
lev:vmax = 1.e+15f ;
lev:vmin = -1.e+15f ;
lev:valid_range = -1.e+15f, 1.e+15f ;

After:
double lev(lev) ;
lev:long_name = "vertical level" ;
lev:units = "layer" ;
lev:axis = "Z" ;

Dont know why the deleted attributes violate CF.

RE: Linear level interpolation metadata missing - Added by Karin Meier-Fleischer over 3 years ago

I'm not an expert on the CF convention. Your lev coordinate is a so called dimensionless vertical coordinate (units = 'layer'). If you use an interpolation operator CDO cannot know how to keep or set the attributes for the changed coordinates. After the interpolation attributes like positive, vmin, vmax, and valid_range are deleted (just as NCL does) because they have an undefined state. It is always up to the user to pay attention to the correctness of the attributes of the interpolated coordinates or data. The missing attributes of the coordinates can be added with NCO's tool ncatted, missing attributes of variables can be added with CDO's setattribute.

    (1-7/7)