...
 
Commits (2)
......@@ -197,8 +197,13 @@ def writeLight(fname,data,date,meta=None):
meta_not_implemented = {
#'wind_streaks_orientation_stddev' : None
}
# translate dtype is only relevant for NETCDF4_CLASSIC
translate_dtype = {
np.dtype(np.uint8) : np.dtype(np.int16)
}
x,y = data['owiLon'].T.shape
nc=netCDF4.Dataset(fname, 'w', format='NETCDF4')
nc=netCDF4.Dataset(fname, 'w', format='NETCDF4_CLASSIC')
nc.createDimension('time',1)
nc.createDimension('y',y)
nc.createDimension('x',x)
......@@ -213,7 +218,7 @@ def writeLight(fname,data,date,meta=None):
setattr(nc, global_attr, meta[global_attr])
except:
logger.warning('skipping missing attr %s' % global_attr)
time = nc.createVariable('time',np.int64,dimensions=('time'))
time = nc.createVariable('time',np.int32,dimensions=('time')) # np.int32 induce 2038 bug, but is compatible with nc3
time.standard_name = 'time'
epoch = datetime.datetime(1970, 1, 1)
time.units = "seconds since %s" % epoch.strftime("%Y-%m-%d %H:%M:%S")
......@@ -229,7 +234,10 @@ def writeLight(fname,data,date,meta=None):
except:
fill_value=None
# transpose dims for correct netcdf ordering
ncvar = nc.createVariable(out_name,value.dtype,dimensions=('time','y','x'),fill_value=fill_value)
dtype = value.dtype
if dtype in translate_dtype:
dtype = translate_dtype[dtype]
ncvar = nc.createVariable(out_name,dtype,dimensions=('time','y','x'),fill_value=fill_value)
for _attr in attrs:
try:
......