diff --git a/da/ct/statevector.py b/da/ct/statevector.py index 08eaa9ad3ab9db69cc847d87a91bca108ce776c6..591811a372db69ad2a03814f3e1314fa7abe5b24 100755 --- a/da/ct/statevector.py +++ b/da/ct/statevector.py @@ -83,69 +83,6 @@ class CtStateVector(StateVector): ################### End Class CtStateVector ################### -################# Stand alone methods that manipulate the objects above ############## - -def PrepareState(CycleInfo): - """ - - Prepare the ensemble of parameters needed by the forecast model. There are two possible pathways: - - (A) Construct a brand new ensemble from a covariance matrix - - (B) Get an existing ensemble and propagate it - - The steps for procedure A are: - - (A1) Construct the covariance matrix - (A2) Make a Cholesky decomposition - (A3) Prepare a set of [nmembers] input parameters for each forecast member - - The steps for procedure B are: - - (B1) Get existing parameter values for each member - (B2) Run them through a forecast model - - - Both procedures finish with writing the parameter values to a NetCDF file - - - """ - dims = ( int(CycleInfo.da_settings['time.nlag']), - int(CycleInfo.da_settings['forecast.nmembers']), - int(CycleInfo.DaSystem.da_settings['nparameters']), - ) - StateVector = CtStateVector(dims) - - nlag = dims[0] - - # We now have an empty CtStateVector object that we need to populate with data. If this is a continuation from a previous cycle, we can read - # the previous StateVector values from a NetCDF file in the save/ directory. If this is the first cycle, we need to populate the CtStateVector - # with new values for each week. After we have constructed the StateVector, it will be propagated by one cycle length so it is ready to be used - # in the current cycle - - if not CycleInfo.da_settings['time.restart']: - - # Fill each week from n=1 to n=nlag with a new ensemble - - for n in range(0,nlag): - cov = StateVector.GetCovariance(CycleInfo.DaSystem) - dummy = StateVector.MakeNewEnsemble(n+1,cov) - else: - - # Read the StateVector data from file - - savedir = CycleInfo.da_settings['dir.save'] - filtertime = CycleInfo.da_settings['time.start'].strftime('%Y%m%d') - filename = os.path.join(savedir,'savestate.nc') - - StateVector.ReadFromFile(filename) - - # Now propagate the ensemble by one cycle to prepare for the current cycle - - dummy = StateVector.Propagate() - - return StateVector - if __name__ == "__main__": diff --git a/da/ct/tools.py b/da/ct/tools.py index dab211de71d4db521c226792e47030f1ddf7f868..7e4fb249a6ad06502342efa708711413e503bb8e 100755 --- a/da/ct/tools.py +++ b/da/ct/tools.py @@ -23,69 +23,6 @@ needed_rc_items = ['obs.input.dir', 'deltaco2.prefix', 'regtype'] -################### Begin Class DaInfo ################### - -class DaInfo(object): - """ Information on the data assimilation system used. For CarbonTracker, this is an rc-file with settings. - The settings list includes at least the values above, in needed_rc_items. - """ - - def __init__(self,rcfilename): - """ - Initialization occurs from passed rc-file name - """ - - self.LoadRc(rcfilename) - self.ValidateRC() - - 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 ValidateRC(self): - """ - 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 DaInfo ################### - 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