Commit f821782d authored by Peters, Wouter's avatar Peters, Wouter
Browse files

changed name conversion, writing of different variables now to sample_info.nc file

parent c62b1397
......@@ -178,7 +178,7 @@ class ObsPackObservations(Observation):
msg = 'Creating new observations file for ObservationOperator (%s)' % obsinputfile ; logging.debug(msg)
dimid = f.AddDim('obs',len(self.Data))
dim50char = f.AddDim('string_of50chars',50)
dim200char = f.AddDim('string_of200chars',200)
dim10char = f.AddDim('string_of10chars',10)
dimcalcomp = f.AddDim('calendar_components',6)
......@@ -259,7 +259,7 @@ class ObsPackObservations(Observation):
savedict['dtype'] = "char"
savedict['name'] = "obs_id"
savedict['units'] = "NOAA database identifier"
savedict['dims'] = dimid+dim50char
savedict['dims'] = dimid+dim200char
savedict['values'] = data
savedict['missing_value'] = '-'
savedict['_FillValue'] = '-'
......@@ -284,6 +284,7 @@ class ObsPackObservations(Observation):
"""
import da.tools.rc as rc
from da.tools.general import NameConvert
filename = self.DaCycle.DaSystem['obs.sites.rc']
......@@ -325,7 +326,7 @@ class ObsPackObservations(Observation):
SiteInfo = {}
for key in active:
sitename, sitecategory = SitesWeights[key].split(';')
sitename = sitename.strip().lower()
sitename = sitename.strip()
sitecategory = sitecategory.strip().lower()
SiteInfo[sitename] = SiteCategories[sitecategory]
#print sitename,SiteInfo[sitename]
......@@ -338,6 +339,8 @@ class ObsPackObservations(Observation):
identifier = "%s_%02d_%s"%(site,int(lab),method,)
identifier = NameConvert(name="%s_%s_%s"%(site.lower(),method.lower(),lab.lower(),), to='GV')
if SiteInfo.has_key(identifier):
msg = "Observation found (%s, %s)" % (obs.code, identifier,) ; logging.debug(msg)
obs.mdm = SiteInfo[identifier]['error']
......@@ -359,6 +362,7 @@ class ObsPackObservations(Observation):
import shutil
import da.tools.io4 as io
from da.tools.general import ToDectime
import numpy as np
outfile = os.path.join(self.DaCycle['dir.output'],'sampleinfo_%s.nc'% self.DaCycle['time.sample.stamp'])
......@@ -366,7 +370,7 @@ class ObsPackObservations(Observation):
msg = 'Creating new Sample output file for postprocessing (%s)' % outfile ; logging.debug(msg)
dimid = f.AddDim('obs',len(self.Data))
dim200char = f.AddDim('string_of200chars',200)
dim200char = f.AddDim('string_of50chars',200)
dim10char = f.AddDim('string_of10chars',10)
dimcalcomp = f.AddDim('calendar_components',6)
......@@ -418,31 +422,19 @@ class ObsPackObservations(Observation):
savedict['comment'] = 'Variance of mole fractions resulting from model-data mismatch'
dummy = f.AddData(savedict)
meandata = self.Data.getvalues('simulated')[:,0]
savedict = io.std_savedict.copy()
savedict['name'] = "modelsamplesmean_%s"%type
savedict['long_name'] = "modelsamplesforecastmean_%s" %type
savedict['units'] = "mol mol-1"
savedict['dims'] = dimid
savedict['values'] = meandata.tolist()
savedict['comment'] = '%s mean mixing ratios based on %s state vector'% (type,type,)
dummy = f.AddData(savedict)
devdata = self.Data.getvalues('simulated') - meandata
data = self.Data.getvalues('simulated')
dimmembers = f.AddDim('members',devdata.shape[1])
dimmembers = f.AddDim('members',data.shape[1])
savedict = io.std_savedict.copy()
savedict['name'] = "modelsamplesdeviations_%s"% type
savedict['long_name'] = "modelsamplesforecastdeviations_%s"%type
savedict['name'] = "modelsamples"
savedict['long_name'] = "modelsamples for all ensemble members"
savedict['units'] = "mol mol-1"
savedict['dims'] = dimid+dimmembers
savedict['values'] = devdata.tolist()
savedict['comment'] = '%s mixing ratio deviations based on %s state vector'% (type,type,)
savedict['values'] = data.tolist()
savedict['comment'] = 'simulated mixing ratios based on optimized state vector'
dummy = f.AddData(savedict)
data = self.Data.getvalues('fromfile')
savedict = io.std_savedict.copy()
......@@ -454,6 +446,7 @@ class ObsPackObservations(Observation):
savedict['missing_value'] = '-'
savedict['_FillValue'] = '-'
dummy = f.AddData(savedict)
status = f.close()
msg = "Successfully wrote data to Sample output file (%s)"%outfile ;logging.debug(msg)
......@@ -462,7 +455,6 @@ class ObsPackObservations(Observation):
################### End Class CtObservations ###################
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment