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

made all import statements dependent on the rc-file options for system

parent dadc24e9
......@@ -11,6 +11,7 @@ dir.da_run : ${HOME}/tmp/test_da
da.system : CarbonTracker
da.system.rc : carbontracker.rc
da.platform : maunaloa
! Info on the forward model to be used
......
......@@ -54,11 +54,13 @@ class DaSystem(object):
return True
def Validate(self, needed_rc_items):
def Validate(self ):
"""
Validate the contents of the rc-file given a dictionary of required keys
"""
needed_rc_items={}
for k,v in self.da_settings.iteritems():
if v == 'True' : self.da_settings[k] = True
if v == 'False': self.da_settings[k] = False
......
......@@ -14,51 +14,28 @@ import sys
import logging
import datetime
################### Begin Class DaSystem ###################
################### Begin Class CtDaSystem ###################
class DaSystem(object):
from da.baseclasses.dasystem import DaSystem
class CtDaSystem(DaSystem):
""" Information on the data assimilation system used. This is normally an rc-file with settings.
"""
def __init__(self,rcfilename):
"""
Initialization occurs from passed rc-file name
"""
self.LoadRc(rcfilename)
def __str__(self):
"""
String representation of a DaInfo object
"""
msg = "===============================================================" ; print msg
msg = "DA System Info rc-file is %s" % self.RcFileName ; print msg
msg = "===============================================================" ; print msg
return ""
def LoadRc(self,RcFileName):
def Validate(self):
"""
This method loads a DA System Info rc-file with settings for this simulation
Validate the contents of the rc-file given a dictionary of required keys
"""
import da.tools.rc as rc
self.da_settings = rc.read(RcFileName)
self.RcFileName = RcFileName
self.DaRcLoaded = True
msg = 'DA System Info rc-file (%s) loaded successfully'%self.RcFileName ; logging.info(msg)
return True
needed_rc_items = ['obs.input.dir',
'obs.input.fname',
'ocn.covariance',
'nparameters',
'bio.covariance',
'deltaco2.prefix',
'regtype']
def Validate(self, needed_rc_items):
"""
Validate the contents of the rc-file given a dictionary of required keys
"""
for k,v in self.da_settings.iteritems():
if v == 'True' : self.da_settings[k] = True
if v == 'False': self.da_settings[k] = False
......@@ -73,7 +50,7 @@ class DaSystem(object):
status,msg = ( True,'DA System Info settings have been validated succesfully' ) ; logging.debug(msg)
return None
################### End Class DaSystem ###################
################### End Class CtDaSystem ###################
if __name__ == "__main__":
......
......@@ -15,14 +15,6 @@ import datetime
identifier = 'CarbonTracker CO2'
needed_rc_items = ['obs.input.dir',
'obs.input.fname',
'ocn.covariance',
'nparameters',
'bio.covariance',
'deltaco2.prefix',
'regtype']
def StateToGrid(DaInfo,values,reverse=False,avg=False):
"""
This method converts parameters from a CarbonTracker StateVector object to a gridded map of linear multiplication values. These
......
......@@ -25,10 +25,6 @@ system_not_implemented_message = "Unable to import a system specific class or fu
def JobStart(opts,args):
""" Set up the job specific directory structure and create an expanded rc-file """
from da.tools.initexit import CycleControl
from da.baseclasses.dasystem import DaSystem
from da.ct.tools import needed_rc_items
#from da.platform.jet import JetPlatForm as PlatForm
from da.baseclasses.platform import PlatForm
# First create a CycleControl object that handles all the details of the da cycle
......@@ -36,19 +32,25 @@ def JobStart(opts,args):
# Next create a DaSystem object that contains all the details related to the DA system
DaSystem = DaSystem(DaCycle.da_settings['da.system.rc'])
if DaCycle.da_settings['da.system'] == 'CarbonTracker':
from da.ct.dasystem import CtDaSystem as DaSystem
else:
from da.baseclasses.dasystem import DaSystem
dummy = DaSystem.Validate(needed_rc_items)
DaSystem = DaSystem(DaCycle.da_settings['da.system.rc'])
# And add the DaSystem info the DaCycle object
dummy = DaSystem.Validate()
DaCycle.DaSystem = DaSystem
# Next, get the information on the platform, and on the DaCycle
# Next, get the information on the platform
DaPlatForm = PlatForm()
if DaCycle.da_settings['da.platform'] == 'jet':
from da.platform.jet import JetPlatForm as PlatForm
else:
from da.baseclasses.platform import PlatForm
# And add the DaPlatForm info the DaCycle object
DaPlatForm = PlatForm()
DaCycle.DaPlatForm = DaPlatForm
......@@ -57,7 +59,10 @@ def JobStart(opts,args):
def JobInput(DaCycle):
""" Set up the input data for the forward model: obs and parameters/fluxes"""
from da.ct.statevector import CtStateVector as StateVector
if DaCycle.da_settings['da.system'] == 'CarbonTracker':
from da.ct.statevector import CtStateVector as StateVector
else:
from da.baseclasses.statevector import StateVector
dims = ( int(DaCycle.da_settings['time.nlag']),
int(DaCycle.da_settings['forecast.nmembers']),
......
......@@ -11,6 +11,7 @@ dir.da_run : ${HOME}/tmp/test_da
da.system : CarbonTracker
da.system.rc : carbontrackerjet.rc
da.platform : jet
! Info on the forward model to be used
......
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