In [1]:
%run basics
import csv
In [2]:
csvname=qcio.get_filename_dialog()
In [8]:
# in here we open the file, read the header, work out the columns we want and then close the file
csvfile = open(csvname,'rb')
csvreader = csv.reader(csvfile)
header = csvreader.next()
dt_col=header.index("MODISdatecopy_new")
eviint_col = header.index("250m_16_days_EVI_new_interp")
evismo_col = header.index("250m_16_days_EVI_new_smooth")
print dt_col,eviint_col,evismo_col
csvfile.close()
In [86]:
evi=numpy.genfromtxt(csvname,skip_header=1,delimiter=",",usecols=(dt_col,eviint_col,evismo_col))
In [79]:
ds=qcio.DataStructure()
ds.globalattributes["xl_datemode"]=0
ds.globalattributes["time_step"]=30
ds.globalattributes["time_zone"]="Australia/Darwin"
ds.globalattributes["latitude"]=-34.00206
ds.globalattributes["longitude"]=140.58912
In [80]:
ds.series["xlDateTime"]={}
ds.series["xlDateTime"]["Data"]=numpy.array(evi[:,0]+1,dtype=numpy.float64)
nRecs=len(ds.series["xlDateTime"]["Data"])
ds.globalattributes["nc_nrecs"]=nRecs
flag=numpy.zeros(nRecs,dtype=numpy.int32)
ds.series["xlDateTime"]["Flag"]=flag
ds.series["xlDateTime"]["Attr"]={}
ds.series["xlDateTime"]["Attr"]["long_name"]="Date/time in Excel format"
ds.series["xlDateTime"]["Attr"]["units"]="days since 1899-12-31 00:00:00 +9:30"
ds.series["xlDateTime"]["Attr"]["standard_name"]="not defined"
ds.series["xlDateTime"]["Attr"]["cf_role"]="timeseries_id"
In [81]:
qcutils.get_datetimefromxldate(ds)
qcutils.get_ymdhms_from_datetime(ds)
In [82]:
ldt=ds.series["DateTime"]["Data"]
print ldt[0],ldt[-1]
In [83]:
attr=qcutils.MakeAttributeDictionary(long_name="MODIS EVI, 250m, interpolated",units="none")
qcutils.CreateSeries(ds,"EVI_MODIS_interp",evi[:,1],Flag=flag,Attr=attr)
attr=qcutils.MakeAttributeDictionary(long_name="MODIS EVI, 250m, interpolated and smooothed",units="none")
qcutils.CreateSeries(ds,"EVI_MODIS_smooth",evi[:,2],Flag=flag,Attr=attr)
In [84]:
ncname="../../Sites/Calperum/Data/MODIS/Calperum_MODIS_20000218to20140813.nc"
ncfile=qcio.nc_open_write(ncname)
qcio.nc_write_series(ncfile,ds)
In [ ]: