Commit 3bf2a95c authored by karolina's avatar karolina
Browse files

renamed package ct to carbondioxide and ctgridded to co2gridded

renamed class names Ct- to CO2-
changed class name Observation to Observations 
small cleanup changes to template.py
parent ab8ac2df
......@@ -117,7 +117,7 @@ def save_weekly_avg_1x1_data(DaCycle, StateVector):
for n in range(nlag, 0, -1):
priordate = enddate - timedelta(dt.days * n)
savedir = DaCycle['dir.output'].replace(startdate.strftime('%Y%m%d'), priordate.strftime('%Y%m%d'))
filename = os.path.join(savedir, 'savestate.nc')#LU i suppose that it would be priordate (savestate gets same stamp as dir.output=
filename = os.path.join(savedir, 'savestate_%s.nc' % priordate.strftime('%Y%m%d'))
if os.path.exists(filename):
StateVector.read_from_file(filename, qual=qual_short)
gridmean, gridensemble = StateVector.state_to_grid(lag=n)
......@@ -131,7 +131,7 @@ def save_weekly_avg_1x1_data(DaCycle, StateVector):
else:
qual_short = 'opt'
savedir = DaCycle['dir.output']
filename = os.path.join(savedir, 'savestate.nc')
filename = os.path.join(savedir, 'savestate_%s.nc' % startdate.strftime('%Y%m%d'))
StateVector.read_from_file(filename, qual=qual_short)
gridmean, gridensemble = StateVector.state_to_grid(lag=1)
......@@ -301,7 +301,7 @@ def save_weekly_avg_state_data(DaCycle, StateVector):
for n in range(nlag, 0, -1):
priordate = enddate - timedelta(dt.days * n)
savedir = DaCycle['dir.output'].replace(startdate.strftime('%Y%m%d'), priordate.strftime('%Y%m%d'))
filename = os.path.join(savedir, 'savestate.nc')
filename = os.path.join(savedir,'savestate_%s.nc' % priordate.strftime('%Y%m%d'))
if os.path.exists(filename):
StateVector.read_from_file(filename, qual=qual_short)
......@@ -316,7 +316,7 @@ def save_weekly_avg_state_data(DaCycle, StateVector):
else:
qual_short = 'opt'
savedir = DaCycle['dir.output']
filename = os.path.join(savedir, 'savestate.nc')
filename = os.path.join(savedir, 'savestate_%s.nc' % startdate.strftime('%Y%m%d'))
StateVector.read_from_file(filename)
choicelag = 1
statemean = StateVector.EnsembleMembers[choicelag - 1][0].ParameterValues
......@@ -1027,8 +1027,8 @@ if __name__ == "__main__":
import logging
from da.tools.initexit import CycleControl
from da.ct.dasystem import CtDaSystem
from da.ct.statevector import CtStateVector
from da.carbondioxide.dasystem import CO2DaSystem
from da.carbondioxide.statevector import CO2StateVector
sys.path.append('../../')
......@@ -1038,11 +1038,11 @@ if __name__ == "__main__":
DaCycle.initialize()
DaCycle.parse_times()
DaSystem = CtDaSystem('../rc/carbontracker_ct09_opfnew.rc')
DaSystem = CO2DaSystem('../rc/carbontracker_ct09_opfnew.rc')
DaCycle.DaSystem = DaSystem
StateVector = CtStateVector()
StateVector = CO2StateVector()
StateVector.initialize(DaCycle)
while DaCycle['time.end'] < DaCycle['time.finish']:
......
......@@ -315,10 +315,9 @@ def write_mixing_ratios(DaCycle):
if __name__ == "__main__":
import logging
from da.tools.initexit import CycleControl
from da.ct.dasystem import CtDaSystem
from da.carbondioxide.dasystem import CO2DaSystem
sys.path.append('../../')
......@@ -328,7 +327,7 @@ if __name__ == "__main__":
DaCycle.initialize()
DaCycle.parse_times()
DaSystem = CtDaSystem('../rc/carbontracker_ct09_opf.rc')
DaSystem = CO2DaSystem('../rc/carbontracker_ct09_opf.rc')
DaSystem.initialize()
DaCycle.DaSystem = DaSystem
......
......@@ -745,8 +745,8 @@ def residuals_new(fig, infile):
if __name__ == '__main__': # started as script
from da.tools.initexit import CycleControl
from da.ct.dasystem import CtDaSystem
from da.ct.statevector import CtStateVector
from da.carbondioxide.dasystem import CO2DaSystem
from da.carbondioxide.statevector import CO2StateVector
sys.path.append('../../')
......@@ -756,7 +756,7 @@ if __name__ == '__main__': # started as script
DaCycle.initialize()
DaCycle.parse_times()
DaSystem = CtDaSystem('../rc/carbontracker_ct09_opf.rc')
DaSystem = CO2DaSystem('../rc/carbontracker_ct09_opf.rc')
DaSystem.initialize()
DaCycle.DaSystem = DaSystem
......
......@@ -332,7 +332,7 @@ def grep(pattern, fil):
if __name__ == '__main__': # started as script
from da.tools.initexit import CycleControl
from da.ct.dasystem import CtDaSystem
from da.carbondioxide.dasystem import CO2DaSystem
sys.path.append('../../')
......@@ -342,7 +342,7 @@ if __name__ == '__main__': # started as script
DaCycle.initialize()
DaCycle.parse_times()
DaSystem = CtDaSystem('../rc/carbontracker_ct09_opf.rc')
DaSystem = CO2DaSystem('../rc/carbontracker_ct09_opf.rc')
DaSystem.initialize()
DaCycle.DaSystem = DaSystem
......
......@@ -8,7 +8,7 @@
Revision History:
File created on 28 Jul 2010.
.. autoclass:: da.baseclasses.obs.Observation
.. autoclass:: da.baseclasses.obs.Observations
:members: initialize, Validate, add_observations, add_simulations, add_model_data_mismatch, write_sample_info
.. autoclass:: da.baseclasses.obs.ObservationList
......@@ -19,14 +19,14 @@ File created on 28 Jul 2010.
import logging
from numpy import array, ndarray
identifier = 'Observation baseclass'
identifier = 'Observations baseclass'
version = '0.0'
################### Begin Class Observation ###################
################### Begin Class Observations ###################
class Observation(object):
class Observations(object):
"""
The baseclass Observation is a generic object that provides a number of methods required for any type of observations used in
The baseclass Observations is a generic object that provides a number of methods required for any type of observations used in
a data assimilation system. These methods are called from the CarbonTracker pipeline.
.. note:: Most of the actual functionality will need to be provided through a derived Observations class with the methods
......@@ -35,17 +35,17 @@ class Observation(object):
Upon initialization of the class, an object is created that holds no actual data, but has a placeholder attribute `self.Data`
which is an empty list of type :class:`~da.baseclasses.obs.ObservationList`. An ObservationList object is created when the
method :meth:`~da.baseclasses.obs.Observation.add_observations` is invoked in the pipeline.
method :meth:`~da.baseclasses.obs.Observations.add_observations` is invoked in the pipeline.
From the list of observations, a file is written by method
:meth:`~da.baseclasses.obs.Observation.write_sample_info`
:meth:`~da.baseclasses.obs.Observations.write_sample_info`
with the sample info needed by the
:class:`~da.baseclasses.observationoperator.ObservationOperator` object. The values returned after sampling
are finally added by :meth:`~da.baseclasses.obs.Observation.add_simulations`
are finally added by :meth:`~da.baseclasses.obs.Observations.add_simulations`
"""
def __init__(self, DaCycle=None):#LU to sie nigdy nie wywola, prawda?
def __init__(self):
"""
create an object with an identifier, version, and an empty ObservationList
"""
......@@ -56,12 +56,7 @@ class Observation(object):
# The following code allows the object to be initialized with a DaCycle object already present. Otherwise, it can
# be added at a later moment.
if DaCycle != None:
self.DaCycle = DaCycle
else:
self.DaCycle = {}
logging.info('Observation object initialized: %s' % self.Identifier)
logging.info('Observations object initialized: %s' % self.Identifier)
def getlength(self):
return len(self.datalist)
......@@ -73,7 +68,7 @@ class Observation(object):
def add_observations(self):
"""
Add actual observation data to the Observation object. This is in a form of an
Add actual observation data to the Observations object. This is in a form of an
:class:`~da.baseclasses.obs.ObservationList` that is contained in self.Data. The
list has as only requirement that it can return the observed+simulated values
through the method :meth:`~da.baseclasses.obs.ObservationList.getvalues`
......@@ -81,7 +76,7 @@ class Observation(object):
"""
def add_simulations(self):
""" Add the simulation data to the Observation object.
""" Add the simulation data to the Observations object.
"""
def add_model_data_mismatch(self):
......
......@@ -116,7 +116,7 @@ class Optimizer(object):
simulatedensemble = Samples.getvalues('simulated')
if allsimulated == None : #LU if allsimulated: np.concatenate; else: np.array
if allsimulated == None :
allsimulated = np.array(simulatedensemble)
else:
allsimulated = np.concatenate((allsimulated, np.array(simulatedensemble)), axis=0)
......
......@@ -11,11 +11,11 @@ File created on 26 Aug 2010.
import logging
################### Begin Class CtDaSystem ###################
################### Begin Class CO2DaSystem ###################
from da.baseclasses.dasystem import DaSystem
class CtDaSystem(DaSystem):
class CO2DaSystem(DaSystem):
""" Information on the data assimilation system used. This is normally an rc-file with settings.
"""
def validate(self):
......@@ -43,7 +43,7 @@ class CtDaSystem(DaSystem):
logging.warning('Missing a required value in rc-file : %s' % key)
logging.debug('DA System Info settings have been validated succesfully')
################### End Class CtDaSystem ###################
################### End Class CO2DaSystem ###################
if __name__ == "__main__":
......
......@@ -22,13 +22,13 @@ sys.path.append('../../')
identifier = 'CarbonTracker CO2 mixing ratios'
version = '0.0'
from da.baseclasses.obs import Observation
from da.baseclasses.obs import Observations
import da.tools.io4 as io
import da.tools.rc as rc
################### Begin Class CtObservations ###################
################### Begin Class CO2Observations ###################
class CtObservations(Observation):
class CO2Observations(Observations):
""" an object that holds data + methods and attributes needed to manipulate mixing ratio values """
def initialize(self, DaCycle):
......@@ -305,13 +305,13 @@ class CtObservations(Observation):
logging.warning("Observation NOT found (%s, %s), please check sites.rc file (%s) !!!" % (obs.code, identifier, self.SitesFile))
obs.flag = 99
# Add SiteInfo dictionary to the Observation object for future use
# Add SiteInfo dictionary to the Observations object for future use
self.SiteInfo = SiteInfo
def write_obs_to_file(self, outfile):
"""
Write selected information contained in the Observation object to a file.
Write selected information contained in the Observations object to a file.
"""
......@@ -415,7 +415,7 @@ class CtObservations(Observation):
#return outfile
################### End Class CtObservations ###################
################### End Class CO2Observations ###################
......
......@@ -20,7 +20,7 @@ sys.path.append('../../')
import da.tools.io4 as io
import da.tools.rc as rc
from da.baseclasses.obs import Observation
from da.baseclasses.obs import Observations
from da.tools.general import name_convert
identifier = 'CarbonTracker CO2 mixing ratios'
......@@ -30,7 +30,7 @@ version = '0.0'
################### Begin Class ObsPackObservations ###################
class ObsPackObservations(Observation):
class ObsPackObservations(Observations):
""" an object that holds data + methods and attributes needed to manipulate mixing ratio values """
def initialize(self, DaCycle):
......@@ -111,7 +111,7 @@ class ObsPackObservations(Observation):
logging.debug("Added %d observations from file (%s) to the Data list" % (len(dates), ncfile))
logging.info("Observation list now holds %d values" % len(self.datalist))
logging.info("Observations list now holds %d values" % len(self.datalist))
def add_simulations(self, filename, silent=False):
""" Adds model simulated values to the mixing ratio objects """
......@@ -330,13 +330,13 @@ class ObsPackObservations(Observation):
logging.warning("Observation found (%s, %s), but not used in assimilation !!!" % (obs.code, identifier))
obs.flag = 99
# Add SiteInfo dictionary to the Observation object for future use
# Add SiteInfo dictionary to the Observations object for future use
self.SiteInfo = SiteInfo
def write_obs_to_file(self, outfile):
"""
Write selected information contained in the Observation object to a file.
Write selected information contained in the Observations object to a file.
"""
......
......@@ -21,12 +21,12 @@ sys.path.append('../../')
identifier = 'CarbonTracker CO2 mixing ratios'
version = '0.0'
from da.baseclasses.obs import Observation
from da.baseclasses.obs import Observations
import da.tools.io4 as io
import da.tools.rc as rc
################### Begin Class ObsPackObservations ###################
class ObsPackObservations(Observation):
class ObsPackObservations(Observations):
""" an object that holds data + methods and attributes needed to manipulate mixing ratio values """
def initialize(self, DaCycle):
......@@ -104,7 +104,7 @@ class ObsPackObservations(Observation):
logging.debug("Added %d observations from file (%s) to the Data list" % (len(dates), ncfile))
logging.info("Observation list now holds %d values" % len(self.datalist))
logging.info("Observations list now holds %d values" % len(self.datalist))
def add_simulations(self, filename, silent=False):
""" Adds model simulated values to the mixing ratio objects """
......@@ -318,7 +318,7 @@ class ObsPackObservations(Observation):
if SiteHourly.has_key(identifier):
hourf, hourt = SiteHourly[identifier]
if int(obs.xdate.hour) >= hourf and int(obs.xdate.hour) <= hourt:
logging.warning("Observation in hourly dataset INCLUDED, while sampling time %s was between %s:00-%s:00"%(obs.xdate.time(),hourf,hourt))
logging.warning("Observations in hourly dataset INCLUDED, while sampling time %s was between %s:00-%s:00"%(obs.xdate.time(),hourf,hourt))
else:
logging.warning("Observation in hourly dataset EXCLUDED, while sampling time %s was outside %s:00-%s:00"%(obs.xdate.time(),hourf,hourt))
exclude_hourly = True
......@@ -346,7 +346,7 @@ class ObsPackObservations(Observation):
logging.warning("Observation location for (%s, %d), is moved by %3.2f degrees latitude and %3.2f degrees longitude" % (identifier, obs.id, movelat, movelon))
# Add SiteInfo dictionary to the Observation object for future use
# Add SiteInfo dictionary to the Observations object for future use
self.SiteInfo = SiteInfo
self.SiteMove = SiteMove
......@@ -356,7 +356,7 @@ class ObsPackObservations(Observation):
def write_obs_to_file(self, outfile):
"""
Write selected information contained in the Observation object to a file.
Write selected information contained in the Observations object to a file.
"""
......
......@@ -19,12 +19,12 @@ from da.baseclasses.optimizer import Optimizer
identifier = 'Ensemble Square Root Filter'
version = '0.0'
################### Begin Class CtOptimizer ###################
################### Begin Class CO2Optimizer ###################
class CtOptimizer(Optimizer):
class CO2Optimizer(Optimizer):
"""
This creates an instance of a CarbonTracker optimization object. The base class it derives from is the optimizer object.
Additionally, this CtOptimizer implements a special localization option following the CT2007 method.
Additionally, this CO2Optimizer implements a special localization option following the CT2007 method.
All other methods are inherited from the base class Optimizer.
"""
......@@ -83,7 +83,7 @@ class CtOptimizer(Optimizer):
logging.info("Current minimum least squares algorithm is set to %s" % self.algorithm)
################### End Class CtOptimizer ###################
################### End Class CO2Optimizer ###################
if __name__ == "__main__":
pass
......@@ -22,9 +22,9 @@ import da.tools.io4 as io
identifier = 'CarbonTracker Statevector '
version = '0.0'
################### Begin Class CtStateVector ###################
################### Begin Class CO2StateVector ###################
class CtStateVector(StateVector):
class CO2StateVector(StateVector):
""" This is a StateVector object for CarbonTracker. It has a private method to make new ensemble members """
def get_covariance(self, date, DaCycle):
......@@ -40,7 +40,7 @@ class CtStateVector(StateVector):
# Get the needed matrices from the specified covariance files
file_ocn_cov = DaCycle.DaSystem['ocn.covariance']
file_bio_cov = DaCycle.DaSystem['bio.covariance'] #LU logika tego to powrot do dacycle zeby potem z systemu(CT) pobrac parametr
file_bio_cov = DaCycle.DaSystem['bio.covariance']
# replace YYYY.MM in the ocean covariance file string
......@@ -136,7 +136,7 @@ class CtStateVector(StateVector):
logging.info('Successfully read the State Vector from file (%s) ' % filename)
################### End Class CtStateVector ###################
################### End Class CO2StateVector ###################
if __name__ == "__main__":
......
......@@ -16,7 +16,7 @@ import logging
from da.baseclasses.dasystem import DaSystem
class CtGriddedDaSystem(DaSystem):
class CO2GriddedDaSystem(DaSystem):
""" Information on the data assimilation system used. This is normally an rc-file with settings.
"""
......
......@@ -24,7 +24,7 @@ version = '0.0'
################### Begin Class CtStateVector ###################
class CtGriddedStateVector(StateVector):
class CO2GriddedStateVector(StateVector):
""" This is a StateVector object for CarbonTracker. It has a private method to make new ensemble members """
def get_covariance(self, date, DaCycle):
......
......@@ -16,12 +16,12 @@ sys.path.append(os.getcwd())
from da.tools.initexit import start_logger, validate_opts_args, parse_options, CycleControl
from da.tools.pipeline import ensemble_smoother_pipeline
from da.platform.maunaloa import MaunaloaPlatForm
from da.ct.dasystem import CtDaSystem
from da.ct.statevector import CtStateVector
#from da.ct.obspack import ObsPackObservations
from da.ct.obs import CtObservations
from da.carbondioxide.dasystem import CO2DaSystem
from da.carbondioxide.statevector import CO2StateVector
#from da.carbondioxide.obspack import ObsPackObservations
from da.carbondioxide.obs import CO2Observations
from da.tm5.observationoperator import TM5ObservationOperator
from da.ct.optimizer import CtOptimizer
from da.carbondioxide.optimizer import CO2Optimizer
from da.analysis.expand_fluxes import save_weekly_avg_1x1_data, save_weekly_avg_state_data, save_weekly_avg_tc_data, save_weekly_avg_ext_tc_data
from da.analysis.expand_mixingratios import write_mixing_ratios
......@@ -43,12 +43,12 @@ DaCycle = CycleControl(opts, args)
PlatForm = MaunaloaPlatForm()
DaSystem = CtDaSystem(DaCycle['da.system.rc'])
DaSystem = CO2DaSystem(DaCycle['da.system.rc'])
ObsOperator = TM5ObservationOperator(DaCycle['da.obsoperator.rc'])
#Samples = ObsPackObservations()
Samples = CtObservations()
StateVector = CtStateVector()
Optimizer = CtOptimizer()
Samples = CO2Observations()
StateVector = CO2StateVector()
Optimizer = CO2Optimizer()
##########################################################################################
################### ENTER THE PIPELINE WITH THE OBJECTS PASSED BY THE USER ###############
......
......@@ -18,12 +18,12 @@ from da.tools.initexit import start_logger, parse_options, validate_opts_args, C
from da.tools.pipeline import ensemble_smoother_pipeline
from da.platform.maunaloa import MaunaloaPlatForm
from da.ctgridded.dasystem import CtGriddedDaSystem
from da.ctgridded.statevector import CtGriddedStateVector
from da.ct.obs import CtObservations
from da.co2gridded.dasystem import CO2GriddedDaSystem
from da.co2gridded.statevector import CO2GriddedStateVector
from da.carbondioxide.obs import CO2Observations
from da.tm5.observationoperator import TM5ObservationOperator
from da.ct.optimizer import CtOptimizer
from da.carbondioxide.optimizer import CO2Optimizer
from da.tools.pipeline import header, footer
from da.analysis.expand_fluxes import save_weekly_avg_1x1_data, save_weekly_avg_state_data, save_weekly_avg_tc_data, save_weekly_avg_ext_tc_data
......@@ -44,11 +44,11 @@ opts, args = validate_opts_args(parse_options())
DaCycle = CycleControl(opts, args)
PlatForm = MaunaloaPlatForm()
DaSystem = CtGriddedDaSystem(DaCycle['da.system.rc'])
DaSystem = CO2GriddedDaSystem(DaCycle['da.system.rc'])
ObsOperator = TM5ObservationOperator(DaCycle['da.obsoperator.rc'])
Samples = CtObservations()
StateVector = CtGriddedStateVector()
Optimizer = CtOptimizer()
Samples = CO2Observations()
StateVector = CO2GriddedStateVector()
Optimizer = CO2Optimizer()
##########################################################################################
################### ENTER THE PIPELINE WITH THE OBJECTS PASSED BY THE USER ###############
......
......@@ -16,11 +16,11 @@ sys.path.append(os.getcwd())
from da.tools.initexit import start_logger, validate_opts_args, parse_options, CycleControl
from da.tools.pipeline import ensemble_smoother_pipeline
from da.platform.jet import JetPlatForm
from da.ct.dasystem import CtDaSystem
from da.ct.statevector import CtStateVector
from da.ct.obs import CtObservations
from da.carbondioxide.dasystem import CO2DaSystem
from da.carbondioxide.statevector import CO2StateVector
from da.carbondioxide.obs import CO2Observations
from da.tm5.observationoperator import TM5ObservationOperator
from da.ct.optimizer import CtOptimizer
from da.carbondioxide.optimizer import CO2Optimizer
from da.tools.pipeline import header, footer
......@@ -38,11 +38,11 @@ opts, args = validate_opts_args(parse_options())
DaCycle = CycleControl(opts, args)
PlatForm = JetPlatForm()
DaSystem = CtDaSystem(DaCycle['da.system.rc'])
DaSystem = CO2DaSystem(DaCycle['da.system.rc'])
ObsOperator = TM5ObservationOperator(DaCycle['da.obsoperator.rc'])
Samples = CtObservations()
StateVector = CtStateVector()
Optimizer = CtOptimizer()
Samples = CO2Observations()
StateVector = CO2StateVector()
Optimizer = CO2Optimizer()
##########################################################################################
################### ENTER THE PIPELINE WITH THE OBJECTS PASSED BY THE USER ###############
......
Markdown is supported
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