This has arisen as a problem of converting NETCDF4 to NETCDF3_CLASSIC which is still used by some old software. I did try nc4tonc3 provided with netCDF4 but that one also wanted the input file in NETCDF4_CLASSIC format... That is why I wrote this little script to actually copy variables and dimensions. There were no attributes in the files, so I did not care to handle attributes.
From a comment by Nikolay Koldunov, there is a utility for this tasks nccopy ...
Showing posts with label netcdf. Show all posts
Showing posts with label netcdf. Show all posts
Tuesday, January 21, 2014
Friday, January 6, 2012
Summation along a dimension
Suppose you have a netcdf file with temporal data of say evaporation (in meters).
And you want to know how much water evaporates during a year. And also you do not want to loose
time writing a program for this. Fortunately we have NCO.
I did the procedure for the ERA-Interim reanalysis file downloaded from the ECMWF site. I picked the year 1985.
The header of the file looks like this:
Here is the description of the procedure that I used:
Here is the description of the procedure that I used:
-
Calculate the mean of the variable along the specified dimension (time in my case).
~# ncra -d time,0,729 -v e evap-1985.nc mean_evap_1985.nc
Here I was not sure whether I should take care of the scale_factor and add_offset. The answer is no, because nco takes care of it for you. -
Then, since sum = mean * ntimes, I use the mean to get the sum. Minus is because of the model convention, they consider
the flux negative if it is upwards.
~# ncap -O -s "e=-730*e" mean_evap_1985.nc sum_evap_1985.nc
- So we have our resulting field in the file sum_evap_1985.nc, which can be viewed using ncview.
The field looks as shown below. I do not know how to save the legend in ncview, so the figure is not very informative.
The result corresponds to the means given by ECMWF: E-P and P.
Subscribe to:
Posts (Atom)
