template.py 3.66 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
"""CarbonTracker Data Assimilation Shell (CTDAS) Copyright (C) 2017 Wouter Peters. 
Users are recommended to contact the developers (wouter.peters@wur.nl) to receive
updates of the code. See also: http://www.carbontracker.eu. 

This program is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software Foundation, 
version 3. This program is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 

You should have received a copy of the GNU General Public License along with this 
program. If not, see <http://www.gnu.org/licenses/>."""
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python

#################################################################################################
# First order of business is always to make all other python modules accessible through the path
#################################################################################################

import sys
import os
import logging
22
sys.path.append(os.getcwd())
23
24
25
26
27

#################################################################################################
# Next, import the tools needed to initialize a data assimilation cycle
#################################################################################################

brunner's avatar
brunner committed
28
from da.tools.initexit import start_logger, validate_opts_args, parse_options, CycleControl
29
30
from da.stilt.pipeline import forward_pipeline, header, footer
from da.platform.cartesius import CartesiusPlatform
31
from da.baseclasses.dasystem import DaSystem
Woude, Auke van der's avatar
Woude, Auke van der committed
32
from da.stilt.statevector import CO2GriddedStateVector 
33
from da.baseclasses.obs import Observations
34
from da.baseclasses.optimizer import Optimizer
35
from da.stilt.observationoperator import STILTObservationOperator
36

37

38
39
40
41
42

#################################################################################################
# Parse and validate the command line options, start logging
#################################################################################################

43
44
45
start_logger()
opts, args = parse_options()
opts, args = validate_opts_args(opts, args)
46
47
48
49
50

#################################################################################################
# Create the Cycle Control object for this job    
#################################################################################################

51
dacycle = CycleControl(opts, args)
52

53
platform = CartesiusPlatform()
brunner's avatar
brunner committed
54
dasystem = DaSystem(dacycle['da.system.rc'])
55
obsoperator = STILTObservationOperator(dacycle['da.obsoperator.rc'])
56
samples     = Observations()
57
58
statevector = CO2GriddedStateVector()
optimizer = Optimizer()
59
60
61
62
63
64

##########################################################################################
################### ENTER THE PIPELINE WITH THE OBJECTS PASSED BY THE USER ###############
##########################################################################################


65
66
logging.info(header + "Entering Pipeline " + footer) 

67
forward_pipeline(dacycle, platform, dasystem, samples, statevector, obsoperator)
68
69
70
71
72


##########################################################################################
################### All done, extra stuff can be added next, such as analysis
##########################################################################################
73
74
75
76
77
78
79
80
81
82
#
#logging.info(header + "Starting analysis" + footer) 
#sys.exit(0)
#
#save_weekly_avg_1x1_data(dacycle, statevector)
#save_weekly_avg_state_data(dacycle, statevector)
#save_weekly_avg_tc_data(dacycle, statevector)
#save_weekly_avg_ext_tc_data(dacycle)
#write_mole_fractions(dacycle)
#
83
84
85
sys.exit(0)