Commit 33a1f72f authored by Peters, Wouter's avatar Peters, Wouter
Browse files

added site codes to optimizer file, just for convenience...

parent d66cbc2f
......@@ -76,6 +76,8 @@ class Optimizer(object):
self.flags = np.zeros(self.nobs,int)
# species type
self.species = np.zeros(self.nobs,str)
# species type
self.sitecode = np.zeros(self.nobs,str)
# species mask
self.speciesmask = {}
......@@ -92,6 +94,7 @@ class Optimizer(object):
except:
pass
allsites=[] # collect all obs for n=1,..,nlag
allobs=[] # collect all obs for n=1,..,nlag
allmdm=[] # collect all mdm for n=1,..,nlag
allsamples=[] # collect all model samples for n=1,..,nlag
......@@ -118,6 +121,7 @@ class Optimizer(object):
allflags.extend( Samples.Data.getvalues('flag') )
allspecies.extend( Samples.Data.getvalues('species') )
allobs.extend( Samples.Data.getvalues('obs') )
allsites.extend( Samples.Data.getvalues('code') )
allmdm.extend( Samples.Data.getvalues('mdm') )
allids.extend( Samples.Data.getvalues('id') )
......@@ -132,7 +136,6 @@ class Optimizer(object):
self.obs[:] = np.array(allobs)
self.obs_ids[:] = np.array(allids)
print self.HX_prime[:,:].shape,np.array(allsimulated).shape
self.HX_prime[:,:] = np.array(allsimulated)
self.Hx[:] = self.HX_prime[:,0]
......@@ -140,7 +143,7 @@ class Optimizer(object):
self.may_localize[:] = np.array(alllocalize)
self.flags[:] = np.array(allflags)
self.species[:] = np.array(allspecies)
self.sitecode = allsites
self.X_prime = self.X_prime - self.x[:,np.newaxis] # make into a deviation matrix
self.HX_prime = self.HX_prime - self.Hx[:,np.newaxis] # make a deviation matrix
......@@ -202,6 +205,7 @@ class Optimizer(object):
dimlag = f.AddLagDim(self.nlag, unlimited=False)
dimobs = f.AddObsDim(self.nobs)
dimstate = f.AddDim('nstate',self.nparams*self.nlag)
dim200char = f.AddDim('string_of200chars',200)
# Add data, first the ones that are written both before and after the optimization
......@@ -249,10 +253,23 @@ class Optimizer(object):
savedict['comment'] = '%s mixing ratio deviations based on %s state vector'% (type,type,)
dummy = f.AddData(savedict)
# Continue with prior only data
if type == 'prior':
data = self.sitecode
savedict = io.std_savedict.copy()
savedict['name'] = "sitecode"
savedict['long_name'] = "site code propagated from observation file"
savedict['dtype'] = "char"
savedict['dims'] = dimobs+dim200char
savedict['values'] = data
savedict['missing_value'] = '!'
status = f.AddData(savedict)
data = self.obs
savedict = io.std_savedict.copy()
......
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