Make a lowres domain for DA dev work!#
A typical workflow of utilizing CrocoDash consists of four main steps:
Generate a regional MOM6 domain.
Create the CESM case.
Prepare ocean forcing data.
Build and run the case.
SECTION 1: Generate a regional MOM6 domain#
We begin by defining a regional MOM6 domain using CrocoDash. To do so, we first carve out a subdomain from a 1/12 degree global grid. We then generate the topography by remapping an existing bathymetric dataset to our horizontal grid. Finally, we define a vertical grid.
Step 1.1: Horizontal Grid#
Extract a subgrid from a lowres global grid using the subgrid_from_supergrid
method:
from CrocoDash.grid import Grid
grid = Grid.subgrid_from_supergrid(
path = "<HGRID_221123>", # supergrid
llc = (15, -99), # (l)ower (l)eft (c)orner coords
urc = (30, -80.), # (u)pper (r)ight (c)orner coords
name = "little_nwa12"
)
Step 1.2: Topography#
from CrocoDash.topo import Topo
topo = Topo(
grid = grid,
min_depth = 9.5,
)
bathymetry_path='<GEBCO>'
topo.interpolate_from_file(
file_path = bathymetry_path,
longitude_coordinate_name="lon",
latitude_coordinate_name="lat",
vertical_coordinate_name="elevation"
)
topo.depth.plot()
# Erase Pacific -> Go to Basinmask, Select basin you want to keep (Atlantic), press the erase disconnected basin button to erase the pacific
%matplotlib ipympl
from CrocoDash.topo_editor import TopoEditor
topo.depth["units"] = "m" # Short term bug fix
TopoEditor(topo)
Step 1.3: Vertical Grid#
from CrocoDash.vgrid import VGrid
vgrid = VGrid.hyperbolic(
nk = 75,
depth = topo.max_depth,
ratio=20.0
)
SECTION 2: Create the CESM case#
After generating the MOM6 domain, the next step is to create a CESM case using CrocoDash. This process is straightforward and involves instantiating the CrocoDash Case object. The Case object requires the following inputs:
CESM Source Directory: A local path to a compatible CESM source copy.
Case Name: A unique name for the CESM case.
Input Directory: The directory where all necessary input files will be written.
MOM6 Domain Objects: The horizontal grid, topography, and vertical grid created in the previous section.
Project ID: (Optional) A project ID, if required by the machine.
from pathlib import Path
# CESM case (experiment) name
casename = "little-nwa-three-boundary-t232"
# CESM source root (Update this path accordingly!!!)
cesmroot = "<CESM>"
# Place where all your input files go
inputdir = Path.home() / "croc_input" / casename
# CESM case directory
caseroot = Path.home() / "croc_cases" / casename
Step 2.2: Create the Case#
To create the CESM case, instantiate the Case
object as shown below. This will automatically set up the CESM case based on the provided inputs: The cesmroot
argument specifies the path to your local CESM source directory.
The caseroot
argument defines the directory where the case will be created. CrocoDash will handle all necessary namelist modifications and XML changes to align with the MOM6 domain objects generated earlier.
from CrocoDash.case import Case
case = Case(
cesmroot = cesmroot,
caseroot = caseroot,
inputdir = inputdir,
ocn_grid = grid,
ocn_vgrid = vgrid,
ocn_topo = topo,
project = 'NCGD0011',
override = True,
ninst = 2,
)
Section 3: Prepare ocean forcing data#
We need to cut out our ocean forcing. The package expects an initial condition and one time-dependent segment per non-land boundary. Naming convention is "east_unprocessed"
for segments and "ic_unprocessed"
for the initial condition.
In this notebook, we are forcing with the Copernicus Marine “Glorys” reanalysis dataset. There’s a function in the CrocoDash
package, called configure_forcings
, that generates a bash script to download the correct boundary forcing files for your experiment. First, you will need to create an account with Copernicus, and then call copernicusmarine login
to set up your login details on your machine. Then you can run the get_glorys_data.sh
bash script.
Step 3.1 Configure Initial Conditions and Forcings#
case.configure_forcings(
date_range = ["2020-01-01 00:00:00", "2020-02-01 00:00:00"],
boundaries = ["south", "north","east"],
)
Step 3.2 Run get_glorys_data.sh
#
In a terminal session, locate the get_glorys_data.sh
script and execute it to download the initial conditions and boundary conditions. Follow the instructions printed by the configure_forcings
method above.
TODO: user copernicusmarine python API within CrocoDash, instead of directing users to run it via CLI. Also, on a derecho login node, both CLI and API fails to run due to the computational demand. We also need to address that.
Step 3.3: Process forcing data#
In this final step, we call the process_forcings
method of CrocoDash to cut out and interpolate the initial condition as well as all boundaries. CrocoDash also updates MOM6 runtime parameters and CESM xml variables accordingly.
case.process_forcings()
# Because this case is so small, AFTER CREATING THE CASE, we change NTASKS to be 4 instead of the default of 128.
from visualCaseGen.custom_widget_types.case_tools import xmlchange
xmlchange("NTASKS", "4")
Section 4: Build and run the case#
After completing the previous steps, you are ready to build and run your CESM case. Begin by navigating to the case root directory specified during the case creation. Before proceeding, review the user_nl_mom
file located in the case directory. This file contains MOM6 parameter settings that were automatically generated by CrocoDash. Carefully examine these parameters and make any necessary adjustments to fine-tune the model for your specific requirements. While CrocoDash aims to provide a solid starting point, further tuning and adjustments are typically necessary to improve the model for your use case.
Once you have reviewed and modified the parameters as needed, you can prepare, build, and execute the case using the following commands:
./case.setup
./case.build
./case.submit