diff --git a/carbontrackerjet.rc b/carbontrackerjet.rc index 3b79020eb03287bab9c3458d0ca42c81549b6a25..41c631ce9557c219ac2aa667f39846db9a8cf050 100644 --- a/carbontrackerjet.rc +++ b/carbontrackerjet.rc @@ -1,8 +1,7 @@ !!! Info for the CarbonTracker data assimilation system -datadir : /lfs0/projects/co2/input/ -!datadir : /data/CO2/carbontracker/ct08/ -obs.input.dir : ${datadir}/obsnc/ +datadir : /lfs0/projects/co2/input/ct_new_2010 +obs.input.dir : ${datadir}/obsnc obs.input.fname : obs_final ocn.covariance : ${datadir}/covariance_ocn_base.nc bio.covariance : ${datadir}/covariance_bio_olson19.nc diff --git a/da/ct/obs.py b/da/ct/obs.py index 6d5e82b5aca4379aa73e5f224df3b21f9b611fd4..4ca95271df470827e5c65d79f28fde8471552830 100755 --- a/da/ct/obs.py +++ b/da/ct/obs.py @@ -107,7 +107,7 @@ class CtObservations(object): idates = ncf.select('date_components').get() ids = ncf.select('id').get() sites = ncf.select('site').get() - sites = [join(s,'').lower() for s in sites] + sites = [s.tostring().lower() for s in sites] sites = map(strip,sites) lats = ncf.select('lat').get() lons = ncf.select('lon').get() @@ -117,7 +117,7 @@ class CtObservations(object): date = ncf.select('date').get() window = ncf.select('sampling_strategy').get() flags = ncf.select('NOAA_QC_flags').get() - flags = [join(s,'') for s in flags] + flags = [s.tostring().lower() for s in flags] flags = map(strip,flags) dummy = ncf.end() msg = "Successfully read data from obs file (%s)"%self.ObsFilename ; logging.debug(msg) diff --git a/da/tm5/model.py b/da/tm5/model.py index 501e1dc2b3336cf0991fc28464d6a13eac3aa239..8277614556b9fd172698c423ad6f65be32f993fb 100755 --- a/da/tm5/model.py +++ b/da/tm5/model.py @@ -40,7 +40,7 @@ needed_rc_items = [ ################### Begin Class TM5 ################### -class TM5(): +class TM5(object): """ This class holds methods and variables that are needed to run the TM5 model. It is initiated with as only argument a TM5 rc-file location. This rc-file will be used to figure out the settings for the run. @@ -100,16 +100,16 @@ class TM5(): Validate the contents of the tm_settings dictionary and add extra values. The required items for the TM5 rc-file are specified in the tm5_tools module, as dictionary variable "needed_rc_items". """ - import datetime + from da.tools.general import ToDatetime for k,v in self.tm_settings.iteritems(): if v == 'True' : self.tm_settings[k] = True if v == 'False': self.tm_settings[k] = False - if 'date' in k : self.tm_settings[k] = datetime.datetime.strptime(v,'%Y-%m-%d %H:%M:%S') + if 'date' in k : self.tm_settings[k] = ToDatetime(v) if 'time.start' in k : - self.tm_settings[k] = datetime.datetime.strptime(v,'%Y%m%d%H') + self.tm_settings[k] = ToDatetime(v,fmt='TM5') if 'time.final' in k : - self.tm_settings[k] = datetime.datetime.strptime(v,'%Y%m%d%H') + self.tm_settings[k] = ToDatetime(v,fmt='TM5') for key in needed_rc_items: diff --git a/da/tools/general.py b/da/tools/general.py index d07aaa67486316eeef3b04bc687c7d494267dc69..de29c3a51d539ead5ad5683bc809de63b06f4efc 100755 --- a/da/tools/general.py +++ b/da/tools/general.py @@ -380,6 +380,23 @@ def CleanUpCycle(CycleInfo): dummy = f.close() msg = "The complete log file is now at: %s"%(joblogfile) ; logging.info(msg) +def ToDatetime(datestring,fmt=None): + """ convert a date string to a datetime object """ + import datetime + + print datestring + if fmt == 'TM5': + datestring = '%04s-%02s-%02s %02s:%02s:00'%(datestring[0:4],datestring[4:6],datestring[6:8],datestring[8:10],datestring[10:12]) + + print datestring + + try: + return datetime.datetime.strptime(datestring,'%Y-%m-%d %H:%M:%S') + except: + date,time = datestring.split(' ') + year,month,day = map(int,date.split('-')) + hour,minute,second = map(int,time.split(':')) + return datetime.datetime(year,month,day,hour,minute,second) if __name__ == "__main__": pass diff --git a/da/tools/initexit.py b/da/tools/initexit.py index 48b4c39b617f1bb2d4e8c5e51327df8397218b2d..5d5078ce6446dcb9a3c83150373e888fd2215e51 100755 --- a/da/tools/initexit.py +++ b/da/tools/initexit.py @@ -90,6 +90,7 @@ class CycleControl(object): """ Validate the contents of the rc-file given a dictionary of required keys """ + from da.tools.general import ToDatetime for k,v in self.da_settings.iteritems(): if v == 'True' : self.da_settings[k] = True @@ -508,17 +509,6 @@ class CycleControl(object): return None -def ToDatetime(datestring): - """ convert a date string to a datetime object """ - import datetime - - try: - return datetime.datetime.strptime(datestring,'%Y-%m-%d %H:%M:%S') - except: - date,time = datestring.split(' ') - year,month,day = map(int,date.split('-')) - hour,minute,second = map(int,time.split(':')) - return datetime.datetime(year,month,day,hour,minute,second) if __name__ == "__main__": diff --git a/dajet.rc b/dajet.rc index 452bb39e65b371e17a091d90e5644179c8a51588..3e690bd161501ffce442efb89dbecde5d103c461 100644 --- a/dajet.rc +++ b/dajet.rc @@ -15,5 +15,5 @@ da.system.rc : carbontrackerjet.rc ! Info on the forward model to be used forecast.model : TM5 -forecast.model.rc : ${HOME}/TM5/TM5_new/ct_new.rc +forecast.model.rc : ${HOME}/TM/TM5_new/ct_new.rc forecast.nmembers : 2