Commit 8726d7a6 authored by karolina's avatar karolina
Browse files

deleted unused functions as agreed in email #2

ct/ (whole file)
tm5/ WriteRunRc
tools/ SubmitSubStep
tools/ CreateLinks, ToDectime, StoreData, RestoreData
parent ab4590d0
#!/usr/bin/env python
Author : peters
Revision History:
File created on 12 Feb 2009.
import sys
identifier = 'CarbonTracker CO2'
def StateToGrid(values,regionmap,reverse=False,avg=False):
This method converts parameters from a CarbonTracker StateVector object to a gridded map of linear multiplication values. These
can subsequently be used in the transport model code to multiply/manipulate fluxes
import numpy as np
nregions = regionmap.max()
# dictionary for region <-> map conversions
for r in np.arange(1,nregions+1):
sel = (regionmap.flat == r).nonzero()
if len(sel[0]) > 0: regs[r]=sel
if reverse:
""" project 1x1 degree map onto ecoregions """
for k,v in regionselect.iteritems():
if avg:
else :
return result
""" project ecoregion properties onto 1x1 degree map """
result = np.zeros((180,360,),float)
for k,v in regionselect.iteritems():
return result
if __name__ == "__main__":
from import StartLogger
from import CycleControl
from pylab import *
opts = ['-v']
args = {'rc':'da.rc','logfile':'da_initexit.log','jobrcfilename':'test.rc'}
DaCycle = CycleControl(opts,args)
print DaCycle
# a=arange(240)+100
#b = StateToGrid(DaCycle.DaSystem,a)
#print b.max()
#c = StateToGrid(DaCycle.DaSystem,b,reverse=True,avg=True)
#print c.max()
......@@ -321,42 +321,6 @@ class TM5ObservationOperator(ObservationOperator):
rc.write(tm5rcfilename, self.tm_settings)
logging.debug("Modified rc file for TM5 written (%s)" % tm5rcfilename)
def WriteRunRc(self):
Create the tm5-runtime.rc file which is read by initexit.F90 to control time loop and restart from save files
import as rc
tm5rcfilename = os.path.join(self.tm_settings[self.rundirkey], 'tm5_runtime.rc')
rc.write(tm5rcfilename, self.tm_settings)
rc_runtm5 = {}
rc_runtm5['year1'] = self.tm_settings[self.timestartkey].year
rc_runtm5['month1'] = self.tm_settings[self.timestartkey].month
rc_runtm5['day1'] = self.tm_settings[self.timestartkey].day
rc_runtm5['hour1'] = self.tm_settings[self.timestartkey].hour
rc_runtm5['minu1'] = 0
rc_runtm5['sec1'] = 0
rc_runtm5['year2'] = self.tm_settings[self.timefinalkey].year
rc_runtm5['month2'] = self.tm_settings[self.timefinalkey].month
rc_runtm5['day2'] = self.tm_settings[self.timefinalkey].day
rc_runtm5['hour2'] = self.tm_settings[self.timefinalkey].hour
rc_runtm5['minu2'] = 0
rc_runtm5['sec2'] = 0
rc_runtm5[self.istartkey] = self.tm_settings[self.istartkey]
rc_runtm5[self.savedirkey] = self.tm_settings[self.savedirkey]
rc_runtm5[self.outputdirkey] = self.tm_settings[self.outputdirkey]
rc.write(tm5rcfilename, rc_runtm5)
logging.debug("Modified tm5_runtime.rc written (%s)" % tm5rcfilename)
def validate_input(self):
Make sure that parameter files are written to the TM5 inputdir, and that observation lists are present
......@@ -50,26 +50,6 @@ def CreateDirs(dirname, forceclean=False):
return dirname
def CreateLinks(sourcedir, targetdir):
""" Create a symbolic link from, source to target and report success, note
that exisiting links are first removed and then recreated """
if os.path.exists(targetdir):
msg = 'Unlinking existing directory %s' % targetdir
os.symlink(sourcedir, targetdir)
msg = 'Created new link from %s to %s' % (sourcedir, targetdir)
except OSError, msg:
msg = 'Failed to create link from %s to %s' % (sourcedir, targetdir)
raise OSError
return None
def AdvanceTime(time_in, interval):
""" Advance time_in by a specified interval"""
......@@ -102,7 +82,6 @@ def ToDatetime(datestring, fmt=None):
return datetime.datetime.strptime(datestring, '%Y-%m-%d %H:%M:%S')
......@@ -111,40 +90,6 @@ def ToDatetime(datestring, fmt=None):
hour, minute, second = map(int, time.split(':'))
return datetime.datetime(year, month, day, hour, minute, second)
def ToDectime(dd):
""" convert a datetime object to a decimal date """
import calendar
from matplotlib.pylab import date2num
Days0 = date2num(datetime.datetime(dd.year, 1, 1))
if calendar.isleap(dd.year):
DaysPerYear = 366.
DaysPerYear = 365.
DayFrac = date2num(dd)
return dd.year + (DayFrac - Days0) / DaysPerYear
def StoreData(pickleobject, filename):
""" pickle object into a specified file name """
import cPickle
f = open(filename, 'wb')
dummy = cPickle.dump(pickleobject, f, -1)
return None
def RestoreData(filename):
""" unpickle object into a specified file name """
import cPickle
f = open(filename, 'rb')
pickleobject = cPickle.load(f)
return pickleobject
def NameConvert(name=None, to=None):
""" Convert between old GLOBALVIEW-style and new ObsPack-style
......@@ -660,30 +660,6 @@ class CycleControl(dict):'Final date reached, no new cycle started')
def SubmitSubStep(self, stepname):
Submit the next substep of a DA cycle, this consists of
* getting a job template as returned by :meth:``
* adding the lines needed to start a next run with a newly created rc-file
* Writing the jobfile as done by :meth:``
* Submitting the jobfile as done by :meth:``
from string import join
DaPlatForm = self.DaPlatForm
jobparams = {'jobname':'das.%s' % stepname}
template = DaPlatForm.get_job_template(jobparams)
template += 'cd %s\n' % os.getcwd()
template += '%s rc=%s process=%s %s' % (sys.argv[0], self['jobrcfilename'], stepname, join(self.opts, ''),)
jobfile = DaPlatForm.write_job(self, template, stepname)
def StartLogger(level=logging.INFO):
""" start the logging of messages to screen"""
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