diff --git a/compass/ocean/tests/global_ocean/files_for_e3sm/remap_sea_surface_salinity_restoring.py b/compass/ocean/tests/global_ocean/files_for_e3sm/remap_sea_surface_salinity_restoring.py index cc34fddd86..a74b1f3fc4 100644 --- a/compass/ocean/tests/global_ocean/files_for_e3sm/remap_sea_surface_salinity_restoring.py +++ b/compass/ocean/tests/global_ocean/files_for_e3sm/remap_sea_surface_salinity_restoring.py @@ -29,8 +29,8 @@ def __init__(self, test_case): ntasks=512, min_tasks=1) self.add_input_file( - filename='woa_decav_0.25_sss_monthly_extrap.20241031.nc', - target='woa_decav_0.25_sss_monthly_extrap.20241031.nc', + filename='woa23_decav_0.25_sss_monthly_extrap.20241031.nc', + target='woa23_decav_0.25_sss_monthly_extrap.20241031.nc', database='initial_condition_database') self.add_output_file(filename='sss.WOA23_monthlyClimatology.nc') diff --git a/compass/ocean/tests/utility/__init__.py b/compass/ocean/tests/utility/__init__.py index 6d59abad4a..aab46ff420 100644 --- a/compass/ocean/tests/utility/__init__.py +++ b/compass/ocean/tests/utility/__init__.py @@ -1,7 +1,7 @@ from compass.ocean.tests.utility.combine_topo import CombineTopo from compass.ocean.tests.utility.cull_restarts import CullRestarts from compass.ocean.tests.utility.extrap_woa import ExtrapWoa -from compass.ocean.tests.utility.create_salinity_restoring import CreateSalinRestoring +from compass.ocean.tests.utility.create_salin_restoring import CreateSalinRestoring from compass.testgroup import TestGroup diff --git a/compass/ocean/tests/utility/create_salinity_restoring/__init__.py b/compass/ocean/tests/utility/create_salin_restoring/__init__.py similarity index 77% rename from compass/ocean/tests/utility/create_salinity_restoring/__init__.py rename to compass/ocean/tests/utility/create_salin_restoring/__init__.py index 94deeaebec..20c243c383 100644 --- a/compass/ocean/tests/utility/create_salinity_restoring/__init__.py +++ b/compass/ocean/tests/utility/create_salin_restoring/__init__.py @@ -1,5 +1,5 @@ -from compass.ocean.tests.utility.create_salinity_restoring.salinity_restoring import Salinity -from compass.ocean.tests.utility.create_salinity_restoring.extrap_salin import ExtrapSalin +from compass.ocean.tests.utility.create_salin_restoring.salinity_restoring import Salinity +from compass.ocean.tests.utility.create_salin_restoring.extrap_salin import ExtrapSalin from compass.testcase import TestCase @@ -19,7 +19,7 @@ def __init__(self, test_group): test_group : compass.ocean.tests.utility.Utility The test group that this test case belongs to """ - super().__init__(test_group=test_group, name='create_salinity_restoring') + super().__init__(test_group=test_group, name='create_salin_restoring') self.add_step(Salinity(test_case=self)) self.add_step(ExtrapSalin(test_case=self)) diff --git a/compass/ocean/tests/utility/create_salinity_restoring/extrap_salin.py b/compass/ocean/tests/utility/create_salin_restoring/extrap_salin.py similarity index 88% rename from compass/ocean/tests/utility/create_salinity_restoring/extrap_salin.py rename to compass/ocean/tests/utility/create_salin_restoring/extrap_salin.py index 74865c528c..c7add1dd15 100644 --- a/compass/ocean/tests/utility/create_salinity_restoring/extrap_salin.py +++ b/compass/ocean/tests/utility/create_salin_restoring/extrap_salin.py @@ -1,5 +1,6 @@ import numpy as np import xarray as xr +from datetime import datetime from scipy.signal import convolve2d from compass.step import Step @@ -8,7 +9,7 @@ class ExtrapSalin(Step): """ Extrapolate WOA 2023 monthly sea surface salinity data into missing ocean - regions, including ice cavities and coasts + regions, including ice cavities and coasts Attributes ---------- @@ -22,7 +23,7 @@ def __init__(self, test_case): Parameters ---------- - test_case : compass.ocean.tests.utility.extrap_woa.ExtrapWoa + test_case : compass.ocean.tests.utility.create_salin_restoring.CreateSalinRestoring The test case this step belongs to """ @@ -39,7 +40,12 @@ def setup(self): """ Determine the output filename """ - self.woa_filename = 'woa_surface_salinity_monthly_extrap.nc' + + now = datetime.now() + + datestring = now.strftime("%Y%m%d") + + self.woa_filename = f'woa23_decav_0.25_sss_monthly_extrap.{datestring}.nc' self.add_output_file(self.woa_filename) def run(self): @@ -48,9 +54,9 @@ def run(self): cavities. """ # extrapolate horizontally using the ocean mask - _extrap_level(self.woa_filename) + _extrap(self.woa_filename) -def _extrap_level(out_filename): +def _extrap(out_filename): in_filename = 'woa_surface_salinity_monthly.nc' ds = xr.open_dataset(in_filename) diff --git a/compass/ocean/tests/utility/create_salinity_restoring/salinity_restoring.py b/compass/ocean/tests/utility/create_salin_restoring/salinity_restoring.py similarity index 87% rename from compass/ocean/tests/utility/create_salinity_restoring/salinity_restoring.py rename to compass/ocean/tests/utility/create_salin_restoring/salinity_restoring.py index 08de479f2c..38d44b0116 100644 --- a/compass/ocean/tests/utility/create_salinity_restoring/salinity_restoring.py +++ b/compass/ocean/tests/utility/create_salin_restoring/salinity_restoring.py @@ -9,7 +9,7 @@ class Salinity(Step): """ A step for combining January through December sea surface salinity data into a single file for salinity restoring in G-cases. - The top level data of the monthly woa is utilized. + The top level data of the monthly WOA23 is utilized. """ def __init__(self, test_case): @@ -18,7 +18,7 @@ def __init__(self, test_case): Parameters ---------- - test_case : compass.ocean.tests.utility.extrap_woa.ExtraWoa + test_case : compass.ocean.tests.utility.create_salin_restoring.CreateSalinRestoring The test case this step belongs to """ super().__init__(test_case, name='salinity_restoring', ntasks=1, min_tasks=1) @@ -84,29 +84,28 @@ def run(self): ds_out['s_an'] = xr.concat(slices, dim='time') ds_out['s_an'].attrs = ds_jan['s_an'].attrs - #Change names of variables and alter attributes + # Change names of variables and alter attributes ds_out = ds_out.rename_dims({'time':'Time'}) ds_out = ds_out.rename_vars({'s_an':'SALT'}) - #ds_out.SALT.attrs['coordinates'] = "Time lat lon" ds_out = ds_out.drop_vars('time') # Create a time index - time_var = np.arange(1,12.1,1) + time_var = np.arange(1, 12.1, 1) ds_out = ds_out.assign(Time=xr.DataArray(time_var, dims=['Time'])) # Create a xtime array xtime_list = [] - for i in range(1,13): + for i in range(1, 13): xtime_string = f"0000-{i:02d}-15_00:00:00" xtime_list.append(xtime_string) xtime_out = np.array(xtime_list,dtype='S64') ds_out = ds_out.assign(xtime=xr.DataArray(xtime_out, dims=['Time'])) - #Change attributes to be consistent with PHC restoring file + # Change attributes to be consistent with PHC restoring file ds_out.Time.attrs['long_name'] = "Month Index" ds_out.Time.attrs['units'] = "month" ds_out.Time.attrs['axis'] = "T" - #Save file and change time dimension to unlimited - write_netcdf(ds_out,'woa_surface_salinity_monthly.nc') + # Save file and change time dimension to unlimited + write_netcdf(ds_out, 'woa_surface_salinity_monthly.nc') diff --git a/compass/ocean/tests/utility/extrap_woa/extrap_step.py b/compass/ocean/tests/utility/extrap_woa/extrap_step.py index 5f0c4e125a..9e07db0ac1 100644 --- a/compass/ocean/tests/utility/extrap_woa/extrap_step.py +++ b/compass/ocean/tests/utility/extrap_woa/extrap_step.py @@ -35,16 +35,12 @@ def __init__(self, test_case): min_cpus_per_task=1, openmp_threads=1) self.add_input_file( - filename='woa_surface_salinity_monthly.nc', - target='../salinity_restoring/woa_surface_salinity_monthly.nc') + filename='woa.nc', + target='../combine/woa_combined.nc') -# self.add_input_file( -# filename='woa.nc', -# target='../combine/woa_combined.nc') - -# self.add_input_file( -# filename='topography.nc', -# target='../remap_topography/topography_remapped.nc') + self.add_input_file( + filename='topography.nc', + target='../remap_topography/topography_remapped.nc') self.woa_filename = None