Commit 0fd31898 authored by karolina's avatar karolina
Browse files

removed the body of if __name__ == "__main__", except analysis folder

parent 01f2e8c7
......@@ -417,35 +417,4 @@ class Optimizer(object):
if __name__ == "__main__":
sys.path.append('../../')
from da.tools.initexit import start_logger
from da.tools.initexit import CycleControl
from da.ct.obs import CtObservations
opts = ['-v']
args = {'rc':'../../da.rc', 'logfile':'da_initexit.log', 'jobrcfilename':'test.rc'}
start_logger()
DaCycle = CycleControl(opts, args)
DaCycle.initialize()
print DaCycle
samples = CtObservations(DaCycle.DaSystem, datetime.datetime(2005, 3, 5))
samples.add_observations()
samples.add_simulations('/Users/peters/tmp/test_da/output/20050305/samples.000.nc')
nobs = len(samples.datalist)
dims = (int(DaCycle['time.nlag']),
int(DaCycle['da.optimizer.nmembers']),
int(DaCycle.DaSystem['nparameters']),
nobs,)
# opt = CtOptimizer(dims)
# opt.state_to_matrix(StateVector)
# opt.MinimumLeastSquares()
# opt.matrix_to_state(StateVector)
pass
......@@ -594,44 +594,5 @@ class StateVector(object):
################### End Class StateVector ###################
if __name__ == "__main__":
sys.path.append('../../')
from da.tools.initexit import start_logger
from da.tools.initexit import CycleControl
opts = ['-v']
args = {'rc':'../../da.rc', 'logfile':'da_initexit.log', 'jobrcfilename':'test.rc'}
start_logger()
DaCycle = CycleControl(opts, args)
dummy = EnsembleMember(0)
print dummy
DaCycle.initialize()
print DaCycle
dims = (int(DaCycle['time.nlag']),
int(DaCycle['da.optimizer.nmembers']),
int(DaCycle.DaSystem['nparameters']),
)
StateVector = StateVector(dims)
StateVector.make_new_ensemble(lag=1)
members = StateVector.EnsembleMembers[0]
members[0].write_to_file(DaCycle['dir.input'])
StateVector.propagate()
savedir = DaCycle['dir.output']
filename = os.path.join(savedir, 'savestate.nc')
StateVector.write_to_file(filename)
savedir = DaCycle['dir.output']
filename = os.path.join(savedir, 'savestate.nc')
StateVector.read_from_file(filename)
pass
......@@ -465,34 +465,4 @@ class MixingRatioSample(object):
if __name__ == "__main__":
from da.tools.initexit import start_logger
from datetime import datetime
sys.path.append(os.getcwd())
start_logger()
obs = CtObservations()
#DaCycle = JobStart(['-v'], {'rc':'da.rc'})
#DaCycle['time.sample.start'] = datetime(2000, 1, 1)
#DaCycle['time.sample.end'] = datetime(2000, 1, 2)
#obs.initialize()
#obs.Validate()
#obs.add_observations()
#print(obs.Data.getvalues('obs'))
obs.Data = []
obs.Data.append(MixingRatioSample("10",datetime(2000,1,1)))
obs.Data.append(MixingRatioSample("20",datetime(2000,1,2)))
obs.Data.append(MixingRatioSample("30",datetime(2000,1,3)))
obs.Data.append(MixingRatioSample("40",datetime(2000,1,4)))
for d in obs.Data:
print d
new = obs.Data.unflagged()
print new
#new = obs.Data.selectsite("10")
#print new
pass
......@@ -478,41 +478,4 @@ class MixingRatioSample(object):
if __name__ == "__main__":
from da.tools.initexit import CycleControl
from da.ct.dasystem import CtDaSystem
sys.path.append('../../')
logging.root.setLevel(logging.DEBUG)
DaCycle = CycleControl(args={'rc':'../../dagriddedjet.rc'})
DaCycle.initialize()
DaCycle.parse_times()
DaSystem = CtDaSystem('../rc/carbontracker.rc')
DaSystem.initialize()
DaCycle.DaSystem = DaSystem
obs = ObsPackObservations()
obs.DaCycle = DaCycle
while DaCycle['time.start'] < DaCycle['time.finish']:
DaCycle['time.sample.start'] = DaCycle['time.start']
DaCycle['time.sample.end'] = DaCycle['time.end']
obs.initialize()
obs.validate()
obs.add_observations()
obs.add_model_data_mismatch()
print(obs.getvalues('obs'))
print(obs.getvalues('mdm'))
DaCycle.advance_cycle_times()
pass
\ No newline at end of file
......@@ -507,37 +507,7 @@ class MixingRatioSample(object):
if __name__ == "__main__":
from da.tools.initexit import CycleControl
from da.ct.dasystem import CtDaSystem
sys.path.append('../../')
logging.root.setLevel(logging.DEBUG)
DaCycle = CycleControl(args={'rc':'../../ctdas-ei-gfed2-bcb-6x4-gridded.rc'})
DaCycle.parse_times()
DaSystem = CtDaSystem('../rc/carbontracker_geocarbon_gridded.rc')
DaCycle.DaSystem = DaSystem
obs = ObsPackObservations()
obs.DaCycle = DaCycle
while DaCycle['time.start'] < DaCycle['time.finish']:
DaCycle['time.sample.start'] = DaCycle['time.start']
DaCycle['time.sample.end'] = DaCycle['time.end']
obs.initialize()
obs.add_observations()
obs.add_model_data_mismatch()
print(obs.getvalues('obs'))
print(obs.getvalues('mdm'))
DaCycle.advance_cycle_times()
pass
......@@ -86,27 +86,4 @@ class CtOptimizer(Optimizer):
################### End Class CtOptimizer ###################
if __name__ == "__main__":
from da.tools.initexit import start_logger
from da.tools.pipeline import start_job
sys.path.append(os.getcwd())
opts = ['-v']
args = {'rc':'da.rc', 'logfile':'da_initexit.log', 'jobrcfilename':'test.rc'}
start_logger()
DaCycle = start_job(opts, args)
DaCycle.initialize()
opt = CtOptimizer()
nobs = 100
dims = (int(DaCycle['time.nlag']),
int(DaCycle['da.optimizer.nmembers']),
int(DaCycle.DaSystem['nparameters']),
nobs,)
opt.initialize(dims)
opt.set_localization(type='CT2007')
pass
......@@ -142,34 +142,4 @@ class CtStateVector(StateVector):
if __name__ == "__main__":
from da.tools.initexit import start_logger
from da.tools.pipeline import start_job
sys.path.append(os.getcwd())
opts = ['-v']
args = {'rc':'da.rc', 'logfile':'da_initexit.log', 'jobrcfilename':'test.rc'}
start_logger()
DaCycle = start_job(opts, args)
DaCycle.initialize()
StateVector = CtStateVector()
StateVector.initialize()
for n in range(dims[0]):
cov = StateVector.get_covariance()
dummy = StateVector.make_new_ensemble(n + 1, cov)
StateVector.propagate()
savedir = DaCycle['dir.output']
filename = os.path.join(savedir, 'savestate.nc')
dummy = StateVector.write_to_file()
StateVector.read_from_file(filename)
pass
......@@ -200,62 +200,4 @@ class CtGriddedStateVector(StateVector):
if __name__ == "__main__":
from da.tools.initexit import start_logger , parse_options
from da.tools.initexit import CycleControl
from da.ctgridded.dasystem import CtGriddedDaSystem
sys.path.append(os.getcwd())
sys.path.append('../../')
opts = ['-v']
args = {'rc':'../../dagridded.rc'}
start_logger(level=logging.DEBUG)
DaCycle = CycleControl(opts, args)
DaSystem = CtGriddedDaSystem('../../da/rc/carbontrackergridded.rc')
StateVector = CtGriddedStateVector()
DaSystem.initialize()
DaSystem.validate()
DaCycle.DaSystem = DaSystem
DaCycle.initialize()
StateVector.DaCycle = DaCycle # also embed object in StateVector so it can access cycle information for I/O etc
dummy = StateVector.initialize()
for n in range(1):
cov = StateVector.get_covariance(DaCycle['time.start'])
dummy = StateVector.make_new_ensemble(n + 1, cov)
#StateVector.propagate()
#savedir = './'
#filename = os.path.join(savedir,'savestate.nc')
#dummy = StateVector.WriteToFile(filename)
#StateVector.ReadFromFile(filename)
StateVector.state2tc(fluxvector=np.ones(StateVector.nparams))
sys.exit(2)
members = StateVector.EnsembleMembers[-1]
for mem in members[0:1]:
mem.ParameterValues = np.arange(StateVector.nparams) + 1.0
data = StateVector.vector2grid(vectordata=mem.ParameterValues)
params = StateVector.vector2grid(griddata=data, reverse=True, method="minval")
tcparams = StateVector.vector2tc(mem.ParameterValues)
print (StateVector.gridmap - data).min()
print (StateVector.gridmap - data).max()
print (mem.ParameterValues - params).min()
print (mem.ParameterValues - params).max()
pass
......@@ -205,39 +205,4 @@ def serial_vs_bulk():
if __name__ == "__main__":
import sys
sys.path.append('../../')
import os
from da.tools.general import start_logger
from da.tools.initexit import CycleControl
from da.ct.statevector import CtStateVector, CtMember
from da.ct.obs import CtObservations, MixingRatioSample
from da.ct.optimizer import CtOptimizer
import numpy as np
import da.tools.rc as rc
import datetime
import Nio
import matplotlib.pyplot as plt
opts = ['-v']
args = {'rc':'da.rc', 'logfile':'da_initexit.log', 'jobrcfilename':'test.rc'}
start_logger()
DaCycle = CycleControl(opts, args)
dummy = CtMember(0)
DaCycle.initialize()
StateVector = CtStateVector(DaCycle)
samples = CtObservations(DaCycle.DaSystem, datetime.datetime(2000, 1, 1))
# This is a test of the CarbonTracker release ct2009 fortran solution and the one implemented here
#serial_py_against_serial_fortran()
#sys.exit(0)
serial_vs_bulk()
sys.exit(0)
pass
......@@ -627,29 +627,7 @@ class TM5ObservationOperator(ObservationOperator):
if __name__ == "__main__":
sys.path.append('../../')
from da.tools.initexit import start_logger
from da.tools.pipeline import start_job
import datetime as dtm
sys.path.append(os.getcwd())
start_logger()
DaCycle = start_job([], {'rc':'da.rc'})
DaCycle.initialize()
DaCycle['time.sample.start'] = dtm.datetime(2000, 1, 1)
DaCycle['time.sample.end'] = dtm.datetime(2000, 1, 2)
DaCycle['time.sample.window'] = 0
tm = TM5ObservationOperator()
tm.Setup()
tm.initialize()
tm.run()
tm.save_data()
pass
......
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