From 7781433f661e4e62d3230a8074b02e0fe4a75cbe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 16:24:20 +0000 Subject: [PATCH 1/6] Initial plan From 7821c796f5fae7946a5a9dd39a4d9a8e89737dfe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 16:32:35 +0000 Subject: [PATCH 2/6] Remove hardcoded cpus_per_task=128 in landice mesh_gen cases Override constrain_resources in all 7 landice mesh step classes to set cpus_per_task to all available cores rather than hardcoding 128. This allows region mask creation and culling operations to use all allocated processors, which is especially beneficial for large meshes (Antarctica, Greenland) that require many nodes. --- compass/landice/tests/antarctica/mesh.py | 10 ++++++++-- compass/landice/tests/crane/mesh.py | 10 ++++++++-- compass/landice/tests/greenland/mesh.py | 10 ++++++++-- compass/landice/tests/humboldt/mesh.py | 10 ++++++++-- compass/landice/tests/kangerlussuaq/mesh.py | 10 ++++++++-- compass/landice/tests/koge_bugt_s/mesh.py | 10 ++++++++-- compass/landice/tests/thwaites/mesh.py | 10 ++++++++-- 7 files changed, 56 insertions(+), 14 deletions(-) diff --git a/compass/landice/tests/antarctica/mesh.py b/compass/landice/tests/antarctica/mesh.py index d18b80ebcc..501856b3a3 100644 --- a/compass/landice/tests/antarctica/mesh.py +++ b/compass/landice/tests/antarctica/mesh.py @@ -35,8 +35,7 @@ def __init__(self, test_case): The test case this step belongs to """ - super().__init__(test_case=test_case, name='mesh', cpus_per_task=128, - min_cpus_per_task=1) + super().__init__(test_case=test_case, name='mesh') self.mesh_filename = 'Antarctica.nc' self.add_output_file(filename='graph.info') @@ -52,6 +51,13 @@ def __init__(self, test_case): # no setup() method is needed + def constrain_resources(self, available_resources): + """ + Update ``cpus_per_task`` to use all available cores + """ + super().constrain_resources(available_resources) + self.cpus_per_task = available_resources['cores'] + def run(self): """ Run this step of the test case diff --git a/compass/landice/tests/crane/mesh.py b/compass/landice/tests/crane/mesh.py index 649b2eb309..d62bc679ab 100644 --- a/compass/landice/tests/crane/mesh.py +++ b/compass/landice/tests/crane/mesh.py @@ -21,8 +21,7 @@ def __init__(self, test_case): test_case : compass.TestCase The test case this step belongs to """ - super().__init__(test_case=test_case, name='mesh', cpus_per_task=128, - min_cpus_per_task=1) + super().__init__(test_case=test_case, name='mesh') self.add_output_file(filename='graph.info') self.add_output_file(filename='Crane.nc') @@ -39,6 +38,13 @@ def __init__(self, test_case): # no setup() method is needed + def constrain_resources(self, available_resources): + """ + Update ``cpus_per_task`` to use all available cores + """ + super().constrain_resources(available_resources) + self.cpus_per_task = available_resources['cores'] + def run(self): """ Run this step of the test case diff --git a/compass/landice/tests/greenland/mesh.py b/compass/landice/tests/greenland/mesh.py index 029ac3444e..c49991ca3a 100644 --- a/compass/landice/tests/greenland/mesh.py +++ b/compass/landice/tests/greenland/mesh.py @@ -32,8 +32,7 @@ def __init__(self, test_case): The test case this step belongs to """ - super().__init__(test_case=test_case, name='mesh', cpus_per_task=128, - min_cpus_per_task=1) + super().__init__(test_case=test_case, name='mesh') # output files self.mesh_filename = 'GIS.nc' @@ -64,6 +63,13 @@ def setup(self): target=geojson_filename, database=None) + def constrain_resources(self, available_resources): + """ + Update ``cpus_per_task`` to use all available cores + """ + super().constrain_resources(available_resources) + self.cpus_per_task = available_resources['cores'] + def run(self): """ Run this step of the test case diff --git a/compass/landice/tests/humboldt/mesh.py b/compass/landice/tests/humboldt/mesh.py index 11e1eb639e..e626bdbf05 100644 --- a/compass/landice/tests/humboldt/mesh.py +++ b/compass/landice/tests/humboldt/mesh.py @@ -30,8 +30,7 @@ def __init__(self, test_case): mesh_type : str The resolution or mesh type of the test case """ - super().__init__(test_case=test_case, name='mesh', cpus_per_task=128, - min_cpus_per_task=1) + super().__init__(test_case=test_case, name='mesh') self.add_output_file(filename='graph.info') self.add_output_file(filename='Humboldt.nc') @@ -49,6 +48,13 @@ def __init__(self, test_case): # no setup() method is needed + def constrain_resources(self, available_resources): + """ + Update ``cpus_per_task`` to use all available cores + """ + super().constrain_resources(available_resources) + self.cpus_per_task = available_resources['cores'] + def run(self): """ Run this step of the test case diff --git a/compass/landice/tests/kangerlussuaq/mesh.py b/compass/landice/tests/kangerlussuaq/mesh.py index 94bac4d727..2ace4a9f76 100644 --- a/compass/landice/tests/kangerlussuaq/mesh.py +++ b/compass/landice/tests/kangerlussuaq/mesh.py @@ -31,8 +31,7 @@ def __init__(self, test_case): mesh_type : str The resolution or mesh type of the test case """ - super().__init__(test_case=test_case, name='mesh', cpus_per_task=128, - min_cpus_per_task=1) + super().__init__(test_case=test_case, name='mesh') self.add_output_file(filename='graph.info') self.add_output_file(filename='Kangerlussuaq.nc') @@ -50,6 +49,13 @@ def __init__(self, test_case): # no setup() method is needed + def constrain_resources(self, available_resources): + """ + Update ``cpus_per_task`` to use all available cores + """ + super().constrain_resources(available_resources) + self.cpus_per_task = available_resources['cores'] + def run(self): """ Run this step of the test case diff --git a/compass/landice/tests/koge_bugt_s/mesh.py b/compass/landice/tests/koge_bugt_s/mesh.py index 61c4f8f940..07958fd823 100644 --- a/compass/landice/tests/koge_bugt_s/mesh.py +++ b/compass/landice/tests/koge_bugt_s/mesh.py @@ -31,8 +31,7 @@ def __init__(self, test_case): mesh_type : str The resolution or mesh type of the test case """ - super().__init__(test_case=test_case, name='mesh', cpus_per_task=128, - min_cpus_per_task=1) + super().__init__(test_case=test_case, name='mesh') self.add_output_file(filename='graph.info') self.add_output_file(filename='Koge_Bugt_S.nc') @@ -50,6 +49,13 @@ def __init__(self, test_case): # no setup() method is needed + def constrain_resources(self, available_resources): + """ + Update ``cpus_per_task`` to use all available cores + """ + super().constrain_resources(available_resources) + self.cpus_per_task = available_resources['cores'] + def run(self): """ Run this step of the test case diff --git a/compass/landice/tests/thwaites/mesh.py b/compass/landice/tests/thwaites/mesh.py index 0c1b6a439b..0dbba8a8ad 100644 --- a/compass/landice/tests/thwaites/mesh.py +++ b/compass/landice/tests/thwaites/mesh.py @@ -21,8 +21,7 @@ def __init__(self, test_case): test_case : compass.TestCase The test case this step belongs to """ - super().__init__(test_case=test_case, name='mesh', cpus_per_task=128, - min_cpus_per_task=1) + super().__init__(test_case=test_case, name='mesh') self.add_output_file(filename='graph.info') self.add_output_file(filename='Thwaites.nc') @@ -39,6 +38,13 @@ def __init__(self, test_case): # no setup() method is needed + def constrain_resources(self, available_resources): + """ + Update ``cpus_per_task`` to use all available cores + """ + super().constrain_resources(available_resources) + self.cpus_per_task = available_resources['cores'] + def run(self): """ Run this step of the test case From 7d5608b4b2286d306453f5e3f77e9e4d31d19643 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 16:40:49 +0000 Subject: [PATCH 3/6] Move constrain_resources to compass/landice/mesh.py Consolidate the repeated constrain_resources logic into a shared module-level function in compass/landice/mesh.py that calls Step.constrain_resources then sets cpus_per_task to all available cores. All 7 mesh_gen step files now import and delegate to this shared function instead of duplicating the logic. --- compass/landice/mesh.py | 15 +++++++++++++++ compass/landice/tests/antarctica/mesh.py | 7 ++----- compass/landice/tests/crane/mesh.py | 7 ++----- compass/landice/tests/greenland/mesh.py | 7 ++----- compass/landice/tests/humboldt/mesh.py | 7 ++----- compass/landice/tests/kangerlussuaq/mesh.py | 7 ++----- compass/landice/tests/koge_bugt_s/mesh.py | 7 ++----- compass/landice/tests/thwaites/mesh.py | 7 ++----- 8 files changed, 29 insertions(+), 35 deletions(-) diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index 0d7455bcc4..56e77e94b5 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -864,6 +864,21 @@ def build_mali_mesh(self, cell_width, x1, y1, geom_points, check_call(args, logger=logger) +def constrain_resources(self, available_resources): + """ + Update ``cpus_per_task`` to use all available cores + + Parameters + ---------- + available_resources : dict + A dictionary containing available resources (cores, tasks, nodes + and cores_per_node) + """ + from compass.step import Step + Step.constrain_resources(self, available_resources) + self.cpus_per_task = available_resources['cores'] + + def make_region_masks(self, mesh_filename, mask_filename, cores, tags, component='landice', all_tags=True): """ diff --git a/compass/landice/tests/antarctica/mesh.py b/compass/landice/tests/antarctica/mesh.py index 501856b3a3..cc44d48346 100644 --- a/compass/landice/tests/antarctica/mesh.py +++ b/compass/landice/tests/antarctica/mesh.py @@ -6,6 +6,7 @@ add_bedmachine_thk_to_ais_gridded_data, build_cell_width, build_mali_mesh, + constrain_resources, get_optional_interp_datasets, make_region_masks, preprocess_ais_data, @@ -52,11 +53,7 @@ def __init__(self, test_case): # no setup() method is needed def constrain_resources(self, available_resources): - """ - Update ``cpus_per_task`` to use all available cores - """ - super().constrain_resources(available_resources) - self.cpus_per_task = available_resources['cores'] + constrain_resources(self, available_resources) def run(self): """ diff --git a/compass/landice/tests/crane/mesh.py b/compass/landice/tests/crane/mesh.py index d62bc679ab..8998fe58e4 100644 --- a/compass/landice/tests/crane/mesh.py +++ b/compass/landice/tests/crane/mesh.py @@ -1,6 +1,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, + constrain_resources, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, @@ -39,11 +40,7 @@ def __init__(self, test_case): # no setup() method is needed def constrain_resources(self, available_resources): - """ - Update ``cpus_per_task`` to use all available cores - """ - super().constrain_resources(available_resources) - self.cpus_per_task = available_resources['cores'] + constrain_resources(self, available_resources) def run(self): """ diff --git a/compass/landice/tests/greenland/mesh.py b/compass/landice/tests/greenland/mesh.py index c49991ca3a..6b7186dda1 100644 --- a/compass/landice/tests/greenland/mesh.py +++ b/compass/landice/tests/greenland/mesh.py @@ -4,6 +4,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, + constrain_resources, get_mesh_config_bounding_box, get_optional_interp_datasets, make_region_masks, @@ -64,11 +65,7 @@ def setup(self): database=None) def constrain_resources(self, available_resources): - """ - Update ``cpus_per_task`` to use all available cores - """ - super().constrain_resources(available_resources) - self.cpus_per_task = available_resources['cores'] + constrain_resources(self, available_resources) def run(self): """ diff --git a/compass/landice/tests/humboldt/mesh.py b/compass/landice/tests/humboldt/mesh.py index e626bdbf05..d2dc6da21c 100644 --- a/compass/landice/tests/humboldt/mesh.py +++ b/compass/landice/tests/humboldt/mesh.py @@ -1,6 +1,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, + constrain_resources, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, @@ -49,11 +50,7 @@ def __init__(self, test_case): # no setup() method is needed def constrain_resources(self, available_resources): - """ - Update ``cpus_per_task`` to use all available cores - """ - super().constrain_resources(available_resources) - self.cpus_per_task = available_resources['cores'] + constrain_resources(self, available_resources) def run(self): """ diff --git a/compass/landice/tests/kangerlussuaq/mesh.py b/compass/landice/tests/kangerlussuaq/mesh.py index 2ace4a9f76..2f662a0445 100644 --- a/compass/landice/tests/kangerlussuaq/mesh.py +++ b/compass/landice/tests/kangerlussuaq/mesh.py @@ -1,6 +1,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, + constrain_resources, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, @@ -50,11 +51,7 @@ def __init__(self, test_case): # no setup() method is needed def constrain_resources(self, available_resources): - """ - Update ``cpus_per_task`` to use all available cores - """ - super().constrain_resources(available_resources) - self.cpus_per_task = available_resources['cores'] + constrain_resources(self, available_resources) def run(self): """ diff --git a/compass/landice/tests/koge_bugt_s/mesh.py b/compass/landice/tests/koge_bugt_s/mesh.py index 07958fd823..32e17da097 100644 --- a/compass/landice/tests/koge_bugt_s/mesh.py +++ b/compass/landice/tests/koge_bugt_s/mesh.py @@ -1,6 +1,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, + constrain_resources, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, @@ -50,11 +51,7 @@ def __init__(self, test_case): # no setup() method is needed def constrain_resources(self, available_resources): - """ - Update ``cpus_per_task`` to use all available cores - """ - super().constrain_resources(available_resources) - self.cpus_per_task = available_resources['cores'] + constrain_resources(self, available_resources) def run(self): """ diff --git a/compass/landice/tests/thwaites/mesh.py b/compass/landice/tests/thwaites/mesh.py index 0dbba8a8ad..96e8d71ddf 100644 --- a/compass/landice/tests/thwaites/mesh.py +++ b/compass/landice/tests/thwaites/mesh.py @@ -1,6 +1,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, + constrain_resources, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, @@ -39,11 +40,7 @@ def __init__(self, test_case): # no setup() method is needed def constrain_resources(self, available_resources): - """ - Update ``cpus_per_task`` to use all available cores - """ - super().constrain_resources(available_resources) - self.cpus_per_task = available_resources['cores'] + constrain_resources(self, available_resources) def run(self): """ From c48e299a852775ea1eabd33886d6bcdaff9d1b04 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 16:46:44 +0000 Subject: [PATCH 4/6] Replace wrapper methods with direct class attribute assignment for constrain_resources --- compass/landice/tests/antarctica/mesh.py | 5 ++--- compass/landice/tests/crane/mesh.py | 5 ++--- compass/landice/tests/greenland/mesh.py | 5 ++--- compass/landice/tests/humboldt/mesh.py | 5 ++--- compass/landice/tests/kangerlussuaq/mesh.py | 5 ++--- compass/landice/tests/koge_bugt_s/mesh.py | 5 ++--- compass/landice/tests/thwaites/mesh.py | 5 ++--- 7 files changed, 14 insertions(+), 21 deletions(-) diff --git a/compass/landice/tests/antarctica/mesh.py b/compass/landice/tests/antarctica/mesh.py index cc44d48346..7a4935c564 100644 --- a/compass/landice/tests/antarctica/mesh.py +++ b/compass/landice/tests/antarctica/mesh.py @@ -6,7 +6,7 @@ add_bedmachine_thk_to_ais_gridded_data, build_cell_width, build_mali_mesh, - constrain_resources, + constrain_resources as _constrain_resources, get_optional_interp_datasets, make_region_masks, preprocess_ais_data, @@ -52,8 +52,7 @@ def __init__(self, test_case): # no setup() method is needed - def constrain_resources(self, available_resources): - constrain_resources(self, available_resources) + constrain_resources = _constrain_resources def run(self): """ diff --git a/compass/landice/tests/crane/mesh.py b/compass/landice/tests/crane/mesh.py index 8998fe58e4..c97ee094cd 100644 --- a/compass/landice/tests/crane/mesh.py +++ b/compass/landice/tests/crane/mesh.py @@ -1,7 +1,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - constrain_resources, + constrain_resources as _constrain_resources, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, @@ -39,8 +39,7 @@ def __init__(self, test_case): # no setup() method is needed - def constrain_resources(self, available_resources): - constrain_resources(self, available_resources) + constrain_resources = _constrain_resources def run(self): """ diff --git a/compass/landice/tests/greenland/mesh.py b/compass/landice/tests/greenland/mesh.py index 6b7186dda1..64e49611bb 100644 --- a/compass/landice/tests/greenland/mesh.py +++ b/compass/landice/tests/greenland/mesh.py @@ -4,7 +4,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - constrain_resources, + constrain_resources as _constrain_resources, get_mesh_config_bounding_box, get_optional_interp_datasets, make_region_masks, @@ -64,8 +64,7 @@ def setup(self): target=geojson_filename, database=None) - def constrain_resources(self, available_resources): - constrain_resources(self, available_resources) + constrain_resources = _constrain_resources def run(self): """ diff --git a/compass/landice/tests/humboldt/mesh.py b/compass/landice/tests/humboldt/mesh.py index d2dc6da21c..6546c282c1 100644 --- a/compass/landice/tests/humboldt/mesh.py +++ b/compass/landice/tests/humboldt/mesh.py @@ -1,7 +1,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - constrain_resources, + constrain_resources as _constrain_resources, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, @@ -49,8 +49,7 @@ def __init__(self, test_case): # no setup() method is needed - def constrain_resources(self, available_resources): - constrain_resources(self, available_resources) + constrain_resources = _constrain_resources def run(self): """ diff --git a/compass/landice/tests/kangerlussuaq/mesh.py b/compass/landice/tests/kangerlussuaq/mesh.py index 2f662a0445..6fc429867e 100644 --- a/compass/landice/tests/kangerlussuaq/mesh.py +++ b/compass/landice/tests/kangerlussuaq/mesh.py @@ -1,7 +1,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - constrain_resources, + constrain_resources as _constrain_resources, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, @@ -50,8 +50,7 @@ def __init__(self, test_case): # no setup() method is needed - def constrain_resources(self, available_resources): - constrain_resources(self, available_resources) + constrain_resources = _constrain_resources def run(self): """ diff --git a/compass/landice/tests/koge_bugt_s/mesh.py b/compass/landice/tests/koge_bugt_s/mesh.py index 32e17da097..844413746f 100644 --- a/compass/landice/tests/koge_bugt_s/mesh.py +++ b/compass/landice/tests/koge_bugt_s/mesh.py @@ -1,7 +1,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - constrain_resources, + constrain_resources as _constrain_resources, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, @@ -50,8 +50,7 @@ def __init__(self, test_case): # no setup() method is needed - def constrain_resources(self, available_resources): - constrain_resources(self, available_resources) + constrain_resources = _constrain_resources def run(self): """ diff --git a/compass/landice/tests/thwaites/mesh.py b/compass/landice/tests/thwaites/mesh.py index 96e8d71ddf..4aa85b4b25 100644 --- a/compass/landice/tests/thwaites/mesh.py +++ b/compass/landice/tests/thwaites/mesh.py @@ -1,7 +1,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - constrain_resources, + constrain_resources as _constrain_resources, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, @@ -39,8 +39,7 @@ def __init__(self, test_case): # no setup() method is needed - def constrain_resources(self, available_resources): - constrain_resources(self, available_resources) + constrain_resources = _constrain_resources def run(self): """ From 6563525db76ac02553ba639451de338340cc39c6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 17:04:27 +0000 Subject: [PATCH 5/6] Refactor landice mesh steps to use shared LandiceMeshStep base class --- compass/landice/mesh.py | 29 +++++++++++++-------- compass/landice/tests/antarctica/mesh.py | 7 ++--- compass/landice/tests/crane/mesh.py | 7 ++--- compass/landice/tests/greenland/mesh.py | 6 ++--- compass/landice/tests/humboldt/mesh.py | 7 ++--- compass/landice/tests/kangerlussuaq/mesh.py | 7 ++--- compass/landice/tests/koge_bugt_s/mesh.py | 7 ++--- compass/landice/tests/thwaites/mesh.py | 7 ++--- 8 files changed, 32 insertions(+), 45 deletions(-) diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index 56e77e94b5..88f230290f 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -22,6 +22,8 @@ from scipy.interpolate import interpn from scipy.ndimage import distance_transform_edt +from compass.step import Step + def mpas_flood_fill(seed_mask, grow_mask, cellsOnCell, nEdgesOnCell, grow_iters=sys.maxsize): @@ -864,19 +866,24 @@ def build_mali_mesh(self, cell_width, x1, y1, geom_points, check_call(args, logger=logger) -def constrain_resources(self, available_resources): +class LandiceMeshStep(Step): """ - Update ``cpus_per_task`` to use all available cores - - Parameters - ---------- - available_resources : dict - A dictionary containing available resources (cores, tasks, nodes - and cores_per_node) + A base class for land-ice mesh-generation steps that should use all + available cores for serial post-processing steps. """ - from compass.step import Step - Step.constrain_resources(self, available_resources) - self.cpus_per_task = available_resources['cores'] + + def constrain_resources(self, available_resources): + """ + Update ``cpus_per_task`` to use all available cores + + Parameters + ---------- + available_resources : dict + A dictionary containing available resources (cores, tasks, nodes + and cores_per_node) + """ + super().constrain_resources(available_resources) + self.cpus_per_task = available_resources['cores'] def make_region_masks(self, mesh_filename, mask_filename, diff --git a/compass/landice/tests/antarctica/mesh.py b/compass/landice/tests/antarctica/mesh.py index 7a4935c564..83b76fc982 100644 --- a/compass/landice/tests/antarctica/mesh.py +++ b/compass/landice/tests/antarctica/mesh.py @@ -6,17 +6,16 @@ add_bedmachine_thk_to_ais_gridded_data, build_cell_width, build_mali_mesh, - constrain_resources as _constrain_resources, + LandiceMeshStep, get_optional_interp_datasets, make_region_masks, preprocess_ais_data, run_optional_interpolation, ) from compass.model import make_graph_file -from compass.step import Step -class Mesh(Step): +class Mesh(LandiceMeshStep): """ A step for creating a mesh and initial condition for Antarctica test cases @@ -52,8 +51,6 @@ def __init__(self, test_case): # no setup() method is needed - constrain_resources = _constrain_resources - def run(self): """ Run this step of the test case diff --git a/compass/landice/tests/crane/mesh.py b/compass/landice/tests/crane/mesh.py index c97ee094cd..ca107af46f 100644 --- a/compass/landice/tests/crane/mesh.py +++ b/compass/landice/tests/crane/mesh.py @@ -1,16 +1,15 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - constrain_resources as _constrain_resources, + LandiceMeshStep, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, ) from compass.model import make_graph_file -from compass.step import Step -class Mesh(Step): +class Mesh(LandiceMeshStep): """ A step for creating a mesh and initial condition for thwaites test cases """ @@ -39,8 +38,6 @@ def __init__(self, test_case): # no setup() method is needed - constrain_resources = _constrain_resources - def run(self): """ Run this step of the test case diff --git a/compass/landice/tests/greenland/mesh.py b/compass/landice/tests/greenland/mesh.py index 64e49611bb..f38e46dd6d 100644 --- a/compass/landice/tests/greenland/mesh.py +++ b/compass/landice/tests/greenland/mesh.py @@ -4,17 +4,16 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - constrain_resources as _constrain_resources, + LandiceMeshStep, get_mesh_config_bounding_box, get_optional_interp_datasets, make_region_masks, run_optional_interpolation, ) from compass.model import make_graph_file -from compass.step import Step -class Mesh(Step): +class Mesh(LandiceMeshStep): """ A step for creating a mesh and initial condition for greenland test cases @@ -64,7 +63,6 @@ def setup(self): target=geojson_filename, database=None) - constrain_resources = _constrain_resources def run(self): """ diff --git a/compass/landice/tests/humboldt/mesh.py b/compass/landice/tests/humboldt/mesh.py index 6546c282c1..53d166dc28 100644 --- a/compass/landice/tests/humboldt/mesh.py +++ b/compass/landice/tests/humboldt/mesh.py @@ -1,16 +1,15 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - constrain_resources as _constrain_resources, + LandiceMeshStep, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, ) from compass.model import make_graph_file -from compass.step import Step -class Mesh(Step): +class Mesh(LandiceMeshStep): """ A step for creating a mesh and initial condition for humboldt test cases @@ -49,8 +48,6 @@ def __init__(self, test_case): # no setup() method is needed - constrain_resources = _constrain_resources - def run(self): """ Run this step of the test case diff --git a/compass/landice/tests/kangerlussuaq/mesh.py b/compass/landice/tests/kangerlussuaq/mesh.py index 6fc429867e..65ded4664c 100644 --- a/compass/landice/tests/kangerlussuaq/mesh.py +++ b/compass/landice/tests/kangerlussuaq/mesh.py @@ -1,16 +1,15 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - constrain_resources as _constrain_resources, + LandiceMeshStep, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, ) from compass.model import make_graph_file -from compass.step import Step -class Mesh(Step): +class Mesh(LandiceMeshStep): """ A step for creating a mesh and initial condition for kangerlussuaq test cases @@ -50,8 +49,6 @@ def __init__(self, test_case): # no setup() method is needed - constrain_resources = _constrain_resources - def run(self): """ Run this step of the test case diff --git a/compass/landice/tests/koge_bugt_s/mesh.py b/compass/landice/tests/koge_bugt_s/mesh.py index 844413746f..80c3fb6a9a 100644 --- a/compass/landice/tests/koge_bugt_s/mesh.py +++ b/compass/landice/tests/koge_bugt_s/mesh.py @@ -1,16 +1,15 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - constrain_resources as _constrain_resources, + LandiceMeshStep, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, ) from compass.model import make_graph_file -from compass.step import Step -class Mesh(Step): +class Mesh(LandiceMeshStep): """ A step for creating a mesh and initial condition for koge_bugt_s test cases @@ -50,8 +49,6 @@ def __init__(self, test_case): # no setup() method is needed - constrain_resources = _constrain_resources - def run(self): """ Run this step of the test case diff --git a/compass/landice/tests/thwaites/mesh.py b/compass/landice/tests/thwaites/mesh.py index 4aa85b4b25..2899ea5107 100644 --- a/compass/landice/tests/thwaites/mesh.py +++ b/compass/landice/tests/thwaites/mesh.py @@ -1,16 +1,15 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - constrain_resources as _constrain_resources, + LandiceMeshStep, get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_interpolation, ) from compass.model import make_graph_file -from compass.step import Step -class Mesh(Step): +class Mesh(LandiceMeshStep): """ A step for creating a mesh and initial condition for thwaites test cases """ @@ -39,8 +38,6 @@ def __init__(self, test_case): # no setup() method is needed - constrain_resources = _constrain_resources - def run(self): """ Run this step of the test case From bebe051be7b955ca04db91f25afce2e9a54a7797 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 17:32:46 +0000 Subject: [PATCH 6/6] Refactor landice test meshes to import mesh module alias Agent-Logs-Url: https://github.com/MPAS-Dev/compass/sessions/244d2d93-5b38-497f-b70a-e7813f2214b8 Co-authored-by: trhille <17446278+trhille@users.noreply.github.com> --- compass/landice/tests/antarctica/mesh.py | 47 +++++++--------- compass/landice/tests/crane/mesh.py | 24 +++----- compass/landice/tests/greenland/mesh.py | 56 +++++++++---------- compass/landice/tests/humboldt/mesh.py | 24 +++----- .../landice/tests/isunnguata_sermia/mesh.py | 21 +++---- compass/landice/tests/kangerlussuaq/mesh.py | 24 +++----- compass/landice/tests/koge_bugt_s/mesh.py | 24 +++----- compass/landice/tests/thwaites/mesh.py | 24 +++----- 8 files changed, 98 insertions(+), 146 deletions(-) diff --git a/compass/landice/tests/antarctica/mesh.py b/compass/landice/tests/antarctica/mesh.py index 83b76fc982..352cbf369f 100644 --- a/compass/landice/tests/antarctica/mesh.py +++ b/compass/landice/tests/antarctica/mesh.py @@ -2,20 +2,11 @@ import xarray as xr from mpas_tools.logging import check_call -from compass.landice.mesh import ( - add_bedmachine_thk_to_ais_gridded_data, - build_cell_width, - build_mali_mesh, - LandiceMeshStep, - get_optional_interp_datasets, - make_region_masks, - preprocess_ais_data, - run_optional_interpolation, -) +from compass.landice import mesh as landice_mesh from compass.model import make_graph_file -class Mesh(LandiceMeshStep): +class Mesh(landice_mesh.LandiceMeshStep): """ A step for creating a mesh and initial condition for Antarctica test cases @@ -63,8 +54,8 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section_ais.get('nProcs') src_proj = section_ais.get("src_proj") - bedmachine_dataset, measures_dataset = get_optional_interp_datasets( - section_ais, logger) + bedmachine_dataset, measures_dataset = \ + landice_mesh.get_optional_interp_datasets(section_ais, logger) section_name = 'mesh' @@ -73,7 +64,7 @@ def run(self): if bedmachine_dataset is not None: bm_updated_gridded_dataset = ( - add_bedmachine_thk_to_ais_gridded_data( + landice_mesh.add_bedmachine_thk_to_ais_gridded_data( self, source_gridded_dataset, bedmachine_dataset)) @@ -85,13 +76,13 @@ def run(self): ds.close() logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodFillMask = \ - build_cell_width( + landice_mesh.build_cell_width( self, section_name=section_name, gridded_dataset=bm_updated_gridded_dataset, flood_fill_start=[nx // 2, ny // 2]) # Now build the base mesh and perform the standard interpolation - build_mali_mesh( + landice_mesh.build_mali_mesh( self, cell_width, x1, y1, geom_points, geom_edges, mesh_name=self.mesh_filename, section_name=section_name, gridded_dataset=bm_updated_gridded_dataset, @@ -114,7 +105,7 @@ def run(self): # Preprocess the gridded AIS source datasets to work # with the rest of the workflow logger.info('calling preprocess_ais_data') - preprocessed_gridded_dataset = preprocess_ais_data( + preprocessed_gridded_dataset = landice_mesh.preprocess_ais_data( self, bm_updated_gridded_dataset, floodFillMask) # interpolate fields from *preprocessed* composite dataset @@ -139,7 +130,7 @@ def run(self): interpolate_data = section_ais.getboolean( 'interpolate_data', fallback=False) if interpolate_data: - run_optional_interpolation( + landice_mesh.run_optional_interpolation( self, self.mesh_filename, src_proj, parallel_executable, nProcs, bedmachine_dataset=bedmachine_dataset, @@ -152,14 +143,16 @@ def run(self): # create a region mask mask_filename = f'{self.mesh_filename[:-3]}_imbie_regionMasks.nc' - make_region_masks(self, self.mesh_filename, mask_filename, - self.cpus_per_task, - tags=['EastAntarcticaIMBIE', - 'WestAntarcticaIMBIE', - 'AntarcticPeninsulaIMBIE'], - all_tags=False) + landice_mesh.make_region_masks( + self, self.mesh_filename, mask_filename, + self.cpus_per_task, + tags=['EastAntarcticaIMBIE', + 'WestAntarcticaIMBIE', + 'AntarcticPeninsulaIMBIE'], + all_tags=False) mask_filename = f'{self.mesh_filename[:-3]}_ismip6_regionMasks.nc' - make_region_masks(self, self.mesh_filename, mask_filename, - self.cpus_per_task, - tags=['ISMIP6_Basin']) + landice_mesh.make_region_masks( + self, self.mesh_filename, mask_filename, + self.cpus_per_task, + tags=['ISMIP6_Basin']) diff --git a/compass/landice/tests/crane/mesh.py b/compass/landice/tests/crane/mesh.py index ca107af46f..f9e5430bfc 100644 --- a/compass/landice/tests/crane/mesh.py +++ b/compass/landice/tests/crane/mesh.py @@ -1,15 +1,8 @@ -from compass.landice.mesh import ( - build_cell_width, - build_mali_mesh, - LandiceMeshStep, - get_mesh_config_bounding_box, - get_optional_interp_datasets, - run_optional_interpolation, -) +from compass.landice import mesh as landice_mesh from compass.model import make_graph_file -class Mesh(LandiceMeshStep): +class Mesh(landice_mesh.LandiceMeshStep): """ A step for creating a mesh and initial condition for thwaites test cases """ @@ -48,16 +41,16 @@ def run(self): section_name = 'mesh' section = config[section_name] src_proj = section.get('src_proj') - bedmachine_dataset, measures_dataset = get_optional_interp_datasets( - section, logger) + bedmachine_dataset, measures_dataset = \ + landice_mesh.get_optional_interp_datasets(section, logger) logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ - build_cell_width( + landice_mesh.build_cell_width( self, section_name=section_name, gridded_dataset='antarctica_8km_2024_01_29.nc') - build_mali_mesh( + landice_mesh.build_mali_mesh( self, cell_width, x1, y1, geom_points, geom_edges, mesh_name=mesh_name, section_name=section_name, gridded_dataset='antarctica_1km_2024_01_29_AP.nc', @@ -70,9 +63,10 @@ def run(self): interpolate_data = section.getboolean( 'interpolate_data', fallback=False) if interpolate_data: - run_optional_interpolation( + landice_mesh.run_optional_interpolation( self, mesh_name, src_proj, parallel_executable, nProcs, - subset_bounds=get_mesh_config_bounding_box(section), + subset_bounds=landice_mesh.get_mesh_config_bounding_box( + section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) diff --git a/compass/landice/tests/greenland/mesh.py b/compass/landice/tests/greenland/mesh.py index f38e46dd6d..666d14f2e6 100644 --- a/compass/landice/tests/greenland/mesh.py +++ b/compass/landice/tests/greenland/mesh.py @@ -1,19 +1,11 @@ import numpy as np import xarray as xr -from compass.landice.mesh import ( - build_cell_width, - build_mali_mesh, - LandiceMeshStep, - get_mesh_config_bounding_box, - get_optional_interp_datasets, - make_region_masks, - run_optional_interpolation, -) +from compass.landice import mesh as landice_mesh from compass.model import make_graph_file -class Mesh(LandiceMeshStep): +class Mesh(landice_mesh.LandiceMeshStep): """ A step for creating a mesh and initial condition for greenland test cases @@ -78,8 +70,8 @@ def run(self): src_proj = section_gis.get("src_proj") geojson_filename = section_gis.get('geojson_filename') - bedmachine_dataset, measures_dataset = get_optional_interp_datasets( - section_gis, logger) + bedmachine_dataset, measures_dataset = \ + landice_mesh.get_optional_interp_datasets(section_gis, logger) if bedmachine_dataset is not None: ds_bm = xr.open_dataset(bedmachine_dataset) @@ -89,7 +81,7 @@ def run(self): float(ds_bm.y1.min()), float(ds_bm.y1.max())] ds_bm.close() - bounding_box = get_mesh_config_bounding_box( + bounding_box = landice_mesh.get_mesh_config_bounding_box( section_gis, default_bounds=default_bounds) else: bounding_box = None @@ -101,13 +93,13 @@ def run(self): logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ - build_cell_width( + landice_mesh.build_cell_width( self, section_name=section_name, gridded_dataset=source_gridded_dataset_2km, flood_fill_start=[100, 700]) # Now build the base mesh and perform the standard interpolation - build_mali_mesh( + landice_mesh.build_mali_mesh( self, cell_width, x1, y1, geom_points, geom_edges, mesh_name=self.mesh_filename, section_name=section_name, gridded_dataset=source_gridded_dataset_1km, @@ -120,7 +112,7 @@ def run(self): interpolate_data = section_gis.getboolean( 'interpolate_data', fallback=False) if interpolate_data: - run_optional_interpolation( + landice_mesh.run_optional_interpolation( self, self.mesh_filename, src_proj, parallel_executable, nProcs, bedmachine_dataset=bedmachine_dataset, @@ -133,23 +125,25 @@ def run(self): # create region masks mask_filename = f'{self.mesh_filename[:-3]}_ismip6_regionMasks.nc' - make_region_masks(self, self.mesh_filename, mask_filename, - self.cpus_per_task, - tags=["Greenland", "ISMIP6", "Shelf"], - component='ocean') + landice_mesh.make_region_masks( + self, self.mesh_filename, mask_filename, + self.cpus_per_task, + tags=["Greenland", "ISMIP6", "Shelf"], + component='ocean') mask_filename = f'{self.mesh_filename[:-3]}_zwally_regionMasks.nc' - make_region_masks(self, self.mesh_filename, mask_filename, - self.cpus_per_task, - tags=['eastCentralGreenland', - 'northEastGreenland', - 'northGreenland', - 'northWestGreenland', - 'southEastGreenland', - 'southGreenland', - 'southWestGreenland', - 'westCentralGreenland'], - all_tags=False) + landice_mesh.make_region_masks( + self, self.mesh_filename, mask_filename, + self.cpus_per_task, + tags=['eastCentralGreenland', + 'northEastGreenland', + 'northGreenland', + 'northWestGreenland', + 'southEastGreenland', + 'southGreenland', + 'southWestGreenland', + 'westCentralGreenland'], + all_tags=False) # Do some final validation of the mesh ds = xr.open_dataset(self.mesh_filename) diff --git a/compass/landice/tests/humboldt/mesh.py b/compass/landice/tests/humboldt/mesh.py index 53d166dc28..37bc0abfc2 100644 --- a/compass/landice/tests/humboldt/mesh.py +++ b/compass/landice/tests/humboldt/mesh.py @@ -1,15 +1,8 @@ -from compass.landice.mesh import ( - build_cell_width, - build_mali_mesh, - LandiceMeshStep, - get_mesh_config_bounding_box, - get_optional_interp_datasets, - run_optional_interpolation, -) +from compass.landice import mesh as landice_mesh from compass.model import make_graph_file -class Mesh(LandiceMeshStep): +class Mesh(landice_mesh.LandiceMeshStep): """ A step for creating a mesh and initial condition for humboldt test cases @@ -58,16 +51,16 @@ def run(self): section = config[section_name] mesh_name = 'Humboldt.nc' src_proj = section.get('src_proj') - bedmachine_dataset, measures_dataset = get_optional_interp_datasets( - section, logger) + bedmachine_dataset, measures_dataset = \ + landice_mesh.get_optional_interp_datasets(section, logger) logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ - build_cell_width( + landice_mesh.build_cell_width( self, section_name=section_name, gridded_dataset='greenland_2km_2024_01_29.epsg3413.nc') - build_mali_mesh( + landice_mesh.build_mali_mesh( self, cell_width, x1, y1, geom_points, geom_edges, mesh_name=mesh_name, section_name=section_name, gridded_dataset='humboldt_1km_2024_01_29.epsg3413.icesheetonly.nc', @@ -80,9 +73,10 @@ def run(self): interpolate_data = section.getboolean( 'interpolate_data', fallback=False) if interpolate_data: - run_optional_interpolation( + landice_mesh.run_optional_interpolation( self, mesh_name, src_proj, parallel_executable, nProcs, - subset_bounds=get_mesh_config_bounding_box(section), + subset_bounds=landice_mesh.get_mesh_config_bounding_box( + section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) diff --git a/compass/landice/tests/isunnguata_sermia/mesh.py b/compass/landice/tests/isunnguata_sermia/mesh.py index e2c50ed1db..07ed90b001 100644 --- a/compass/landice/tests/isunnguata_sermia/mesh.py +++ b/compass/landice/tests/isunnguata_sermia/mesh.py @@ -1,10 +1,4 @@ -from compass.landice.mesh import ( - build_cell_width, - build_mali_mesh, - get_mesh_config_bounding_box, - get_optional_interp_datasets, - run_optional_interpolation, -) +from compass.landice import mesh as landice_mesh from compass.model import make_graph_file from compass.step import Step @@ -59,16 +53,16 @@ def run(self): section = config[section_name] mesh_name = 'Isunnguata_Sermia.nc' src_proj = section.get('src_proj') - bedmachine_dataset, measures_dataset = get_optional_interp_datasets( - section, logger) + bedmachine_dataset, measures_dataset = \ + landice_mesh.get_optional_interp_datasets(section, logger) logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ - build_cell_width( + landice_mesh.build_cell_width( self, section_name=section_name, gridded_dataset='greenland_2km_2024_01_29.epsg3413.nc') - build_mali_mesh( + landice_mesh.build_mali_mesh( self, cell_width, x1, y1, geom_points, geom_edges, mesh_name=mesh_name, section_name=section_name, gridded_dataset='greenland_1km_2024_01_29.epsg3413.icesheetonly.nc', # noqa @@ -80,9 +74,10 @@ def run(self): interpolate_data = section.getboolean( 'interpolate_data', fallback=False) if interpolate_data: - run_optional_interpolation( + landice_mesh.run_optional_interpolation( self, mesh_name, src_proj, parallel_executable, nProcs, - subset_bounds=get_mesh_config_bounding_box(section), + subset_bounds=landice_mesh.get_mesh_config_bounding_box( + section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) diff --git a/compass/landice/tests/kangerlussuaq/mesh.py b/compass/landice/tests/kangerlussuaq/mesh.py index 65ded4664c..d54aaacef8 100644 --- a/compass/landice/tests/kangerlussuaq/mesh.py +++ b/compass/landice/tests/kangerlussuaq/mesh.py @@ -1,15 +1,8 @@ -from compass.landice.mesh import ( - build_cell_width, - build_mali_mesh, - LandiceMeshStep, - get_mesh_config_bounding_box, - get_optional_interp_datasets, - run_optional_interpolation, -) +from compass.landice import mesh as landice_mesh from compass.model import make_graph_file -class Mesh(LandiceMeshStep): +class Mesh(landice_mesh.LandiceMeshStep): """ A step for creating a mesh and initial condition for kangerlussuaq test cases @@ -59,16 +52,16 @@ def run(self): section_name = 'mesh' section = config[section_name] src_proj = section.get('src_proj') - bedmachine_dataset, measures_dataset = get_optional_interp_datasets( - section, logger) + bedmachine_dataset, measures_dataset = \ + landice_mesh.get_optional_interp_datasets(section, logger) logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ - build_cell_width( + landice_mesh.build_cell_width( self, section_name=section_name, gridded_dataset='greenland_8km_2024_01_29.epsg3413.nc') - build_mali_mesh( + landice_mesh.build_mali_mesh( self, cell_width, x1, y1, geom_points, geom_edges, mesh_name=mesh_name, section_name=section_name, gridded_dataset='greenland_1km_2024_01_29.epsg3413.icesheetonly.nc', # noqa @@ -81,9 +74,10 @@ def run(self): interpolate_data = section.getboolean( 'interpolate_data', fallback=False) if interpolate_data: - run_optional_interpolation( + landice_mesh.run_optional_interpolation( self, mesh_name, src_proj, parallel_executable, nProcs, - subset_bounds=get_mesh_config_bounding_box(section), + subset_bounds=landice_mesh.get_mesh_config_bounding_box( + section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) diff --git a/compass/landice/tests/koge_bugt_s/mesh.py b/compass/landice/tests/koge_bugt_s/mesh.py index 80c3fb6a9a..93f36bee56 100644 --- a/compass/landice/tests/koge_bugt_s/mesh.py +++ b/compass/landice/tests/koge_bugt_s/mesh.py @@ -1,15 +1,8 @@ -from compass.landice.mesh import ( - build_cell_width, - build_mali_mesh, - LandiceMeshStep, - get_mesh_config_bounding_box, - get_optional_interp_datasets, - run_optional_interpolation, -) +from compass.landice import mesh as landice_mesh from compass.model import make_graph_file -class Mesh(LandiceMeshStep): +class Mesh(landice_mesh.LandiceMeshStep): """ A step for creating a mesh and initial condition for koge_bugt_s test cases @@ -59,16 +52,16 @@ def run(self): section_name = 'mesh' section = config[section_name] src_proj = section.get('src_proj') - bedmachine_dataset, measures_dataset = get_optional_interp_datasets( - section, logger) + bedmachine_dataset, measures_dataset = \ + landice_mesh.get_optional_interp_datasets(section, logger) logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ - build_cell_width( + landice_mesh.build_cell_width( self, section_name=section_name, gridded_dataset='greenland_8km_2024_01_29.epsg3413.nc') - build_mali_mesh( + landice_mesh.build_mali_mesh( self, cell_width, x1, y1, geom_points, geom_edges, mesh_name=mesh_name, section_name=section_name, gridded_dataset='greenland_1km_2024_01_29.epsg3413.icesheetonly.nc', # noqa @@ -81,9 +74,10 @@ def run(self): interpolate_data = section.getboolean( 'interpolate_data', fallback=False) if interpolate_data: - run_optional_interpolation( + landice_mesh.run_optional_interpolation( self, mesh_name, src_proj, parallel_executable, nProcs, - subset_bounds=get_mesh_config_bounding_box(section), + subset_bounds=landice_mesh.get_mesh_config_bounding_box( + section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) diff --git a/compass/landice/tests/thwaites/mesh.py b/compass/landice/tests/thwaites/mesh.py index 2899ea5107..6563873fdb 100644 --- a/compass/landice/tests/thwaites/mesh.py +++ b/compass/landice/tests/thwaites/mesh.py @@ -1,15 +1,8 @@ -from compass.landice.mesh import ( - build_cell_width, - build_mali_mesh, - LandiceMeshStep, - get_mesh_config_bounding_box, - get_optional_interp_datasets, - run_optional_interpolation, -) +from compass.landice import mesh as landice_mesh from compass.model import make_graph_file -class Mesh(LandiceMeshStep): +class Mesh(landice_mesh.LandiceMeshStep): """ A step for creating a mesh and initial condition for thwaites test cases """ @@ -48,16 +41,16 @@ def run(self): section_name = 'mesh' section = config[section_name] src_proj = section.get('src_proj') - bedmachine_dataset, measures_dataset = get_optional_interp_datasets( - section, logger) + bedmachine_dataset, measures_dataset = \ + landice_mesh.get_optional_interp_datasets(section, logger) logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ - build_cell_width( + landice_mesh.build_cell_width( self, section_name=section_name, gridded_dataset='antarctica_8km_2024_01_29.nc') - build_mali_mesh( + landice_mesh.build_mali_mesh( self, cell_width, x1, y1, geom_points, geom_edges, mesh_name=mesh_name, section_name=section_name, gridded_dataset='antarctica_1km_2024_01_29_ASE.nc', @@ -70,9 +63,10 @@ def run(self): interpolate_data = section.getboolean( 'interpolate_data', fallback=False) if interpolate_data: - run_optional_interpolation( + landice_mesh.run_optional_interpolation( self, mesh_name, src_proj, parallel_executable, nProcs, - subset_bounds=get_mesh_config_bounding_box(section), + subset_bounds=landice_mesh.get_mesh_config_bounding_box( + section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset)