import netCDF4
from pylab import *
from pandas import read_csv
ncout = netCDF4.Dataset('test.nc','w')
data=array(read_csv('../dmsclimatology/DMSclim_APR.csv',header=None))
dim0 = size(data,0)
dim1 = size(data,1)
lats_out = 89.5 - 1.0*arange(dim0,dtype='float32')
lons_out = -179.5 + 1.0*arange(dim1,dtype='float32')
ncout.createDimension('latitude',dim0)
ncout.createDimension('longitude',dim1)
lats = ncout.createVariable('latitude',dtype('float32').char,('latitude',))
lons = ncout.createVariable('longitude',dtype('float32').char,('longitude',))
lats.units = 'degrees_north'
lons.units = 'degrees_east'
lats[:] = lats_out
lons[:] = lons_out
dms = ncout.createVariable('DMS',dtype('float32').char,('latitude','longitude'))
dms.units = 'nmol L-1'
dms[:] = data
ncout.close()
If you want to use this script, you would need to make sure you have those three modules and change the file name associated with the read_csv function to your own.
The output looks like this (on the right) and you can confirm that this is consistent with the published figure (on the left). NOTE: the color bar scales are different, so they don't look exactly the same.
0 件のコメント:
コメントを投稿