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

Check that all BSF projections are present #1079

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
35 changes: 35 additions & 0 deletions mpas_analysis/ocean/climatology_map_bsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# Additional copyright and license information can be found in the LICENSE file
# distributed with this code, or at
# https://raw.githubusercontent.com/MPAS-Dev/MPAS-Analysis/main/LICENSE
import os

import xarray as xr
import numpy as np
import scipy.sparse
Expand Down Expand Up @@ -253,6 +255,39 @@ def setup_and_check(self):
# Add the variables and seasons, now that we have the variable list
self.mpasClimatologyTask.add_variables(self.variableList, self.seasons)

def run_task(self):
"""
Compute the requested climatologies
"""
config = self.config
# check if climatology exists and if all comparison grids are present
for season in self.seasons:
masked_climatology_filename = self.get_masked_file_name(season)
if not os.path.exists(masked_climatology_filename):
continue
all_found = True
with xr.open_dataset(masked_climatology_filename) as ds:
for comparison_grid_name in self.comparisonDescriptors.keys():
grid_suffix = \
comparison_grid_option_suffixes[comparison_grid_name]
config_section_name = f'{self.taskName}{grid_suffix}'
if config.has_section(config_section_name):
mpas_field_name = \
f'barotropicStreamfunction{grid_suffix}'
if mpas_field_name not in ds:
all_found = False
break
if not all_found:
# if not, remove the files and recompute/remap
os.remove(masked_climatology_filename)
for comparison_grid_name in self.comparisonDescriptors.keys():
remapped_filename = self.get_remapped_file_name(
season, comparison_grid_name)
if os.path.exists(remapped_filename):
os.remove(remapped_filename)

super().run_task()

def customize_masked_climatology(self, climatology, season):
"""
Compute the masked climatology from the normal velocity
Expand Down
Loading