Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation of max temp. during dynamic adjustment #328

Merged
merged 1 commit into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions compass/ocean/tests/global_ocean/dynamic_adjustment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import os
import xarray
import glob

from compass.validate import compare_variables
from compass.ocean.tests.global_ocean.forward import ForwardTestCase

Expand Down Expand Up @@ -52,8 +56,28 @@ def validate(self):
Test cases can override this method to perform validation of variables
and timers
"""
config = self.config
variables = ['temperature', 'salinity', 'layerThickness',
'normalVelocity']

compare_variables(test_case=self, variables=variables,
filename1='simulation/output.nc')

temp_max = config.getfloat('dynamic_adjustment', 'temperature_max')
max_values = {'temperatureMax': temp_max}

for step_name in self.steps_to_run:
step = self.steps[step_name]
step_path = os.path.join(self.work_dir, step.subdir)
global_stats_path = os.path.join(step_path, 'analysis_members',
'globalStats.*.nc')
global_stats_path = glob.glob(global_stats_path)
for filename in global_stats_path:
ds = xarray.open_dataset(filename)
for var, max_value in max_values.items():
max_in_global_stats = ds[var].max().values
if max_in_global_stats > max_value:
raise ValueError(
f'Max of {var} > allowed threshold: '
f'{max_in_global_stats} > {max_value} '
f'in {filename}')
7 changes: 7 additions & 0 deletions compass/ocean/tests/global_ocean/global_ocean.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ email = autodetect
pull_request = <<<Missing>>>


# config options related to dynamic adjustment
[dynamic_adjustment]

# the maximum allowed value of temperatureMax in global statistics
temperature_max = 33.0
Comment on lines +77 to +78
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to make sure this threshold is reasonable.



# config options related to initial condition and diagnostics support files
# for E3SM
[files_for_e3sm]
Expand Down