|
| 1 | +# Topography Tasks |
| 2 | + |
| 3 | +The `polaris.tasks.e3sm.init.topo` module provides tools for working with |
| 4 | +topography data in Polaris. This includes steps for processing, modifying, and |
| 5 | +combining topography datasets to create inputs for E3SM components such as |
| 6 | +MPAS-Ocean. The framework is designed to handle both global and regional |
| 7 | +datasets, supporting various grid types like lat-lon and cubed-sphere grids. |
| 8 | + |
| 9 | +## Combine Steps and Task |
| 10 | + |
| 11 | +```{image} images/bathymetry_500.png |
| 12 | +:align: center |
| 13 | +:width: 500 px |
| 14 | +``` |
| 15 | + |
| 16 | +Global bathymetry datasets do not typically include the latest datasets around |
| 17 | +Antarctica needed for ice-sheet and ice-shelf modeling. For this reason, we |
| 18 | +typically combine a global topography dataset north of the Southern Ocean with |
| 19 | +one for Antarctica. |
| 20 | + |
| 21 | +```{note} |
| 22 | +At the moment, the step for combining these datasets provides fields that are |
| 23 | +masked to locations where the bed topography (bathymetry) is below sea level. |
| 24 | +This avoids the risk of interpolated topography resulting in a bed that is |
| 25 | +above sea level in ocean regions when we perform further interpolation of |
| 26 | +the data to an MPAS mesh. However, a more general topogrpahy data set will |
| 27 | +likely be needed in the future that accommodates both the ocean and land/river |
| 28 | +components. |
| 29 | +``` |
| 30 | + |
| 31 | +The {py:class}`polaris.tasks.e3sm.init.topo.combine.CombineStep` step is a key |
| 32 | +component of the topography framework. It is responsible for combining global |
| 33 | +and Antarctic topography datasets into a single dataset suitable for use in |
| 34 | +E3SM simulations. The step supports blending datasets across specified latitude |
| 35 | +ranges and remapping them to a target grid. |
| 36 | + |
| 37 | +The {py:class}`polaris.tasks.e3sm.init.topo.combine.CombineTask` wraps the |
| 38 | +`CombineStep` into a task that can be used to generate and cache combined |
| 39 | +topography datasets for reuse in other contexts. |
| 40 | + |
| 41 | +The {py:class}`polaris.tasks.e3sm.init.topo.combine.VizCombinedStep` step is |
| 42 | +an optional visualization step that can be added to the workflow to create |
| 43 | +plots of the combined topography dataset. This step is particularly useful for |
| 44 | +debugging or analyzing the combined dataset. |
| 45 | + |
| 46 | +### Key Features |
| 47 | + |
| 48 | +- **Dataset Support**: Supports multiple datasets, including `bedmap3`, |
| 49 | + `bedmachinev3`, and `gebco2023`. |
| 50 | +- **Grid Types**: Handles both lat-lon and cubed-sphere target grids. |
| 51 | +- **Blending**: Blends global and Antarctic datasets across a configurable |
| 52 | + latitude range. |
| 53 | +- **Remapping**: Uses tools like `mbtempest`, `ESMF_RegridWeightGen` and |
| 54 | + `ncremap` for remapping datasets to the target grid. |
| 55 | +- **Output**: Produces combined topography datasets with consistent variables |
| 56 | + and attributes. |
| 57 | +- **Visualization**: Generates rasterized images of various fields (e.g., |
| 58 | + bathymetry, ice draft) using the `datashader` library. |
| 59 | + |
| 60 | +### Configuration Options |
| 61 | + |
| 62 | +The `CombineStep` step is configured through the `[combine_topo]` section in |
| 63 | +the configuration file. Key options include: |
| 64 | + |
| 65 | +- `resolution_latlon`: Target resolution for lat-lon grids (in degrees). |
| 66 | +- `resolution_cubedsphere`: Target resolution for cubed-sphere grids (e.g., |
| 67 | + `3000` for NExxx grids). |
| 68 | +- `latmin` and `latmax`: Latitude range for blending datasets. |
| 69 | +- `ntasks` and `min_tasks`: Number of MPI tasks for remapping. |
| 70 | +- `method`: Remapping method (e.g., `bilinear`). |
| 71 | + |
| 72 | +### Workflow |
| 73 | + |
| 74 | +1. **Setup**: The step downloads required datasets and sets up input/output |
| 75 | + files. |
| 76 | +2. **Modification**: Antarctic and global datasets are modified to include |
| 77 | + necessary variables and attributes. |
| 78 | +3. **Remapping**: Datasets are remapped to the target grid using SCRIP files |
| 79 | + and weight generation. |
| 80 | +4. **Blending**: The datasets are blended across the specified latitude range. |
| 81 | +5. **Output**: The combined dataset is saved in NetCDF format. |
| 82 | +8. **Optional Field Plotting**: Each field in the dataset is rasterized and saved as an image with a colorbar. |
| 83 | + |
| 84 | +### Example Usage |
| 85 | + |
| 86 | +Below is an example of how the `CombineStep` can be added to a Polaris |
| 87 | +task: |
| 88 | + |
| 89 | +```python |
| 90 | +from polaris.tasks.e3sm.init.topo.combine import CombineStep |
| 91 | + |
| 92 | + |
| 93 | +component = task.component |
| 94 | +subdir = CombineStep.get_subdir() |
| 95 | +if subdir in component.steps: |
| 96 | + step = component.steps[subdir] |
| 97 | +else: |
| 98 | + step = CombineStep(component=component) |
| 99 | + component.add_step(step) |
| 100 | +task.add_step(step) |
| 101 | +``` |
| 102 | + |
| 103 | +To create a `CombineTask` for caching combined datasets: |
| 104 | + |
| 105 | +```python |
| 106 | +from polaris.tasks.e3sm.init.topo.combine import CombineTask |
| 107 | + |
| 108 | +combine_task = CombineTask(component=my_component) |
| 109 | +my_component.add_task(combine_task) |
| 110 | +``` |
| 111 | + |
| 112 | +Below is an example of how the `VizCombinedStep` can be added to a Polaris task: |
| 113 | + |
| 114 | +```python |
| 115 | +from polaris.tasks.e3sm.init.topo.combine import VizCombinedStep |
| 116 | + |
| 117 | +viz_step = VizCombinedStep(component=my_component, combine_step=combine_step) |
| 118 | +my_component.add_step(viz_step) |
| 119 | +``` |
| 120 | + |
| 121 | +Since there is a single shared step for each pair of Antarctic and global |
| 122 | +datasets, the step should be added only once to the component and the existing |
| 123 | +step (identifiable via its `subdir`) should be used subsequently. |
| 124 | + |
| 125 | +The `VizCombinedStep` is typically added only when visualization is explicitly required, as it is not part of the default workflow. |
| 126 | + |
| 127 | +For more details, refer to the source code of the |
| 128 | +{py:class}`polaris.tasks.e3sm.init.topo.combine.CombineStep` and |
| 129 | +{py:class}`polaris.tasks.e3sm.init.topo.combine.CombineTask` classes. |
| 130 | + |
| 131 | +```{note} |
| 132 | +Since this step is expensive and time-consuming to run, most tasks will |
| 133 | +want to use cached outputs from this step rather than running it in full. |
| 134 | +``` |
0 commit comments