Example #1
0
foo = Dataset('chirps-v2.0.monthly.as.nc', 'w', format='NETCDF3_CLASSIC')

foo.createDimension('time', None)
foo.createDimension('latitude', pcp.shape[1])
foo.createDimension('longitude', pcp.shape[2])

foo.institution = 'Climate Hazards Group.  University of California at Santa Barbara'
foo.creator_name = 'Pete Peterson'
foo.history = 'created by Climate Hazards Group - Modified by Funceme (NetCDF3 - South America)'
foo.title = 'CHIRPS Version 2.0'
foo.creator_email = '*****@*****.**'
foo.documentation = 'http://pubs.usgs.gov/ds/832/'
foo.comments = 'time variable denotes the first day of the given month.'
foo.ftp_url = 'ftp://chg-ftpout.geog.ucsb.edu/pub/org/chg/products/CHIRPS-latest/'
foo.website = 'http://chg.geog.ucsb.edu/data/chirps/index.html'
foo.faq = 'http://chg-wiki.geog.ucsb.edu/wiki/CHIRPS_FAQ'
foo.version = 'Version 2.0'
foo.date_created = '2015-12-02'

lats = foo.createVariable('latitude', 'f4', ('latitude'))
lats.units = 'degrees_north'
lats.long_name = 'latitude'
lats.axis = "Y"
lats[:] = lat[:]

lons = foo.createVariable('longitude', 'f4', ('longitude'))
lons.units = 'degrees_east'
lons.long_name = 'longitude'
lons.axis = "X"
lons[:] = lon[:]