You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use netCDF as the output format for my thermo-mechanical code in a field far away from climatology, therefore I haven't used conventions.
Conventionally, netCDF files may have coordinate variables, which have the same name as corresponding dimensions and contain grid coordinates.
Instead, I create scalar integer variables which have the same name and value as corresponding dimensions. Now I consider that decision a big mistake, but a lot of calculations has been performed already and some software depends on this format.
I use ncks to extract variable values from large datasets. But ncks fails to convert these extracted files to HDF-5 varieties. I have prepared trivial examples. File t1.cdl
netcdf t1 {
dimensions:
lat = 3;
variables:
float lat (lat);
float vvv (lat);
data:
vvv = 0., 10., 20.;
lat = 30., 40., 50.;
}
which has a coordinate variable "lat" can be processed with ncgen:
ncgen -o t1.nc t1.cdl
and then successfully converted by ncks:
ncks -7 t1.nc t1_7.nc
But file t2.cdl
netcdf t2 {
dimensions:
lat = 3;
variables:
int lat;
float vvv (lat);
data:
vvv = 0., 10., 20.;
lat = 3;
}
contains a scalar integer variable lat with the same value as dimension. It can also be processed with ncgen:
ncgen -o t2.nc t2.cdl
But conversion by ncks:
ncks -7 t2.nc t2_7.nc
fails with the
nco_err_exit(): ERROR Error code is -101. Translation into English with nc_strerror(-101) is "NetCDF: HDF error"
An odd case may arise in which the user defines a variable with the same name as a dimension, but which is not intended to be the coordinate variable for that dimension. In this case the string "nc4_non_coord" is pre-pended to the name of the HDF5 dataset, and stripped from the name for the netCDF API.
It seems that I've encountered this odd corner case. Interestingly, nccopy converts both data files to netCDF-4 without any problem.
As a workaround, I will use ncks to extract variables to netCDF-3 file and then use nccopy to convert them to netCDF-4.
With best regards,
Vadim Zborovskii
The text was updated successfully, but these errors were encountered:
I learned something new from your careful reporting, thank you. You have found a good work-around for this corner case, which we will try to address in due course. BTW, you can generate files directly to netCDF4 format with, e.g., ncgen -7 -o t2.nc t2.cdl.
Hello,
I use netCDF as the output format for my thermo-mechanical code in a field far away from climatology, therefore I haven't used conventions.
Conventionally, netCDF files may have coordinate variables, which have the same name as corresponding dimensions and contain grid coordinates.
Instead, I create scalar integer variables which have the same name and value as corresponding dimensions. Now I consider that decision a big mistake, but a lot of calculations has been performed already and some software depends on this format.
I use ncks to extract variable values from large datasets. But ncks fails to convert these extracted files to HDF-5 varieties. I have prepared trivial examples. File t1.cdl
which has a coordinate variable "lat" can be processed with ncgen:
ncgen -o t1.nc t1.cdl
and then successfully converted by ncks:
ncks -7 t1.nc t1_7.nc
But file t2.cdl
contains a scalar integer variable lat with the same value as dimension. It can also be processed with ncgen:
ncgen -o t2.nc t2.cdl
But conversion by ncks:
ncks -7 t2.nc t2_7.nc
fails with the
nco_err_exit(): ERROR Error code is -101. Translation into English with nc_strerror(-101) is "NetCDF: HDF error"
A netCDF format specification states that
It seems that I've encountered this odd corner case. Interestingly, nccopy converts both data files to netCDF-4 without any problem.
As a workaround, I will use ncks to extract variables to netCDF-3 file and then use nccopy to convert them to netCDF-4.
With best regards,
Vadim Zborovskii
The text was updated successfully, but these errors were encountered: