Skip to content

Commit 5cd941c

Browse files
committed
Fail a viz step if no variables to plot is provided
1 parent d8a8408 commit 5cd941c

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

polaris/tasks/ocean/customizable_viz/viz_horiz_field.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ def runtime_setup(self):
1818
self.mesh_file = section.get('mesh_file')
1919
self.input_file = section.get('input_file')
2020

21+
section_name = 'customizable_viz_horiz_field'
22+
self.variables = self.config.getlist(
23+
section_name, 'variables', dtype=str
24+
)
25+
if not self.variables:
26+
raise ValueError(
27+
f'No variables specified in the {section_name} section of '
28+
'the config file.'
29+
)
30+
2131
def run(self): # noqa:C901
2232
section_name = 'customizable_viz_horiz_field'
2333
section = self.config[section_name]
@@ -97,9 +107,8 @@ def run(self): # noqa:C901
97107
f'and input {ds.sizes["nCells"]} do not match. '
98108
)
99109
viz_dict = get_viz_defaults()
100-
variables = self.config.getlist(section_name, 'variables', dtype=str)
101110

102-
for var_name in variables:
111+
for var_name in self.variables:
103112
if 'accumulated' in var_name:
104113
full_var_name = var_name
105114
else:

polaris/tasks/ocean/customizable_viz/viz_transect.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@ def runtime_setup(self):
1818
section = self.config['customizable_viz']
1919
self.mesh_file = section.get('mesh_file')
2020
self.input_file = section.get('input_file')
21+
section_name = 'customizable_viz_transect'
22+
self.variables = self.config.getlist(
23+
section_name, 'variables', dtype=str
24+
)
25+
if not self.variables:
26+
raise ValueError(
27+
f'No variables specified in the {section_name} section of '
28+
'the config file.'
29+
)
2130

2231
def run(self):
2332
section_name = 'customizable_viz_transect'
24-
variables = self.config.getlist(section_name, 'variables', dtype=str)
2533
section = self.config[section_name]
2634
layer_interface_color = section.get('layer_interface_color')
2735
x_start = section.getfloat('x_start')
@@ -61,7 +69,7 @@ def run(self):
6169
)
6270

6371
viz_dict = get_viz_defaults()
64-
for var_name in variables:
72+
for var_name in self.variables:
6573
mpas_field = ds[f'{prefix}{var_name}']
6674
if self.config.has_option(section_name, 'vmin'):
6775
vmin = section.getfloat('vmin')

0 commit comments

Comments
 (0)