Skip to content

Commit

Permalink
Merge pull request #756 from trhille/landice/add_crane_glacier_mesh
Browse files Browse the repository at this point in the history
Add Crane Glacier mesh generation

This merge adds a Crane Glacier test group with a mesh generation test case.
  • Loading branch information
matthewhoffman authored Feb 5, 2024
2 parents a1b433d + a5e3193 commit 1eea50e
Show file tree
Hide file tree
Showing 13 changed files with 305 additions and 2 deletions.
2 changes: 2 additions & 0 deletions compass/landice/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from compass.landice.tests.antarctica import Antarctica
from compass.landice.tests.calving_dt_convergence import CalvingDtConvergence
from compass.landice.tests.circular_shelf import CircularShelf
from compass.landice.tests.crane import Crane
from compass.landice.tests.dome import Dome
from compass.landice.tests.eismint2 import Eismint2
from compass.landice.tests.ensemble_generator import EnsembleGenerator
Expand Down Expand Up @@ -31,6 +32,7 @@ def __init__(self):
self.add_test_group(Antarctica(mpas_core=self))
self.add_test_group(CalvingDtConvergence(mpas_core=self))
self.add_test_group(CircularShelf(mpas_core=self))
self.add_test_group(Crane(mpas_core=self))
self.add_test_group(Dome(mpas_core=self))
self.add_test_group(Eismint2(mpas_core=self))
self.add_test_group(EnsembleGenerator(mpas_core=self))
Expand Down
8 changes: 8 additions & 0 deletions compass/landice/tests/crane/Crane.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "crane",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "name": "Crane", "tags": "Crane", "object": "region", "component": "landice", "author": "https://nsidc.org/data/nsidc-0709/versions/2" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -62.711133639719051, -65.201690711497449 ], [ -62.670350055324924, -65.222528990830909 ], [ -62.603459729541953, -65.242580535851928 ], [ -62.572933915847166, -65.263459838062047 ], [ -62.5447479615612, -65.280135328846143 ], [ -62.526497752286581, -65.28953644693928 ], [ -62.505122164004312, -65.302192318858971 ], [ -62.485513843643858, -65.307365058584693 ], [ -62.456050254898265, -65.306845472030545 ], [ -62.416719886631014, -65.301407479922261 ], [ -62.325208704931725, -65.295492600965616 ], [ -62.335693172886117, -65.281896177745708 ], [ -62.317445266252619, -65.267199412520284 ], [ -62.298527185097853, -65.256186534513901 ], [ -62.270881390790265, -65.25997099550591 ], [ -62.243281563118522, -65.273087823873411 ], [ -62.224460224612052, -65.281283149356511 ], [ -62.207546873139194, -65.287430270161053 ], [ -62.190867321049865, -65.293903404053424 ], [ -62.156665341547331, -65.292936788753778 ], [ -62.098387196049593, -65.288693547437447 ], [ -62.007252795520166, -65.281089453867637 ], [ -62.018859863281264, -65.375587463378082 ], [ -62.016600511940915, -65.379978412162856 ], [ -62.077136087381596, -65.380590210127849 ], [ -62.145699215470813, -65.372818470998254 ], [ -62.167281294498281, -65.375205553640882 ], [ -62.222861066440238, -65.371647482909793 ], [ -62.291680881779712, -65.372550024011389 ], [ -62.345048311349345, -65.367675194569742 ], [ -62.390573553751047, -65.370527255810515 ], [ -62.461664445041194, -65.389161881004426 ], [ -62.514312160790922, -65.402953390636739 ], [ -62.56636193602624, -65.414222755333114 ], [ -62.659506325283054, -65.431956710379481 ], [ -62.737637116748708, -65.454237931998676 ], [ -62.805918071586682, -65.482698633184754 ], [ -62.811183455537751, -65.484889234346724 ], [ -62.867708260649586, -65.511061365188823 ], [ -62.885804488291811, -65.542376342806179 ], [ -62.886691630407086, -65.569250665285935 ], [ -62.890670180308163, -65.576005754891469 ], [ -62.89831926564306, -65.588982307100196 ], [ -62.900773458184162, -65.589992247734628 ], [ -62.929764097326832, -65.601912856045203 ], [ -63.002567564209123, -65.629035378321959 ], [ -63.126602388643924, -65.631554288838103 ], [ -63.236318220802865, -65.63019217813239 ], [ -63.303819000409725, -65.599646937653191 ], [ -63.34925965578536, -65.569997824340518 ], [ -63.365154289162966, -65.55375966578741 ], [ -63.385548345064301, -65.53767854182712 ], [ -63.388604133476498, -65.516436113569014 ], [ -63.322626984854296, -65.457362380394201 ], [ -63.293553165044756, -65.420795970865555 ], [ -63.263005675425205, -65.393281566591043 ], [ -63.22118042805085, -65.379796313503746 ], [ -63.189035571735126, -65.375371224505727 ], [ -63.092184036117075, -65.343941847844178 ], [ -63.057623964387204, -65.307638195868762 ], [ -62.98940255786006, -65.283710009963457 ], [ -62.912046122160845, -65.275008725259099 ], [ -62.889459667642733, -65.25213604170456 ], [ -62.861455853629565, -65.239849619201379 ], [ -62.848620556551481, -65.21727944406112 ], [ -62.711133639719051, -65.201690711497449 ] ] ] } }
]
}
16 changes: 16 additions & 0 deletions compass/landice/tests/crane/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from compass.landice.tests.crane.mesh_gen import MeshGen
from compass.testgroup import TestGroup


