Project

General

Profile

How to add a variable and a dimension to a netcdf file

Added by nazanin tavakoli about 3 years ago

Hi,
I want to add a dimension that is called lengthd to my NetCDF data. My data's dimension has time, longitude, and latitude, and I want to add lengthd= 10 to my data. Also, I want to add date and time_weights to my variable which have the following properties:

time_weights
Size: 12x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'number of days per time step'
units = 'days'
date
Size: 10x12
Dimensions: lengthd,time
Datatype: char
Attributes:
long_name = 'label for each time step'
units = ''
Could anybody help me?
I would appreciate it if you help me.


Replies (3)

RE: How to add a variable and a dimension to a netcdf file - Added by Ralf Mueller about 3 years ago

CDO is not designed for a request like this. you better use NCO or a scripting language that offers netcdf bindings (Python,Ruby,R,...)

hth
ralf

RE: How to add a variable and a dimension to a netcdf file - Added by nazanin tavakoli about 3 years ago

Could you please help me how can I do it with nco?

RE: How to add a variable and a dimension to a netcdf file - Added by Ralf Mueller about 3 years ago

I think ncap2 should be a good choice http://nco.sourceforge.net/nco.html#ncap2-netCDF-Arithmetic-Processor

the python-netCDF4 package is also well suited for what you want I think: https://github.com/Unidata/netcdf4-python/blob/master/examples/tutorial.py you can google it for more examples

    (1-3/3)