pyissm.model.param

Functions for parameterising ISSM models.

Functions

contour_envelope(mh[, flags])

Build a set of segments enveloping a contour. This function computes segments that form the boundary envelope of a contour within a given mesh. It identifies elements on the domain boundary and extracts the segments that define the contour envelope. :type mh: ISSM model mesh object containing vertex and element information. :param mh: :type mh: ISSM model mesh object containing vertex and element information. :type flags: {str, int, float, bool}, optional :param flags: Currently not supported. Reserved for future use. If provided, raises NotImplementedError. Default is None. :type flags: {str, int, float, bool}, optional.

kill_icebergs(md)

Remove isolated floating ice patches (icebergs) by setting their ice_levelset values to +1.

parameterize(md, parameter_file)

Parameterize an ISSM model from a Python parameter file.

reinitialize_levelset(md, levelset)

Reinitialize a levelset field using the ExpToLevelSet backend.

set_flow_equation(md[, SIA, SSA, HO, L1L2, ...])

Set flow equation for model

set_mask(md[, floating_ice_name, ...])

Set the mask of a model based on a floating ice region and a grounded ice region.

pyissm.model.param.contour_envelope(mh, flags=None)

Build a set of segments enveloping a contour. This function computes segments that form the boundary envelope of a contour within a given mesh. It identifies elements on the domain boundary and extracts the segments that define the contour envelope. :type mh: ISSM model mesh object containing vertex and element information. :param mh: :type mh: ISSM model mesh object containing vertex and element information. :type flags: {str, int, float, bool}, optional :param flags: Currently not supported. Reserved for future use. If provided, raises

NotImplementedError. Default is None.

Returns:

segments – Array of shape (n_segments, 3) containing segment information where: - Column 0: First node index of the segment - Column 1: Second node index of the segment - Column 2: Associated element index (1-indexed)

Return type:

ndarray

Raises:
  • NotImplementedError – If flags argument is provided (not yet supported).

  • ImportError – If ISSM wrappers are not installed.

Notes

This function requires ISSM wrappers to be installed. It computes node and element connectivity tables and identifies boundary elements that separate interior from exterior regions.

Examples

>>> segments = contour_envelope(mh)
pyissm.model.param.kill_icebergs(md)

Remove isolated floating ice patches (icebergs) by setting their ice_levelset values to +1.

Parameters:

md (ISSM model object) – The model containing the mesh and mask information.

Returns:

Modified ice_levelset array with isolated icebergs set to +1. If no icebergs are found, returns a copy of the original ice_levelset.

Return type:

ndarray

Notes

The algorithm works in three main steps:

  1. Mark elements without ice as done

  2. Initialize mask from grounded ice elements

  3. Use flood-fill algorithm to propagate connectivity from grounded ice through floating ice patches

  4. Set vertices that remain unconnected and have ice to +1 (removing icebergs)

Isolated floating ice patches are identified as ice vertices that cannot be reached through the flood-fill algorithm starting from grounded ice regions.

pyissm.model.param.parameterize(md, parameter_file)

Parameterize an ISSM model from a Python parameter file.

Parameters:
  • md (object) – ISSM model instance to populate. The parameter file is expected to mutate this object in-place and may refer to it as md.

  • parameter_file (str or pathlib.Path) – Path to a Python file containing parameter-setting code. This file is executed with an empty global namespace and a local namespace where md is pre-defined.

Returns:

The modified model instance (same object passed in).

Return type:

object

Raises:
  • FileNotFoundError – If the provided parameter_file does not exist.

  • Exception – Any exception raised while executing the parameter file is propagated.

Notes

The parameter file must be a valid Python script that assigns values or calls functions that modify the provided md object. For security, be cautious when executing untrusted parameter files since they are run with exec() and may perform arbitrary operations.

Examples

>>> parameterize(md, "parameters.py")
pyissm.model.param.reinitialize_levelset(md, levelset)

Reinitialize a levelset field using the ExpToLevelSet backend. This function takes a levelset field defined on the vertices of the mesh and reinitializes it to be a signed distance function using the ExpToLevelSet backend. The zero level of the resulting field is the original levelset contour.

Parameters:
  • md (ISSM model object) – The model containing the mesh information.

  • levelset (array-like) – The levelset field to reinitialize, defined at the vertices of the mesh. For 3D meshes, this should be defined at the 2D vertices.

Returns:

  • ndarray (The reinitialized levelset field, with the same shape as the input levelset. The zero level of this field corresponds to the original levelset contour, and the values represent the signed distance to)

  • the contour (negative inside, positive outside).

pyissm.model.param.set_flow_equation(md, SIA=None, SSA=None, HO=None, L1L2=None, MOLHO=None, FS=None, fill=None, coupling='tiling', **kwargs)

Set flow equation for model

pyissm.model.param.set_mask(md, floating_ice_name=None, grounded_ice_name='all', ice_domain=None, **kwargs)

Set the mask of a model based on a floating ice region and a grounded ice region.

Parameters:
  • md (ISSM model object) – The model to set the mask on.

  • floating_ice_name (str, optional) – The name of the floating ice region. Default is ‘’, which means no floating ice region is set.

  • grounded_ice_name (str, optional) – The name of the grounded ice region. Default is ‘all’, which means all grounded ice is set.

  • ice_domain (str, optional) – Path to file defining the ice domain contour. If provided, used to define the ice levelset field. Default is None.

  • **kwargs (dict) – Additional keyword arguments to pass to the flag_elements function.

Returns:

The modified model with updated mask fields.

Return type:

model

Raises:

FileNotFoundError – If ice_domain file path is provided but the file does not exist.