-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore_parameter.py
More file actions
88 lines (73 loc) · 3.04 KB
/
core_parameter.py
File metadata and controls
88 lines (73 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from __future__ import print_function
import sys
import cdp.cdp_parameter
class CoreParameter(cdp.cdp_parameter.CDPParameter):
def __init__(self):
self.case_id = ''
# The user must define these, so don't give any defaults.
# self.reference_data_path = ''
# self.test_data_path = ''
self.ref_timeseries_input = False
self.test_timeseries_input = False
self.viewer_descr = {}
self.sets = ['zonal_mean_xy', 'zonal_mean_2d', 'meridional_mean_2d',
'lat_lon', 'polar', 'area_mean_time_series', 'cosp_histogram']
self.dataset = ''
self.run_type = 'model_vs_obs'
self.variables = []
self.seasons = ['ANN', 'DJF', 'MAM', 'JJA', 'SON']
self.regions = ['global']
self.regrid_tool = 'esmf'
self.regrid_method = 'conservative'
self.plevs = []
self.zonal_mean_2d_plevs = []
# Plotting related.
self.main_title = ''
self.backend = 'mpl'
self.save_netcdf = False
self.output_format = ['png']
self.output_format_subplot = []
self.canvas_size_w = 1212
self.canvas_size_h = 1628
self.figsize = [8.5, 11.0]
self.dpi = 150
self.arrows = True
self.logo = False
self.contour_levels = []
self.test_name = ''
self.short_test_name = ''
self.test_title = ''
self.test_colormap = 'cet_rainbow.rgb'
self.test_units = ''
self.ref_name = ''
self.reference_name = ''
self.short_ref_name = ''
self.reference_title = ''
self.reference_colormap = 'cet_rainbow.rgb'
self.reference_units = ''
self.diff_name = ''
self.diff_title = 'Model - Observation'
self.diff_colormap = 'diverging_bwr.rgb'
self.diff_levels = []
self.diff_units = ''
self.multiprocessing = False
self.distributed = False
self.num_workers = 4
self.no_viewer = False
self.debug = False
self.granulate = ['variables', 'seasons', 'plevs', 'regions']
self.selectors = ['sets', 'seasons']
self.viewer_descr = {}
def check_values(self):
#must_have_params = ['reference_data_path', 'test_data_path', 'results_dir']
must_have_params = ['test_data_path', 'results_dir']
for param in must_have_params:
if not hasattr(self, param):
msg = 'You need to specify {p} in the parameters file or via the command line using --{p}'.format(p=param)
raise RuntimeError(msg)
if self.ref_timeseries_input and not (hasattr(self, 'ref_start_yr') and hasattr(self, 'ref_end_yr')):
msg = "You need to define both the 'ref_start_yr' and 'ref_end_yr' parameter."
raise RuntimeError(msg)
if self.test_timeseries_input and not (hasattr(self, 'test_start_yr') and hasattr(self, 'test_end_yr')):
msg = "You need to define both the 'test_start_yr' and 'test_end_yr' parameter."
raise RuntimeError(msg)