Feature Masks

The polaris.tasks.mesh.spherical.feature_masks package provides the model-neutral implementation for creating region or transect masks on standard MPAS meshes.

The mesh component owns only standard MPAS behavior:

The mesh package must not contain Omega-specific translation. Ocean-native input support lives in polaris.tasks.ocean.feature_masks, where polaris.tasks.ocean.feature_masks.ComputeOceanFeatureMasksStep subclasses the mesh step and overrides mesh opening and mask writing through the ocean component’s native I/O translation. See Feature Masks.

Shared Steps

Use polaris.tasks.mesh.spherical.feature_masks.get_feature_mask_steps() when another mesh workflow already has an upstream mesh-producing step. The caller provides:

  • mesh_name, used for output filenames and metadata;

  • mask_group, passed to get_aggregator_by_name();

  • mesh_step and mesh_filename, when the mesh is produced by another step.

The shared step does not special-case base meshes or culled meshes. Workflows such as E3SM init should pass the relevant upstream step and filename explicitly.

Implementation Map

polaris.tasks.mesh.spherical.feature_masks.FeatureMasksTask registers the configurable task at mesh/spherical/feature_masks/configurable.

polaris.tasks.mesh.spherical.feature_masks.build_mask_feature_collection() uses geometric_features.get_aggregator_by_name() to build the feature collection and return the filename prefix and date stamp.

polaris.tasks.mesh.spherical.feature_masks.get_feature_object_type() validates that the collection contains only regions or only transects.

polaris.tasks.mesh.spherical.feature_masks.compute_feature_masks() dispatches to mpas_tools.mesh.mask.compute_mpas_region_masks() or mpas_tools.mesh.mask.compute_mpas_transect_masks().

MOC Helpers

polaris.tasks.mesh.spherical.feature_masks.moc is a leaf module holding the two pieces of 'MOC Basins' behavior that are not specific to any model:

The module also defines MOC_MASK_GROUP ('MOC Basins') and MOC_PREFIX ('mocBasinsAndTransects').

Neither helper needs a step, and neither touches an ocean model: they operate on standard MPAS meshes and masks. mpas_tools.ocean.moc is a plain mpas_tools module, so importing it does not pull in polaris.tasks.ocean or require an [ocean] config section. That is what lets a step in another component — for example the e3sm/init component_inputs staging of the per-mesh MOC file that MPAS-Ocean reads through its regionalMasksInput and transectMasksInput streams — subclass the model-neutral polaris.tasks.mesh.spherical.feature_masks.ComputeFeatureMasksStep and call the same two functions.

polaris.tasks.ocean.feature_masks.ComputeOceanFeatureMasksStep delegates to these helpers rather than implementing the behavior itself, so the MOC logic lives in exactly one place. See Feature Masks.

Testing

Unit tests cover object-type detection, mask-type validation, shared-step configuration, configurable setup, output metadata, the MOC helpers (including that importing the moc module does not import polaris.tasks.ocean), and the ocean subclass’s Omega-name translation boundary.