Skip to content
Snippets Groups Projects
Commit 1f4e2380 authored by Peters, Wouter's avatar Peters, Wouter
Browse files

Changes needed for WRF-STIL, all compatible with base code

parent feaab268
No related branches found
No related tags found
No related merge requests found
......@@ -141,6 +141,12 @@ class ObservationOperator(object):
################### End Class ObservationOperator ###################
class RandomizerObservationOperator(ObservationOperator):
""" This class holds methods and variables that are needed to use a random number generated as substitute
for a true observation operator. It takes observations and returns values for each obs, with a specified
amount of white noise added
"""
if __name__ == "__main__":
......
......@@ -91,7 +91,7 @@ class Optimizer(object):
alllocalize = [] # collect all model samples for n=1,..,nlag
allflags = [] # collect all model samples for n=1,..,nlag
allspecies = [] # collect all model samples for n=1,..,nlag
allsimulated = None # collect all members model samples for n=1,..,nlag
allsimulated = [] # collect all members model samples for n=1,..,nlag
for n in range(self.nlag):
samples = statevector.obs_to_assimilate[n]
......@@ -112,11 +112,8 @@ class Optimizer(object):
allids.extend(samples.getvalues('id'))
simulatedensemble = samples.getvalues('simulated')
if allsimulated == None :
allsimulated = np.array(simulatedensemble)
else:
allsimulated = np.concatenate((allsimulated, np.array(simulatedensemble)), axis=0)
for s in range(simulatedensemble.shape[0]):
allsimulated.append(simulatedensemble[s])
self.obs[:] = np.array(allobs)
self.obs_ids[:] = np.array(allids)
......
......@@ -399,9 +399,11 @@ class StateVector(object):
logging.info('Successfully read the State Vector from file (%s) ' % filename)
def write_members_to_file(self, lag, outdir):
def write_members_to_file(self, lag, outdir,endswith='.nc'):
"""
:param: lag: Which lag step of the filter to write, must lie in range [1,...,nlag]
:param: outdir: Directory where to write files
:param: endswith: Optional label to add to the filename, default is simply .nc
:rtype: None
Write ensemble member information to a NetCDF file for later use. The standard output filename is
......@@ -424,7 +426,7 @@ class StateVector(object):
members = self.ensemble_members[lag]
for mem in members:
filename = os.path.join(outdir, 'parameters.%03d.nc' % mem.membernumber)
filename = os.path.join(outdir, 'parameters.%03d%s' % (mem.membernumber, endswith))
ncf = io.CT_CDF(filename, method='create')
dimparams = ncf.add_params_dim(self.nparams)
dimgrid = ncf.add_latlon_dim()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment