template.py 3.7 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
29
from da.tools.initexit import start_logger, validate_opts_args, parse_options, CycleControl
from da.tools.pipeline import ensemble_smoother_pipeline, header, footer
30
31
32
from da.platform.capegrim import CapeGrimPlatform
from da.baseclasses.dasystem import DaSystem
from da.co2gridded.statevector import CO2GriddedStateVector 
33
from da.baseclasses.obs import Observations
34
35
36
from da.baseclasses.optimizer import Optimizer
from da.baseclasses.observationoperator import RandomizerObservationOperator

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 = CapeGrimPlatform()
brunner's avatar
brunner committed
54
dasystem = DaSystem(dacycle['da.system.rc'])
55
obsoperator = RandomizerObservationOperator(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
ensemble_smoother_pipeline(dacycle, platform, dasystem, samples, statevector, obsoperator, optimizer)
68
69
70
71
72
73


##########################################################################################
################### All done, extra stuff can be added next, such as analysis
##########################################################################################

brunner's avatar
brunner committed
74
75
logging.info(header + "Starting analysis" + footer) 
sys.exit(0)
76

brunner's avatar
brunner committed
77
78
79
80
81
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)
82
83
84
85

sys.exit(0)