...
 
Commits (3)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division
from builtins import str
from builtins import range
......@@ -154,15 +154,17 @@ def writeLight(fname,data,date,meta=None):
('owiMask' , 'mask_flag'),
('owiPreProcessing/ND_2','nrcs_detrend_co'),
('owiPreProcessing/ND_2_cross' , 'nrcs_detrend_cr'),
# ('owiPreProcessing/FilterBinary_1' , 'heterogeneity_co_h'),
# ('owiPreProcessing/FilterBinary_2' , 'heterogeneity_co_m'),
# ('owiPreProcessing/FilterBinary_3' , 'heterogeneity_co_l'),
# ('owiPreProcessing/FilterBinary_1_cross' , 'heterogeneity_cr_h'),
# ('owiPreProcessing/FilterBinary_2_cross' , 'heterogeneity_cr_m'),
# ('owiPreProcessing/FilterBinary_3_cross' , 'heterogeneity_cr_l'),
('owiPreProcessing/FilterBinary_2' , 'heterogeneity_mask'), # TODO: waiting for merged filter
# heterogeneity mask should be commented in the future, once sarwing v3.0 is stable
('owiPreProcessing/FilterBinary_1' , 'heterogeneity_co_h'),
('owiPreProcessing/FilterBinary_2' , 'heterogeneity_co_m'),
('owiPreProcessing/FilterBinary_3' , 'heterogeneity_co_l'),
('owiPreProcessing/FilterBinary_1_cross' , 'heterogeneity_cr_h'),
('owiPreProcessing/FilterBinary_2_cross' , 'heterogeneity_cr_m'),
('owiPreProcessing/FilterBinary_3_cross' , 'heterogeneity_cr_l'),
('owiWindFilter' , 'heterogeneity_mask'),
('owiPreProcessing/wind_streaks_orientation_stddev' , 'wind_streaks_orientation_stddev'),
('owiPreProcessing/estimWindDir_2' , 'wind_streaks_orientation'), # TODO: should be owiPreProcessing/wind_streaks_orientation
('owiPreProcessing/wind_streaks_orientation' , 'wind_streaks_orientation'),
('owiNrcs' , 'nrcs_co'),
('owiNrcs_cross' , 'nrcs_cr'),
('owiElevationAngle' , 'elevation_angle'),
......@@ -193,7 +195,7 @@ def writeLight(fname,data,date,meta=None):
}
# missing input will be forced to NaN/not implemented
meta_not_implemented = {
'wind_streaks_orientation_stddev' : None
#'wind_streaks_orientation_stddev' : None
}
x,y = data['owiLon'].T.shape
nc=netCDF4.Dataset(fname, 'w', format='NETCDF4')
......@@ -392,13 +394,14 @@ def nclight2gridded(filein,fileout):
for var in list(set(ds_gd.coords.keys()) | set(ds_gd.keys())):
if var in meta_over:
# python 3 only (merge dict )
ds_gd[var].attrs = { **ds_sw[var].attrs,**meta_over[var] }
# ds_gd[var].attrs = { **ds_sw[var].attrs,**meta_over[var] }
# python 2 compat:
ds_gd[var].attrs.update(meta_over[var])
ds_gd.rio.set_spatial_dims('x','y', inplace=True)
ds_gd.rio.write_crs(crs, inplace=True)
ds_gd.to_netcdf(fileout)
ds_gd.to_netcdf(fileout,format='NETCDF4_CLASSIC')
def getAttribute(fname, attr):
try:
......