diff --git a/da/ct/dasystem.py b/da/ct/dasystem.py new file mode 100755 index 0000000000000000000000000000000000000000..fa793538ccf4cffa10a143d62c3658f1a9ddfa61 --- /dev/null +++ b/da/ct/dasystem.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# control.py + +""" +Author : peters + +Revision History: +File created on 26 Aug 2010. + +""" + +import os +import sys +import logging +import datetime + +################### Begin Class DaSystem ################### + +class DaSystem(object): + """ 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): + """ + This method loads a DA System Info rc-file with settings for this simulation + """ + 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 + + + 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 + + for key in needed_rc_items: + + if not self.da_settings.has_key(key): + status,msg = ( False,'Missing a required value in rc-file : %s' % key) + logging.error(msg) + raise IOError,msg + + status,msg = ( True,'DA System Info settings have been validated succesfully' ) ; logging.debug(msg) + + return None +################### End Class DaSystem ################### + + +if __name__ == "__main__": + pass