Commit 44c27ad1 authored by karolina's avatar karolina
Browse files

removed need for a DaCycle in ObsOperator

parent 7efad832
...@@ -143,7 +143,7 @@ class Optimizer(object): ...@@ -143,7 +143,7 @@ class Optimizer(object):
StateVector.isOptimized = True StateVector.isOptimized = True
logging.debug('Returning optimized data to the StateVector, setting "StateVector.isOptimized = True" ') logging.debug('Returning optimized data to the StateVector, setting "StateVector.isOptimized = True" ')
def write_diagnostics(self, DaCycle, StateVector, type='prior'): def write_diagnostics(self, diagdir, timestart, StateVector, type='prior'):
""" """
Open a NetCDF file and write diagnostic output from optimization process: Open a NetCDF file and write diagnostic output from optimization process:
...@@ -160,9 +160,9 @@ class Optimizer(object): ...@@ -160,9 +160,9 @@ class Optimizer(object):
import da.tools.io4 as io import da.tools.io4 as io
#import da.tools.io as io #import da.tools.io as io
outdir = DaCycle['dir.diagnostics']
filename = os.path.join(outdir, 'optimizer.%s.nc' % DaCycle['time.start'].strftime('%Y%m%d')) filename = os.path.join(diagdir, 'optimizer.%s.nc' % timestart.strftime('%Y%m%d'))
DaCycle.OutputFileList.append(filename) #DaCycle.OutputFileList.append(filename)
# Open or create file # Open or create file
...@@ -294,7 +294,7 @@ class Optimizer(object): ...@@ -294,7 +294,7 @@ class Optimizer(object):
f.close() f.close()
logging.debug('Diagnostics file closed') logging.debug('Diagnostics file closed')
return filename
def serial_minimum_least_squares(self): def serial_minimum_least_squares(self):
""" Make minimum least squares solution by looping over obs""" """ Make minimum least squares solution by looping over obs"""
......
...@@ -58,7 +58,7 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -58,7 +58,7 @@ class TM5ObservationOperator(ObservationOperator):
""" """
def __init__(self, RcFileName, DaCycle=None): def __init__(self, RcFileName):
""" The instance of an TMObservationOperator is application dependent """ """ The instance of an TMObservationOperator is application dependent """
self.Identifier = identifier # the identifier gives the model name self.Identifier = identifier # the identifier gives the model name
self.Version = version # the model version used self.Version = version # the model version used
...@@ -73,10 +73,6 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -73,10 +73,6 @@ class TM5ObservationOperator(ObservationOperator):
# The following code allows the object to be initialized with a DaCycle object already present. Otherwise, it can # The following code allows the object to be initialized with a DaCycle object already present. Otherwise, it can
# be added at a later moment. # be added at a later moment.
if DaCycle != None:
self.DaCycle = DaCycle
else:
self.DaCycle = {}
logging.info('Observation Operator initialized: %s (%s)' % (self.Identifier, self.Version)) logging.info('Observation Operator initialized: %s (%s)' % (self.Identifier, self.Version))
......
...@@ -41,14 +41,14 @@ def EnsembleSmootherPipeline(DaCycle, PlatForm, DaSystem, Samples, StateVector, ...@@ -41,14 +41,14 @@ def EnsembleSmootherPipeline(DaCycle, PlatForm, DaSystem, Samples, StateVector,
def start_job(DaCycle, DaSystem, DaPlatForm, StateVector, Samples, ObsOperator): def start_job(DaCycle, DaSystem, DaPlatForm, StateVector, Samples, ObsOperator):
""" Set up the job specific directory structure and create an expanded rc-file """ """ Set up the job specific directory structure and create an expanded rc-file """
DaSystem.Validate() #LU tylko sprawdza needed rc items in the file DaSystem.Validate()
DaCycle.DaSystem = DaSystem #LU przypisuje dacyclowi liste parametrow DaCycle.DaSystem = DaSystem
DaCycle.DaPlatForm = DaPlatForm #LU przypisuje cyklowi platforme (tez liste parametrow) DaCycle.DaPlatForm = DaPlatForm
DaCycle.Initialize() #LU nastepnie cykl zostaje inicjalizowany...bardzo logiczne DaCycle.Initialize()
#StateVector.DaCycle = DaCycle # also embed object in StateVector so it can access cycle information for I/O etc #LU cykl zostaje przypisany state vectorowi #StateVector.DaCycle = DaCycle # also embed object in StateVector so it can access cycle information for I/O etc
Samples.DaCycle = DaCycle # also embed object in Samples object so it can access cycle information for I/O etc #LU cykl zostaje przypisany probkom #Samples.DaCycle = DaCycle # also embed object in Samples object so it can access cycle information for I/O etc
ObsOperator.DaCycle = DaCycle # also embed object in ObsOperator object so it can access cycle information for I/O etc #LU cykl zostaje przypisany obsoperatorowi ObsOperator.DaCycle = DaCycle # also embed object in ObsOperator object so it can access cycle information for I/O etc
ObsOperator.Initialize() # Setup Observation Operator #LU a pote mobsoperator jest inicjalizowany ObsOperator.Initialize() # Setup Observation Operator
def prepare_state(DaCycle, StateVector, newrc): def prepare_state(DaCycle, StateVector, newrc):
...@@ -257,7 +257,8 @@ def invert(DaCycle, StateVector, Optimizer): ...@@ -257,7 +257,8 @@ def invert(DaCycle, StateVector, Optimizer):
Optimizer.Initialize(dims) Optimizer.Initialize(dims)
Optimizer.state_to_matrix(StateVector) Optimizer.state_to_matrix(StateVector)
Optimizer.write_diagnostics(DaCycle, StateVector, type='prior') filename = Optimizer.write_diagnostics(DaCycle['dir.diagnostics'], DaCycle['time.start'], StateVector, type='prior')
DaCycle.OutputFileList.append(filename)
Optimizer.set_localization('None') Optimizer.set_localization('None')
if not DaCycle.DaSystem.has_key('opt.algorithm'): if not DaCycle.DaSystem.has_key('opt.algorithm'):
...@@ -273,7 +274,7 @@ def invert(DaCycle, StateVector, Optimizer): ...@@ -273,7 +274,7 @@ def invert(DaCycle, StateVector, Optimizer):
Optimizer.matrix_to_state(StateVector) Optimizer.matrix_to_state(StateVector)
Optimizer.write_diagnostics(DaCycle, StateVector, type='optimized') Optimizer.write_diagnostics(DaCycle['dir.diagnostics'], DaCycle['time.start'], StateVector, type='optimized')
StateVector.isOptimized = True StateVector.isOptimized = True
......
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