class Crane(TestGroup):
"""
A test group for Crane Glacier test cases.
"""
def __init__(self, mpas_core):
"""
mpas_core : compass.landice.Landice
the MPAS core that this test group belongs to
"""
super().__init__(mpas_core=mpas_core, name='crane')

self.add_test_case(MeshGen(test_group=self))
59 changes: 59 additions & 0 deletions compass/landice/tests/crane/mesh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from compass.landice.mesh import build_cell_width, build_mali_mesh
from compass.model import make_graph_file
from compass.step import Step


class Mesh(Step):
"""
A step for creating a mesh and initial condition for thwaites test cases
"""
def __init__(self, test_case):
"""
Create the step
Parameters
----------
test_case : compass.TestCase
The test case this step belongs to
"""
super().__init__(test_case=test_case, name='mesh', cpus_per_task=128,
min_cpus_per_task=1)

self.add_output_file(filename='graph.info')
self.add_output_file(filename='Crane.nc')
self.add_input_file(filename='antarctica_8km_2024_01_29.nc',
target='antarctica_8km_2024_01_29.nc',
database='')
self.add_input_file(filename='Crane.geojson',
package='compass.landice.tests.crane',
target='Crane.geojson',
database=None)
self.add_input_file(filename='antarctica_1km_2024_01_29_AP.nc',
target='antarctica_1km_2024_01_29_AP.nc',
database='')

# no setup() method is needed

def run(self):
"""
Run this step of the test case
"""
logger = self.logger
mesh_name = 'Crane.nc'
section_name = 'mesh'

logger.info('calling build_cell_width')
cell_width, x1, y1, geom_points, geom_edges, floodMask = \
build_cell_width(
self, section_name=section_name,
gridded_dataset='antarctica_8km_2024_01_29.nc')

build_mali_mesh(
self, cell_width, x1, y1, geom_points, geom_edges,
mesh_name=mesh_name, section_name=section_name,
gridded_dataset='antarctica_1km_2024_01_29_AP.nc',
projection='ais-bedmap2', geojson_file='Crane.geojson',
cores=self.cpus_per_task)

logger.info('creating graph.info')
make_graph_file(mesh_filename=mesh_name,
graph_filename='graph.info')
39 changes: 39 additions & 0 deletions compass/landice/tests/crane/mesh_gen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from compass.landice.tests.crane.mesh import Mesh
from compass.testcase import TestCase
from compass.validate import compare_variables


class MeshGen(TestCase):
"""
The high resolution test case for the crane test
group simply creates the mesh and initial condition.
The basal friction optimization occurs separately,
outside of COMPASS.
"""

def __init__(self, test_group):
"""
Create the test case
Parameters
----------
test_group : compass.landice.tests.crane.Crane
The test group that this test case belongs to
"""
name = 'mesh_gen'
subdir = name
super().__init__(test_group=test_group, name=name,
subdir=subdir)

self.add_step(
Mesh(test_case=self))

def validate(self):
"""
Compare ``thickness``, ``bedTopography``, ``iceMask`` and
``beta`` with a baseline if one was provided.
"""
variables = ['thickness', 'bedTopography', 'iceMask',
'beta']
compare_variables(test_case=self, variables=variables,
filename1='mesh/Crane.nc')
48 changes: 48 additions & 0 deletions compass/landice/tests/crane/mesh_gen/mesh_gen.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# config options for mesh_gen test case
[mesh]

# number of levels in the mesh
levels = 10

# Bounds of Crane regional mesh
x_min = -2.442e6
x_max = -2.246e6
y_min = 1.124e6
y_max = 1.334e6

# distance from ice margin to cull (km).
# Set to a value <= 0 if you do not want
# to cull based on distance from margin.
cull_distance = -1.0

# mesh density parameters
# minimum cell spacing (meters)
min_spac = 5.e2
# maximum cell spacing (meters)
max_spac = 1.e3
# log10 of max speed for cell spacing
high_log_speed = 2.5
# log10 of min speed for cell spacing
low_log_speed = 0.75
# distance at which cell spacing = max_spac
high_dist = 1.e5
# distance within which cell spacing = min_spac
low_dist = 5.e4

