Project

General

Profile

ncdump functionality: overwriting input file and ncdump -h

Added by Bjorn Stevens about 5 years ago

In a recent department meeting we were discussing the different functionality of cdo and other file-inspection software. Two issues arose:

1. some of the information that is very concisely and usefully provided by ncdump -h would be nice if it were also provided by some CDO command ... ideally -h then moving help to -help. There are many info commands but they are often hard to keep in mind. Is there something analogous to ncdump -h; here what would be particularly desirable is to view the global attributes, in particular the history as looking at the history provides nice templates for our own CDO processing. Note when I type cdo showattsglob I don't seem to get the same attributes as with ncdump. Consider:

$ cdo showattsglob /work/ka1081/Hackathon/GrossStats/ICON_R2B10_0.10_grid_wghts.nc 
Global:
  title = "SCRIP remapping with CDO" 
  normalization = "fracarea" 
  map_method = "Conservative remapping using clipping on sphere" 
  conventions = "SCRIP" 
  source_grid = "unstructured" 
  dest_grid = "lonlat" 
cdo showattsglob: Processed 19 variables [0.01s 31MB]

versus

$ ncdump -h /work/ka1081/Hackathon/GrossStats/ICON_R2B10_0.10_grid_wghts.nc
...
// global attributes:
        :_NCProperties = "version=1|netcdflibversion=4.6.1|hdf5libversion=1.8.14" ;
        :title = "SCRIP remapping with CDO" ;
        :normalization = "fracarea" ;
        :map_method = "Conservative remapping using clipping on sphere" ;
        :conventions = "SCRIP" ;
        :source_grid = "unstructured" ;
        :dest_grid = "lonlat" ;
        :history = "31 Aug 2018 : cdo -P 16 --cellsearchmethod spherepart genycon,0.10_grid.nc -selname,cell_area /work/bk1040/experiments/input/2.5km/icon_grid_0017_R02B10_G.nc ICON_0.10_grid_wghts.nc" ;
        :CDO = "Climate Data Operators version 1.9.5 (http://mpimet.mpg.de/cdo)" ;
}

2. for some commands it would be nice to overwrite the input file, for instant a chname command often is something you want to do to a file, rather than to create a new file, and then have to replace the old file with the new. Is there a good way to do this in CDO speak. I am thinking of being able to simply have


cdo chname,oldname,newname file.nc


Replies (2)

RE: ncdump functionality: overwriting input file and ncdump -h - Added by Uwe Schulzweida about 5 years ago

1.
Thanks for your contribution. The treatment of attributes in CDO is still in need of improvement.
There are several operators for the output of attributes. But none of them outputs all attributes like ncdump.
One reason for this is that CDO doesn't read all NetCDF attributes but at least most of them.
Some of these operators have been implemented by external CDO users for their needs.

I will soon revise the processing of the attributes in their output in CDO.
But I think the output will never be exactly the same as with ncdump.
This is mainly because CDO has a different view on the data and the attributes than NetCDF.

The output of the history attribute will be implemented as soon as possible!

RE: ncdump functionality: overwriting input file and ncdump -h - Added by Uwe Schulzweida about 5 years ago

2.
Overwriting the input data is a very NetCDF specific task. And in terms of performance interesting only for netCDF4.
We could implement this for operators like e.g. chname and setattribute. But that would probably only be a wrapper for the NCO tool ncrename.
We will have to discuss if that really makes sense.

    (1-2/2)