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

merged r1186 and r1218 into new version that works under current trunk

parent 9ad0f3f9
Branches
No related tags found
No related merge requests found
......@@ -24,13 +24,13 @@ from da.baseclasses.obs import Observation
class ObsPackObservations(Observation):
""" an object that holds data + methods and attributes needed to manipulate mixing ratio values """
def Initialize(self, start, end, params):
def Initialize(self):
self.startdate = start
self.enddate = end
self.startdate = self.DaCycle['time.sample.start']
self.enddate = self.DaCycle['time.sample.end']
op_id = params['obspack.input.id']
op_dir = params['obspack.input.dir']
op_id = self.DaCycle.DaSystem['obspack.input.id']
op_dir = self.DaCycle.DaSystem['obspack.input.dir']
if not os.path.exists(op_dir):
msg = 'Could not find the required ObsPack distribution (%s) ' % op_dir
......@@ -67,7 +67,7 @@ class ObsPackObservations(Observation):
items = line.split()
#ncfile, lab , start_date, stop_date, data_comparison = items[0:5]
ncfile, lab, start_date, stop_date, data_comparison= line[:105].split()
ncfile, lab , start_date, stop_date, data_comparison= line[:105].split()
ncfilelist += [ncfile]
......@@ -133,6 +133,7 @@ class ObsPackObservations(Observation):
for idx, val in zip(ids, simulated):
if idx in obs_ids:
index = obs_ids.index(idx)
self.datalist[index].simulated = val # in mol/mol
else:
missing_samples.append(idx)
......@@ -143,14 +144,14 @@ class ObsPackObservations(Observation):
logging.debug("Added %d simulated values to the Data list" % (len(ids) - len(missing_samples)))
def write_sample_info(self, dirinput, timestamp):
def write_sample_info(self):
"""
Write the information needed by the observation operator to a file. Return the filename that was written for later use
"""
import da.tools.io4 as io
obsinputfile = os.path.join(dirinput, 'observations_%s.nc' % timestamp)
obsinputfile = os.path.join(self.DaCycle['dir.input'], 'observations_%s.nc' % self.DaCycle['time.sample.stamp'])
f = io.CT_CDF(obsinputfile, method='create')
logging.debug('Creating new observations file for ObservationOperator (%s)' % obsinputfile)
......@@ -252,7 +253,7 @@ class ObsPackObservations(Observation):
return obsinputfile
def add_model_data_mismatch(self, filename):
def add_model_data_mismatch(self):
"""
Get the model-data mismatch values for this cycle.
......@@ -264,7 +265,7 @@ class ObsPackObservations(Observation):
"""
import da.tools.rc as rc
filename = self.DaCycle.DaSystem['obs.sites.rc']
if not os.path.exists(filename):
msg = 'Could not find the required sites.rc input file (%s) ' % filename
......@@ -359,14 +360,14 @@ class ObsPackObservations(Observation):
logging.debug("Added Model Data Mismatch to all samples ")
def write_obs_to_file(self, outdir, timestamp, filenam="oldstyle"):
def write_obs_to_file(self,filenam="oldstyle"):
"""
Write selected information contained in the Observation object to a file.
"""
import da.tools.io4 as io
outfile = os.path.join(outdir, 'sampleinfo_%s__%s.nc' % (timestamp, filenam))
outfile = os.path.join(self.DaCycle['dir.output'], 'sampleinfo_%s__%s.nc' % (self.DaCycle['time.sample.stamp'], filenam))
f = io.CT_CDF(outfile, method='create')
logging.debug('Creating new Sample output file for postprocessing (%s)' % outfile)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment