{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": "# Modify existing MOM6 grid" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Import Modules" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%%capture\n", "\n", "from mom6_forge.grid import Grid\n", "from mom6_forge.topo import Topo" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. Create a MOM6 grid object from an existing supergrid\n", "\n", "tx2_3v2 is the current MOM6-CESM workhorse grid (0.66deg, tripolar)." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "grid = Grid.from_supergrid('/glade/p/cesmdata/inputdata/ocn/mom/tx2_3v2/ocean_hgrid_221123.nc')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3. Read the bathymetry" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "topo = Topo.from_topo_file(grid, '/glade/p/cesmdata/inputdata/ocn/mom/tx2_3v2/ocean_topog_230413.nc')" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "## 4. Modify Depth" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e80c474148ed4c098408ca4032408d15", "version_major": 2, "version_minor": 0 }, "text/plain": [ "TopoEditor(children=(VBox(children=(HTML(value='

Topo Editor

'), VBox(children=(VBox(children=(HTML(val…" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%matplotlib ipympl\n", "from mom6_forge.topo_editor import TopoEditor\n", "TopoEditor(topo)" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "## 5. Save the grid and bathymetry files" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# MOM6 supergrid file:\n", "grid.write_supergrid(\"./ocean_hgrid_t232_modified.nc\")\n", "\n", "# MOM6 topography file:\n", "topo.write_topo(\"./ocean_topog_t232_modified.nc\")\n", "\n", "# CICE grid file:\n", "topo.write_cice_grid(\"./cice_grid_t232_modified.nc\")\n", "\n", "# SCRIP grid file (for runoff remapping, if needed):\n", "topo.write_scrip_grid(\"./scrip_grid_t232_modified.nc\")\n", "\n", "# ESMF mesh file:\n", "topo.write_esmf_mesh(\"./ESMF_mesh_t232_modified.nc\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:mom6_forge]", "language": "python", "name": "conda-env-mom6_forge-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.15" } }, "nbformat": 4, "nbformat_minor": 4 }