diff --git a/compass/ocean/tests/tides/__init__.py b/compass/ocean/tests/tides/__init__.py index ec029d4db5..0288850c34 100644 --- a/compass/ocean/tests/tides/__init__.py +++ b/compass/ocean/tests/tides/__init__.py @@ -1,8 +1,7 @@ -from compass.testgroup import TestGroup - -from compass.ocean.tests.tides.mesh import Mesh -from compass.ocean.tests.tides.init import Init from compass.ocean.tests.tides.forward import Forward +from compass.ocean.tests.tides.init import Init +from compass.ocean.tests.tides.mesh import Mesh +from compass.testgroup import TestGroup class Tides(TestGroup): @@ -17,7 +16,7 @@ def __init__(self, mpas_core): super().__init__(mpas_core=mpas_core, name='tides') - for mesh_name in ['Icos7']: + for mesh_name in ['Icos7', 'VR45to5']: mesh = Mesh(test_group=self, mesh_name=mesh_name) self.add_test_case(mesh) diff --git a/compass/ocean/tests/tides/analysis/__init__.py b/compass/ocean/tests/tides/analysis/__init__.py index 423dc32ac1..14ff6644e2 100644 --- a/compass/ocean/tests/tides/analysis/__init__.py +++ b/compass/ocean/tests/tides/analysis/__init__.py @@ -1,4 +1,5 @@ import os +import subprocess import cartopy.crs as ccrs import cartopy.feature as cfeature @@ -6,7 +7,6 @@ import netCDF4 import numpy as np from matplotlib import colormaps -from mpas_tools.logging import check_call from compass.step import Step @@ -42,7 +42,8 @@ def __init__(self, test_case): self.harmonic_analysis_file = 'harmonicAnalysis.nc' self.grid_file = 'initial_state.nc' - self.constituents = ['k1', 'k2', 'm2', 'n2', 'o1', 'p1', 'q1', 's2'] + self.constituents_valid = ['k1', 'k2', 'm2', 'n2', + 'o1', 'p1', 'q1', 's2'] self.add_input_file( filename=self.harmonic_analysis_file, @@ -60,6 +61,8 @@ def setup(self): config = self.config self.tpxo_version = config.get('tides', 'tpxo_version') + self.constituents = config.getlist('tides', 'constituents') + os.makedirs(f'{self.work_dir}/TPXO_data', exist_ok=True) if self.tpxo_version == 'TPXO9': for constituent in self.constituents: @@ -90,24 +93,28 @@ def setup(self): target='TPXO8/grid_tpxo8_atlas_30_v1', database='tides') - def write_coordinate_file(self, idx): + def write_coordinate_file(self, nchunks): """ Write mesh coordinates for TPXO extraction """ # Read in mesh grid_nc = netCDF4.Dataset(self.grid_file, 'r') - lon_grid = np.degrees(grid_nc.variables['lonCell'][idx]) - lat_grid = np.degrees(grid_nc.variables['latCell'][idx]) - nCells = len(lon_grid) + lon_grid = np.degrees(grid_nc.variables['lonCell'][:]) + lat_grid = np.degrees(grid_nc.variables['latCell'][:]) + + lon_grid_split = np.array_split(lon_grid, nchunks) + lat_grid_split = np.array_split(lat_grid, nchunks) # Write coordinate file for OTPS2 - f = open('lat_lon', 'w') - for i in range(nCells): - f.write(f'{lat_grid[i]} {lon_grid[i]} \n') - f.close() + for chunk in range(nchunks): + f = open(f'inputs/lat_lon_{chunk}', 'w') + for i in range(lon_grid_split[chunk].size): + f.write(f'{lat_grid_split[chunk][i]} ' + f'{lon_grid_split[chunk][i]} \n') + f.close() - def setup_otps2(self): + def setup_otps2(self, nchunks): """ Write input files for TPXO extraction """ @@ -115,47 +122,50 @@ def setup_otps2(self): for con in self.constituents: print(f'setup {con}') - # Lines for the setup_con files - lines = [{'inp': f'inputs/Model_atlas_{con}', - 'comment': '! 1. tidal model control file'}, - {'inp': 'lat_lon', - 'comment': '! 2. latitude/longitude/