From f496c0d498452eb08da7c7ce57fa0d316676befa Mon Sep 17 00:00:00 2001 From: Trevor Hillebrand Date: Wed, 18 Mar 2026 15:04:02 -0500 Subject: [PATCH 01/10] Make data interpolation optional for all meshes. Add data interpolation option for all meshes. If data path is not set in .cfg file, interpolation will be skipped. By default, interpolation will be performed for antarctica and greenland, but not for regional meshes. --- compass/landice/tests/antarctica/mesh.py | 74 ++++++++++++++----- compass/landice/tests/crane/mesh.py | 65 +++++++++++++++- .../landice/tests/crane/mesh_gen/mesh_gen.cfg | 5 ++ compass/landice/tests/greenland/mesh.py | 66 ++++++++++++----- compass/landice/tests/humboldt/mesh.py | 65 +++++++++++++++- .../tests/humboldt/mesh_gen/mesh_gen.cfg | 5 ++ .../landice/tests/isunnguata_sermia/mesh.py | 65 +++++++++++++++- .../isunnguata_sermia/mesh_gen/mesh_gen.cfg | 5 ++ compass/landice/tests/kangerlussuaq/mesh.py | 65 +++++++++++++++- .../tests/kangerlussuaq/mesh_gen/mesh_gen.cfg | 5 ++ compass/landice/tests/koge_bugt_s/mesh.py | 65 +++++++++++++++- .../tests/koge_bugt_s/mesh_gen/mesh_gen.cfg | 5 ++ compass/landice/tests/thwaites/mesh.py | 65 +++++++++++++++- .../tests/thwaites/mesh_gen/mesh_gen.cfg | 5 ++ 14 files changed, 517 insertions(+), 43 deletions(-) diff --git a/compass/landice/tests/antarctica/mesh.py b/compass/landice/tests/antarctica/mesh.py index 57a8d82b39..24b5bbbd92 100644 --- a/compass/landice/tests/antarctica/mesh.py +++ b/compass/landice/tests/antarctica/mesh.py @@ -63,23 +63,52 @@ def run(self): section_ais = config['antarctica'] + def _specified(value): + return value is not None and str(value).strip().lower() not in [ + '', 'none'] + parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section_ais.get('nProcs') src_proj = section_ais.get("src_proj") - data_path = section_ais.get('data_path') - measures_filename = section_ais.get("measures_filename") - bedmachine_filename = section_ais.get("bedmachine_filename") - - measures_dataset = os.path.join(data_path, measures_filename) - bedmachine_dataset = os.path.join(data_path, bedmachine_filename) + data_path = section_ais.get('data_path', fallback=None) + measures_filename = section_ais.get("measures_filename", fallback=None) + bedmachine_filename = section_ais.get( + "bedmachine_filename", fallback=None) + + use_bedmachine_interp = _specified(data_path) and \ + _specified(bedmachine_filename) + use_measures_interp = _specified(data_path) and \ + _specified(measures_filename) + + if use_bedmachine_interp: + bedmachine_dataset = os.path.join(data_path, bedmachine_filename) + else: + bedmachine_dataset = None + logger.info('Skipping BedMachine interpolation because ' + '`data_path` and/or `bedmachine_filename` are ' + 'not specified in config.') + + if use_measures_interp: + measures_dataset = os.path.join(data_path, measures_filename) + else: + measures_dataset = None + logger.info('Skipping MEaSUREs interpolation because ' + '`data_path` and/or `measures_filename` are ' + 'not specified in config.') section_name = 'mesh' # TODO: do we want to add this to the config file? source_gridded_dataset = 'antarctica_8km_2024_01_29.nc' - bm_updated_gridded_dataset = add_bedmachine_thk_to_ais_gridded_data( - self, source_gridded_dataset, bedmachine_dataset) + if use_bedmachine_interp: + bm_updated_gridded_dataset = ( + add_bedmachine_thk_to_ais_gridded_data( + self, + source_gridded_dataset, + bedmachine_dataset)) + else: + bm_updated_gridded_dataset = source_gridded_dataset logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodFillMask = \ @@ -133,27 +162,34 @@ def run(self): check_call(args, logger=logger) # Create scrip file for the newly generated mesh - logger.info('creating scrip file for destination mesh') - dst_scrip_file = f"{self.mesh_filename.split('.')[:-1][0]}_scrip.nc" - scrip_from_mpas(self.mesh_filename, dst_scrip_file) + do_bespoke_interp = use_bedmachine_interp or use_measures_interp + if do_bespoke_interp: + logger.info('creating scrip file for destination mesh') + dst_scrip_file = \ + f"{self.mesh_filename.split('.')[:-1][0]}_scrip.nc" + scrip_from_mpas(self.mesh_filename, dst_scrip_file) # Now perform bespoke interpolation of geometry and velocity data # from their respective sources - interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, - parallel_executable, nProcs, - self.mesh_filename, src_proj, variables="all") + if use_bedmachine_interp: + interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, + parallel_executable, nProcs, + self.mesh_filename, src_proj, + variables="all") # only interpolate a subset of MEaSUREs variables onto the MALI mesh measures_vars = ['observedSurfaceVelocityX', 'observedSurfaceVelocityY', 'observedSurfaceVelocityUncertainty'] - interp_gridded2mali(self, measures_dataset, dst_scrip_file, - parallel_executable, nProcs, - self.mesh_filename, src_proj, - variables=measures_vars) + if use_measures_interp: + interp_gridded2mali(self, measures_dataset, dst_scrip_file, + parallel_executable, nProcs, + self.mesh_filename, src_proj, + variables=measures_vars) # perform some final cleanup details - clean_up_after_interp(self.mesh_filename) + if do_bespoke_interp: + clean_up_after_interp(self.mesh_filename) # create graph file logger.info('creating graph.info') diff --git a/compass/landice/tests/crane/mesh.py b/compass/landice/tests/crane/mesh.py index 002e03283d..1a65546696 100644 --- a/compass/landice/tests/crane/mesh.py +++ b/compass/landice/tests/crane/mesh.py @@ -1,4 +1,13 @@ -from compass.landice.mesh import build_cell_width, build_mali_mesh +import os + +from mpas_tools.scrip.from_mpas import scrip_from_mpas + +from compass.landice.mesh import ( + build_cell_width, + build_mali_mesh, + clean_up_after_interp, + interp_gridded2mali, +) from compass.model import make_graph_file from compass.step import Step @@ -38,8 +47,39 @@ def run(self): Run this step of the test case """ logger = self.logger + config = self.config mesh_name = 'Crane.nc' section_name = 'mesh' + section = config[section_name] + + def _specified(value): + return value is not None and str(value).strip().lower() not in [ + '', 'none'] + + data_path = section.get('data_path', fallback=None) + bedmachine_filename = section.get('bedmachine_filename', fallback=None) + measures_filename = section.get('measures_filename', fallback=None) + + use_bedmachine_interp = _specified(data_path) and \ + _specified(bedmachine_filename) + use_measures_interp = _specified(data_path) and \ + _specified(measures_filename) + do_bespoke_interp = use_bedmachine_interp or use_measures_interp + + if use_bedmachine_interp: + bedmachine_dataset = os.path.join(data_path, bedmachine_filename) + else: + bedmachine_dataset = None + + if use_measures_interp: + measures_dataset = os.path.join(data_path, measures_filename) + else: + measures_dataset = None + + if not do_bespoke_interp: + logger.info('Skipping optional bespoke interpolation because ' + '`data_path` and interpolation filenames are ' + 'not specified in config.') logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ @@ -54,6 +94,29 @@ def run(self): projection='ais-bedmap2', geojson_file='Crane.geojson', cores=self.cpus_per_task) + if do_bespoke_interp: + parallel_executable = config.get('parallel', 'parallel_executable') + nProcs = str(self.cpus_per_task) + + logger.info('creating scrip file for destination mesh') + dst_scrip_file = f"{mesh_name.split('.')[:-1][0]}_scrip.nc" + scrip_from_mpas(mesh_name, dst_scrip_file) + + if use_bedmachine_interp: + interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, + parallel_executable, nProcs, mesh_name, + 'ais-bedmap2', variables='all') + + if use_measures_interp: + measures_vars = ['observedSurfaceVelocityX', + 'observedSurfaceVelocityY', + 'observedSurfaceVelocityUncertainty'] + interp_gridded2mali(self, measures_dataset, dst_scrip_file, + parallel_executable, nProcs, mesh_name, + 'ais-bedmap2', variables=measures_vars) + + clean_up_after_interp(mesh_name) + logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, graph_filename='graph.info') diff --git a/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg b/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg index bd23901804..8b80bfd53d 100644 --- a/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg @@ -46,3 +46,8 @@ use_speed = True use_dist_to_grounding_line = True use_dist_to_edge = False use_bed = False + +# Optional bespoke interpolation inputs (skip when set to None) +data_path = None +bedmachine_filename = None +measures_filename = None diff --git a/compass/landice/tests/greenland/mesh.py b/compass/landice/tests/greenland/mesh.py index e7a6a64e1f..938bc05536 100644 --- a/compass/landice/tests/greenland/mesh.py +++ b/compass/landice/tests/greenland/mesh.py @@ -75,18 +75,42 @@ def run(self): section_gis = config['greenland'] + def _specified(value): + return value is not None and str(value).strip().lower() not in [ + '', 'none'] + parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section_gis.get('nProcs') src_proj = section_gis.get("src_proj") - data_path = section_gis.get('data_path') - measures_filename = section_gis.get("measures_filename") - bedmachine_filename = section_gis.get("bedmachine_filename") + data_path = section_gis.get('data_path', fallback=None) + measures_filename = section_gis.get("measures_filename", fallback=None) + bedmachine_filename = section_gis.get( + "bedmachine_filename", fallback=None) geojson_filename = section_gis.get('geojson_filename') - measures_dataset = os.path.join(data_path, measures_filename) - bedmachine_dataset = os.path.join(data_path, bedmachine_filename) - - bounding_box = self._get_bedmachine_bounding_box(bedmachine_dataset) + use_bedmachine_interp = _specified(data_path) and \ + _specified(bedmachine_filename) + use_measures_interp = _specified(data_path) and \ + _specified(measures_filename) + + if use_bedmachine_interp: + bedmachine_dataset = os.path.join(data_path, bedmachine_filename) + bounding_box = self._get_bedmachine_bounding_box( + bedmachine_dataset) + else: + bedmachine_dataset = None + bounding_box = None + logger.info('Skipping BedMachine interpolation because ' + '`data_path` and/or `bedmachine_filename` are ' + 'not specified in config.') + + if use_measures_interp: + measures_dataset = os.path.join(data_path, measures_filename) + else: + measures_dataset = None + logger.info('Skipping MEaSUREs interpolation because ' + '`data_path` and/or `measures_filename` are ' + 'not specified in config.') section_name = 'mesh' @@ -110,27 +134,33 @@ def run(self): ) # Create scrip file for the newly generated mesh - logger.info('creating scrip file for destination mesh') - dst_scrip_file = f"{self.mesh_filename.split('.')[:-1][0]}_scrip.nc" - scrip_from_mpas(self.mesh_filename, dst_scrip_file) + do_bespoke_interp = use_bedmachine_interp or use_measures_interp + if do_bespoke_interp: + logger.info('creating scrip file for destination mesh') + dst_scrip_file = \ + f"{self.mesh_filename.split('.')[:-1][0]}_scrip.nc" + scrip_from_mpas(self.mesh_filename, dst_scrip_file) # Now perform bespoke interpolation of geometry and velocity data # from their respective sources - interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, - parallel_executable, nProcs, - self.mesh_filename, src_proj, variables="all") + if use_bedmachine_interp: + interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, + parallel_executable, nProcs, + self.mesh_filename, src_proj, variables="all") # only interpolate a subset of MEaSUREs variables onto the MALI mesh measures_vars = ['observedSurfaceVelocityX', 'observedSurfaceVelocityY', 'observedSurfaceVelocityUncertainty'] - interp_gridded2mali(self, measures_dataset, dst_scrip_file, - parallel_executable, nProcs, - self.mesh_filename, src_proj, - variables=measures_vars) + if use_measures_interp: + interp_gridded2mali(self, measures_dataset, dst_scrip_file, + parallel_executable, nProcs, + self.mesh_filename, src_proj, + variables=measures_vars) # perform some final cleanup details - clean_up_after_interp(self.mesh_filename) + if do_bespoke_interp: + clean_up_after_interp(self.mesh_filename) # create graph file logger.info('creating graph.info') diff --git a/compass/landice/tests/humboldt/mesh.py b/compass/landice/tests/humboldt/mesh.py index 33c4e34eef..c9ee6e0653 100644 --- a/compass/landice/tests/humboldt/mesh.py +++ b/compass/landice/tests/humboldt/mesh.py @@ -1,4 +1,13 @@ -from compass.landice.mesh import build_cell_width, build_mali_mesh +import os + +from mpas_tools.scrip.from_mpas import scrip_from_mpas + +from compass.landice.mesh import ( + build_cell_width, + build_mali_mesh, + clean_up_after_interp, + interp_gridded2mali, +) from compass.model import make_graph_file from compass.step import Step @@ -48,9 +57,40 @@ def run(self): Run this step of the test case """ logger = self.logger + config = self.config section_name = 'mesh' + section = config[section_name] mesh_name = 'Humboldt.nc' + def _specified(value): + return value is not None and str(value).strip().lower() not in [ + '', 'none'] + + data_path = section.get('data_path', fallback=None) + bedmachine_filename = section.get('bedmachine_filename', fallback=None) + measures_filename = section.get('measures_filename', fallback=None) + + use_bedmachine_interp = _specified(data_path) and \ + _specified(bedmachine_filename) + use_measures_interp = _specified(data_path) and \ + _specified(measures_filename) + do_bespoke_interp = use_bedmachine_interp or use_measures_interp + + if use_bedmachine_interp: + bedmachine_dataset = os.path.join(data_path, bedmachine_filename) + else: + bedmachine_dataset = None + + if use_measures_interp: + measures_dataset = os.path.join(data_path, measures_filename) + else: + measures_dataset = None + + if not do_bespoke_interp: + logger.info('Skipping optional bespoke interpolation because ' + '`data_path` and interpolation filenames are ' + 'not specified in config.') + logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ build_cell_width( @@ -64,6 +104,29 @@ def run(self): projection='gis-gimp', geojson_file='Humboldt.geojson', cores=self.cpus_per_task) + if do_bespoke_interp: + parallel_executable = config.get('parallel', 'parallel_executable') + nProcs = str(self.cpus_per_task) + + logger.info('creating scrip file for destination mesh') + dst_scrip_file = f"{mesh_name.split('.')[:-1][0]}_scrip.nc" + scrip_from_mpas(mesh_name, dst_scrip_file) + + if use_bedmachine_interp: + interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, + parallel_executable, nProcs, mesh_name, + 'gis-gimp', variables='all') + + if use_measures_interp: + measures_vars = ['observedSurfaceVelocityX', + 'observedSurfaceVelocityY', + 'observedSurfaceVelocityUncertainty'] + interp_gridded2mali(self, measures_dataset, dst_scrip_file, + parallel_executable, nProcs, mesh_name, + 'gis-gimp', variables=measures_vars) + + clean_up_after_interp(mesh_name) + logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, graph_filename='graph.info') diff --git a/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg b/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg index 6927514134..06789f981f 100644 --- a/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg @@ -42,3 +42,8 @@ use_speed = True use_dist_to_grounding_line = False use_dist_to_edge = True use_bed = True + +# Optional bespoke interpolation inputs (skip when set to None) +data_path = None +bedmachine_filename = None +measures_filename = None diff --git a/compass/landice/tests/isunnguata_sermia/mesh.py b/compass/landice/tests/isunnguata_sermia/mesh.py index bd7a9bf2e0..b7a39f9614 100644 --- a/compass/landice/tests/isunnguata_sermia/mesh.py +++ b/compass/landice/tests/isunnguata_sermia/mesh.py @@ -1,4 +1,13 @@ -from compass.landice.mesh import build_cell_width, build_mali_mesh +import os + +from mpas_tools.scrip.from_mpas import scrip_from_mpas + +from compass.landice.mesh import ( + build_cell_width, + build_mali_mesh, + clean_up_after_interp, + interp_gridded2mali, +) from compass.model import make_graph_file from compass.step import Step @@ -48,9 +57,40 @@ def run(self): Run this step of the test case """ logger = self.logger + config = self.config section_name = 'mesh' + section = config[section_name] mesh_name = 'Isunnguata_Sermia.nc' + def _specified(value): + return value is not None and str(value).strip().lower() not in [ + '', 'none'] + + data_path = section.get('data_path', fallback=None) + bedmachine_filename = section.get('bedmachine_filename', fallback=None) + measures_filename = section.get('measures_filename', fallback=None) + + use_bedmachine_interp = _specified(data_path) and \ + _specified(bedmachine_filename) + use_measures_interp = _specified(data_path) and \ + _specified(measures_filename) + do_bespoke_interp = use_bedmachine_interp or use_measures_interp + + if use_bedmachine_interp: + bedmachine_dataset = os.path.join(data_path, bedmachine_filename) + else: + bedmachine_dataset = None + + if use_measures_interp: + measures_dataset = os.path.join(data_path, measures_filename) + else: + measures_dataset = None + + if not do_bespoke_interp: + logger.info('Skipping optional bespoke interpolation because ' + '`data_path` and interpolation filenames are ' + 'not specified in config.') + logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ build_cell_width( @@ -63,6 +103,29 @@ def run(self): gridded_dataset='greenland_1km_2024_01_29.epsg3413.icesheetonly.nc', # noqa projection='gis-gimp', geojson_file='Isunnguata_Sermia.geojson') + if do_bespoke_interp: + parallel_executable = config.get('parallel', 'parallel_executable') + nProcs = str(self.cpus_per_task) + + logger.info('creating scrip file for destination mesh') + dst_scrip_file = f"{mesh_name.split('.')[:-1][0]}_scrip.nc" + scrip_from_mpas(mesh_name, dst_scrip_file) + + if use_bedmachine_interp: + interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, + parallel_executable, nProcs, mesh_name, + 'gis-gimp', variables='all') + + if use_measures_interp: + measures_vars = ['observedSurfaceVelocityX', + 'observedSurfaceVelocityY', + 'observedSurfaceVelocityUncertainty'] + interp_gridded2mali(self, measures_dataset, dst_scrip_file, + parallel_executable, nProcs, mesh_name, + 'gis-gimp', variables=measures_vars) + + clean_up_after_interp(mesh_name) + logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, graph_filename='graph.info') diff --git a/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg b/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg index 27c2988eac..d543e4645c 100644 --- a/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg @@ -42,3 +42,8 @@ use_speed = True use_dist_to_grounding_line = False use_dist_to_edge = False use_bed = False + +# Optional bespoke interpolation inputs (skip when set to None) +data_path = None +bedmachine_filename = None +measures_filename = None diff --git a/compass/landice/tests/kangerlussuaq/mesh.py b/compass/landice/tests/kangerlussuaq/mesh.py index 19430ca41f..fc255806e2 100644 --- a/compass/landice/tests/kangerlussuaq/mesh.py +++ b/compass/landice/tests/kangerlussuaq/mesh.py @@ -1,4 +1,13 @@ -from compass.landice.mesh import build_cell_width, build_mali_mesh +import os + +from mpas_tools.scrip.from_mpas import scrip_from_mpas + +from compass.landice.mesh import ( + build_cell_width, + build_mali_mesh, + clean_up_after_interp, + interp_gridded2mali, +) from compass.model import make_graph_file from compass.step import Step @@ -49,8 +58,39 @@ def run(self): Run this step of the test case """ logger = self.logger + config = self.config mesh_name = 'Kangerlussuaq.nc' section_name = 'mesh' + section = config[section_name] + + def _specified(value): + return value is not None and str(value).strip().lower() not in [ + '', 'none'] + + data_path = section.get('data_path', fallback=None) + bedmachine_filename = section.get('bedmachine_filename', fallback=None) + measures_filename = section.get('measures_filename', fallback=None) + + use_bedmachine_interp = _specified(data_path) and \ + _specified(bedmachine_filename) + use_measures_interp = _specified(data_path) and \ + _specified(measures_filename) + do_bespoke_interp = use_bedmachine_interp or use_measures_interp + + if use_bedmachine_interp: + bedmachine_dataset = os.path.join(data_path, bedmachine_filename) + else: + bedmachine_dataset = None + + if use_measures_interp: + measures_dataset = os.path.join(data_path, measures_filename) + else: + measures_dataset = None + + if not do_bespoke_interp: + logger.info('Skipping optional bespoke interpolation because ' + '`data_path` and interpolation filenames are ' + 'not specified in config.') logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ @@ -65,6 +105,29 @@ def run(self): projection='gis-gimp', geojson_file='Kangerlussuaq.geojson', cores=self.cpus_per_task) + if do_bespoke_interp: + parallel_executable = config.get('parallel', 'parallel_executable') + nProcs = str(self.cpus_per_task) + + logger.info('creating scrip file for destination mesh') + dst_scrip_file = f"{mesh_name.split('.')[:-1][0]}_scrip.nc" + scrip_from_mpas(mesh_name, dst_scrip_file) + + if use_bedmachine_interp: + interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, + parallel_executable, nProcs, mesh_name, + 'gis-gimp', variables='all') + + if use_measures_interp: + measures_vars = ['observedSurfaceVelocityX', + 'observedSurfaceVelocityY', + 'observedSurfaceVelocityUncertainty'] + interp_gridded2mali(self, measures_dataset, dst_scrip_file, + parallel_executable, nProcs, mesh_name, + 'gis-gimp', variables=measures_vars) + + clean_up_after_interp(mesh_name) + logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, graph_filename='graph.info') diff --git a/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg b/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg index 72c5a9da2f..fd1e22ed02 100644 --- a/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg @@ -42,3 +42,8 @@ use_speed = True use_dist_to_grounding_line = False use_dist_to_edge = True use_bed = True + +# Optional bespoke interpolation inputs (skip when set to None) +data_path = None +bedmachine_filename = None +measures_filename = None diff --git a/compass/landice/tests/koge_bugt_s/mesh.py b/compass/landice/tests/koge_bugt_s/mesh.py index 65492095ae..af6b583c78 100644 --- a/compass/landice/tests/koge_bugt_s/mesh.py +++ b/compass/landice/tests/koge_bugt_s/mesh.py @@ -1,4 +1,13 @@ -from compass.landice.mesh import build_cell_width, build_mali_mesh +import os + +from mpas_tools.scrip.from_mpas import scrip_from_mpas + +from compass.landice.mesh import ( + build_cell_width, + build_mali_mesh, + clean_up_after_interp, + interp_gridded2mali, +) from compass.model import make_graph_file from compass.step import Step @@ -49,8 +58,39 @@ def run(self): Run this step of the test case """ logger = self.logger + config = self.config mesh_name = 'Koge_Bugt_S.nc' section_name = 'mesh' + section = config[section_name] + + def _specified(value): + return value is not None and str(value).strip().lower() not in [ + '', 'none'] + + data_path = section.get('data_path', fallback=None) + bedmachine_filename = section.get('bedmachine_filename', fallback=None) + measures_filename = section.get('measures_filename', fallback=None) + + use_bedmachine_interp = _specified(data_path) and \ + _specified(bedmachine_filename) + use_measures_interp = _specified(data_path) and \ + _specified(measures_filename) + do_bespoke_interp = use_bedmachine_interp or use_measures_interp + + if use_bedmachine_interp: + bedmachine_dataset = os.path.join(data_path, bedmachine_filename) + else: + bedmachine_dataset = None + + if use_measures_interp: + measures_dataset = os.path.join(data_path, measures_filename) + else: + measures_dataset = None + + if not do_bespoke_interp: + logger.info('Skipping optional bespoke interpolation because ' + '`data_path` and interpolation filenames are ' + 'not specified in config.') logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ @@ -65,6 +105,29 @@ def run(self): projection='gis-gimp', geojson_file='Koge_Bugt_S.geojson', cores=self.cpus_per_task) + if do_bespoke_interp: + parallel_executable = config.get('parallel', 'parallel_executable') + nProcs = str(self.cpus_per_task) + + logger.info('creating scrip file for destination mesh') + dst_scrip_file = f"{mesh_name.split('.')[:-1][0]}_scrip.nc" + scrip_from_mpas(mesh_name, dst_scrip_file) + + if use_bedmachine_interp: + interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, + parallel_executable, nProcs, mesh_name, + 'gis-gimp', variables='all') + + if use_measures_interp: + measures_vars = ['observedSurfaceVelocityX', + 'observedSurfaceVelocityY', + 'observedSurfaceVelocityUncertainty'] + interp_gridded2mali(self, measures_dataset, dst_scrip_file, + parallel_executable, nProcs, mesh_name, + 'gis-gimp', variables=measures_vars) + + clean_up_after_interp(mesh_name) + logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, graph_filename='graph.info') diff --git a/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg b/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg index 770432a6d8..3c946d6f25 100644 --- a/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg @@ -44,3 +44,8 @@ use_speed = True use_dist_to_grounding_line = False use_dist_to_edge = True use_bed = False + +# Optional bespoke interpolation inputs (skip when set to None) +data_path = None +bedmachine_filename = None +measures_filename = None diff --git a/compass/landice/tests/thwaites/mesh.py b/compass/landice/tests/thwaites/mesh.py index 342febacf9..80a1b723ae 100644 --- a/compass/landice/tests/thwaites/mesh.py +++ b/compass/landice/tests/thwaites/mesh.py @@ -1,4 +1,13 @@ -from compass.landice.mesh import build_cell_width, build_mali_mesh +import os + +from mpas_tools.scrip.from_mpas import scrip_from_mpas + +from compass.landice.mesh import ( + build_cell_width, + build_mali_mesh, + clean_up_after_interp, + interp_gridded2mali, +) from compass.model import make_graph_file from compass.step import Step @@ -38,8 +47,39 @@ def run(self): Run this step of the test case """ logger = self.logger + config = self.config mesh_name = 'Thwaites.nc' section_name = 'mesh' + section = config[section_name] + + def _specified(value): + return value is not None and str(value).strip().lower() not in [ + '', 'none'] + + data_path = section.get('data_path', fallback=None) + bedmachine_filename = section.get('bedmachine_filename', fallback=None) + measures_filename = section.get('measures_filename', fallback=None) + + use_bedmachine_interp = _specified(data_path) and \ + _specified(bedmachine_filename) + use_measures_interp = _specified(data_path) and \ + _specified(measures_filename) + do_bespoke_interp = use_bedmachine_interp or use_measures_interp + + if use_bedmachine_interp: + bedmachine_dataset = os.path.join(data_path, bedmachine_filename) + else: + bedmachine_dataset = None + + if use_measures_interp: + measures_dataset = os.path.join(data_path, measures_filename) + else: + measures_dataset = None + + if not do_bespoke_interp: + logger.info('Skipping optional bespoke interpolation because ' + '`data_path` and interpolation filenames are ' + 'not specified in config.') logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ @@ -54,6 +94,29 @@ def run(self): projection='ais-bedmap2', geojson_file='thwaites_minimal.geojson', cores=self.cpus_per_task) + if do_bespoke_interp: + parallel_executable = config.get('parallel', 'parallel_executable') + nProcs = str(self.cpus_per_task) + + logger.info('creating scrip file for destination mesh') + dst_scrip_file = f"{mesh_name.split('.')[:-1][0]}_scrip.nc" + scrip_from_mpas(mesh_name, dst_scrip_file) + + if use_bedmachine_interp: + interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, + parallel_executable, nProcs, mesh_name, + 'ais-bedmap2', variables='all') + + if use_measures_interp: + measures_vars = ['observedSurfaceVelocityX', + 'observedSurfaceVelocityY', + 'observedSurfaceVelocityUncertainty'] + interp_gridded2mali(self, measures_dataset, dst_scrip_file, + parallel_executable, nProcs, mesh_name, + 'ais-bedmap2', variables=measures_vars) + + clean_up_after_interp(mesh_name) + logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, graph_filename='graph.info') diff --git a/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg b/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg index 98ae96049e..b49c9e4f02 100644 --- a/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg @@ -46,3 +46,8 @@ use_speed = True use_dist_to_grounding_line = True use_dist_to_edge = False use_bed = False + +# Optional bespoke interpolation inputs (skip when set to None) +data_path = None +bedmachine_filename = None +measures_filename = None From 5e27126b19fa7aa65b6534655bce7cb61aa0d2ce Mon Sep 17 00:00:00 2001 From: Trevor Hillebrand Date: Wed, 18 Mar 2026 15:20:53 -0500 Subject: [PATCH 02/10] Refactor to reduce repeated interpolation code Refactor to reduced repeated interpolation code between all the individual mesh.py files for mesh_gen cases. --- compass/landice/mesh.py | 111 ++++++++++++++++++ compass/landice/tests/antarctica/mesh.py | 74 ++---------- compass/landice/tests/crane/mesh.py | 67 ++--------- compass/landice/tests/greenland/mesh.py | 69 ++--------- compass/landice/tests/humboldt/mesh.py | 67 ++--------- .../landice/tests/isunnguata_sermia/mesh.py | 67 ++--------- compass/landice/tests/kangerlussuaq/mesh.py | 67 ++--------- compass/landice/tests/koge_bugt_s/mesh.py | 67 ++--------- compass/landice/tests/thwaites/mesh.py | 67 ++--------- 9 files changed, 191 insertions(+), 465 deletions(-) diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index 9c2a125c53..aa096ca15d 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -14,6 +14,7 @@ from mpas_tools.mesh.conversion import convert, cull from mpas_tools.mesh.creation import build_planar_mesh from mpas_tools.mesh.creation.sort_mesh import sort_mesh +from mpas_tools.scrip.from_mpas import scrip_from_mpas from netCDF4 import Dataset from scipy.interpolate import NearestNDInterpolator, interpn @@ -1191,3 +1192,113 @@ def clean_up_after_interp(fname): data.variables['observedSurfaceVelocityUncertainty'][:] == 0.0) data.variables['observedSurfaceVelocityUncertainty'][0, mask[0, :]] = 1.0 data.close() + + +def get_optional_interp_datasets(section, logger): + """ + Determine whether optional bespoke interpolation inputs are configured. + + Parameters + ---------- + section : configparser.SectionProxy + Config section containing optional interpolation options + + logger : logging.Logger + Logger for status messages + + Returns + ------- + bedmachine_dataset : str or None + Path to BedMachine dataset if configured, otherwise ``None`` + + measures_dataset : str or None + Path to MEaSUREs dataset if configured, otherwise ``None`` + """ + + def _specified(value): + return value is not None and str(value).strip().lower() not in [ + '', 'none'] + + data_path = section.get('data_path', fallback=None) + bedmachine_filename = section.get('bedmachine_filename', fallback=None) + measures_filename = section.get('measures_filename', fallback=None) + + use_bedmachine_interp = _specified(data_path) and \ + _specified(bedmachine_filename) + use_measures_interp = _specified(data_path) and \ + _specified(measures_filename) + + if use_bedmachine_interp: + bedmachine_dataset = os.path.join(data_path, bedmachine_filename) + else: + bedmachine_dataset = None + logger.info('Skipping BedMachine interpolation because ' + '`data_path` and/or `bedmachine_filename` are ' + 'not specified in config.') + + if use_measures_interp: + measures_dataset = os.path.join(data_path, measures_filename) + else: + measures_dataset = None + logger.info('Skipping MEaSUREs interpolation because ' + '`data_path` and/or `measures_filename` are ' + 'not specified in config.') + + return bedmachine_dataset, measures_dataset + + +def run_optional_bespoke_interpolation( + self, mesh_filename, src_proj, parallel_executable, nProcs, + bedmachine_dataset=None, measures_dataset=None): + """ + Run optional bespoke interpolation and cleanup if datasets are configured. + + Parameters + ---------- + self : compass.step.Step + Step instance providing logger and context + + mesh_filename : str + Destination MALI mesh file to interpolate to + + src_proj : str + Source dataset projection for SCRIP generation + + parallel_executable : str + Parallel launcher executable (e.g. ``srun``/``mpirun``) + + nProcs : int or str + Number of processes for regridding weight generation + + bedmachine_dataset : str, optional + BedMachine dataset path; if ``None`` this interpolation is skipped + + measures_dataset : str, optional + MEaSUREs dataset path; if ``None`` this interpolation is skipped + """ + + logger = self.logger + do_bespoke_interp = bedmachine_dataset is not None or \ + measures_dataset is not None + if not do_bespoke_interp: + return + + logger.info('creating scrip file for destination mesh') + dst_scrip_file = f"{mesh_filename.split('.')[:-1][0]}_scrip.nc" + scrip_from_mpas(mesh_filename, dst_scrip_file) + + if bedmachine_dataset is not None: + interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, + parallel_executable, nProcs, + mesh_filename, src_proj, variables='all') + + if measures_dataset is not None: + measures_vars = ['observedSurfaceVelocityX', + 'observedSurfaceVelocityY', + 'observedSurfaceVelocityUncertainty'] + interp_gridded2mali(self, measures_dataset, dst_scrip_file, + parallel_executable, nProcs, + mesh_filename, src_proj, + variables=measures_vars) + + clean_up_after_interp(mesh_filename) diff --git a/compass/landice/tests/antarctica/mesh.py b/compass/landice/tests/antarctica/mesh.py index 24b5bbbd92..57de115783 100644 --- a/compass/landice/tests/antarctica/mesh.py +++ b/compass/landice/tests/antarctica/mesh.py @@ -1,17 +1,14 @@ -import os - import netCDF4 from mpas_tools.logging import check_call -from mpas_tools.scrip.from_mpas import scrip_from_mpas from compass.landice.mesh import ( add_bedmachine_thk_to_ais_gridded_data, build_cell_width, build_mali_mesh, - clean_up_after_interp, - interp_gridded2mali, + get_optional_interp_datasets, make_region_masks, preprocess_ais_data, + run_optional_bespoke_interpolation, ) from compass.model import make_graph_file from compass.step import Step @@ -63,45 +60,18 @@ def run(self): section_ais = config['antarctica'] - def _specified(value): - return value is not None and str(value).strip().lower() not in [ - '', 'none'] - parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section_ais.get('nProcs') src_proj = section_ais.get("src_proj") - data_path = section_ais.get('data_path', fallback=None) - measures_filename = section_ais.get("measures_filename", fallback=None) - bedmachine_filename = section_ais.get( - "bedmachine_filename", fallback=None) - - use_bedmachine_interp = _specified(data_path) and \ - _specified(bedmachine_filename) - use_measures_interp = _specified(data_path) and \ - _specified(measures_filename) - - if use_bedmachine_interp: - bedmachine_dataset = os.path.join(data_path, bedmachine_filename) - else: - bedmachine_dataset = None - logger.info('Skipping BedMachine interpolation because ' - '`data_path` and/or `bedmachine_filename` are ' - 'not specified in config.') - - if use_measures_interp: - measures_dataset = os.path.join(data_path, measures_filename) - else: - measures_dataset = None - logger.info('Skipping MEaSUREs interpolation because ' - '`data_path` and/or `measures_filename` are ' - 'not specified in config.') + bedmachine_dataset, measures_dataset = get_optional_interp_datasets( + section_ais, logger) section_name = 'mesh' # TODO: do we want to add this to the config file? source_gridded_dataset = 'antarctica_8km_2024_01_29.nc' - if use_bedmachine_interp: + if bedmachine_dataset is not None: bm_updated_gridded_dataset = ( add_bedmachine_thk_to_ais_gridded_data( self, @@ -161,35 +131,11 @@ def _specified(value): 'observedThicknessTendencyUncertainty', 'thickness'] check_call(args, logger=logger) - # Create scrip file for the newly generated mesh - do_bespoke_interp = use_bedmachine_interp or use_measures_interp - if do_bespoke_interp: - logger.info('creating scrip file for destination mesh') - dst_scrip_file = \ - f"{self.mesh_filename.split('.')[:-1][0]}_scrip.nc" - scrip_from_mpas(self.mesh_filename, dst_scrip_file) - - # Now perform bespoke interpolation of geometry and velocity data - # from their respective sources - if use_bedmachine_interp: - interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, - parallel_executable, nProcs, - self.mesh_filename, src_proj, - variables="all") - - # only interpolate a subset of MEaSUREs variables onto the MALI mesh - measures_vars = ['observedSurfaceVelocityX', - 'observedSurfaceVelocityY', - 'observedSurfaceVelocityUncertainty'] - if use_measures_interp: - interp_gridded2mali(self, measures_dataset, dst_scrip_file, - parallel_executable, nProcs, - self.mesh_filename, src_proj, - variables=measures_vars) - - # perform some final cleanup details - if do_bespoke_interp: - clean_up_after_interp(self.mesh_filename) + run_optional_bespoke_interpolation( + self, self.mesh_filename, src_proj, + parallel_executable, nProcs, + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) # create graph file logger.info('creating graph.info') diff --git a/compass/landice/tests/crane/mesh.py b/compass/landice/tests/crane/mesh.py index 1a65546696..060418e45a 100644 --- a/compass/landice/tests/crane/mesh.py +++ b/compass/landice/tests/crane/mesh.py @@ -1,12 +1,8 @@ -import os - -from mpas_tools.scrip.from_mpas import scrip_from_mpas - from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - clean_up_after_interp, - interp_gridded2mali, + get_optional_interp_datasets, + run_optional_bespoke_interpolation, ) from compass.model import make_graph_file from compass.step import Step @@ -51,35 +47,8 @@ def run(self): mesh_name = 'Crane.nc' section_name = 'mesh' section = config[section_name] - - def _specified(value): - return value is not None and str(value).strip().lower() not in [ - '', 'none'] - - data_path = section.get('data_path', fallback=None) - bedmachine_filename = section.get('bedmachine_filename', fallback=None) - measures_filename = section.get('measures_filename', fallback=None) - - use_bedmachine_interp = _specified(data_path) and \ - _specified(bedmachine_filename) - use_measures_interp = _specified(data_path) and \ - _specified(measures_filename) - do_bespoke_interp = use_bedmachine_interp or use_measures_interp - - if use_bedmachine_interp: - bedmachine_dataset = os.path.join(data_path, bedmachine_filename) - else: - bedmachine_dataset = None - - if use_measures_interp: - measures_dataset = os.path.join(data_path, measures_filename) - else: - measures_dataset = None - - if not do_bespoke_interp: - logger.info('Skipping optional bespoke interpolation because ' - '`data_path` and interpolation filenames are ' - 'not specified in config.') + bedmachine_dataset, measures_dataset = get_optional_interp_datasets( + section, logger) logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ @@ -94,28 +63,12 @@ def _specified(value): projection='ais-bedmap2', geojson_file='Crane.geojson', cores=self.cpus_per_task) - if do_bespoke_interp: - parallel_executable = config.get('parallel', 'parallel_executable') - nProcs = str(self.cpus_per_task) - - logger.info('creating scrip file for destination mesh') - dst_scrip_file = f"{mesh_name.split('.')[:-1][0]}_scrip.nc" - scrip_from_mpas(mesh_name, dst_scrip_file) - - if use_bedmachine_interp: - interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, - parallel_executable, nProcs, mesh_name, - 'ais-bedmap2', variables='all') - - if use_measures_interp: - measures_vars = ['observedSurfaceVelocityX', - 'observedSurfaceVelocityY', - 'observedSurfaceVelocityUncertainty'] - interp_gridded2mali(self, measures_dataset, dst_scrip_file, - parallel_executable, nProcs, mesh_name, - 'ais-bedmap2', variables=measures_vars) - - clean_up_after_interp(mesh_name) + parallel_executable = config.get('parallel', 'parallel_executable') + nProcs = str(self.cpus_per_task) + run_optional_bespoke_interpolation( + self, mesh_name, 'ais-bedmap2', parallel_executable, nProcs, + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, diff --git a/compass/landice/tests/greenland/mesh.py b/compass/landice/tests/greenland/mesh.py index 938bc05536..513ab23a8b 100644 --- a/compass/landice/tests/greenland/mesh.py +++ b/compass/landice/tests/greenland/mesh.py @@ -1,15 +1,12 @@ -import os - import numpy as np import xarray as xr -from mpas_tools.scrip.from_mpas import scrip_from_mpas from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - clean_up_after_interp, - interp_gridded2mali, + get_optional_interp_datasets, make_region_masks, + run_optional_bespoke_interpolation, ) from compass.model import make_graph_file from compass.step import Step @@ -75,42 +72,19 @@ def run(self): section_gis = config['greenland'] - def _specified(value): - return value is not None and str(value).strip().lower() not in [ - '', 'none'] - parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section_gis.get('nProcs') src_proj = section_gis.get("src_proj") - data_path = section_gis.get('data_path', fallback=None) - measures_filename = section_gis.get("measures_filename", fallback=None) - bedmachine_filename = section_gis.get( - "bedmachine_filename", fallback=None) geojson_filename = section_gis.get('geojson_filename') - use_bedmachine_interp = _specified(data_path) and \ - _specified(bedmachine_filename) - use_measures_interp = _specified(data_path) and \ - _specified(measures_filename) + bedmachine_dataset, measures_dataset = get_optional_interp_datasets( + section_gis, logger) - if use_bedmachine_interp: - bedmachine_dataset = os.path.join(data_path, bedmachine_filename) + if bedmachine_dataset is not None: bounding_box = self._get_bedmachine_bounding_box( bedmachine_dataset) else: - bedmachine_dataset = None bounding_box = None - logger.info('Skipping BedMachine interpolation because ' - '`data_path` and/or `bedmachine_filename` are ' - 'not specified in config.') - - if use_measures_interp: - measures_dataset = os.path.join(data_path, measures_filename) - else: - measures_dataset = None - logger.info('Skipping MEaSUREs interpolation because ' - '`data_path` and/or `measures_filename` are ' - 'not specified in config.') section_name = 'mesh' @@ -133,34 +107,11 @@ def _specified(value): bounding_box=bounding_box, ) - # Create scrip file for the newly generated mesh - do_bespoke_interp = use_bedmachine_interp or use_measures_interp - if do_bespoke_interp: - logger.info('creating scrip file for destination mesh') - dst_scrip_file = \ - f"{self.mesh_filename.split('.')[:-1][0]}_scrip.nc" - scrip_from_mpas(self.mesh_filename, dst_scrip_file) - - # Now perform bespoke interpolation of geometry and velocity data - # from their respective sources - if use_bedmachine_interp: - interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, - parallel_executable, nProcs, - self.mesh_filename, src_proj, variables="all") - - # only interpolate a subset of MEaSUREs variables onto the MALI mesh - measures_vars = ['observedSurfaceVelocityX', - 'observedSurfaceVelocityY', - 'observedSurfaceVelocityUncertainty'] - if use_measures_interp: - interp_gridded2mali(self, measures_dataset, dst_scrip_file, - parallel_executable, nProcs, - self.mesh_filename, src_proj, - variables=measures_vars) - - # perform some final cleanup details - if do_bespoke_interp: - clean_up_after_interp(self.mesh_filename) + run_optional_bespoke_interpolation( + self, self.mesh_filename, src_proj, + parallel_executable, nProcs, + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) # create graph file logger.info('creating graph.info') diff --git a/compass/landice/tests/humboldt/mesh.py b/compass/landice/tests/humboldt/mesh.py index c9ee6e0653..08e291cf56 100644 --- a/compass/landice/tests/humboldt/mesh.py +++ b/compass/landice/tests/humboldt/mesh.py @@ -1,12 +1,8 @@ -import os - -from mpas_tools.scrip.from_mpas import scrip_from_mpas - from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - clean_up_after_interp, - interp_gridded2mali, + get_optional_interp_datasets, + run_optional_bespoke_interpolation, ) from compass.model import make_graph_file from compass.step import Step @@ -61,35 +57,8 @@ def run(self): section_name = 'mesh' section = config[section_name] mesh_name = 'Humboldt.nc' - - def _specified(value): - return value is not None and str(value).strip().lower() not in [ - '', 'none'] - - data_path = section.get('data_path', fallback=None) - bedmachine_filename = section.get('bedmachine_filename', fallback=None) - measures_filename = section.get('measures_filename', fallback=None) - - use_bedmachine_interp = _specified(data_path) and \ - _specified(bedmachine_filename) - use_measures_interp = _specified(data_path) and \ - _specified(measures_filename) - do_bespoke_interp = use_bedmachine_interp or use_measures_interp - - if use_bedmachine_interp: - bedmachine_dataset = os.path.join(data_path, bedmachine_filename) - else: - bedmachine_dataset = None - - if use_measures_interp: - measures_dataset = os.path.join(data_path, measures_filename) - else: - measures_dataset = None - - if not do_bespoke_interp: - logger.info('Skipping optional bespoke interpolation because ' - '`data_path` and interpolation filenames are ' - 'not specified in config.') + bedmachine_dataset, measures_dataset = get_optional_interp_datasets( + section, logger) logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ @@ -104,28 +73,12 @@ def _specified(value): projection='gis-gimp', geojson_file='Humboldt.geojson', cores=self.cpus_per_task) - if do_bespoke_interp: - parallel_executable = config.get('parallel', 'parallel_executable') - nProcs = str(self.cpus_per_task) - - logger.info('creating scrip file for destination mesh') - dst_scrip_file = f"{mesh_name.split('.')[:-1][0]}_scrip.nc" - scrip_from_mpas(mesh_name, dst_scrip_file) - - if use_bedmachine_interp: - interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, - parallel_executable, nProcs, mesh_name, - 'gis-gimp', variables='all') - - if use_measures_interp: - measures_vars = ['observedSurfaceVelocityX', - 'observedSurfaceVelocityY', - 'observedSurfaceVelocityUncertainty'] - interp_gridded2mali(self, measures_dataset, dst_scrip_file, - parallel_executable, nProcs, mesh_name, - 'gis-gimp', variables=measures_vars) - - clean_up_after_interp(mesh_name) + parallel_executable = config.get('parallel', 'parallel_executable') + nProcs = str(self.cpus_per_task) + run_optional_bespoke_interpolation( + self, mesh_name, 'gis-gimp', parallel_executable, nProcs, + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, diff --git a/compass/landice/tests/isunnguata_sermia/mesh.py b/compass/landice/tests/isunnguata_sermia/mesh.py index b7a39f9614..a21dc5b621 100644 --- a/compass/landice/tests/isunnguata_sermia/mesh.py +++ b/compass/landice/tests/isunnguata_sermia/mesh.py @@ -1,12 +1,8 @@ -import os - -from mpas_tools.scrip.from_mpas import scrip_from_mpas - from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - clean_up_after_interp, - interp_gridded2mali, + get_optional_interp_datasets, + run_optional_bespoke_interpolation, ) from compass.model import make_graph_file from compass.step import Step @@ -61,35 +57,8 @@ def run(self): section_name = 'mesh' section = config[section_name] mesh_name = 'Isunnguata_Sermia.nc' - - def _specified(value): - return value is not None and str(value).strip().lower() not in [ - '', 'none'] - - data_path = section.get('data_path', fallback=None) - bedmachine_filename = section.get('bedmachine_filename', fallback=None) - measures_filename = section.get('measures_filename', fallback=None) - - use_bedmachine_interp = _specified(data_path) and \ - _specified(bedmachine_filename) - use_measures_interp = _specified(data_path) and \ - _specified(measures_filename) - do_bespoke_interp = use_bedmachine_interp or use_measures_interp - - if use_bedmachine_interp: - bedmachine_dataset = os.path.join(data_path, bedmachine_filename) - else: - bedmachine_dataset = None - - if use_measures_interp: - measures_dataset = os.path.join(data_path, measures_filename) - else: - measures_dataset = None - - if not do_bespoke_interp: - logger.info('Skipping optional bespoke interpolation because ' - '`data_path` and interpolation filenames are ' - 'not specified in config.') + bedmachine_dataset, measures_dataset = get_optional_interp_datasets( + section, logger) logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ @@ -103,28 +72,12 @@ def _specified(value): gridded_dataset='greenland_1km_2024_01_29.epsg3413.icesheetonly.nc', # noqa projection='gis-gimp', geojson_file='Isunnguata_Sermia.geojson') - if do_bespoke_interp: - parallel_executable = config.get('parallel', 'parallel_executable') - nProcs = str(self.cpus_per_task) - - logger.info('creating scrip file for destination mesh') - dst_scrip_file = f"{mesh_name.split('.')[:-1][0]}_scrip.nc" - scrip_from_mpas(mesh_name, dst_scrip_file) - - if use_bedmachine_interp: - interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, - parallel_executable, nProcs, mesh_name, - 'gis-gimp', variables='all') - - if use_measures_interp: - measures_vars = ['observedSurfaceVelocityX', - 'observedSurfaceVelocityY', - 'observedSurfaceVelocityUncertainty'] - interp_gridded2mali(self, measures_dataset, dst_scrip_file, - parallel_executable, nProcs, mesh_name, - 'gis-gimp', variables=measures_vars) - - clean_up_after_interp(mesh_name) + parallel_executable = config.get('parallel', 'parallel_executable') + nProcs = str(self.cpus_per_task) + run_optional_bespoke_interpolation( + self, mesh_name, 'gis-gimp', parallel_executable, nProcs, + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, diff --git a/compass/landice/tests/kangerlussuaq/mesh.py b/compass/landice/tests/kangerlussuaq/mesh.py index fc255806e2..11e1731368 100644 --- a/compass/landice/tests/kangerlussuaq/mesh.py +++ b/compass/landice/tests/kangerlussuaq/mesh.py @@ -1,12 +1,8 @@ -import os - -from mpas_tools.scrip.from_mpas import scrip_from_mpas - from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - clean_up_after_interp, - interp_gridded2mali, + get_optional_interp_datasets, + run_optional_bespoke_interpolation, ) from compass.model import make_graph_file from compass.step import Step @@ -62,35 +58,8 @@ def run(self): mesh_name = 'Kangerlussuaq.nc' section_name = 'mesh' section = config[section_name] - - def _specified(value): - return value is not None and str(value).strip().lower() not in [ - '', 'none'] - - data_path = section.get('data_path', fallback=None) - bedmachine_filename = section.get('bedmachine_filename', fallback=None) - measures_filename = section.get('measures_filename', fallback=None) - - use_bedmachine_interp = _specified(data_path) and \ - _specified(bedmachine_filename) - use_measures_interp = _specified(data_path) and \ - _specified(measures_filename) - do_bespoke_interp = use_bedmachine_interp or use_measures_interp - - if use_bedmachine_interp: - bedmachine_dataset = os.path.join(data_path, bedmachine_filename) - else: - bedmachine_dataset = None - - if use_measures_interp: - measures_dataset = os.path.join(data_path, measures_filename) - else: - measures_dataset = None - - if not do_bespoke_interp: - logger.info('Skipping optional bespoke interpolation because ' - '`data_path` and interpolation filenames are ' - 'not specified in config.') + bedmachine_dataset, measures_dataset = get_optional_interp_datasets( + section, logger) logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ @@ -105,28 +74,12 @@ def _specified(value): projection='gis-gimp', geojson_file='Kangerlussuaq.geojson', cores=self.cpus_per_task) - if do_bespoke_interp: - parallel_executable = config.get('parallel', 'parallel_executable') - nProcs = str(self.cpus_per_task) - - logger.info('creating scrip file for destination mesh') - dst_scrip_file = f"{mesh_name.split('.')[:-1][0]}_scrip.nc" - scrip_from_mpas(mesh_name, dst_scrip_file) - - if use_bedmachine_interp: - interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, - parallel_executable, nProcs, mesh_name, - 'gis-gimp', variables='all') - - if use_measures_interp: - measures_vars = ['observedSurfaceVelocityX', - 'observedSurfaceVelocityY', - 'observedSurfaceVelocityUncertainty'] - interp_gridded2mali(self, measures_dataset, dst_scrip_file, - parallel_executable, nProcs, mesh_name, - 'gis-gimp', variables=measures_vars) - - clean_up_after_interp(mesh_name) + parallel_executable = config.get('parallel', 'parallel_executable') + nProcs = str(self.cpus_per_task) + run_optional_bespoke_interpolation( + self, mesh_name, 'gis-gimp', parallel_executable, nProcs, + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, diff --git a/compass/landice/tests/koge_bugt_s/mesh.py b/compass/landice/tests/koge_bugt_s/mesh.py index af6b583c78..1bd7540f82 100644 --- a/compass/landice/tests/koge_bugt_s/mesh.py +++ b/compass/landice/tests/koge_bugt_s/mesh.py @@ -1,12 +1,8 @@ -import os - -from mpas_tools.scrip.from_mpas import scrip_from_mpas - from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - clean_up_after_interp, - interp_gridded2mali, + get_optional_interp_datasets, + run_optional_bespoke_interpolation, ) from compass.model import make_graph_file from compass.step import Step @@ -62,35 +58,8 @@ def run(self): mesh_name = 'Koge_Bugt_S.nc' section_name = 'mesh' section = config[section_name] - - def _specified(value): - return value is not None and str(value).strip().lower() not in [ - '', 'none'] - - data_path = section.get('data_path', fallback=None) - bedmachine_filename = section.get('bedmachine_filename', fallback=None) - measures_filename = section.get('measures_filename', fallback=None) - - use_bedmachine_interp = _specified(data_path) and \ - _specified(bedmachine_filename) - use_measures_interp = _specified(data_path) and \ - _specified(measures_filename) - do_bespoke_interp = use_bedmachine_interp or use_measures_interp - - if use_bedmachine_interp: - bedmachine_dataset = os.path.join(data_path, bedmachine_filename) - else: - bedmachine_dataset = None - - if use_measures_interp: - measures_dataset = os.path.join(data_path, measures_filename) - else: - measures_dataset = None - - if not do_bespoke_interp: - logger.info('Skipping optional bespoke interpolation because ' - '`data_path` and interpolation filenames are ' - 'not specified in config.') + bedmachine_dataset, measures_dataset = get_optional_interp_datasets( + section, logger) logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ @@ -105,28 +74,12 @@ def _specified(value): projection='gis-gimp', geojson_file='Koge_Bugt_S.geojson', cores=self.cpus_per_task) - if do_bespoke_interp: - parallel_executable = config.get('parallel', 'parallel_executable') - nProcs = str(self.cpus_per_task) - - logger.info('creating scrip file for destination mesh') - dst_scrip_file = f"{mesh_name.split('.')[:-1][0]}_scrip.nc" - scrip_from_mpas(mesh_name, dst_scrip_file) - - if use_bedmachine_interp: - interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, - parallel_executable, nProcs, mesh_name, - 'gis-gimp', variables='all') - - if use_measures_interp: - measures_vars = ['observedSurfaceVelocityX', - 'observedSurfaceVelocityY', - 'observedSurfaceVelocityUncertainty'] - interp_gridded2mali(self, measures_dataset, dst_scrip_file, - parallel_executable, nProcs, mesh_name, - 'gis-gimp', variables=measures_vars) - - clean_up_after_interp(mesh_name) + parallel_executable = config.get('parallel', 'parallel_executable') + nProcs = str(self.cpus_per_task) + run_optional_bespoke_interpolation( + self, mesh_name, 'gis-gimp', parallel_executable, nProcs, + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, diff --git a/compass/landice/tests/thwaites/mesh.py b/compass/landice/tests/thwaites/mesh.py index 80a1b723ae..97f85e6451 100644 --- a/compass/landice/tests/thwaites/mesh.py +++ b/compass/landice/tests/thwaites/mesh.py @@ -1,12 +1,8 @@ -import os - -from mpas_tools.scrip.from_mpas import scrip_from_mpas - from compass.landice.mesh import ( build_cell_width, build_mali_mesh, - clean_up_after_interp, - interp_gridded2mali, + get_optional_interp_datasets, + run_optional_bespoke_interpolation, ) from compass.model import make_graph_file from compass.step import Step @@ -51,35 +47,8 @@ def run(self): mesh_name = 'Thwaites.nc' section_name = 'mesh' section = config[section_name] - - def _specified(value): - return value is not None and str(value).strip().lower() not in [ - '', 'none'] - - data_path = section.get('data_path', fallback=None) - bedmachine_filename = section.get('bedmachine_filename', fallback=None) - measures_filename = section.get('measures_filename', fallback=None) - - use_bedmachine_interp = _specified(data_path) and \ - _specified(bedmachine_filename) - use_measures_interp = _specified(data_path) and \ - _specified(measures_filename) - do_bespoke_interp = use_bedmachine_interp or use_measures_interp - - if use_bedmachine_interp: - bedmachine_dataset = os.path.join(data_path, bedmachine_filename) - else: - bedmachine_dataset = None - - if use_measures_interp: - measures_dataset = os.path.join(data_path, measures_filename) - else: - measures_dataset = None - - if not do_bespoke_interp: - logger.info('Skipping optional bespoke interpolation because ' - '`data_path` and interpolation filenames are ' - 'not specified in config.') + bedmachine_dataset, measures_dataset = get_optional_interp_datasets( + section, logger) logger.info('calling build_cell_width') cell_width, x1, y1, geom_points, geom_edges, floodMask = \ @@ -94,28 +63,12 @@ def _specified(value): projection='ais-bedmap2', geojson_file='thwaites_minimal.geojson', cores=self.cpus_per_task) - if do_bespoke_interp: - parallel_executable = config.get('parallel', 'parallel_executable') - nProcs = str(self.cpus_per_task) - - logger.info('creating scrip file for destination mesh') - dst_scrip_file = f"{mesh_name.split('.')[:-1][0]}_scrip.nc" - scrip_from_mpas(mesh_name, dst_scrip_file) - - if use_bedmachine_interp: - interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, - parallel_executable, nProcs, mesh_name, - 'ais-bedmap2', variables='all') - - if use_measures_interp: - measures_vars = ['observedSurfaceVelocityX', - 'observedSurfaceVelocityY', - 'observedSurfaceVelocityUncertainty'] - interp_gridded2mali(self, measures_dataset, dst_scrip_file, - parallel_executable, nProcs, mesh_name, - 'ais-bedmap2', variables=measures_vars) - - clean_up_after_interp(mesh_name) + parallel_executable = config.get('parallel', 'parallel_executable') + nProcs = str(self.cpus_per_task) + run_optional_bespoke_interpolation( + self, mesh_name, 'ais-bedmap2', parallel_executable, nProcs, + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, From 2de47f1cb75e8debc58a9cca837cd3b72edd237c Mon Sep 17 00:00:00 2001 From: Trevor Hillebrand Date: Wed, 18 Mar 2026 15:31:22 -0500 Subject: [PATCH 03/10] Subset data sets before interpolation to regional domains Subset Measures and BedMachine data sets before interpolation to regional domains. This will save a lot of memory and computing time. --- compass/landice/mesh.py | 135 ++++++++++++++++-- compass/landice/tests/crane/mesh.py | 2 + compass/landice/tests/humboldt/mesh.py | 2 + .../landice/tests/isunnguata_sermia/mesh.py | 2 + compass/landice/tests/kangerlussuaq/mesh.py | 2 + compass/landice/tests/koge_bugt_s/mesh.py | 2 + compass/landice/tests/thwaites/mesh.py | 2 + 7 files changed, 139 insertions(+), 8 deletions(-) diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index aa096ca15d..2f20e1fb6f 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -637,13 +637,10 @@ def build_cell_width(self, section_name, gridded_dataset, f.close() - # Get bounds defined by user, or use bound of gridded dataset - bnds = [np.min(x1), np.max(x1), np.min(y1), np.max(y1)] - bnds_options = ['x_min', 'x_max', 'y_min', 'y_max'] - for index, option in enumerate(bnds_options): - bnd = section.get(option) - if bnd != 'None': - bnds[index] = float(bnd) + # Get bounds defined by user, or use bounds from the gridded dataset. + bnds = get_mesh_config_bounding_box( + section, + default_bounds=[np.min(x1), np.max(x1), np.min(y1), np.max(y1)]) geom_points, geom_edges = set_rectangular_geom_points_and_edges(*bnds) @@ -1247,9 +1244,111 @@ def _specified(value): return bedmachine_dataset, measures_dataset +def get_mesh_config_bounding_box(section, default_bounds=None): + """ + Get bounding-box coordinates from a mesh config section. + + Parameters + ---------- + section : configparser.SectionProxy + Mesh config section containing ``x_min``, ``x_max``, ``y_min``, + and ``y_max`` + + default_bounds : list of float, optional + Default bounds in the form ``[x_min, x_max, y_min, y_max]`` to use + when config values are missing or set to ``None`` + + Returns + ------- + bounding_box : list of float + Bounding box in the form ``[x_min, x_max, y_min, y_max]`` + """ + + if default_bounds is None: + default_bounds = [None, None, None, None] + + def _get_bound(option, default): + value = section.get(option, fallback=None) + if value is None or str(value).strip().lower() in ['', 'none']: + if default is None: + raise ValueError( + f'Missing required config option `{option}` and no ' + 'default was provided.') + return float(default) + return float(value) + + return [ + _get_bound('x_min', default_bounds[0]), + _get_bound('x_max', default_bounds[1]), + _get_bound('y_min', default_bounds[2]), + _get_bound('y_max', default_bounds[3])] + + +def subset_gridded_dataset_to_bounds( + source_dataset, bounding_box, subset_tag, logger): + """ + Subset a gridded source dataset to a bounding box. + + Parameters + ---------- + source_dataset : str + Path to source gridded dataset + + bounding_box : list of float + Bounding box in the form ``[x_min, x_max, y_min, y_max]`` + + subset_tag : str + Tag to include in the subset filename + + logger : logging.Logger + Logger for status messages + + Returns + ------- + subset_dataset : str + Path to subsetted gridded dataset written to the current directory + """ + + x_min, x_max, y_min, y_max = bounding_box + ds = xarray.open_dataset(source_dataset) + + if 'x1' in ds and 'y1' in ds: + x_name = 'x1' + y_name = 'y1' + elif 'x' in ds and 'y' in ds: + x_name = 'x' + y_name = 'y' + else: + ds.close() + raise ValueError( + f'Could not find x/y coordinates in {source_dataset}. ' + 'Expected either x1/y1 or x/y.') + + subset = ds.where( + (ds[x_name] >= x_min) & (ds[x_name] <= x_max) & + (ds[y_name] >= y_min) & (ds[y_name] <= y_max), + drop=True) + + if subset.sizes[x_name] == 0 or subset.sizes[y_name] == 0: + subset.close() + ds.close() + raise ValueError( + f'Bounding box {bounding_box} produced an empty subset for ' + f'{source_dataset}.') + + base = os.path.splitext(os.path.basename(source_dataset))[0] + subset_dataset = f'{base}_{subset_tag}_subset.nc' + logger.info(f'Writing subset dataset: {subset_dataset}') + subset.to_netcdf(subset_dataset) + + subset.close() + ds.close() + return subset_dataset + + def run_optional_bespoke_interpolation( self, mesh_filename, src_proj, parallel_executable, nProcs, - bedmachine_dataset=None, measures_dataset=None): + bedmachine_dataset=None, measures_dataset=None, subset_bounds=None): """ Run optional bespoke interpolation and cleanup if datasets are configured. @@ -1275,6 +1374,12 @@ def run_optional_bespoke_interpolation( measures_dataset : str, optional MEaSUREs dataset path; if ``None`` this interpolation is skipped + + subset_bounds : list of float, optional + Optional source-dataset subset bounds in the form + ``[x_min, x_max, y_min, y_max]``. If provided, BedMachine and + MEaSUREs datasets are subsetted before SCRIP generation and + interpolation. """ logger = self.logger @@ -1283,6 +1388,20 @@ def run_optional_bespoke_interpolation( if not do_bespoke_interp: return + if subset_bounds is not None: + if bedmachine_dataset is not None: + bedmachine_dataset = subset_gridded_dataset_to_bounds( + bedmachine_dataset, + subset_bounds, + 'bedmachine', + logger) + if measures_dataset is not None: + measures_dataset = subset_gridded_dataset_to_bounds( + measures_dataset, + subset_bounds, + 'measures', + logger) + logger.info('creating scrip file for destination mesh') dst_scrip_file = f"{mesh_filename.split('.')[:-1][0]}_scrip.nc" scrip_from_mpas(mesh_filename, dst_scrip_file) diff --git a/compass/landice/tests/crane/mesh.py b/compass/landice/tests/crane/mesh.py index 060418e45a..30ef420a6d 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, + get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_bespoke_interpolation, ) @@ -67,6 +68,7 @@ def run(self): nProcs = str(self.cpus_per_task) run_optional_bespoke_interpolation( self, mesh_name, 'ais-bedmap2', parallel_executable, nProcs, + subset_bounds=get_mesh_config_bounding_box(section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) diff --git a/compass/landice/tests/humboldt/mesh.py b/compass/landice/tests/humboldt/mesh.py index 08e291cf56..d331356d2f 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, + get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_bespoke_interpolation, ) @@ -77,6 +78,7 @@ def run(self): nProcs = str(self.cpus_per_task) run_optional_bespoke_interpolation( self, mesh_name, 'gis-gimp', parallel_executable, nProcs, + subset_bounds=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 a21dc5b621..7365cf6c39 100644 --- a/compass/landice/tests/isunnguata_sermia/mesh.py +++ b/compass/landice/tests/isunnguata_sermia/mesh.py @@ -1,6 +1,7 @@ from compass.landice.mesh import ( build_cell_width, build_mali_mesh, + get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_bespoke_interpolation, ) @@ -76,6 +77,7 @@ def run(self): nProcs = str(self.cpus_per_task) run_optional_bespoke_interpolation( self, mesh_name, 'gis-gimp', parallel_executable, nProcs, + subset_bounds=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 11e1731368..5665a1ab44 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, + get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_bespoke_interpolation, ) @@ -78,6 +79,7 @@ def run(self): nProcs = str(self.cpus_per_task) run_optional_bespoke_interpolation( self, mesh_name, 'gis-gimp', parallel_executable, nProcs, + subset_bounds=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 1bd7540f82..d981c8fac9 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, + get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_bespoke_interpolation, ) @@ -78,6 +79,7 @@ def run(self): nProcs = str(self.cpus_per_task) run_optional_bespoke_interpolation( self, mesh_name, 'gis-gimp', parallel_executable, nProcs, + subset_bounds=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 97f85e6451..db9170342a 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, + get_mesh_config_bounding_box, get_optional_interp_datasets, run_optional_bespoke_interpolation, ) @@ -67,6 +68,7 @@ def run(self): nProcs = str(self.cpus_per_task) run_optional_bespoke_interpolation( self, mesh_name, 'ais-bedmap2', parallel_executable, nProcs, + subset_bounds=get_mesh_config_bounding_box(section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) From ac29c990750b9fb48fd0d6ac50049289650fb9c7 Mon Sep 17 00:00:00 2001 From: Trevor Hillebrand Date: Wed, 18 Mar 2026 15:41:31 -0500 Subject: [PATCH 04/10] Update docs Update docs to incorporate new data interpolation workflow --- docs/developers_guide/landice/api.rst | 4 ++++ .../landice/test_groups/antarctica.rst | 6 ++++++ docs/developers_guide/landice/test_groups/crane.rst | 6 ++++++ .../developers_guide/landice/test_groups/greenland.rst | 5 +++++ docs/developers_guide/landice/test_groups/humboldt.rst | 6 ++++++ .../landice/test_groups/isunnguata_sermia.rst | 6 ++++++ .../landice/test_groups/kangerlussuaq.rst | 6 ++++++ .../landice/test_groups/koge_bugt_s.rst | 6 ++++++ docs/developers_guide/landice/test_groups/thwaites.rst | 6 ++++++ docs/users_guide/landice/test_groups/antarctica.rst | 5 +++++ docs/users_guide/landice/test_groups/crane.rst | 10 ++++++++++ docs/users_guide/landice/test_groups/greenland.rst | 5 +++++ docs/users_guide/landice/test_groups/humboldt.rst | 10 ++++++++++ .../landice/test_groups/isunnguata_sermia.rst | 10 ++++++++++ docs/users_guide/landice/test_groups/kangerlussuaq.rst | 10 ++++++++++ docs/users_guide/landice/test_groups/koge_bugt_s.rst | 10 ++++++++++ docs/users_guide/landice/test_groups/thwaites.rst | 10 ++++++++++ 17 files changed, 121 insertions(+) diff --git a/docs/developers_guide/landice/api.rst b/docs/developers_guide/landice/api.rst index 2c83287ad6..0976218237 100644 --- a/docs/developers_guide/landice/api.rst +++ b/docs/developers_guide/landice/api.rst @@ -493,12 +493,16 @@ Landice Framework mesh.add_bedmachine_thk_to_ais_gridded_data mesh.clean_up_after_interp mesh.clip_mesh_to_bounding_box + mesh.get_mesh_config_bounding_box + mesh.get_optional_interp_datasets mesh.gridded_flood_fill mesh.interp_gridded2mali mesh.mpas_flood_fill mesh.preprocess_ais_data + mesh.run_optional_bespoke_interpolation mesh.set_rectangular_geom_points_and_edges mesh.set_cell_width + mesh.subset_gridded_dataset_to_bounds mesh.get_dist_to_edge_and_gl mesh.build_cell_width mesh.build_mali_mesh diff --git a/docs/developers_guide/landice/test_groups/antarctica.rst b/docs/developers_guide/landice/test_groups/antarctica.rst index 76041d0cb9..061a96008f 100644 --- a/docs/developers_guide/landice/test_groups/antarctica.rst +++ b/docs/developers_guide/landice/test_groups/antarctica.rst @@ -50,3 +50,9 @@ From here, dataset interpolation happens, starting with the standard interpolation script applied to the standard dataset, followed by bespoke interpolation of the high resolution BedMachine and MEASURES datasets. The step completes with some clean up and creation of a graph file. + +The BedMachine and MEaSUREs remapping steps are optional and are controlled by +``[antarctica]`` config options. If ``data_path`` or the corresponding +filename is unset (empty or ``None``), that dataset interpolation is skipped. +The default config includes both datasets, so interpolation is enabled by +default. diff --git a/docs/developers_guide/landice/test_groups/crane.rst b/docs/developers_guide/landice/test_groups/crane.rst index 7636cea85a..807fb2840e 100644 --- a/docs/developers_guide/landice/test_groups/crane.rst +++ b/docs/developers_guide/landice/test_groups/crane.rst @@ -28,3 +28,9 @@ mesh_gen The :py:class:`compass.landice.tests.crane.mesh_gen.MeshGen` calls the :py:class:`compass.landice.tests.crane.mesh.Mesh` to create the variable resolution Crane Glacier mesh. + +Optional BedMachine and MEaSUREs interpolation can be enabled through +``[mesh]`` config options ``data_path``, ``bedmachine_filename``, and +``measures_filename``. If enabled, source datasets are subset to the +configured mesh bounding box before SCRIP generation and conservative +remapping. diff --git a/docs/developers_guide/landice/test_groups/greenland.rst b/docs/developers_guide/landice/test_groups/greenland.rst index cdc7e1a3d2..629b7946d6 100644 --- a/docs/developers_guide/landice/test_groups/greenland.rst +++ b/docs/developers_guide/landice/test_groups/greenland.rst @@ -101,3 +101,8 @@ velocity observations are conservatively remapped from BedMachine v5 and MEaSUREs 2006-2010 data sets. Finally, there is some cleanup to set large velocity uncertainties outside the ice mask, check the sign of the basal heat flux, and set reasonable values for dH/dt and its uncertainty. + +The BedMachine and MEaSUREs remapping steps are optional and are controlled by +``[greenland]`` config options. If ``data_path`` or the corresponding filename +is unset (empty or ``None``), that dataset interpolation is skipped. The +default config includes both datasets, so interpolation is enabled by default. diff --git a/docs/developers_guide/landice/test_groups/humboldt.rst b/docs/developers_guide/landice/test_groups/humboldt.rst index 1836091e19..318d29e94c 100644 --- a/docs/developers_guide/landice/test_groups/humboldt.rst +++ b/docs/developers_guide/landice/test_groups/humboldt.rst @@ -30,6 +30,12 @@ The :py:class:`compass.landice.tests.humboldt.mesh_gen.MeshGen` calls the :py:class:`compass.landice.tests.humboldt.mesh.Mesh` to create the 1-10 km variable resolution Humboldt Glacier mesh. +Optional BedMachine and MEaSUREs interpolation can be enabled through +``[mesh]`` config options ``data_path``, ``bedmachine_filename``, and +``measures_filename``. If enabled, source datasets are subset to the +configured mesh bounding box before SCRIP generation and conservative +remapping. + run_model --------- The :py:class:`compass.landice.tests.humboldt.run_model.RunModel` defines diff --git a/docs/developers_guide/landice/test_groups/isunnguata_sermia.rst b/docs/developers_guide/landice/test_groups/isunnguata_sermia.rst index d76d6e4753..f78549b694 100644 --- a/docs/developers_guide/landice/test_groups/isunnguata_sermia.rst +++ b/docs/developers_guide/landice/test_groups/isunnguata_sermia.rst @@ -28,3 +28,9 @@ mesh_gen The :py:class:`compass.landice.tests.isunnguata_sermia.mesh_gen.MeshGen` calls the :py:class:`compass.landice.tests.isunnguata_sermia.mesh.Mesh` to create the variable resolution Isunnguata Sermia mesh. + +Optional BedMachine and MEaSUREs interpolation can be enabled through +``[mesh]`` config options ``data_path``, ``bedmachine_filename``, and +``measures_filename``. If enabled, source datasets are subset to the +configured mesh bounding box before SCRIP generation and conservative +remapping. diff --git a/docs/developers_guide/landice/test_groups/kangerlussuaq.rst b/docs/developers_guide/landice/test_groups/kangerlussuaq.rst index ff33ddf537..22f4c1d268 100644 --- a/docs/developers_guide/landice/test_groups/kangerlussuaq.rst +++ b/docs/developers_guide/landice/test_groups/kangerlussuaq.rst @@ -28,3 +28,9 @@ mesh_gen The :py:class:`compass.landice.tests.kangerlussuaq.mesh_gen.MeshGen` calls the :py:class:`compass.landice.tests.kangerlussuaq.mesh.Mesh` to create the variable resolution Kangerlussuaq Glacier mesh. + +Optional BedMachine and MEaSUREs interpolation can be enabled through +``[mesh]`` config options ``data_path``, ``bedmachine_filename``, and +``measures_filename``. If enabled, source datasets are subset to the +configured mesh bounding box before SCRIP generation and conservative +remapping. diff --git a/docs/developers_guide/landice/test_groups/koge_bugt_s.rst b/docs/developers_guide/landice/test_groups/koge_bugt_s.rst index 4f88a16d0a..f7603a658d 100644 --- a/docs/developers_guide/landice/test_groups/koge_bugt_s.rst +++ b/docs/developers_guide/landice/test_groups/koge_bugt_s.rst @@ -28,3 +28,9 @@ mesh_gen The :py:class:`compass.landice.tests.koge_bugt_s.mesh_gen.MeshGen` calls the :py:class:`compass.landice.tests.koge_bugt_s.mesh.Mesh` to create the variable resolution Koge Bugt S mesh. + +Optional BedMachine and MEaSUREs interpolation can be enabled through +``[mesh]`` config options ``data_path``, ``bedmachine_filename``, and +``measures_filename``. If enabled, source datasets are subset to the +configured mesh bounding box before SCRIP generation and conservative +remapping. diff --git a/docs/developers_guide/landice/test_groups/thwaites.rst b/docs/developers_guide/landice/test_groups/thwaites.rst index 7217d948d4..7b9c12b42b 100644 --- a/docs/developers_guide/landice/test_groups/thwaites.rst +++ b/docs/developers_guide/landice/test_groups/thwaites.rst @@ -76,3 +76,9 @@ mesh_gen The :py:class:`compass.landice.tests.thwaites.mesh_gen.MeshGen` calls the :py:class:`compass.landice.tests.thwaites.mesh.Mesh` to create the variable resolution Thwaites Glacier mesh. + +Optional BedMachine and MEaSUREs interpolation can be enabled through +``[mesh]`` config options ``data_path``, ``bedmachine_filename``, and +``measures_filename``. If enabled, source datasets are subset to the +configured mesh bounding box before SCRIP generation and conservative +remapping. diff --git a/docs/users_guide/landice/test_groups/antarctica.rst b/docs/users_guide/landice/test_groups/antarctica.rst index ec49e5f1df..ca042f87b7 100644 --- a/docs/users_guide/landice/test_groups/antarctica.rst +++ b/docs/users_guide/landice/test_groups/antarctica.rst @@ -115,4 +115,9 @@ or the processed data files could be added to the server on Anvil and downloaded as needed. However, until then, this test case provides a reproducible workflow for setting up Antarctic meshes at varying resolutions +The BedMachine and MEaSUREs interpolation is optional. If ``data_path`` or the +corresponding filename in ``[antarctica]`` is unset (empty or ``None``), that +dataset interpolation step is skipped. The default config values include both +datasets, so interpolation is enabled by default. + There is no model integration step. diff --git a/docs/users_guide/landice/test_groups/crane.rst b/docs/users_guide/landice/test_groups/crane.rst index 019482763a..601494b537 100644 --- a/docs/users_guide/landice/test_groups/crane.rst +++ b/docs/users_guide/landice/test_groups/crane.rst @@ -73,6 +73,12 @@ the mesh generation options are adjusted through the config file. use_dist_to_edge = False use_bed = False + # optional bespoke interpolation inputs + # set to None to skip optional BedMachine/MEaSUREs remapping + data_path = None + bedmachine_filename = None + measures_filename = None + mesh_gen -------- @@ -80,3 +86,7 @@ mesh_gen The default is 500m-1km resolution with mesh density determined by observed ice speed and distance to grounding line. There is no model integration step. + +If optional BedMachine and/or MEaSUREs datasets are configured, they are +subset to the mesh bounding box from ``[mesh]`` before SCRIP generation and +conservative remapping to reduce memory and runtime. diff --git a/docs/users_guide/landice/test_groups/greenland.rst b/docs/users_guide/landice/test_groups/greenland.rst index d50f2f2a46..7e1ba9b384 100644 --- a/docs/users_guide/landice/test_groups/greenland.rst +++ b/docs/users_guide/landice/test_groups/greenland.rst @@ -156,3 +156,8 @@ that pre-processing could be integrated into a new step in COMPASS, or the processed data files could be added to the server on Anvil and downloaded as needed. However, until then, this test case provides a reproducible workflow for setting up Greenland meshes at varying resolutions. + +The BedMachine and MEaSUREs interpolation is optional. If ``data_path`` or the +corresponding filename in ``[greenland]`` is unset (empty or ``None``), that +dataset interpolation step is skipped. The default config values include both +datasets, so interpolation is enabled by default. diff --git a/docs/users_guide/landice/test_groups/humboldt.rst b/docs/users_guide/landice/test_groups/humboldt.rst index 724ff9cf04..3f082bf7b8 100644 --- a/docs/users_guide/landice/test_groups/humboldt.rst +++ b/docs/users_guide/landice/test_groups/humboldt.rst @@ -65,12 +65,22 @@ the mesh generation options are adjusted through the config file. use_dist_to_grounding_line = False use_dist_to_edge = True + # optional bespoke interpolation inputs + # set to None to skip optional BedMachine/MEaSUREs remapping + data_path = None + bedmachine_filename = None + measures_filename = None + mesh_gen -------- ``landice/humboldt/default`` creates a 1-10km variable resolution mesh. There is no model integration step. +If optional BedMachine and/or MEaSUREs datasets are configured, they are +subset to the mesh bounding box from ``[mesh]`` before SCRIP generation and +conservative remapping to reduce memory and runtime. + decomposition_tests ------------------- diff --git a/docs/users_guide/landice/test_groups/isunnguata_sermia.rst b/docs/users_guide/landice/test_groups/isunnguata_sermia.rst index 3cb66b0936..a97746a7c4 100644 --- a/docs/users_guide/landice/test_groups/isunnguata_sermia.rst +++ b/docs/users_guide/landice/test_groups/isunnguata_sermia.rst @@ -69,9 +69,19 @@ the mesh generation options are adjusted through the config file. use_dist_to_edge = False use_bed = False + # optional bespoke interpolation inputs + # set to None to skip optional BedMachine/MEaSUREs remapping + data_path = None + bedmachine_filename = None + measures_filename = None + mesh_gen -------- ``landice/isunnguata_sermia/mesh_gen`` creates a variable resolution mesh. The default is 1-10km resolution with mesh density determined by observed ice speed. There is no model integration step. + +If optional BedMachine and/or MEaSUREs datasets are configured, they are +subset to the mesh bounding box from ``[mesh]`` before SCRIP generation and +conservative remapping to reduce memory and runtime. diff --git a/docs/users_guide/landice/test_groups/kangerlussuaq.rst b/docs/users_guide/landice/test_groups/kangerlussuaq.rst index 5c91bd16a6..dbf680e04b 100644 --- a/docs/users_guide/landice/test_groups/kangerlussuaq.rst +++ b/docs/users_guide/landice/test_groups/kangerlussuaq.rst @@ -53,6 +53,12 @@ the mesh generation options are adjusted through the config file. use_dist_to_grounding_line = False use_dist_to_edge = True + # optional bespoke interpolation inputs + # set to None to skip optional BedMachine/MEaSUREs remapping + data_path = None + bedmachine_filename = None + measures_filename = None + mesh_gen -------- @@ -60,3 +66,7 @@ mesh_gen The default is 1-10km resolution with mesh density determined by observed ice speed and distance to ice margin. There is no model integration step. + +If optional BedMachine and/or MEaSUREs datasets are configured, they are +subset to the mesh bounding box from ``[mesh]`` before SCRIP generation and +conservative remapping to reduce memory and runtime. diff --git a/docs/users_guide/landice/test_groups/koge_bugt_s.rst b/docs/users_guide/landice/test_groups/koge_bugt_s.rst index 4f65ad5009..f38161bde6 100644 --- a/docs/users_guide/landice/test_groups/koge_bugt_s.rst +++ b/docs/users_guide/landice/test_groups/koge_bugt_s.rst @@ -53,6 +53,12 @@ the mesh generation options are adjusted through the config file. use_dist_to_grounding_line = False use_dist_to_edge = True + # optional bespoke interpolation inputs + # set to None to skip optional BedMachine/MEaSUREs remapping + data_path = None + bedmachine_filename = None + measures_filename = None + mesh_gen -------- @@ -60,3 +66,7 @@ mesh_gen The default is 500m-4km resolution with mesh density determined by observed ice speed and distance to ice margin. There is no model integration step. + +If optional BedMachine and/or MEaSUREs datasets are configured, they are +subset to the mesh bounding box from ``[mesh]`` before SCRIP generation and +conservative remapping to reduce memory and runtime. diff --git a/docs/users_guide/landice/test_groups/thwaites.rst b/docs/users_guide/landice/test_groups/thwaites.rst index 9a7c4bf0b1..e742102b3d 100644 --- a/docs/users_guide/landice/test_groups/thwaites.rst +++ b/docs/users_guide/landice/test_groups/thwaites.rst @@ -66,6 +66,12 @@ The other test cases do not use config options. use_dist_to_grounding_line = True use_dist_to_edge = True + # optional bespoke interpolation inputs + # set to None to skip optional BedMachine/MEaSUREs remapping + data_path = None + bedmachine_filename = None + measures_filename = None + decomposition_test ------------------ @@ -92,3 +98,7 @@ on the the config options listed above. This will not be the same as the pre-generated 4-14km mesh used in ``decomposition_test`` and ``restart_test`` because it uses a newer version of Jigsaw. Note that the basal friction optimization is performed separately and is not part of this test case. + +If optional BedMachine and/or MEaSUREs datasets are configured, they are +subset to the mesh bounding box from ``[mesh]`` before SCRIP generation and +conservative remapping to reduce memory and runtime. From 7174fd42dcabbab2938c18df4023082847dfe2d0 Mon Sep 17 00:00:00 2001 From: Trevor Hillebrand Date: Wed, 18 Mar 2026 15:52:28 -0500 Subject: [PATCH 05/10] Specify nProcs for ESMF_RegridWeightGen Specify nProcs for ESMF_RegridWeightGen in mesh_gen.cfg files. Also remove duplicate nProcs from greenland mesh_gen.cfg file and update docs. --- compass/landice/tests/crane/mesh.py | 2 +- compass/landice/tests/crane/mesh_gen/mesh_gen.cfg | 3 +++ compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg | 3 --- compass/landice/tests/humboldt/mesh.py | 2 +- compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg | 3 +++ compass/landice/tests/isunnguata_sermia/mesh.py | 2 +- .../landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg | 3 +++ compass/landice/tests/kangerlussuaq/mesh.py | 2 +- compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg | 3 +++ compass/landice/tests/koge_bugt_s/mesh.py | 2 +- compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg | 3 +++ compass/landice/tests/thwaites/mesh.py | 2 +- compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg | 3 +++ docs/developers_guide/landice/test_groups/crane.rst | 5 +++-- docs/developers_guide/landice/test_groups/humboldt.rst | 5 +++-- .../landice/test_groups/isunnguata_sermia.rst | 5 +++-- docs/developers_guide/landice/test_groups/kangerlussuaq.rst | 5 +++-- docs/developers_guide/landice/test_groups/koge_bugt_s.rst | 5 +++-- docs/developers_guide/landice/test_groups/thwaites.rst | 5 +++-- docs/users_guide/landice/test_groups/crane.rst | 3 +++ docs/users_guide/landice/test_groups/greenland.rst | 3 --- docs/users_guide/landice/test_groups/humboldt.rst | 3 +++ docs/users_guide/landice/test_groups/isunnguata_sermia.rst | 3 +++ docs/users_guide/landice/test_groups/kangerlussuaq.rst | 3 +++ docs/users_guide/landice/test_groups/koge_bugt_s.rst | 3 +++ docs/users_guide/landice/test_groups/thwaites.rst | 3 +++ 26 files changed, 60 insertions(+), 24 deletions(-) diff --git a/compass/landice/tests/crane/mesh.py b/compass/landice/tests/crane/mesh.py index 30ef420a6d..6c7c416e39 100644 --- a/compass/landice/tests/crane/mesh.py +++ b/compass/landice/tests/crane/mesh.py @@ -65,7 +65,7 @@ def run(self): cores=self.cpus_per_task) parallel_executable = config.get('parallel', 'parallel_executable') - nProcs = str(self.cpus_per_task) + nProcs = section.get('nProcs') run_optional_bespoke_interpolation( self, mesh_name, 'ais-bedmap2', parallel_executable, nProcs, subset_bounds=get_mesh_config_bounding_box(section), diff --git a/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg b/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg index 8b80bfd53d..7c5af37147 100644 --- a/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg @@ -15,6 +15,9 @@ y_max = 1.334e6 # to cull based on distance from margin. cull_distance = -1.0 +# number of processors to use for ESMF_RegridWeightGen +nProcs = 128 + # mesh density parameters # minimum cell spacing (meters) min_spac = 5.e2 diff --git a/compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg b/compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg index 2115294d24..fa999c966d 100644 --- a/compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg @@ -17,9 +17,6 @@ y_max = None # to cull based on distance from margin. cull_distance = 10.0 -# number of processors to use for ESMF_RegridWeightGen -nProcs = 128 - # mesh density parameters # minimum cell spacing (meters) min_spac = 3.e3 diff --git a/compass/landice/tests/humboldt/mesh.py b/compass/landice/tests/humboldt/mesh.py index d331356d2f..a565aa54a6 100644 --- a/compass/landice/tests/humboldt/mesh.py +++ b/compass/landice/tests/humboldt/mesh.py @@ -75,7 +75,7 @@ def run(self): cores=self.cpus_per_task) parallel_executable = config.get('parallel', 'parallel_executable') - nProcs = str(self.cpus_per_task) + nProcs = section.get('nProcs') run_optional_bespoke_interpolation( self, mesh_name, 'gis-gimp', parallel_executable, nProcs, subset_bounds=get_mesh_config_bounding_box(section), diff --git a/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg b/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg index 06789f981f..e5bed2f114 100644 --- a/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg @@ -15,6 +15,9 @@ y_max = -860000. # to cull based on distance from margin. cull_distance = 5.0 +# number of processors to use for ESMF_RegridWeightGen +nProcs = 128 + # mesh density parameters # minimum cell spacing (meters) min_spac = 1.e3 diff --git a/compass/landice/tests/isunnguata_sermia/mesh.py b/compass/landice/tests/isunnguata_sermia/mesh.py index 7365cf6c39..6b7142a34b 100644 --- a/compass/landice/tests/isunnguata_sermia/mesh.py +++ b/compass/landice/tests/isunnguata_sermia/mesh.py @@ -74,7 +74,7 @@ def run(self): projection='gis-gimp', geojson_file='Isunnguata_Sermia.geojson') parallel_executable = config.get('parallel', 'parallel_executable') - nProcs = str(self.cpus_per_task) + nProcs = section.get('nProcs') run_optional_bespoke_interpolation( self, mesh_name, 'gis-gimp', parallel_executable, nProcs, subset_bounds=get_mesh_config_bounding_box(section), diff --git a/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg b/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg index d543e4645c..c9f3f90ce8 100644 --- a/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg @@ -15,6 +15,9 @@ y_max = -2400000. # to cull based on distance from margin. cull_distance = 5.0 +# number of processors to use for ESMF_RegridWeightGen +nProcs = 128 + # mesh density parameters # minimum cell spacing (meters) min_spac = 1.e3 diff --git a/compass/landice/tests/kangerlussuaq/mesh.py b/compass/landice/tests/kangerlussuaq/mesh.py index 5665a1ab44..719a72e592 100644 --- a/compass/landice/tests/kangerlussuaq/mesh.py +++ b/compass/landice/tests/kangerlussuaq/mesh.py @@ -76,7 +76,7 @@ def run(self): cores=self.cpus_per_task) parallel_executable = config.get('parallel', 'parallel_executable') - nProcs = str(self.cpus_per_task) + nProcs = section.get('nProcs') run_optional_bespoke_interpolation( self, mesh_name, 'gis-gimp', parallel_executable, nProcs, subset_bounds=get_mesh_config_bounding_box(section), diff --git a/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg b/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg index fd1e22ed02..0d9fc99c2b 100644 --- a/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg @@ -15,6 +15,9 @@ y_max = -2070000. # to cull based on distance from margin. cull_distance = 5.0 +# number of processors to use for ESMF_RegridWeightGen +nProcs = 128 + # mesh density parameters # minimum cell spacing (meters) min_spac = 1.e3 diff --git a/compass/landice/tests/koge_bugt_s/mesh.py b/compass/landice/tests/koge_bugt_s/mesh.py index d981c8fac9..b95382dee3 100644 --- a/compass/landice/tests/koge_bugt_s/mesh.py +++ b/compass/landice/tests/koge_bugt_s/mesh.py @@ -76,7 +76,7 @@ def run(self): cores=self.cpus_per_task) parallel_executable = config.get('parallel', 'parallel_executable') - nProcs = str(self.cpus_per_task) + nProcs = section.get('nProcs') run_optional_bespoke_interpolation( self, mesh_name, 'gis-gimp', parallel_executable, nProcs, subset_bounds=get_mesh_config_bounding_box(section), diff --git a/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg b/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg index 3c946d6f25..770d82ceaf 100644 --- a/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg @@ -15,6 +15,9 @@ y_max = -2700000. # to cull based on distance from margin. cull_distance = 5.0 +# number of processors to use for ESMF_RegridWeightGen +nProcs = 128 + # mesh density parameters # minimum cell spacing (meters) min_spac = 5.e2 diff --git a/compass/landice/tests/thwaites/mesh.py b/compass/landice/tests/thwaites/mesh.py index db9170342a..63d86a28d4 100644 --- a/compass/landice/tests/thwaites/mesh.py +++ b/compass/landice/tests/thwaites/mesh.py @@ -65,7 +65,7 @@ def run(self): cores=self.cpus_per_task) parallel_executable = config.get('parallel', 'parallel_executable') - nProcs = str(self.cpus_per_task) + nProcs = section.get('nProcs') run_optional_bespoke_interpolation( self, mesh_name, 'ais-bedmap2', parallel_executable, nProcs, subset_bounds=get_mesh_config_bounding_box(section), diff --git a/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg b/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg index b49c9e4f02..14c5f97f2d 100644 --- a/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg @@ -15,6 +15,9 @@ y_max = 0. # to cull based on distance from margin. cull_distance = 10.0 +# number of processors to use for ESMF_RegridWeightGen +nProcs = 128 + # mesh density parameters # minimum cell spacing (meters) min_spac = 1.e3 diff --git a/docs/developers_guide/landice/test_groups/crane.rst b/docs/developers_guide/landice/test_groups/crane.rst index 807fb2840e..bd200403ed 100644 --- a/docs/developers_guide/landice/test_groups/crane.rst +++ b/docs/developers_guide/landice/test_groups/crane.rst @@ -30,7 +30,8 @@ calls the :py:class:`compass.landice.tests.crane.mesh.Mesh` to create the variable resolution Crane Glacier mesh. Optional BedMachine and MEaSUREs interpolation can be enabled through -``[mesh]`` config options ``data_path``, ``bedmachine_filename``, and -``measures_filename``. If enabled, source datasets are subset to the +``[mesh]`` config options ``nProcs``, ``data_path``, +``bedmachine_filename``, and ``measures_filename``. If enabled, source +datasets are subset to the configured mesh bounding box before SCRIP generation and conservative remapping. diff --git a/docs/developers_guide/landice/test_groups/humboldt.rst b/docs/developers_guide/landice/test_groups/humboldt.rst index 318d29e94c..4fcfe18dd5 100644 --- a/docs/developers_guide/landice/test_groups/humboldt.rst +++ b/docs/developers_guide/landice/test_groups/humboldt.rst @@ -31,8 +31,9 @@ calls the :py:class:`compass.landice.tests.humboldt.mesh.Mesh` to create the 1-10 km variable resolution Humboldt Glacier mesh. Optional BedMachine and MEaSUREs interpolation can be enabled through -``[mesh]`` config options ``data_path``, ``bedmachine_filename``, and -``measures_filename``. If enabled, source datasets are subset to the +``[mesh]`` config options ``nProcs``, ``data_path``, +``bedmachine_filename``, and ``measures_filename``. If enabled, source +datasets are subset to the configured mesh bounding box before SCRIP generation and conservative remapping. diff --git a/docs/developers_guide/landice/test_groups/isunnguata_sermia.rst b/docs/developers_guide/landice/test_groups/isunnguata_sermia.rst index f78549b694..42f06163dc 100644 --- a/docs/developers_guide/landice/test_groups/isunnguata_sermia.rst +++ b/docs/developers_guide/landice/test_groups/isunnguata_sermia.rst @@ -30,7 +30,8 @@ calls the :py:class:`compass.landice.tests.isunnguata_sermia.mesh.Mesh` to creat the variable resolution Isunnguata Sermia mesh. Optional BedMachine and MEaSUREs interpolation can be enabled through -``[mesh]`` config options ``data_path``, ``bedmachine_filename``, and -``measures_filename``. If enabled, source datasets are subset to the +``[mesh]`` config options ``nProcs``, ``data_path``, +``bedmachine_filename``, and ``measures_filename``. If enabled, source +datasets are subset to the configured mesh bounding box before SCRIP generation and conservative remapping. diff --git a/docs/developers_guide/landice/test_groups/kangerlussuaq.rst b/docs/developers_guide/landice/test_groups/kangerlussuaq.rst index 22f4c1d268..c4bee49a59 100644 --- a/docs/developers_guide/landice/test_groups/kangerlussuaq.rst +++ b/docs/developers_guide/landice/test_groups/kangerlussuaq.rst @@ -30,7 +30,8 @@ calls the :py:class:`compass.landice.tests.kangerlussuaq.mesh.Mesh` to create the variable resolution Kangerlussuaq Glacier mesh. Optional BedMachine and MEaSUREs interpolation can be enabled through -``[mesh]`` config options ``data_path``, ``bedmachine_filename``, and -``measures_filename``. If enabled, source datasets are subset to the +``[mesh]`` config options ``nProcs``, ``data_path``, +``bedmachine_filename``, and ``measures_filename``. If enabled, source +datasets are subset to the configured mesh bounding box before SCRIP generation and conservative remapping. diff --git a/docs/developers_guide/landice/test_groups/koge_bugt_s.rst b/docs/developers_guide/landice/test_groups/koge_bugt_s.rst index f7603a658d..0f02ce66f2 100644 --- a/docs/developers_guide/landice/test_groups/koge_bugt_s.rst +++ b/docs/developers_guide/landice/test_groups/koge_bugt_s.rst @@ -30,7 +30,8 @@ calls the :py:class:`compass.landice.tests.koge_bugt_s.mesh.Mesh` to create the variable resolution Koge Bugt S mesh. Optional BedMachine and MEaSUREs interpolation can be enabled through -``[mesh]`` config options ``data_path``, ``bedmachine_filename``, and -``measures_filename``. If enabled, source datasets are subset to the +``[mesh]`` config options ``nProcs``, ``data_path``, +``bedmachine_filename``, and ``measures_filename``. If enabled, source +datasets are subset to the configured mesh bounding box before SCRIP generation and conservative remapping. diff --git a/docs/developers_guide/landice/test_groups/thwaites.rst b/docs/developers_guide/landice/test_groups/thwaites.rst index 7b9c12b42b..39ecd77157 100644 --- a/docs/developers_guide/landice/test_groups/thwaites.rst +++ b/docs/developers_guide/landice/test_groups/thwaites.rst @@ -78,7 +78,8 @@ calls the :py:class:`compass.landice.tests.thwaites.mesh.Mesh` to create the variable resolution Thwaites Glacier mesh. Optional BedMachine and MEaSUREs interpolation can be enabled through -``[mesh]`` config options ``data_path``, ``bedmachine_filename``, and -``measures_filename``. If enabled, source datasets are subset to the +``[mesh]`` config options ``nProcs``, ``data_path``, +``bedmachine_filename``, and ``measures_filename``. If enabled, source +datasets are subset to the configured mesh bounding box before SCRIP generation and conservative remapping. diff --git a/docs/users_guide/landice/test_groups/crane.rst b/docs/users_guide/landice/test_groups/crane.rst index 601494b537..b34a5bca2d 100644 --- a/docs/users_guide/landice/test_groups/crane.rst +++ b/docs/users_guide/landice/test_groups/crane.rst @@ -40,6 +40,9 @@ the mesh generation options are adjusted through the config file. # Set to a value <= 0 if you do not want # to cull based on distance from margin. cull_distance = -1.0 + + # number of processors to use for ESMF_RegridWeightGen + nProcs = 128 # mesh density parameters # minimum cell spacing (meters) diff --git a/docs/users_guide/landice/test_groups/greenland.rst b/docs/users_guide/landice/test_groups/greenland.rst index 7e1ba9b384..34494948ea 100644 --- a/docs/users_guide/landice/test_groups/greenland.rst +++ b/docs/users_guide/landice/test_groups/greenland.rst @@ -55,9 +55,6 @@ The other test cases do not use config options. # to cull based on distance from margin. cull_distance = 10.0 - # number of processors to use for ESMF_RegridWeightGen - nProcs = 128 - # mesh density parameters # minimum cell spacing (meters) min_spac = 3.e3 diff --git a/docs/users_guide/landice/test_groups/humboldt.rst b/docs/users_guide/landice/test_groups/humboldt.rst index 3f082bf7b8..866f74d001 100644 --- a/docs/users_guide/landice/test_groups/humboldt.rst +++ b/docs/users_guide/landice/test_groups/humboldt.rst @@ -46,6 +46,9 @@ the mesh generation options are adjusted through the config file. # to cull based on distance from margin. cull_distance = 5.0 + # number of processors to use for ESMF_RegridWeightGen + nProcs = 128 + # mesh density parameters # minimum cell spacing (meters) min_spac = 1.e3 diff --git a/docs/users_guide/landice/test_groups/isunnguata_sermia.rst b/docs/users_guide/landice/test_groups/isunnguata_sermia.rst index a97746a7c4..e7850a4f1f 100644 --- a/docs/users_guide/landice/test_groups/isunnguata_sermia.rst +++ b/docs/users_guide/landice/test_groups/isunnguata_sermia.rst @@ -40,6 +40,9 @@ the mesh generation options are adjusted through the config file. # Set to a value <= 0 if you do not want # to cull based on distance from margin. cull_distance = 5.0 + + # number of processors to use for ESMF_RegridWeightGen + nProcs = 128 # mesh density parameters # minimum cell spacing (meters) diff --git a/docs/users_guide/landice/test_groups/kangerlussuaq.rst b/docs/users_guide/landice/test_groups/kangerlussuaq.rst index dbf680e04b..2298ba4ee3 100644 --- a/docs/users_guide/landice/test_groups/kangerlussuaq.rst +++ b/docs/users_guide/landice/test_groups/kangerlussuaq.rst @@ -34,6 +34,9 @@ the mesh generation options are adjusted through the config file. # to cull based on distance from margin. cull_distance = 5.0 + # number of processors to use for ESMF_RegridWeightGen + nProcs = 128 + # mesh density parameters # minimum cell spacing (meters) min_spac = 1.e3 diff --git a/docs/users_guide/landice/test_groups/koge_bugt_s.rst b/docs/users_guide/landice/test_groups/koge_bugt_s.rst index f38161bde6..6760ed77bf 100644 --- a/docs/users_guide/landice/test_groups/koge_bugt_s.rst +++ b/docs/users_guide/landice/test_groups/koge_bugt_s.rst @@ -34,6 +34,9 @@ the mesh generation options are adjusted through the config file. # to cull based on distance from margin. cull_distance = 5.0 + # number of processors to use for ESMF_RegridWeightGen + nProcs = 128 + # mesh density parameters # minimum cell spacing (meters) min_spac = 5.e2 diff --git a/docs/users_guide/landice/test_groups/thwaites.rst b/docs/users_guide/landice/test_groups/thwaites.rst index e742102b3d..f4ab1e08b4 100644 --- a/docs/users_guide/landice/test_groups/thwaites.rst +++ b/docs/users_guide/landice/test_groups/thwaites.rst @@ -46,6 +46,9 @@ The other test cases do not use config options. # Set to a value <= 0 if you do not want # to cull based on distance from margin. cull_distance = 10.0 + + # number of processors to use for ESMF_RegridWeightGen + nProcs = 128 # mesh density parameters # minimum cell spacing (meters) From 75691834e2c5204e0b64ebb848d1f21b8b471270 Mon Sep 17 00:00:00 2001 From: Trevor Hillebrand Date: Wed, 18 Mar 2026 14:58:42 -0600 Subject: [PATCH 06/10] Fix potential bug in reading nProcs Fix potential bug in reading nProcs Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- compass/landice/mesh.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index 2f20e1fb6f..ce5321632c 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -1388,6 +1388,10 @@ def run_optional_bespoke_interpolation( if not do_bespoke_interp: return + if nProcs is None: + raise ValueError("nProcs must be provided as an int or str") + nProcs = str(nProcs) + if subset_bounds is not None: if bedmachine_dataset is not None: bedmachine_dataset = subset_gridded_dataset_to_bounds( From c830a0be3f095fa869f5f96c7fe5c23c5f8e34c3 Mon Sep 17 00:00:00 2001 From: Trevor Hillebrand Date: Wed, 18 Mar 2026 16:01:48 -0500 Subject: [PATCH 07/10] Address outdated PR review suggestions Use os.path.splitext() when deriving destination SCRIP filename. Use unique subset filenames and clean up temporary subset files after optional interpolation. --- compass/landice/mesh.py | 81 +++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 32 deletions(-) diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index ce5321632c..d55ea9b9da 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -2,6 +2,7 @@ import re import sys import time +import uuid from shutil import copyfile import jigsawpy @@ -1337,7 +1338,8 @@ def subset_gridded_dataset_to_bounds( f'{source_dataset}.') base = os.path.splitext(os.path.basename(source_dataset))[0] - subset_dataset = f'{base}_{subset_tag}_subset.nc' + unique_id = uuid.uuid4().hex + subset_dataset = f'{base}_{subset_tag}_{unique_id}_subset.nc' logger.info(f'Writing subset dataset: {subset_dataset}') subset.to_netcdf(subset_dataset) @@ -1392,36 +1394,51 @@ def run_optional_bespoke_interpolation( raise ValueError("nProcs must be provided as an int or str") nProcs = str(nProcs) - if subset_bounds is not None: + subset_files = [] + + try: + if subset_bounds is not None: + if bedmachine_dataset is not None: + bedmachine_dataset = subset_gridded_dataset_to_bounds( + bedmachine_dataset, + subset_bounds, + 'bedmachine', + logger) + subset_files.append(bedmachine_dataset) + if measures_dataset is not None: + measures_dataset = subset_gridded_dataset_to_bounds( + measures_dataset, + subset_bounds, + 'measures', + logger) + subset_files.append(measures_dataset) + + logger.info('creating scrip file for destination mesh') + mesh_base = os.path.splitext(mesh_filename)[0] + dst_scrip_file = f'{mesh_base}_scrip.nc' + scrip_from_mpas(mesh_filename, dst_scrip_file) + if bedmachine_dataset is not None: - bedmachine_dataset = subset_gridded_dataset_to_bounds( - bedmachine_dataset, - subset_bounds, - 'bedmachine', - logger) + interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, + parallel_executable, nProcs, + mesh_filename, src_proj, variables='all') + if measures_dataset is not None: - measures_dataset = subset_gridded_dataset_to_bounds( - measures_dataset, - subset_bounds, - 'measures', - logger) - - logger.info('creating scrip file for destination mesh') - dst_scrip_file = f"{mesh_filename.split('.')[:-1][0]}_scrip.nc" - scrip_from_mpas(mesh_filename, dst_scrip_file) - - if bedmachine_dataset is not None: - interp_gridded2mali(self, bedmachine_dataset, dst_scrip_file, - parallel_executable, nProcs, - mesh_filename, src_proj, variables='all') - - if measures_dataset is not None: - measures_vars = ['observedSurfaceVelocityX', - 'observedSurfaceVelocityY', - 'observedSurfaceVelocityUncertainty'] - interp_gridded2mali(self, measures_dataset, dst_scrip_file, - parallel_executable, nProcs, - mesh_filename, src_proj, - variables=measures_vars) - - clean_up_after_interp(mesh_filename) + measures_vars = ['observedSurfaceVelocityX', + 'observedSurfaceVelocityY', + 'observedSurfaceVelocityUncertainty'] + interp_gridded2mali(self, measures_dataset, dst_scrip_file, + parallel_executable, nProcs, + mesh_filename, src_proj, + variables=measures_vars) + + clean_up_after_interp(mesh_filename) + finally: + for subset_file in subset_files: + if os.path.exists(subset_file): + logger.info(f'Removing subset dataset: {subset_file}') + try: + os.remove(subset_file) + except OSError as exc: + logger.warning('Could not remove subset dataset ' + f'{subset_file}: {exc}') From e910c82b85bcc84c4da407a956f8c5ffa42021cc Mon Sep 17 00:00:00 2001 From: Trevor Hillebrand Date: Thu, 19 Mar 2026 09:20:38 -0500 Subject: [PATCH 08/10] Use src_proj only for optional interpolation remapping Make src_proj configurable across all landice mesh_gen cases for optional bespoke interpolation. Keep build_mali_mesh projection hard-coded in each mesh.py test case. Reorder src_proj and nProcs to sit with interpolation-related options in mesh_gen.cfg files. Update users and developers guide pages to match the new projection behavior and option grouping. --- compass/landice/tests/antarctica/mesh.py | 2 +- compass/landice/tests/crane/mesh.py | 3 ++- compass/landice/tests/crane/mesh_gen/mesh_gen.cfg | 10 +++++++--- compass/landice/tests/greenland/mesh.py | 3 ++- compass/landice/tests/humboldt/mesh.py | 3 ++- .../landice/tests/humboldt/mesh_gen/mesh_gen.cfg | 10 +++++++--- compass/landice/tests/isunnguata_sermia/mesh.py | 3 ++- .../tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg | 10 +++++++--- compass/landice/tests/kangerlussuaq/mesh.py | 3 ++- .../tests/kangerlussuaq/mesh_gen/mesh_gen.cfg | 10 +++++++--- compass/landice/tests/koge_bugt_s/mesh.py | 3 ++- .../landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg | 10 +++++++--- compass/landice/tests/thwaites/mesh.py | 3 ++- .../landice/tests/thwaites/mesh_gen/mesh_gen.cfg | 10 +++++++--- .../landice/test_groups/antarctica.rst | 1 + docs/developers_guide/landice/test_groups/crane.rst | 4 +++- .../landice/test_groups/greenland.rst | 1 + .../landice/test_groups/humboldt.rst | 4 +++- .../landice/test_groups/isunnguata_sermia.rst | 4 +++- .../landice/test_groups/kangerlussuaq.rst | 4 +++- .../landice/test_groups/koge_bugt_s.rst | 4 +++- .../landice/test_groups/thwaites.rst | 4 +++- docs/users_guide/landice/test_groups/antarctica.rst | 5 ++++- docs/users_guide/landice/test_groups/crane.rst | 13 ++++++++++--- docs/users_guide/landice/test_groups/greenland.rst | 5 ++++- docs/users_guide/landice/test_groups/humboldt.rst | 13 ++++++++++--- .../landice/test_groups/isunnguata_sermia.rst | 13 ++++++++++--- .../landice/test_groups/kangerlussuaq.rst | 13 ++++++++++--- .../users_guide/landice/test_groups/koge_bugt_s.rst | 13 ++++++++++--- docs/users_guide/landice/test_groups/thwaites.rst | 13 ++++++++++--- 30 files changed, 145 insertions(+), 52 deletions(-) diff --git a/compass/landice/tests/antarctica/mesh.py b/compass/landice/tests/antarctica/mesh.py index 57de115783..30b19aba54 100644 --- a/compass/landice/tests/antarctica/mesh.py +++ b/compass/landice/tests/antarctica/mesh.py @@ -91,7 +91,7 @@ def run(self): self, cell_width, x1, y1, geom_points, geom_edges, mesh_name=self.mesh_filename, section_name=section_name, gridded_dataset=bm_updated_gridded_dataset, - projection=src_proj, geojson_file=None) + projection='ais-bedmap2', geojson_file=None) # Now that we have base mesh with standard interpolation # perform advanced interpolation for specific fields diff --git a/compass/landice/tests/crane/mesh.py b/compass/landice/tests/crane/mesh.py index 6c7c416e39..f3c4c3a43a 100644 --- a/compass/landice/tests/crane/mesh.py +++ b/compass/landice/tests/crane/mesh.py @@ -48,6 +48,7 @@ def run(self): mesh_name = 'Crane.nc' section_name = 'mesh' section = config[section_name] + src_proj = section.get('src_proj') bedmachine_dataset, measures_dataset = get_optional_interp_datasets( section, logger) @@ -67,7 +68,7 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section.get('nProcs') run_optional_bespoke_interpolation( - self, mesh_name, 'ais-bedmap2', parallel_executable, nProcs, + self, mesh_name, src_proj, parallel_executable, nProcs, subset_bounds=get_mesh_config_bounding_box(section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) diff --git a/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg b/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg index 7c5af37147..9a2b8fc065 100644 --- a/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg @@ -15,9 +15,6 @@ y_max = 1.334e6 # to cull based on distance from margin. cull_distance = -1.0 -# number of processors to use for ESMF_RegridWeightGen -nProcs = 128 - # mesh density parameters # minimum cell spacing (meters) min_spac = 5.e2 @@ -54,3 +51,10 @@ use_bed = False data_path = None bedmachine_filename = None measures_filename = None + +# projection of the source datasets, according to the dictionary keys +# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools +src_proj = ais-bedmap2 + +# number of processors to use for ESMF_RegridWeightGen +nProcs = 128 diff --git a/compass/landice/tests/greenland/mesh.py b/compass/landice/tests/greenland/mesh.py index 513ab23a8b..45c399a008 100644 --- a/compass/landice/tests/greenland/mesh.py +++ b/compass/landice/tests/greenland/mesh.py @@ -102,7 +102,8 @@ def run(self): 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, projection=src_proj, + gridded_dataset=source_gridded_dataset_1km, + projection='gis-gimp', geojson_file=geojson_filename, bounding_box=bounding_box, ) diff --git a/compass/landice/tests/humboldt/mesh.py b/compass/landice/tests/humboldt/mesh.py index a565aa54a6..04f790341c 100644 --- a/compass/landice/tests/humboldt/mesh.py +++ b/compass/landice/tests/humboldt/mesh.py @@ -58,6 +58,7 @@ def run(self): section_name = 'mesh' section = config[section_name] mesh_name = 'Humboldt.nc' + src_proj = section.get('src_proj') bedmachine_dataset, measures_dataset = get_optional_interp_datasets( section, logger) @@ -77,7 +78,7 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section.get('nProcs') run_optional_bespoke_interpolation( - self, mesh_name, 'gis-gimp', parallel_executable, nProcs, + self, mesh_name, src_proj, parallel_executable, nProcs, subset_bounds=get_mesh_config_bounding_box(section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) diff --git a/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg b/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg index e5bed2f114..6891560de0 100644 --- a/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg @@ -15,9 +15,6 @@ y_max = -860000. # to cull based on distance from margin. cull_distance = 5.0 -# number of processors to use for ESMF_RegridWeightGen -nProcs = 128 - # mesh density parameters # minimum cell spacing (meters) min_spac = 1.e3 @@ -50,3 +47,10 @@ use_bed = True data_path = None bedmachine_filename = None measures_filename = None + +# projection of the source datasets, according to the dictionary keys +# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools +src_proj = gis-gimp + +# number of processors to use for ESMF_RegridWeightGen +nProcs = 128 diff --git a/compass/landice/tests/isunnguata_sermia/mesh.py b/compass/landice/tests/isunnguata_sermia/mesh.py index 6b7142a34b..e6996cedcf 100644 --- a/compass/landice/tests/isunnguata_sermia/mesh.py +++ b/compass/landice/tests/isunnguata_sermia/mesh.py @@ -58,6 +58,7 @@ def run(self): section_name = 'mesh' 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) @@ -76,7 +77,7 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section.get('nProcs') run_optional_bespoke_interpolation( - self, mesh_name, 'gis-gimp', parallel_executable, nProcs, + self, mesh_name, src_proj, parallel_executable, nProcs, subset_bounds=get_mesh_config_bounding_box(section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) diff --git a/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg b/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg index c9f3f90ce8..e6a5fa1c07 100644 --- a/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg @@ -15,9 +15,6 @@ y_max = -2400000. # to cull based on distance from margin. cull_distance = 5.0 -# number of processors to use for ESMF_RegridWeightGen -nProcs = 128 - # mesh density parameters # minimum cell spacing (meters) min_spac = 1.e3 @@ -50,3 +47,10 @@ use_bed = False data_path = None bedmachine_filename = None measures_filename = None + +# projection of the source datasets, according to the dictionary keys +# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools +src_proj = gis-gimp + +# number of processors to use for ESMF_RegridWeightGen +nProcs = 128 diff --git a/compass/landice/tests/kangerlussuaq/mesh.py b/compass/landice/tests/kangerlussuaq/mesh.py index 719a72e592..9e392d6849 100644 --- a/compass/landice/tests/kangerlussuaq/mesh.py +++ b/compass/landice/tests/kangerlussuaq/mesh.py @@ -59,6 +59,7 @@ def run(self): mesh_name = 'Kangerlussuaq.nc' section_name = 'mesh' section = config[section_name] + src_proj = section.get('src_proj') bedmachine_dataset, measures_dataset = get_optional_interp_datasets( section, logger) @@ -78,7 +79,7 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section.get('nProcs') run_optional_bespoke_interpolation( - self, mesh_name, 'gis-gimp', parallel_executable, nProcs, + self, mesh_name, src_proj, parallel_executable, nProcs, subset_bounds=get_mesh_config_bounding_box(section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) diff --git a/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg b/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg index 0d9fc99c2b..4ea953d281 100644 --- a/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg @@ -15,9 +15,6 @@ y_max = -2070000. # to cull based on distance from margin. cull_distance = 5.0 -# number of processors to use for ESMF_RegridWeightGen -nProcs = 128 - # mesh density parameters # minimum cell spacing (meters) min_spac = 1.e3 @@ -50,3 +47,10 @@ use_bed = True data_path = None bedmachine_filename = None measures_filename = None + +# projection of the source datasets, according to the dictionary keys +# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools +src_proj = gis-gimp + +# number of processors to use for ESMF_RegridWeightGen +nProcs = 128 diff --git a/compass/landice/tests/koge_bugt_s/mesh.py b/compass/landice/tests/koge_bugt_s/mesh.py index b95382dee3..807e1aa16d 100644 --- a/compass/landice/tests/koge_bugt_s/mesh.py +++ b/compass/landice/tests/koge_bugt_s/mesh.py @@ -59,6 +59,7 @@ def run(self): mesh_name = 'Koge_Bugt_S.nc' section_name = 'mesh' section = config[section_name] + src_proj = section.get('src_proj') bedmachine_dataset, measures_dataset = get_optional_interp_datasets( section, logger) @@ -78,7 +79,7 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section.get('nProcs') run_optional_bespoke_interpolation( - self, mesh_name, 'gis-gimp', parallel_executable, nProcs, + self, mesh_name, src_proj, parallel_executable, nProcs, subset_bounds=get_mesh_config_bounding_box(section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) diff --git a/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg b/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg index 770d82ceaf..3980cbaf78 100644 --- a/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg @@ -15,9 +15,6 @@ y_max = -2700000. # to cull based on distance from margin. cull_distance = 5.0 -# number of processors to use for ESMF_RegridWeightGen -nProcs = 128 - # mesh density parameters # minimum cell spacing (meters) min_spac = 5.e2 @@ -52,3 +49,10 @@ use_bed = False data_path = None bedmachine_filename = None measures_filename = None + +# projection of the source datasets, according to the dictionary keys +# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools +src_proj = gis-gimp + +# number of processors to use for ESMF_RegridWeightGen +nProcs = 128 diff --git a/compass/landice/tests/thwaites/mesh.py b/compass/landice/tests/thwaites/mesh.py index 63d86a28d4..bdfe1414dd 100644 --- a/compass/landice/tests/thwaites/mesh.py +++ b/compass/landice/tests/thwaites/mesh.py @@ -48,6 +48,7 @@ def run(self): mesh_name = 'Thwaites.nc' section_name = 'mesh' section = config[section_name] + src_proj = section.get('src_proj') bedmachine_dataset, measures_dataset = get_optional_interp_datasets( section, logger) @@ -67,7 +68,7 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section.get('nProcs') run_optional_bespoke_interpolation( - self, mesh_name, 'ais-bedmap2', parallel_executable, nProcs, + self, mesh_name, src_proj, parallel_executable, nProcs, subset_bounds=get_mesh_config_bounding_box(section), bedmachine_dataset=bedmachine_dataset, measures_dataset=measures_dataset) diff --git a/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg b/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg index 14c5f97f2d..017fea134e 100644 --- a/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg @@ -15,9 +15,6 @@ y_max = 0. # to cull based on distance from margin. cull_distance = 10.0 -# number of processors to use for ESMF_RegridWeightGen -nProcs = 128 - # mesh density parameters # minimum cell spacing (meters) min_spac = 1.e3 @@ -54,3 +51,10 @@ use_bed = False data_path = None bedmachine_filename = None measures_filename = None + +# projection of the source datasets, according to the dictionary keys +# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools +src_proj = ais-bedmap2 + +# number of processors to use for ESMF_RegridWeightGen +nProcs = 128 diff --git a/docs/developers_guide/landice/test_groups/antarctica.rst b/docs/developers_guide/landice/test_groups/antarctica.rst index 061a96008f..282594acb8 100644 --- a/docs/developers_guide/landice/test_groups/antarctica.rst +++ b/docs/developers_guide/landice/test_groups/antarctica.rst @@ -56,3 +56,4 @@ The BedMachine and MEaSUREs remapping steps are optional and are controlled by filename is unset (empty or ``None``), that dataset interpolation is skipped. The default config includes both datasets, so interpolation is enabled by default. +The base-mesh projection in ``build_mali_mesh()`` is fixed for this test case. diff --git a/docs/developers_guide/landice/test_groups/crane.rst b/docs/developers_guide/landice/test_groups/crane.rst index bd200403ed..b6984e88a7 100644 --- a/docs/developers_guide/landice/test_groups/crane.rst +++ b/docs/developers_guide/landice/test_groups/crane.rst @@ -30,8 +30,10 @@ calls the :py:class:`compass.landice.tests.crane.mesh.Mesh` to create the variable resolution Crane Glacier mesh. Optional BedMachine and MEaSUREs interpolation can be enabled through -``[mesh]`` config options ``nProcs``, ``data_path``, +``[mesh]`` config options ``nProcs``, ``src_proj``, ``data_path``, ``bedmachine_filename``, and ``measures_filename``. If enabled, source datasets are subset to the configured mesh bounding box before SCRIP generation and conservative remapping. +The ``src_proj`` option is used for optional bespoke remapping only; the +base-mesh projection in ``build_mali_mesh()`` is fixed for this test case. diff --git a/docs/developers_guide/landice/test_groups/greenland.rst b/docs/developers_guide/landice/test_groups/greenland.rst index 629b7946d6..8beb16f9f4 100644 --- a/docs/developers_guide/landice/test_groups/greenland.rst +++ b/docs/developers_guide/landice/test_groups/greenland.rst @@ -106,3 +106,4 @@ The BedMachine and MEaSUREs remapping steps are optional and are controlled by ``[greenland]`` config options. If ``data_path`` or the corresponding filename is unset (empty or ``None``), that dataset interpolation is skipped. The default config includes both datasets, so interpolation is enabled by default. +The base-mesh projection in ``build_mali_mesh()`` is fixed for this test case. diff --git a/docs/developers_guide/landice/test_groups/humboldt.rst b/docs/developers_guide/landice/test_groups/humboldt.rst index 4fcfe18dd5..7cd8690ccc 100644 --- a/docs/developers_guide/landice/test_groups/humboldt.rst +++ b/docs/developers_guide/landice/test_groups/humboldt.rst @@ -31,11 +31,13 @@ calls the :py:class:`compass.landice.tests.humboldt.mesh.Mesh` to create the 1-10 km variable resolution Humboldt Glacier mesh. Optional BedMachine and MEaSUREs interpolation can be enabled through -``[mesh]`` config options ``nProcs``, ``data_path``, +``[mesh]`` config options ``nProcs``, ``src_proj``, ``data_path``, ``bedmachine_filename``, and ``measures_filename``. If enabled, source datasets are subset to the configured mesh bounding box before SCRIP generation and conservative remapping. +The ``src_proj`` option is used for optional bespoke remapping only; the +base-mesh projection in ``build_mali_mesh()`` is fixed for this test case. run_model --------- diff --git a/docs/developers_guide/landice/test_groups/isunnguata_sermia.rst b/docs/developers_guide/landice/test_groups/isunnguata_sermia.rst index 42f06163dc..b79532966d 100644 --- a/docs/developers_guide/landice/test_groups/isunnguata_sermia.rst +++ b/docs/developers_guide/landice/test_groups/isunnguata_sermia.rst @@ -30,8 +30,10 @@ calls the :py:class:`compass.landice.tests.isunnguata_sermia.mesh.Mesh` to creat the variable resolution Isunnguata Sermia mesh. Optional BedMachine and MEaSUREs interpolation can be enabled through -``[mesh]`` config options ``nProcs``, ``data_path``, +``[mesh]`` config options ``nProcs``, ``src_proj``, ``data_path``, ``bedmachine_filename``, and ``measures_filename``. If enabled, source datasets are subset to the configured mesh bounding box before SCRIP generation and conservative remapping. +The ``src_proj`` option is used for optional bespoke remapping only; the +base-mesh projection in ``build_mali_mesh()`` is fixed for this test case. diff --git a/docs/developers_guide/landice/test_groups/kangerlussuaq.rst b/docs/developers_guide/landice/test_groups/kangerlussuaq.rst index c4bee49a59..bb0ecffec4 100644 --- a/docs/developers_guide/landice/test_groups/kangerlussuaq.rst +++ b/docs/developers_guide/landice/test_groups/kangerlussuaq.rst @@ -30,8 +30,10 @@ calls the :py:class:`compass.landice.tests.kangerlussuaq.mesh.Mesh` to create the variable resolution Kangerlussuaq Glacier mesh. Optional BedMachine and MEaSUREs interpolation can be enabled through -``[mesh]`` config options ``nProcs``, ``data_path``, +``[mesh]`` config options ``nProcs``, ``src_proj``, ``data_path``, ``bedmachine_filename``, and ``measures_filename``. If enabled, source datasets are subset to the configured mesh bounding box before SCRIP generation and conservative remapping. +The ``src_proj`` option is used for optional bespoke remapping only; the +base-mesh projection in ``build_mali_mesh()`` is fixed for this test case. diff --git a/docs/developers_guide/landice/test_groups/koge_bugt_s.rst b/docs/developers_guide/landice/test_groups/koge_bugt_s.rst index 0f02ce66f2..61aed12995 100644 --- a/docs/developers_guide/landice/test_groups/koge_bugt_s.rst +++ b/docs/developers_guide/landice/test_groups/koge_bugt_s.rst @@ -30,8 +30,10 @@ calls the :py:class:`compass.landice.tests.koge_bugt_s.mesh.Mesh` to create the variable resolution Koge Bugt S mesh. Optional BedMachine and MEaSUREs interpolation can be enabled through -``[mesh]`` config options ``nProcs``, ``data_path``, +``[mesh]`` config options ``nProcs``, ``src_proj``, ``data_path``, ``bedmachine_filename``, and ``measures_filename``. If enabled, source datasets are subset to the configured mesh bounding box before SCRIP generation and conservative remapping. +The ``src_proj`` option is used for optional bespoke remapping only; the +base-mesh projection in ``build_mali_mesh()`` is fixed for this test case. diff --git a/docs/developers_guide/landice/test_groups/thwaites.rst b/docs/developers_guide/landice/test_groups/thwaites.rst index 39ecd77157..f1b7a75f2e 100644 --- a/docs/developers_guide/landice/test_groups/thwaites.rst +++ b/docs/developers_guide/landice/test_groups/thwaites.rst @@ -78,8 +78,10 @@ calls the :py:class:`compass.landice.tests.thwaites.mesh.Mesh` to create the variable resolution Thwaites Glacier mesh. Optional BedMachine and MEaSUREs interpolation can be enabled through -``[mesh]`` config options ``nProcs``, ``data_path``, +``[mesh]`` config options ``nProcs``, ``src_proj``, ``data_path``, ``bedmachine_filename``, and ``measures_filename``. If enabled, source datasets are subset to the configured mesh bounding box before SCRIP generation and conservative remapping. +The ``src_proj`` option is used for optional bespoke remapping only; the +base-mesh projection in ``build_mali_mesh()`` is fixed for this test case. diff --git a/docs/users_guide/landice/test_groups/antarctica.rst b/docs/users_guide/landice/test_groups/antarctica.rst index ca042f87b7..2807e44127 100644 --- a/docs/users_guide/landice/test_groups/antarctica.rst +++ b/docs/users_guide/landice/test_groups/antarctica.rst @@ -82,7 +82,8 @@ the mesh generation options are adjusted through the config file. # (default value is for Perlmutter) measures_filename = antarctica_ice_velocity_450m_v2_edits_extrap.nc - # projection of the source datasets, according to the dictionary keys + # projection of optional interpolation source datasets, + # according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools src_proj = ais-bedmap2 @@ -119,5 +120,7 @@ The BedMachine and MEaSUREs interpolation is optional. If ``data_path`` or the corresponding filename in ``[antarctica]`` is unset (empty or ``None``), that dataset interpolation step is skipped. The default config values include both datasets, so interpolation is enabled by default. +The base-mesh projection used in ``build_mali_mesh()`` is fixed for this test +case. There is no model integration step. diff --git a/docs/users_guide/landice/test_groups/crane.rst b/docs/users_guide/landice/test_groups/crane.rst index b34a5bca2d..91d4dab409 100644 --- a/docs/users_guide/landice/test_groups/crane.rst +++ b/docs/users_guide/landice/test_groups/crane.rst @@ -40,9 +40,6 @@ the mesh generation options are adjusted through the config file. # Set to a value <= 0 if you do not want # to cull based on distance from margin. cull_distance = -1.0 - - # number of processors to use for ESMF_RegridWeightGen - nProcs = 128 # mesh density parameters # minimum cell spacing (meters) @@ -82,6 +79,14 @@ the mesh generation options are adjusted through the config file. bedmachine_filename = None measures_filename = None + # projection of optional interpolation source datasets, + # according to the dictionary keys + # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools + src_proj = ais-bedmap2 + + # number of processors to use for ESMF_RegridWeightGen + nProcs = 128 + mesh_gen -------- @@ -93,3 +98,5 @@ integration step. If optional BedMachine and/or MEaSUREs datasets are configured, they are subset to the mesh bounding box from ``[mesh]`` before SCRIP generation and conservative remapping to reduce memory and runtime. +The base-mesh projection used in ``build_mali_mesh()`` is fixed for this test +case. diff --git a/docs/users_guide/landice/test_groups/greenland.rst b/docs/users_guide/landice/test_groups/greenland.rst index 34494948ea..9ad3f58967 100644 --- a/docs/users_guide/landice/test_groups/greenland.rst +++ b/docs/users_guide/landice/test_groups/greenland.rst @@ -96,7 +96,8 @@ The other test cases do not use config options. # (default value is for Perlmutter) measures_filename = greenland_vel_mosaic500_extrap.nc - # projection of the source datasets, according to the dictionary keys + # projection of optional interpolation source datasets, + # according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools src_proj = gis-gimp @@ -158,3 +159,5 @@ The BedMachine and MEaSUREs interpolation is optional. If ``data_path`` or the corresponding filename in ``[greenland]`` is unset (empty or ``None``), that dataset interpolation step is skipped. The default config values include both datasets, so interpolation is enabled by default. +The base-mesh projection used in ``build_mali_mesh()`` is fixed for this test +case. diff --git a/docs/users_guide/landice/test_groups/humboldt.rst b/docs/users_guide/landice/test_groups/humboldt.rst index 866f74d001..cd5473f32a 100644 --- a/docs/users_guide/landice/test_groups/humboldt.rst +++ b/docs/users_guide/landice/test_groups/humboldt.rst @@ -46,9 +46,6 @@ the mesh generation options are adjusted through the config file. # to cull based on distance from margin. cull_distance = 5.0 - # number of processors to use for ESMF_RegridWeightGen - nProcs = 128 - # mesh density parameters # minimum cell spacing (meters) min_spac = 1.e3 @@ -74,6 +71,14 @@ the mesh generation options are adjusted through the config file. bedmachine_filename = None measures_filename = None + # projection of optional interpolation source datasets, + # according to the dictionary keys + # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools + src_proj = gis-gimp + + # number of processors to use for ESMF_RegridWeightGen + nProcs = 128 + mesh_gen -------- @@ -83,6 +88,8 @@ There is no model integration step. If optional BedMachine and/or MEaSUREs datasets are configured, they are subset to the mesh bounding box from ``[mesh]`` before SCRIP generation and conservative remapping to reduce memory and runtime. +The base-mesh projection used in ``build_mali_mesh()`` is fixed for this test +case. decomposition_tests ------------------- diff --git a/docs/users_guide/landice/test_groups/isunnguata_sermia.rst b/docs/users_guide/landice/test_groups/isunnguata_sermia.rst index e7850a4f1f..d5b77f0d5f 100644 --- a/docs/users_guide/landice/test_groups/isunnguata_sermia.rst +++ b/docs/users_guide/landice/test_groups/isunnguata_sermia.rst @@ -40,9 +40,6 @@ the mesh generation options are adjusted through the config file. # Set to a value <= 0 if you do not want # to cull based on distance from margin. cull_distance = 5.0 - - # number of processors to use for ESMF_RegridWeightGen - nProcs = 128 # mesh density parameters # minimum cell spacing (meters) @@ -78,6 +75,14 @@ the mesh generation options are adjusted through the config file. bedmachine_filename = None measures_filename = None + # projection of optional interpolation source datasets, + # according to the dictionary keys + # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools + src_proj = gis-gimp + + # number of processors to use for ESMF_RegridWeightGen + nProcs = 128 + mesh_gen -------- @@ -88,3 +93,5 @@ observed ice speed. There is no model integration step. If optional BedMachine and/or MEaSUREs datasets are configured, they are subset to the mesh bounding box from ``[mesh]`` before SCRIP generation and conservative remapping to reduce memory and runtime. +The base-mesh projection used in ``build_mali_mesh()`` is fixed for this test +case. diff --git a/docs/users_guide/landice/test_groups/kangerlussuaq.rst b/docs/users_guide/landice/test_groups/kangerlussuaq.rst index 2298ba4ee3..082f6683f2 100644 --- a/docs/users_guide/landice/test_groups/kangerlussuaq.rst +++ b/docs/users_guide/landice/test_groups/kangerlussuaq.rst @@ -34,9 +34,6 @@ the mesh generation options are adjusted through the config file. # to cull based on distance from margin. cull_distance = 5.0 - # number of processors to use for ESMF_RegridWeightGen - nProcs = 128 - # mesh density parameters # minimum cell spacing (meters) min_spac = 1.e3 @@ -62,6 +59,14 @@ the mesh generation options are adjusted through the config file. bedmachine_filename = None measures_filename = None + # projection of optional interpolation source datasets, + # according to the dictionary keys + # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools + src_proj = gis-gimp + + # number of processors to use for ESMF_RegridWeightGen + nProcs = 128 + mesh_gen -------- @@ -73,3 +78,5 @@ integration step. If optional BedMachine and/or MEaSUREs datasets are configured, they are subset to the mesh bounding box from ``[mesh]`` before SCRIP generation and conservative remapping to reduce memory and runtime. +The base-mesh projection used in ``build_mali_mesh()`` is fixed for this test +case. diff --git a/docs/users_guide/landice/test_groups/koge_bugt_s.rst b/docs/users_guide/landice/test_groups/koge_bugt_s.rst index 6760ed77bf..fc6a9de11b 100644 --- a/docs/users_guide/landice/test_groups/koge_bugt_s.rst +++ b/docs/users_guide/landice/test_groups/koge_bugt_s.rst @@ -34,9 +34,6 @@ the mesh generation options are adjusted through the config file. # to cull based on distance from margin. cull_distance = 5.0 - # number of processors to use for ESMF_RegridWeightGen - nProcs = 128 - # mesh density parameters # minimum cell spacing (meters) min_spac = 5.e2 @@ -62,6 +59,14 @@ the mesh generation options are adjusted through the config file. bedmachine_filename = None measures_filename = None + # projection of optional interpolation source datasets, + # according to the dictionary keys + # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools + src_proj = gis-gimp + + # number of processors to use for ESMF_RegridWeightGen + nProcs = 128 + mesh_gen -------- @@ -73,3 +78,5 @@ integration step. If optional BedMachine and/or MEaSUREs datasets are configured, they are subset to the mesh bounding box from ``[mesh]`` before SCRIP generation and conservative remapping to reduce memory and runtime. +The base-mesh projection used in ``build_mali_mesh()`` is fixed for this test +case. diff --git a/docs/users_guide/landice/test_groups/thwaites.rst b/docs/users_guide/landice/test_groups/thwaites.rst index f4ab1e08b4..19cbd54692 100644 --- a/docs/users_guide/landice/test_groups/thwaites.rst +++ b/docs/users_guide/landice/test_groups/thwaites.rst @@ -46,9 +46,6 @@ The other test cases do not use config options. # Set to a value <= 0 if you do not want # to cull based on distance from margin. cull_distance = 10.0 - - # number of processors to use for ESMF_RegridWeightGen - nProcs = 128 # mesh density parameters # minimum cell spacing (meters) @@ -75,6 +72,14 @@ The other test cases do not use config options. bedmachine_filename = None measures_filename = None + # projection of optional interpolation source datasets, + # according to the dictionary keys + # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools + src_proj = ais-bedmap2 + + # number of processors to use for ESMF_RegridWeightGen + nProcs = 128 + decomposition_test ------------------ @@ -105,3 +110,5 @@ optimization is performed separately and is not part of this test case. If optional BedMachine and/or MEaSUREs datasets are configured, they are subset to the mesh bounding box from ``[mesh]`` before SCRIP generation and conservative remapping to reduce memory and runtime. +The base-mesh projection used in ``build_mali_mesh()`` is fixed for this test +case. From 7480d956f563cd052c358f40345aacf26e543fc5 Mon Sep 17 00:00:00 2001 From: Trevor Hillebrand Date: Thu, 19 Mar 2026 09:30:48 -0500 Subject: [PATCH 09/10] Use shared bounding-box helper in Greenland mesh step Replace the local _get_bedmachine_bounding_box() method in greenland/mesh.py with the shared get_mesh_config_bounding_box() helper from compass.landice.mesh. Use BedMachine dataset extents as default bounds to preserve existing clipping behavior. --- compass/landice/tests/greenland/mesh.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/compass/landice/tests/greenland/mesh.py b/compass/landice/tests/greenland/mesh.py index 45c399a008..12552f1dc8 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, + get_mesh_config_bounding_box, get_optional_interp_datasets, make_region_masks, run_optional_bespoke_interpolation, @@ -81,8 +82,15 @@ def run(self): section_gis, logger) if bedmachine_dataset is not None: - bounding_box = self._get_bedmachine_bounding_box( - bedmachine_dataset) + ds_bm = xr.open_dataset(bedmachine_dataset) + default_bounds = [ + float(ds_bm.x1.min()), + float(ds_bm.x1.max()), + float(ds_bm.y1.min()), + float(ds_bm.y1.max())] + ds_bm.close() + bounding_box = get_mesh_config_bounding_box( + section_gis, default_bounds=default_bounds) else: bounding_box = None @@ -158,14 +166,3 @@ def run(self): ds["observedThicknessTendencyUncertainty"] = dHdtErr # Write the data to disk ds.to_netcdf(self.mesh_filename, 'a') - - def _get_bedmachine_bounding_box(self, bedmachine_filepath): - - ds = xr.open_dataset(bedmachine_filepath) - - x_min = ds.x1.min() - x_max = ds.x1.max() - y_min = ds.y1.min() - y_max = ds.y1.max() - - return [x_min, x_max, y_min, y_max] From 434cb936897a091f7157592a4d79847278033e92 Mon Sep 17 00:00:00 2001 From: Trevor Hillebrand Date: Thu, 19 Mar 2026 19:19:18 -0700 Subject: [PATCH 10/10] Add interpolate_data flag to all mesh_gen.cfg files Add interpolate_data flag to all mesh_gen.cfg files, and include default paths to BedMachine and Measures data on Perlmutter. --- compass/landice/mesh.py | 11 ++++++-- compass/landice/tests/antarctica/mesh.py | 14 ++++++---- .../tests/antarctica/mesh_gen/mesh_gen.cfg | 2 ++ compass/landice/tests/crane/mesh.py | 14 ++++++---- .../landice/tests/crane/mesh_gen/mesh_gen.cfg | 17 +++++++++--- compass/landice/tests/greenland/mesh.py | 14 ++++++---- .../tests/greenland/mesh_gen/mesh_gen.cfg | 2 ++ compass/landice/tests/humboldt/mesh.py | 14 ++++++---- .../tests/humboldt/mesh_gen/mesh_gen.cfg | 17 +++++++++--- .../landice/tests/isunnguata_sermia/mesh.py | 14 ++++++---- .../isunnguata_sermia/mesh_gen/mesh_gen.cfg | 17 +++++++++--- compass/landice/tests/kangerlussuaq/mesh.py | 14 ++++++---- .../tests/kangerlussuaq/mesh_gen/mesh_gen.cfg | 17 +++++++++--- compass/landice/tests/koge_bugt_s/mesh.py | 14 ++++++---- .../tests/koge_bugt_s/mesh_gen/mesh_gen.cfg | 17 +++++++++--- compass/landice/tests/thwaites/mesh.py | 14 ++++++---- .../tests/thwaites/mesh_gen/mesh_gen.cfg | 17 +++++++++--- .../landice/test_groups/antarctica.rst | 5 ++-- .../users_guide/landice/test_groups/crane.rst | 23 ++++++++++------ .../landice/test_groups/greenland.rst | 10 ++++--- .../landice/test_groups/humboldt.rst | 26 +++++++++++++------ .../landice/test_groups/isunnguata_sermia.rst | 26 +++++++++++++------ .../landice/test_groups/kangerlussuaq.rst | 26 +++++++++++++------ .../landice/test_groups/koge_bugt_s.rst | 26 +++++++++++++------ .../landice/test_groups/thwaites.rst | 23 ++++++++++------ 25 files changed, 281 insertions(+), 113 deletions(-) diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index d55ea9b9da..ccfc77f2a4 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -1330,12 +1330,19 @@ def subset_gridded_dataset_to_bounds( (ds[y_name] >= y_min) & (ds[y_name] <= y_max), drop=True) - if subset.sizes[x_name] == 0 or subset.sizes[y_name] == 0: + # Check for empty subset, handling possible mismatch + # between variable and dimension names + x_dim = x_name if x_name in subset.sizes else ( + 'x' if 'x' in subset.sizes else None) + y_dim = y_name if y_name in subset.sizes else ( + 'y' if 'y' in subset.sizes else None) + if x_dim is None or y_dim is None or subset.sizes[x_dim] == 0 or subset.sizes[y_dim] == 0: # noqa subset.close() ds.close() raise ValueError( f'Bounding box {bounding_box} produced an empty subset for ' - f'{source_dataset}.') + f'{source_dataset}. Dimension names in subset: ' + f'{list(subset.sizes.keys())}') base = os.path.splitext(os.path.basename(source_dataset))[0] unique_id = uuid.uuid4().hex diff --git a/compass/landice/tests/antarctica/mesh.py b/compass/landice/tests/antarctica/mesh.py index 30b19aba54..038ee44831 100644 --- a/compass/landice/tests/antarctica/mesh.py +++ b/compass/landice/tests/antarctica/mesh.py @@ -131,11 +131,15 @@ def run(self): 'observedThicknessTendencyUncertainty', 'thickness'] check_call(args, logger=logger) - run_optional_bespoke_interpolation( - self, self.mesh_filename, src_proj, - parallel_executable, nProcs, - bedmachine_dataset=bedmachine_dataset, - measures_dataset=measures_dataset) + # Only interpolate data if interpolate_data is True in mesh_gen.cfg + interpolate_data = section_ais.getboolean( + 'interpolate_data', fallback=False) + if interpolate_data: + run_optional_bespoke_interpolation( + self, self.mesh_filename, src_proj, + parallel_executable, nProcs, + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) # create graph file logger.info('creating graph.info') diff --git a/compass/landice/tests/antarctica/mesh_gen/mesh_gen.cfg b/compass/landice/tests/antarctica/mesh_gen/mesh_gen.cfg index cca24f5acd..8662aa63e7 100644 --- a/compass/landice/tests/antarctica/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/antarctica/mesh_gen/mesh_gen.cfg @@ -48,6 +48,8 @@ use_dist_to_edge = False use_bed = False [antarctica] +# Whether to interpolate data (controls run_optional_bespoke_interpolation) +interpolate_data = True # path to directory containing BedMachine and Measures datasets # (default value is for Perlmutter) data_path = /global/cfs/cdirs/fanssie/standard_datasets/AIS_datasets diff --git a/compass/landice/tests/crane/mesh.py b/compass/landice/tests/crane/mesh.py index f3c4c3a43a..2d5055b5a9 100644 --- a/compass/landice/tests/crane/mesh.py +++ b/compass/landice/tests/crane/mesh.py @@ -67,11 +67,15 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section.get('nProcs') - run_optional_bespoke_interpolation( - self, mesh_name, src_proj, parallel_executable, nProcs, - subset_bounds=get_mesh_config_bounding_box(section), - bedmachine_dataset=bedmachine_dataset, - measures_dataset=measures_dataset) + # Only interpolate data if interpolate_data is True in mesh_gen.cfg + interpolate_data = section.getboolean( + 'interpolate_data', fallback=False) + if interpolate_data: + run_optional_bespoke_interpolation( + self, mesh_name, src_proj, parallel_executable, nProcs, + subset_bounds=get_mesh_config_bounding_box(section), + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, diff --git a/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg b/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg index 9a2b8fc065..7d0a84febc 100644 --- a/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg @@ -48,9 +48,20 @@ use_dist_to_edge = False use_bed = False # Optional bespoke interpolation inputs (skip when set to None) -data_path = None -bedmachine_filename = None -measures_filename = None +# Whether to interpolate data (controls run_optional_bespoke_interpolation) +interpolate_data = False + +# path to directory containing BedMachine and Measures datasets +# (default value is for Perlmutter) +data_path = /global/cfs/cdirs/fanssie/standard_datasets/AIS_datasets + +# filename of the BedMachine thickness and bedTopography dataset +# (default value is for Perlmutter) +bedmachine_filename = BedMachineAntarctica_2020-07-15_v02_edits_floodFill_extrap_fillVostok.nc + +# filename of the MEASURES ice velocity dataset +# (default value is for Perlmutter) +measures_filename = antarctica_ice_velocity_450m_v2_edits_extrap.nc # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools diff --git a/compass/landice/tests/greenland/mesh.py b/compass/landice/tests/greenland/mesh.py index 12552f1dc8..ebc0bb24cf 100644 --- a/compass/landice/tests/greenland/mesh.py +++ b/compass/landice/tests/greenland/mesh.py @@ -116,11 +116,15 @@ def run(self): bounding_box=bounding_box, ) - run_optional_bespoke_interpolation( - self, self.mesh_filename, src_proj, - parallel_executable, nProcs, - bedmachine_dataset=bedmachine_dataset, - measures_dataset=measures_dataset) + # Only interpolate data if interpolate_data is True in mesh_gen.cfg + interpolate_data = section_gis.getboolean( + 'interpolate_data', fallback=False) + if interpolate_data: + run_optional_bespoke_interpolation( + self, self.mesh_filename, src_proj, + parallel_executable, nProcs, + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) # create graph file logger.info('creating graph.info') diff --git a/compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg b/compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg index fa999c966d..dfc559ff74 100644 --- a/compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg @@ -46,6 +46,8 @@ use_dist_to_edge = True use_bed = True [greenland] +# Whether to interpolate data (controls run_optional_bespoke_interpolation) +interpolate_data = True # path to directory containing BedMachine and Measures datasets # (default value is for Perlmutter) data_path = /global/cfs/cdirs/fanssie/standard_datasets/GIS_datasets/ diff --git a/compass/landice/tests/humboldt/mesh.py b/compass/landice/tests/humboldt/mesh.py index 04f790341c..7dcad23759 100644 --- a/compass/landice/tests/humboldt/mesh.py +++ b/compass/landice/tests/humboldt/mesh.py @@ -77,11 +77,15 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section.get('nProcs') - run_optional_bespoke_interpolation( - self, mesh_name, src_proj, parallel_executable, nProcs, - subset_bounds=get_mesh_config_bounding_box(section), - bedmachine_dataset=bedmachine_dataset, - measures_dataset=measures_dataset) + # Only interpolate data if interpolate_data is True in mesh_gen.cfg + interpolate_data = section.getboolean( + 'interpolate_data', fallback=False) + if interpolate_data: + run_optional_bespoke_interpolation( + self, mesh_name, src_proj, parallel_executable, nProcs, + subset_bounds=get_mesh_config_bounding_box(section), + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, diff --git a/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg b/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg index 6891560de0..81194fdc0a 100644 --- a/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg @@ -44,9 +44,20 @@ use_dist_to_edge = True use_bed = True # Optional bespoke interpolation inputs (skip when set to None) -data_path = None -bedmachine_filename = None -measures_filename = None +# Whether to interpolate data (controls run_optional_bespoke_interpolation) +interpolate_data = False + +# path to directory containing BedMachine and Measures datasets +# (default value is for Perlmutter) +data_path = /global/cfs/cdirs/fanssie/standard_datasets/GIS_datasets/ + +# filename of the BedMachine thickness and bedTopography dataset +# (default value is for Perlmutter) +bedmachine_filename = BedMachineGreenland-v6_edits_floodFill_extrap.nc + +# filename of the MEaSUREs ice velocity dataset +# (default value is for Perlmutter) +measures_filename = greenland_vel_mosaic500_extrap.nc # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools diff --git a/compass/landice/tests/isunnguata_sermia/mesh.py b/compass/landice/tests/isunnguata_sermia/mesh.py index e6996cedcf..9bc68fbb9a 100644 --- a/compass/landice/tests/isunnguata_sermia/mesh.py +++ b/compass/landice/tests/isunnguata_sermia/mesh.py @@ -76,11 +76,15 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section.get('nProcs') - run_optional_bespoke_interpolation( - self, mesh_name, src_proj, parallel_executable, nProcs, - subset_bounds=get_mesh_config_bounding_box(section), - bedmachine_dataset=bedmachine_dataset, - measures_dataset=measures_dataset) + # Only interpolate data if interpolate_data is True in mesh_gen.cfg + interpolate_data = section.getboolean( + 'interpolate_data', fallback=False) + if interpolate_data: + run_optional_bespoke_interpolation( + self, mesh_name, src_proj, parallel_executable, nProcs, + subset_bounds=get_mesh_config_bounding_box(section), + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, diff --git a/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg b/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg index e6a5fa1c07..1d4ddd178c 100644 --- a/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg @@ -44,9 +44,20 @@ use_dist_to_edge = False use_bed = False # Optional bespoke interpolation inputs (skip when set to None) -data_path = None -bedmachine_filename = None -measures_filename = None +# Whether to interpolate data (controls run_optional_bespoke_interpolation) +interpolate_data = False + +# path to directory containing BedMachine and Measures datasets +# (default value is for Perlmutter) +data_path = /global/cfs/cdirs/fanssie/standard_datasets/GIS_datasets/ + +# filename of the BedMachine thickness and bedTopography dataset +# (default value is for Perlmutter) +bedmachine_filename = BedMachineGreenland-v6_edits_floodFill_extrap.nc + +# filename of the MEaSUREs ice velocity dataset +# (default value is for Perlmutter) +measures_filename = greenland_vel_mosaic500_extrap.nc # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools diff --git a/compass/landice/tests/kangerlussuaq/mesh.py b/compass/landice/tests/kangerlussuaq/mesh.py index 9e392d6849..079b6cfb8f 100644 --- a/compass/landice/tests/kangerlussuaq/mesh.py +++ b/compass/landice/tests/kangerlussuaq/mesh.py @@ -78,11 +78,15 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section.get('nProcs') - run_optional_bespoke_interpolation( - self, mesh_name, src_proj, parallel_executable, nProcs, - subset_bounds=get_mesh_config_bounding_box(section), - bedmachine_dataset=bedmachine_dataset, - measures_dataset=measures_dataset) + # Only interpolate data if interpolate_data is True in mesh_gen.cfg + interpolate_data = section.getboolean( + 'interpolate_data', fallback=False) + if interpolate_data: + run_optional_bespoke_interpolation( + self, mesh_name, src_proj, parallel_executable, nProcs, + subset_bounds=get_mesh_config_bounding_box(section), + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, diff --git a/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg b/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg index 4ea953d281..0b77d2204d 100644 --- a/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg @@ -44,9 +44,20 @@ use_dist_to_edge = True use_bed = True # Optional bespoke interpolation inputs (skip when set to None) -data_path = None -bedmachine_filename = None -measures_filename = None +# Whether to interpolate data (controls run_optional_bespoke_interpolation) +interpolate_data = False + +# path to directory containing BedMachine and Measures datasets +# (default value is for Perlmutter) +data_path = /global/cfs/cdirs/fanssie/standard_datasets/GIS_datasets/ + +# filename of the BedMachine thickness and bedTopography dataset +# (default value is for Perlmutter) +bedmachine_filename = BedMachineGreenland-v6_edits_floodFill_extrap.nc + +# filename of the MEaSUREs ice velocity dataset +# (default value is for Perlmutter) +measures_filename = greenland_vel_mosaic500_extrap.nc # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools diff --git a/compass/landice/tests/koge_bugt_s/mesh.py b/compass/landice/tests/koge_bugt_s/mesh.py index 807e1aa16d..3bd4f6080c 100644 --- a/compass/landice/tests/koge_bugt_s/mesh.py +++ b/compass/landice/tests/koge_bugt_s/mesh.py @@ -78,11 +78,15 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section.get('nProcs') - run_optional_bespoke_interpolation( - self, mesh_name, src_proj, parallel_executable, nProcs, - subset_bounds=get_mesh_config_bounding_box(section), - bedmachine_dataset=bedmachine_dataset, - measures_dataset=measures_dataset) + # Only interpolate data if interpolate_data is True in mesh_gen.cfg + interpolate_data = section.getboolean( + 'interpolate_data', fallback=False) + if interpolate_data: + run_optional_bespoke_interpolation( + self, mesh_name, src_proj, parallel_executable, nProcs, + subset_bounds=get_mesh_config_bounding_box(section), + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, diff --git a/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg b/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg index 3980cbaf78..2d00ae0e6e 100644 --- a/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg @@ -46,9 +46,20 @@ use_dist_to_edge = True use_bed = False # Optional bespoke interpolation inputs (skip when set to None) -data_path = None -bedmachine_filename = None -measures_filename = None +# Whether to interpolate data (controls run_optional_bespoke_interpolation) +interpolate_data = False + +# path to directory containing BedMachine and Measures datasets +# (default value is for Perlmutter) +data_path = /global/cfs/cdirs/fanssie/standard_datasets/GIS_datasets/ + +# filename of the BedMachine thickness and bedTopography dataset +# (default value is for Perlmutter) +bedmachine_filename = BedMachineGreenland-v6_edits_floodFill_extrap.nc + +# filename of the MEaSUREs ice velocity dataset +# (default value is for Perlmutter) +measures_filename = greenland_vel_mosaic500_extrap.nc # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools diff --git a/compass/landice/tests/thwaites/mesh.py b/compass/landice/tests/thwaites/mesh.py index bdfe1414dd..4b988d90d0 100644 --- a/compass/landice/tests/thwaites/mesh.py +++ b/compass/landice/tests/thwaites/mesh.py @@ -67,11 +67,15 @@ def run(self): parallel_executable = config.get('parallel', 'parallel_executable') nProcs = section.get('nProcs') - run_optional_bespoke_interpolation( - self, mesh_name, src_proj, parallel_executable, nProcs, - subset_bounds=get_mesh_config_bounding_box(section), - bedmachine_dataset=bedmachine_dataset, - measures_dataset=measures_dataset) + # Only interpolate data if interpolate_data is True in mesh_gen.cfg + interpolate_data = section.getboolean( + 'interpolate_data', fallback=False) + if interpolate_data: + run_optional_bespoke_interpolation( + self, mesh_name, src_proj, parallel_executable, nProcs, + subset_bounds=get_mesh_config_bounding_box(section), + bedmachine_dataset=bedmachine_dataset, + measures_dataset=measures_dataset) logger.info('creating graph.info') make_graph_file(mesh_filename=mesh_name, diff --git a/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg b/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg index 017fea134e..688ec2e98a 100644 --- a/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg @@ -48,9 +48,20 @@ use_dist_to_edge = False use_bed = False # Optional bespoke interpolation inputs (skip when set to None) -data_path = None -bedmachine_filename = None -measures_filename = None +# Whether to interpolate data (controls run_optional_bespoke_interpolation) +interpolate_data = False + +# path to directory containing BedMachine and Measures datasets +# (default value is for Perlmutter) +data_path = /global/cfs/cdirs/fanssie/standard_datasets/AIS_datasets + +# filename of the BedMachine thickness and bedTopography dataset +# (default value is for Perlmutter) +bedmachine_filename = BedMachineAntarctica_2020-07-15_v02_edits_floodFill_extrap_fillVostok.nc + +# filename of the MEASURES ice velocity dataset +# (default value is for Perlmutter) +measures_filename = antarctica_ice_velocity_450m_v2_edits_extrap.nc # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools diff --git a/docs/users_guide/landice/test_groups/antarctica.rst b/docs/users_guide/landice/test_groups/antarctica.rst index 2807e44127..28d1ea48d9 100644 --- a/docs/users_guide/landice/test_groups/antarctica.rst +++ b/docs/users_guide/landice/test_groups/antarctica.rst @@ -70,6 +70,8 @@ the mesh generation options are adjusted through the config file. use_bed = False [antarctica] + # Whether to interpolate data (controls run_optional_bespoke_interpolation) + interpolate_data = True # path to directory containing BedMachine and Measures datasets # (default value is for Perlmutter) data_path = /global/cfs/cdirs/fanssie/standard_datasets/AIS_datasets @@ -82,8 +84,7 @@ the mesh generation options are adjusted through the config file. # (default value is for Perlmutter) measures_filename = antarctica_ice_velocity_450m_v2_edits_extrap.nc - # projection of optional interpolation source datasets, - # according to the dictionary keys + # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools src_proj = ais-bedmap2 diff --git a/docs/users_guide/landice/test_groups/crane.rst b/docs/users_guide/landice/test_groups/crane.rst index 91d4dab409..4bf6858797 100644 --- a/docs/users_guide/landice/test_groups/crane.rst +++ b/docs/users_guide/landice/test_groups/crane.rst @@ -73,14 +73,21 @@ the mesh generation options are adjusted through the config file. use_dist_to_edge = False use_bed = False - # optional bespoke interpolation inputs - # set to None to skip optional BedMachine/MEaSUREs remapping - data_path = None - bedmachine_filename = None - measures_filename = None - - # projection of optional interpolation source datasets, - # according to the dictionary keys + # Whether to interpolate data (controls run_optional_bespoke_interpolation) + interpolate_data = False + # path to directory containing BedMachine and Measures datasets + # (default value is for Perlmutter) + data_path = /global/cfs/cdirs/fanssie/standard_datasets/AIS_datasets + + # filename of the BedMachine thickness and bedTopography dataset + # (default value is for Perlmutter) + bedmachine_filename = BedMachineAntarctica_2020-07-15_v02_edits_floodFill_extrap_fillVostok.nc + + # filename of the MEASURES ice velocity dataset + # (default value is for Perlmutter) + measures_filename = antarctica_ice_velocity_450m_v2_edits_extrap.nc + + # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools src_proj = ais-bedmap2 diff --git a/docs/users_guide/landice/test_groups/greenland.rst b/docs/users_guide/landice/test_groups/greenland.rst index 9ad3f58967..b05ed89b58 100644 --- a/docs/users_guide/landice/test_groups/greenland.rst +++ b/docs/users_guide/landice/test_groups/greenland.rst @@ -84,20 +84,24 @@ The other test cases do not use config options. use_bed = True [greenland] + # Whether to interpolate data (controls run_optional_bespoke_interpolation) + interpolate_data = True # path to directory containing BedMachine and Measures datasets # (default value is for Perlmutter) data_path = /global/cfs/cdirs/fanssie/standard_datasets/GIS_datasets/ + # geojson used to create the cull mask in mesh generation + geojson_filename = greenland_only_outline_45km_buffer_latlon_singlepart.geojson + # filename of the BedMachine thickness and bedTopography dataset # (default value is for Perlmutter) bedmachine_filename = BedMachineGreenland-v6_edits_floodFill_extrap.nc - # filename of the MEASURES ice velocity dataset + # filename of the MEaSUREs ice velocity dataset # (default value is for Perlmutter) measures_filename = greenland_vel_mosaic500_extrap.nc - # projection of optional interpolation source datasets, - # according to the dictionary keys + # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools src_proj = gis-gimp diff --git a/docs/users_guide/landice/test_groups/humboldt.rst b/docs/users_guide/landice/test_groups/humboldt.rst index cd5473f32a..3cb54b3295 100644 --- a/docs/users_guide/landice/test_groups/humboldt.rst +++ b/docs/users_guide/landice/test_groups/humboldt.rst @@ -65,14 +65,24 @@ the mesh generation options are adjusted through the config file. use_dist_to_grounding_line = False use_dist_to_edge = True - # optional bespoke interpolation inputs - # set to None to skip optional BedMachine/MEaSUREs remapping - data_path = None - bedmachine_filename = None - measures_filename = None - - # projection of optional interpolation source datasets, - # according to the dictionary keys + # Whether to interpolate data (controls run_optional_bespoke_interpolation) + interpolate_data = False + # path to directory containing BedMachine and Measures datasets + # (default value is for Perlmutter) + data_path = /global/cfs/cdirs/fanssie/standard_datasets/GIS_datasets/ + + # geojson used to create the cull mask in mesh generation + geojson_filename = greenland_only_outline_45km_buffer_latlon_singlepart.geojson + + # filename of the BedMachine thickness and bedTopography dataset + # (default value is for Perlmutter) + bedmachine_filename = BedMachineGreenland-v6_edits_floodFill_extrap.nc + + # filename of the MEaSUREs ice velocity dataset + # (default value is for Perlmutter) + measures_filename = greenland_vel_mosaic500_extrap.nc + + # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools src_proj = gis-gimp diff --git a/docs/users_guide/landice/test_groups/isunnguata_sermia.rst b/docs/users_guide/landice/test_groups/isunnguata_sermia.rst index d5b77f0d5f..7c89b31b80 100644 --- a/docs/users_guide/landice/test_groups/isunnguata_sermia.rst +++ b/docs/users_guide/landice/test_groups/isunnguata_sermia.rst @@ -69,14 +69,24 @@ the mesh generation options are adjusted through the config file. use_dist_to_edge = False use_bed = False - # optional bespoke interpolation inputs - # set to None to skip optional BedMachine/MEaSUREs remapping - data_path = None - bedmachine_filename = None - measures_filename = None - - # projection of optional interpolation source datasets, - # according to the dictionary keys + # Whether to interpolate data (controls run_optional_bespoke_interpolation) + interpolate_data = False + # path to directory containing BedMachine and Measures datasets + # (default value is for Perlmutter) + data_path = /global/cfs/cdirs/fanssie/standard_datasets/GIS_datasets/ + + # geojson used to create the cull mask in mesh generation + geojson_filename = greenland_only_outline_45km_buffer_latlon_singlepart.geojson + + # filename of the BedMachine thickness and bedTopography dataset + # (default value is for Perlmutter) + bedmachine_filename = BedMachineGreenland-v6_edits_floodFill_extrap.nc + + # filename of the MEaSUREs ice velocity dataset + # (default value is for Perlmutter) + measures_filename = greenland_vel_mosaic500_extrap.nc + + # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools src_proj = gis-gimp diff --git a/docs/users_guide/landice/test_groups/kangerlussuaq.rst b/docs/users_guide/landice/test_groups/kangerlussuaq.rst index 082f6683f2..c5792f8a66 100644 --- a/docs/users_guide/landice/test_groups/kangerlussuaq.rst +++ b/docs/users_guide/landice/test_groups/kangerlussuaq.rst @@ -53,14 +53,24 @@ the mesh generation options are adjusted through the config file. use_dist_to_grounding_line = False use_dist_to_edge = True - # optional bespoke interpolation inputs - # set to None to skip optional BedMachine/MEaSUREs remapping - data_path = None - bedmachine_filename = None - measures_filename = None - - # projection of optional interpolation source datasets, - # according to the dictionary keys + # Whether to interpolate data (controls run_optional_bespoke_interpolation) + interpolate_data = False + # path to directory containing BedMachine and Measures datasets + # (default value is for Perlmutter) + data_path = /global/cfs/cdirs/fanssie/standard_datasets/GIS_datasets/ + + # geojson used to create the cull mask in mesh generation + geojson_filename = greenland_only_outline_45km_buffer_latlon_singlepart.geojson + + # filename of the BedMachine thickness and bedTopography dataset + # (default value is for Perlmutter) + bedmachine_filename = BedMachineGreenland-v6_edits_floodFill_extrap.nc + + # filename of the MEaSUREs ice velocity dataset + # (default value is for Perlmutter) + measures_filename = greenland_vel_mosaic500_extrap.nc + + # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools src_proj = gis-gimp diff --git a/docs/users_guide/landice/test_groups/koge_bugt_s.rst b/docs/users_guide/landice/test_groups/koge_bugt_s.rst index fc6a9de11b..add3037f9c 100644 --- a/docs/users_guide/landice/test_groups/koge_bugt_s.rst +++ b/docs/users_guide/landice/test_groups/koge_bugt_s.rst @@ -53,14 +53,24 @@ the mesh generation options are adjusted through the config file. use_dist_to_grounding_line = False use_dist_to_edge = True - # optional bespoke interpolation inputs - # set to None to skip optional BedMachine/MEaSUREs remapping - data_path = None - bedmachine_filename = None - measures_filename = None - - # projection of optional interpolation source datasets, - # according to the dictionary keys + # Whether to interpolate data (controls run_optional_bespoke_interpolation) + interpolate_data = False + # path to directory containing BedMachine and Measures datasets + # (default value is for Perlmutter) + data_path = /global/cfs/cdirs/fanssie/standard_datasets/GIS_datasets/ + + # geojson used to create the cull mask in mesh generation + geojson_filename = greenland_only_outline_45km_buffer_latlon_singlepart.geojson + + # filename of the BedMachine thickness and bedTopography dataset + # (default value is for Perlmutter) + bedmachine_filename = BedMachineGreenland-v6_edits_floodFill_extrap.nc + + # filename of the MEaSUREs ice velocity dataset + # (default value is for Perlmutter) + measures_filename = greenland_vel_mosaic500_extrap.nc + + # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools src_proj = gis-gimp diff --git a/docs/users_guide/landice/test_groups/thwaites.rst b/docs/users_guide/landice/test_groups/thwaites.rst index 19cbd54692..fefc85e554 100644 --- a/docs/users_guide/landice/test_groups/thwaites.rst +++ b/docs/users_guide/landice/test_groups/thwaites.rst @@ -66,14 +66,21 @@ The other test cases do not use config options. use_dist_to_grounding_line = True use_dist_to_edge = True - # optional bespoke interpolation inputs - # set to None to skip optional BedMachine/MEaSUREs remapping - data_path = None - bedmachine_filename = None - measures_filename = None - - # projection of optional interpolation source datasets, - # according to the dictionary keys + # Whether to interpolate data (controls run_optional_bespoke_interpolation) + interpolate_data = False + # path to directory containing BedMachine and Measures datasets + # (default value is for Perlmutter) + data_path = /global/cfs/cdirs/fanssie/standard_datasets/AIS_datasets + + # filename of the BedMachine thickness and bedTopography dataset + # (default value is for Perlmutter) + bedmachine_filename = BedMachineAntarctica_2020-07-15_v02_edits_floodFill_extrap_fillVostok.nc + + # filename of the MEASURES ice velocity dataset + # (default value is for Perlmutter) + measures_filename = antarctica_ice_velocity_450m_v2_edits_extrap.nc + + # projection of the source datasets, according to the dictionary keys # create_scrip_file_from_planar_rectangular_grid from MPAS_Tools src_proj = ais-bedmap2