# mesh density parameters used if use_bed = True
# These settings are taken from the Humboldt mesh
# and have not yet been evaluated for Crane.
# distance at which bed topography has no effect
high_dist_bed = 1.e5
# distance within which bed topography has maximum effect
low_dist_bed = 5.e4
# Bed elev beneath which cell spacing is minimized
low_bed = 50.0
# Bed elev above which cell spacing is maximized
high_bed = 100.0

# mesh density functions
use_speed = True
use_dist_to_grounding_line = True
use_dist_to_edge = False
use_bed = False
17 changes: 17 additions & 0 deletions docs/developers_guide/landice/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ circular_shelf
visualize.visualize_circular_shelf


crane
~~~~

.. currentmodule:: compass.landice.tests.crane

.. autosummary::
:toctree: generated/

Crane

mesh_gen.MeshGen
mesh_gen.MeshGen.run

mesh.Mesh
mesh.Mesh.run


dome
~~~~

Expand Down
4 changes: 2 additions & 2 deletions docs/developers_guide/landice/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ mesh

The landice framework module :py:mod:`compass.landice.mesh` provides functions
used by all ``mesh_gen`` tests cases, which currently exist within the
``antarctica``, ``greenland``, ``humboldt``, ``kangerlussuaq``, ``koge_bugt_s``,
and ``thwaites`` test groups. These functions include:
``antarctica``, ``crane``, ``greenland``, ``humboldt``, ``kangerlussuaq``,
``koge_bugt_s``, and ``thwaites`` test groups. These functions include:

:py:func:`compass.landice.mesh.gridded_flood_fill()` applies a flood-fill algorithm
to the gridded dataset in order to separate the ice sheet from peripheral ice.
Expand Down
30 changes: 30 additions & 0 deletions docs/developers_guide/landice/test_groups/crane.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. _dev_landice_crane:

crane
=============

The ``crane`` test group (:py:class:`compass.landice.tests.crane.Crane`)
creates a variable resolution (default 500 m - 1 km) mesh for a regional domain of Crane Glacier
(see :ref:`landice_crane`).

.. _dev_landice_crane_framework:

framework
---------

The shared config options for the ``crane`` test group are described
in :ref:`landice_crane` in the User's Guide.

mesh
~~~~

The class :py:class:`compass.landice.tests.crane.mesh.Mesh`
defines a step for creating a variable resolution Crane Glacier mesh.
This is used by the ``mesh_gen`` test case.

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.
1 change: 1 addition & 0 deletions docs/developers_guide/landice/test_groups/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Test groups
antarctica
calving_dt_convergence
circular_shelf
crane
dome
ensemble_generator
enthalpy_benchmark
Expand Down
82 changes: 82 additions & 0 deletions docs/users_guide/landice/test_groups/crane.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
.. _landice_crane:

crane
=============

The ``landice/crane`` test group includes a test case for creating a
mesh for Crane Glacier, Antarctica. The optimization for basal friction
happens outside of COMPASS because it requires expert usage and takes a
larger amount of computing resources than COMPASS is typically run with.

.. figure:: images/crane_500mto1km.png
:width: 777 px
:align: center

Bed topography in meters above sea level on Crane 500m-1km mesh.

The test group includes a single test case that creates the variable resolution mesh.

config options
--------------

The test group uses the following default config options. At this point only
the mesh generation options are adjusted through the config file.

.. code-block:: cfg
# config options for mesh_gen test case
[mesh]
# number of levels in the mesh
levels = 10
# Bounds of Crane regional mesh
x_min = -2.442e6
x_max = -2.246e6
y_min = 1.124e6
y_max = 1.334e6
# distance from ice margin to cull (km).
# Set to a value <= 0 if you do not want
# to cull based on distance from margin.
cull_distance = -1.0
# mesh density parameters
# minimum cell spacing (meters)
min_spac = 5.e2
# maximum cell spacing (meters)
max_spac = 1.e3
# log10 of max speed for cell spacing
high_log_speed = 2.5
# log10 of min speed for cell spacing
low_log_speed = 0.75
# distance at which cell spacing = max_spac
high_dist = 1.e5
# distance within which cell spacing = min_spac
low_dist = 5.e4
# mesh density parameters used if use_bed = True
# These settings are taken from the Humboldt mesh
# and have not yet been evaluated for Crane.
# distance at which bed topography has no effect
high_dist_bed = 1.e5
# distance within which bed topography has maximum effect
low_dist_bed = 5.e4
# Bed elev beneath which cell spacing is minimized
low_bed = 50.0
# Bed elev above which cell spacing is maximized
high_bed = 100.0
# mesh density functions
use_speed = True
use_dist_to_grounding_line = True
use_dist_to_edge = False
use_bed = False
mesh_gen
--------

``landice/crane/default`` creates a variable resolution mesh.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/users_guide/landice/test_groups/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ physics but that are not run routinely.
antarctica
calving_dt_convergence
circular_shelf
crane
dome
eismint2
ensemble_generator
Expand Down

0 comments on commit 1eea50e

Please sign in to comment.