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....@python.com" 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. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users