Hello, I'm trying to write a function to create a 'vanilla' NetCDF file to
which I can add data.
So far I have created the following, which is designed to set up a netcdf
file for the addition of global or at least lat/lon datasets. My question
has to do with attribute setting. Is it valid to do what I'm doing below
"nco.attribute = attributevalue" or do you have to use the setattr function
as outlined in some tutorials?
Thanks!
def default_netcdf(nco_filename,
lon0=-179.5,lat0=-89.5,
nx=720,ny=360,
dx=0.5,dy=0.5):
""" add default attributes and dimensions to the nc file """
nco = NetCDFFile(nco_filename,'w')
nco.author = "Some One"
nco.createdate = dt.datetime.now().ctime()
nco.contact = "some.one@...2855..."
nco.Conventions = "CF-1.4"
nco.createDimension('lon',nx)
nco.createDimension('lat',ny)
nco.createVariable('lat','d',('lat',))
nco.createVariable('lon','d',('lon',))
lon = np.arange(lon0,lon0+(nx*dx),dx)
lat = np.arange(lat0,lat0+(ny*dy),dy)
nco.variables['lat'][:] = lat
nco.variables['lon'][:] = lon
nco.createVariable('data','d',('lon','lat'))
return nco
···
--
View this message in context: http://old.nabble.com/function-to-create-netcdf-file-tp26301238p26301238.html
Sent from the matplotlib - users mailing list archive at Nabble.com.