template.py 3.91 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
from da.platform.capegrim import CapeGrimPlatform 
brunner's avatar
brunner committed
31
32
33
from da.baseclasses.dasystem import DaSystem 
from da.baseclasses.statevector import StateVector 
from da.carbondioxide.obspack_globalviewplus2 import ObsPackObservations 
brunner's avatar
brunner committed
34
from da.carbondioxide.optimizer import CO2Optimizer
brunner's avatar
brunner committed
35
36
37
from da.baseclasses.observationoperator import ObservationOperator
#from da.analysis.expand_fluxes import save_weekly_avg_1x1_data, save_weekly_avg_state_data, save_weekly_avg_tc_data, save_weekly_avg_ext_tc_data
#from da.analysis.expand_molefractions import write_mole_fractions
38

39
40
41
42
43

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

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

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

52
dacycle = CycleControl(opts, args)
53
54


brunner's avatar
brunner committed
55
56
57
58
59
platform = MaunaloaPlatform()
dasystem = DaSystem(dacycle['da.system.rc'])
obsoperator = ObservationOperator(dacycle['da.obsoperator.rc'])
samples     = ObsPackObservations()
statevector = StateVector()
brunner's avatar
brunner committed
60
optimizer = CO2Optimizer()
61
62
63
64
65
66

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


67
68
logging.info(header + "Entering Pipeline " + footer) 

69
ensemble_smoother_pipeline(dacycle, platform, dasystem, samples, statevector, obsoperator, optimizer)
70
71
72
73
74
75


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

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

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

sys.exit(0)