Diag table generation#

/glade/scratch/gmarques/gmom.e23.GJRAv4.TL319_t061_hycom1_N75.nuopc.baseline.002/run/diag_table

https://mom6.readthedocs.io/en/main/api/generated/pages/Diagnostics.html#title-section

Clone using

/glade/work/gmarques/cesm.sandboxes/cesm2_3_beta08/cime/scripts/create_clone --case gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.002.mixpods --clone gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.001.mixpods
  1. 001 - “default”

  2. 002 - with ri_grad_shear, ri_grad_shear_smooth saved

  3. 003 - KPP defaults branch run with ri_grad_shear

  4. 004 - KPP + PP81

  5. kpp.pp81 - KPP + PP81

  6. epbl.001 - epbl

  7. lmd.002 - KPP with Ri_0 = 0.5

  8. lmd.003 - KPP with Ri_c = 0.2, Ri_0=0.5

  9. lmd.004 - KPP with nu_0=2.5e-3, Ri_c = 0.2, Ri_0=0.5

  10. lmd.005 - KPP with nu_0=2.5e-3, Ri_c = 0.2, Ri_0=0.5, KD=0, KV=0

TODO#

  1. look into ePBL outputs

  2. Add nice padding

  3. add frequency structure

import dataclasses

import cf_xarray  # noqa
import matplotlib.pyplot as plt
import numpy as np

import xarray as xr
casename = "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb"
prefix = f"{casename}.mom6"
source = "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.001.mixpods"

geometry = xr.open_dataset(
    f"/glade/campaign/cgd/oce/projects/pump/cesm/{source}/run/ocean_geometry.nc"
)
geometry
<xarray.Dataset>
Dimensions:  (lath: 458, lonh: 540, latq: 458, lonq: 540)
Coordinates:
  * lath     (lath) float64 -79.2 -79.08 -78.95 -78.82 ... 87.64 87.71 87.74
  * lonh     (lonh) float64 -286.7 -286.0 -285.3 -284.7 ... 71.33 72.0 72.67
  * latq     (latq) float64 -79.14 -79.01 -78.89 -78.76 ... 87.68 87.73 87.74
  * lonq     (lonq) float64 -286.3 -285.7 -285.0 -284.3 ... 71.67 72.33 73.0
Data variables: (12/19)
    geolatb  (latq, lonq) float64 ...
    geolonb  (latq, lonq) float64 ...
    geolat   (lath, lonh) float64 ...
    geolon   (lath, lonh) float64 ...
    D        (lath, lonh) float64 ...
    f        (latq, lonq) float64 ...
    ...       ...
    dyBu     (latq, lonq) float64 ...
    Ah       (lath, lonh) float64 ...
    Aq       (latq, lonq) float64 ...
    dxCvo    (latq, lonh) float64 ...
    dyCuo    (lath, lonq) float64 ...
    wet      (lath, lonh) float64 ...
Attributes:
    filename:  ./ocean_geometry.nc
Keith Lindsay3:16 PM
KPP_NLT_temp_budget
Gustavo Marques3:18 PM
https://github.com/raphaeldussin/om4labs/tree/master/om4labs/diags/surface_wmt
Keith Lindsay3:21 PM
T_lbdxy_cont_tendency
Gustavo Marques3:21 PM
T_lbd_diffx
Gustavo Marques3:26 PM
opottemppmdiff
class DiagTable:
    def __init__(
        self,
        casename,
    ):
        self.casename = casename
        self.files = []

    def add_file():
        pass

    def add_diags(self, fileid, variables, frequency, region="none"):
        pass

"file_name",  output_freq,  "output_freq_units",  file_format,  "time_axis_units",  "time_axis_name"

header = f'"MOM6 diagnostic fields table for CESM case: {casename}"'

header = header + (
    """
1 1 1 0 0 0
### Section-1: File List
#========================
"{casename}.hm%4yr-%2mo",                        1,  "months", 1, "days",   "time", 1, "months"
"{casename}.h%4yr-%2mo",                         1,  "months", 1, "days",   "time", 1, "months"
"{casename}.sfc%4yr-%2mo",                       1,  "days",   1, "days",   "time", 1, "months"
"{casename}.wci%4yr-%2mo",                       1,  "months",   1, "days",   "time", 1, "months"
"{casename}.static",                             -1, "days",   1, "days",   "time"
""".format(
        casename=prefix
    )
)

print(header)
"MOM6 diagnostic fields table for CESM case: gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb"
1 1 1 0 0 0
### Section-1: File List
#========================
"gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo",                        1,  "months", 1, "days",   "time", 1, "months"
"gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo",                         1,  "months", 1, "days",   "time", 1, "months"
"gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo",                       1,  "days",   1, "days",   "time", 1, "months"
"gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.wci%4yr-%2mo",                       1,  "months",   1, "days",   "time", 1, "months"
"gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static",                             -1, "days",   1, "days",   "time"
HEAT_BUDGET_VARS = [  # heat budget
    "opottemptend",
    "opottempdiff",
    "opottemppmdiff",
    "T_advection_xy",
    "Th_tendency_vert_remap",
    "boundary_forcing_heat_tendency",
    "frazil_heat_tendency",
    "KPP_NLT_temp_budget",
    "T_lbdxy_cont_tendency",
]

%matplotlib inline

MIXPODS_VARS = [
    # state
    "uo",
    "vo",
    "zos",
    "SSH",
    "thetao",
    "so",
    "taux",
    "tauy",
    "net_heat_surface",
    "SW",
    "SW_pen",
    "N2",
    "Tflx_dia_diff",  # "Sflx_dia_diff",
    # Total
    "Kd_heat",  # or
    "Kd_salt",
    "Kv_u",
    "Kv_v",
    "mlotst",  # mixed layer
    # KPP
    "KPP_OBLdepth",
    "KPP_buoyFlux",
    "KPP_ustar",
    # "KPP_N2",
    "KPP_NLtransport_heat",
    "KPP_BulkRi",
    # "N2_shear",
    # "S2_shear",
    # ePBL
    # "Kd_ePBL",
    # "ePBL_h_ML",
    # "e"? interface depths; hm files
    "volcello",  # required with h
    "h",
    "ri_grad_shear_orig",
    "ri_grad_shear",
    # Extra
    "KT_extra",
    "KS_extra",
    # "kd_shear_CVMix",
    # "kv_shear_CVMix",
    # "kd_conv",
    # "kv_conv",
    # "KPP_Kheat",
    # "KPP_Ksalt",
    # "KPP_Kd_in",
    # "KPP_Kv",
    # "Kv_slow",
    # "Kd_bkgnd",
    # "Kv_bkgnd",
    # "Kd_itides",
    # "Kd_layer",
    # "Kd_interface",
]  # + HEAT_BUDGET_VARS
section2 = """\n\n
### Section-2: Fields List
#=========================

# "{casename}.h%4yr-%2mo"
"ocean_model_z", "uo",      "uo",      "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "vo",      "vo",      "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "h",       "h",       "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "thetao",  "thetao",  "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "so",      "so",      "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "agessc",  "agessc",  "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "rhopot0", "rhopot0", "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "N2_int",  "N2_int",  "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "volcello","volcello","{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "vmo",     "vmo",     "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "vhGM",    "vhGM",    "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "vhml",    "vhml",    "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "umo",     "umo",     "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "uhGM",    "uhGM",    "{casename}.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "uhml",    "uhml",    "{casename}.h%4yr-%2mo", "all", "mean", "none", 2

# "{casename}.hm%4yr-%2mo"
"ocean_model", "soga",         "soga",         "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "thetaoga",     "thetaoga",     "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "uh",           "uh",           "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vh",           "vh",           "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vhbt",         "vhbt",         "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "uhbt",         "uhbt",         "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "agessc",       "agessc",       "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "T_ady_2d",     "T_ady_2d",     "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "T_adx_2d",     "T_adx_2d",     "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "T_diffy_2d",   "T_diffy_2d",   "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "T_diffx_2d",   "T_diffx_2d",   "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "diftrelo",     "diftrelo",     "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "diftrblo",     "diftrblo",     "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "difmxybo",     "difmxybo",     "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "difmxylo",     "difmxylo",     "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "volcello",     "volcello",     "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vmo",          "vmo",          "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vhGM",         "vhGM",         "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vhml",         "vhml",         "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "umo",          "umo",          "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "uhGM",         "uhGM",         "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "uhml",         "uhml",         "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "uo",           "uo",           "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vo",           "vo",           "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "h",            "h",            "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "e",            "e",            "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "thetao",       "thetao",       "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "so",           "so",           "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "KE",           "KE",           "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "rhopot0",      "rhopot0",      "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "KPP_OBLdepth", "oml",          "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "tauuo",        "tauuo",        "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "tauvo",        "tauvo",        "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "friver",       "friver",       "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "prsn",         "prsn",         "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "prlq",         "prlq",         "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "evs",          "evs",          "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "hfsso",        "hfsso",        "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "rlntds",       "rlntds",       "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "hfsnthermds",  "hfsnthermds",  "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "sfdsi",        "sfdsi",        "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "rsntds",       "rsntds",       "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "hfds",         "hfds",         "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "ustar",        "ustar",        "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "hfsifrazil",   "hfsifrazil",   "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "wfo",          "wfo",          "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vprec",        "vprec",        "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "ficeberg",     "ficeberg",     "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "fsitherm",     "fsitherm",     "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "hflso",        "hflso",        "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "pso",          "pso",          "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "seaice_melt_heat","seaice_melt_heat","{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "Heat_PmE",     "Heat_PmE",     "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "salt_flux_added","salt_flux_added","{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_lrunoff","heat_content_lrunoff","{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_frunoff","heat_content_frunoff","{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_lprec","heat_content_lprec","{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_fprec","heat_content_fprec","{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_vprec","heat_content_vprec","{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_cond","heat_content_cond","{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_evap","heat_content_evap","{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "SSH",          "SSH",          "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "tos",          "tos",          "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "sos",          "sos",          "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "SSU",          "SSU",          "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "SSV",          "SSV",          "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "mass_wt",      "mass_wt",      "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "opottempmint", "opottempmint", "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "somint",       "somint",       "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "Rd_dx",        "Rd_dx",        "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "speed",        "speed",        "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "SW_pen",       "SW_pen",        "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "mlotst",       "mlotst",       "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "opottemptend", "opottemptend",  "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "opottempdiff",  "opottempdiff",  "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "opottemppmdiff", "opottemppmdiff",  "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "T_advection_xy",  "T_advection_xy",   "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "Th_tendency_vert_remap", "Th_tendency_vert_remap",   "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "boundary_forcing_heat_tendency", "boundary_forcing_heat_tendency",        "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "frazil_heat_tendency",  "frazil_heat_tendency",  "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "KPP_NLT_temp_budget", "KPP_NLT_temp_budget",  "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "T_lbdxy_cont_tendency", "T_lbdxy_cont_tendency",  "{casename}.hm%4yr-%2mo", "all", "mean", "none", 2

# "{casename}.sfc%4yr-%2mo"
"ocean_model", "SSH",          "SSH",          "{casename}.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "tos",          "tos",          "{casename}.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "sos",          "sos",          "{casename}.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "SSU",          "SSU",          "{casename}.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "SSV",          "SSV",          "{casename}.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "mass_wt",      "mass_wt",      "{casename}.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "opottempmint", "opottempmint", "{casename}.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "somint",       "somint",       "{casename}.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "Rd_dx",        "Rd_dx",        "{casename}.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "speed",        "speed",        "{casename}.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "mlotst",       "mlotst",       "{casename}.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "KPP_OBLdepth", "oml",          "{casename}.sfc%4yr-%2mo", "all", "mean", "none", 2

# "{casename}.static"
"ocean_model", "geolon",      "geolon",      "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "geolat",      "geolat",      "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "geolon_c",    "geolon_c",    "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "geolat_c",    "geolat_c",    "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "geolon_u",    "geolon_u",    "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "geolat_u",    "geolat_u",    "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "geolon_v",    "geolon_v",    "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "geolat_v",    "geolat_v",    "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "deptho",      "deptho",      "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "wet",         "wet",         "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "wet_c",       "wet_c",       "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "wet_u",       "wet_u",       "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "wet_v",       "wet_v",       "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "Coriolis",    "Coriolis",    "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "areacello",   "areacello",   "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "areacello_cu","areacello_cu","{casename}.static", "all", ".false.", "none", 2
"ocean_model", "areacello_cv","areacello_cv","{casename}.static", "all", ".false.", "none", 2
"ocean_model", "areacello_bu","areacello_bu","{casename}.static", "all", ".false.", "none", 2
"ocean_model", "sin_rot",     "sin_rot",     "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "cos_rot",     "cos_rot",     "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "Kd_bkgnd",     "Kd_bkgnd",     "{casename}.static", "all", ".false.", "none", 2
"ocean_model", "Kv_bkgnd",     "Kv_bkgnd",     "{casename}.static", "all", ".false.", "none", 2
""".format(
    casename=prefix
)
print(section2)
### Section-2: Fields List
#=========================

# "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo"
"ocean_model_z", "uo",      "uo",      "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "vo",      "vo",      "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "h",       "h",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "thetao",  "thetao",  "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "so",      "so",      "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "agessc",  "agessc",  "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "rhopot0", "rhopot0", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "N2_int",  "N2_int",  "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "volcello","volcello","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "vmo",     "vmo",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "vhGM",    "vhGM",    "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "vhml",    "vhml",    "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "umo",     "umo",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "uhGM",    "uhGM",    "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2
"ocean_model_z", "uhml",    "uhml",    "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.h%4yr-%2mo", "all", "mean", "none", 2

# "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo"
"ocean_model", "soga",         "soga",         "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "thetaoga",     "thetaoga",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "uh",           "uh",           "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vh",           "vh",           "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vhbt",         "vhbt",         "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "uhbt",         "uhbt",         "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "agessc",       "agessc",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "T_ady_2d",     "T_ady_2d",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "T_adx_2d",     "T_adx_2d",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "T_diffy_2d",   "T_diffy_2d",   "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "T_diffx_2d",   "T_diffx_2d",   "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "diftrelo",     "diftrelo",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "diftrblo",     "diftrblo",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "difmxybo",     "difmxybo",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "difmxylo",     "difmxylo",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "volcello",     "volcello",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vmo",          "vmo",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vhGM",         "vhGM",         "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vhml",         "vhml",         "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "umo",          "umo",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "uhGM",         "uhGM",         "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "uhml",         "uhml",         "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "uo",           "uo",           "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vo",           "vo",           "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "h",            "h",            "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "e",            "e",            "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "thetao",       "thetao",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "so",           "so",           "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "KE",           "KE",           "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "rhopot0",      "rhopot0",      "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "KPP_OBLdepth", "oml",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "tauuo",        "tauuo",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "tauvo",        "tauvo",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "friver",       "friver",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "prsn",         "prsn",         "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "prlq",         "prlq",         "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "evs",          "evs",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "hfsso",        "hfsso",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "rlntds",       "rlntds",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "hfsnthermds",  "hfsnthermds",  "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "sfdsi",        "sfdsi",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "rsntds",       "rsntds",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "hfds",         "hfds",         "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "ustar",        "ustar",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "hfsifrazil",   "hfsifrazil",   "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "wfo",          "wfo",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "vprec",        "vprec",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "ficeberg",     "ficeberg",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "fsitherm",     "fsitherm",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "hflso",        "hflso",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "pso",          "pso",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "seaice_melt_heat","seaice_melt_heat","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "Heat_PmE",     "Heat_PmE",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "salt_flux_added","salt_flux_added","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_lrunoff","heat_content_lrunoff","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_frunoff","heat_content_frunoff","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_lprec","heat_content_lprec","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_fprec","heat_content_fprec","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_vprec","heat_content_vprec","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_cond","heat_content_cond","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "heat_content_evap","heat_content_evap","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "SSH",          "SSH",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "tos",          "tos",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "sos",          "sos",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "SSU",          "SSU",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "SSV",          "SSV",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "mass_wt",      "mass_wt",      "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "opottempmint", "opottempmint", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "somint",       "somint",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "Rd_dx",        "Rd_dx",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "speed",        "speed",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "SW_pen",       "SW_pen",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "mlotst",       "mlotst",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "opottemptend", "opottemptend",  "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "opottempdiff",  "opottempdiff",  "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "opottemppmdiff", "opottemppmdiff",  "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "T_advection_xy",  "T_advection_xy",   "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "Th_tendency_vert_remap", "Th_tendency_vert_remap",   "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "boundary_forcing_heat_tendency", "boundary_forcing_heat_tendency",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "frazil_heat_tendency",  "frazil_heat_tendency",  "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "KPP_NLT_temp_budget", "KPP_NLT_temp_budget",  "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "T_lbdxy_cont_tendency", "T_lbdxy_cont_tendency",  "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.hm%4yr-%2mo", "all", "mean", "none", 2

# "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo"
"ocean_model", "SSH",          "SSH",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "tos",          "tos",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "sos",          "sos",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "SSU",          "SSU",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "SSV",          "SSV",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "mass_wt",      "mass_wt",      "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "opottempmint", "opottempmint", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "somint",       "somint",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "Rd_dx",        "Rd_dx",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "speed",        "speed",        "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "mlotst",       "mlotst",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo", "all", "mean", "none", 2
"ocean_model", "KPP_OBLdepth", "oml",          "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.sfc%4yr-%2mo", "all", "mean", "none", 2

# "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static"
"ocean_model", "geolon",      "geolon",      "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "geolat",      "geolat",      "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "geolon_c",    "geolon_c",    "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "geolat_c",    "geolat_c",    "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "geolon_u",    "geolon_u",    "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "geolat_u",    "geolat_u",    "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "geolon_v",    "geolon_v",    "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "geolat_v",    "geolat_v",    "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "deptho",      "deptho",      "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "wet",         "wet",         "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "wet_c",       "wet_c",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "wet_u",       "wet_u",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "wet_v",       "wet_v",       "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "Coriolis",    "Coriolis",    "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "areacello",   "areacello",   "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "areacello_cu","areacello_cu","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "areacello_cv","areacello_cv","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "areacello_bu","areacello_bu","gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "sin_rot",     "sin_rot",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "cos_rot",     "cos_rot",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "Kd_bkgnd",     "Kd_bkgnd",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
"ocean_model", "Kv_bkgnd",     "Kv_bkgnd",     "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.static", "all", ".false.", "none", 2
@dataclasses.dataclass
class Section:
    name: str
    index: dict
    extent: dict
    # TODO: freq could be a parameter to generate_*
    freq: str
    delta: int = 0

    def _filename(self, casename):
        prefix = f"{casename}.mom6"
        return f"{prefix}.{self.name.replace(' ', '_')}_%4yr"

    def generate_header(self, casename):
        return f'"{self._filename(casename)}", {self.freq}'

    def generate_entries(self, casename, varnames, geometry=None):
        extentstr = f"{self.extent[0]} {self.extent[1]}"

        δ = self.delta

        line = f"# {self.name} section\n"

        for index_name, loc in self.index.items():
            if index_name not in ["lath", "lonh"]:
                raise NotImplementedError(
                    f"Expected one of ['lath', 'lonh']. Received {index_name}."
                )

            if δ is not None:
                assert geometry is not None
                index = geometry.indexes[index_name]
                (i,) = index.get_indexer([loc], method="nearest")
                low, high = index[i - δ], index[i + δ]
            else:
                low, high = loc, loc

            if index_name == "lonh":
                regionstr = f'"{low:.3f} {high:.3f} {extentstr} -1 -1"'
                # region_in_file = f"{-1 * loc:.0f}W"
                # for idx in index[np.arange(i-delta, i+delta+1)]:
                #    plt.plot([idx, idx], section.extent, lw=0.5, color='k')
            elif index_name == "lath":
                regionstr = f'"{extentstr} {low:.3f} {high:.3f} -1 -1"'
                # region_in_file = f"{-1 * loc:.0f}W"

        fname = self._filename(casename)
        for var in varnames:
            line += f'"ocean_model", "{var}", "{var}", "{fname}", "all", "mean", {regionstr}, 2\n'
        return line


print(
    Section(
        name="TAO 140W",
        index={"lonh": -140},
        extent=(-6, 6),
        freq='1, "hours", 1, "hours", "time", 1, "years"',
        delta=1,
    ).generate_entries(casename, geometry=geometry, varnames=MIXPODS_VARS)
)
# TAO 140W section
"ocean_model", "uo", "uo", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "vo", "vo", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "zos", "zos", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "SSH", "SSH", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "thetao", "thetao", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "so", "so", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "taux", "taux", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "tauy", "tauy", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "net_heat_surface", "net_heat_surface", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "SW", "SW", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "SW_pen", "SW_pen", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "N2", "N2", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "Tflx_dia_diff", "Tflx_dia_diff", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "Kd_heat", "Kd_heat", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "Kd_salt", "Kd_salt", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "Kv_u", "Kv_u", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "Kv_v", "Kv_v", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "mlotst", "mlotst", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "KPP_OBLdepth", "KPP_OBLdepth", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "KPP_buoyFlux", "KPP_buoyFlux", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "KPP_ustar", "KPP_ustar", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "KPP_NLtransport_heat", "KPP_NLtransport_heat", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "KPP_BulkRi", "KPP_BulkRi", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "volcello", "volcello", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "h", "h", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "ri_grad_shear_orig", "ri_grad_shear_orig", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "ri_grad_shear", "ri_grad_shear", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "KT_extra", "KT_extra", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
"ocean_model", "KS_extra", "KS_extra", "gmom.e23.GJRAv3.TL319_t061_zstar_N65.baseline.hb.mom6.TAO_140W_%4yr", "all", "mean", "-140.667 -139.333 -6 6 -1 -1", 2
def generate_sections_diag_table(casename, section_name, section, varnames):
    # extents for constant lon
    # lat_min, lat_max = -6, 6  # 100, 500

    # TODO: generalize
    # extents for constant lat
    # lon_min, lon_max = 240 - 0.15, 283 + 0.2  # 100, 800

    extentstr = f"{section.extent[0]} {section.extent[1]}"

    top = dict()

    delta = section.delta

    line = f"# {section_name} section\n"
    for index_name, locations in section.index.items():
        index = geometry.indexes[index_name]
        for loc in locations:
            (i,) = index.get_indexer([loc], method="nearest")
            if index_name == "lonh":
                regionstr = (
                    f'"{index[i-delta]:.3f} {index[i+delta]:.3f} {extentstr} -1 -1"'
                )
                # for idx in index[np.arange(i-delta, i+delta+1)]:
                #    plt.plot([idx, idx], section.extent, lw=0.5, color='k')

            elif index_name == "lath":
                regionstr = (
                    f'"{extentstr} {index[i-delta]:.3f} {index[i+delta]:.3f} -1 -1"'
                )
                for idx in index[np.arange(i - delta, i + delta + 1)]:
                    plt.plot(section.extent, [idx, idx], lw=0.5, color="k")

            fname = f"{prefix}.{section_name.replace(' ', '_')}_%4yr"
            if fname not in top:
                top[fname] = f'"{fname}", {section.freq}'
            for var in varnames:
                line += f'"ocean_model", "{var}", "{var}", "{fname}", "all", "mean", {regionstr}, 2\n'
                # print(fname)

    return top, line


MIXPODS_FREQ = '1, "hours", 1, "hours", "time", 1, "years"'
SECTIONS_FREQ = '1,  "days",   1, "days",   "time", 365, "days"'
SECTIONS_VARS = ["volcello", "thetao", "so", "umo", "vmo", "uo", "vo"]

tao = [
    Section(
        name=f"TAO {abs(lon)}W",
        index={"lonh": lon},
        extent=(-6, 6),
        freq=MIXPODS_FREQ,
        delta=1,
    )
    for lon in [-170, -155, -140, -125, -110, -90]
]

pirata = [
    Section(
        name=f"PIRATA {abs(lon)}W",
        index={"lonh": lon},
        extent=(-6, 6),
        freq=MIXPODS_FREQ,
        delta=1,
    )
    for lon in [-23, -10]
]

rama = [
    Section(
        name="RAMA 80E",
        index={"lonh": 80.5},
        extent=(-3, 6),
        freq=MIXPODS_FREQ,
    ),
    Section(name="RAMA 90E", index={"lonh": 90}, extent=(-6, 23), freq=MIXPODS_FREQ),
]
default_sections = [
    Section(
        name="agulhas section",
        index={"lonh": 20.1},
        extent=(-70, -34.6),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Bab al mandab Strait",
        index={"lonh": 45},
        extent=(10.5, 13.5),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Barents opening",
        index={"lath": 78.93},
        extent=(-5.2, 18.8),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Bering Strait",
        index={"lath": 66.6},
        extent=(-174.5, -171.5),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Davis Strait",
        index={"lath": 69.5},
        extent=(-53.5, -45.3),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Denmark Strait",
        index={"lath": 65.0},
        extent=(-38.5, -21.5),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Drake Passage",
        index={"lonh": -67.0},
        extent=(-69.0, -55.2),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="English Channel",
        index={"lonh": 0.0},
        extent=(51.0, 52.9),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Fram Strait",
        index={"lath": 80.5},
        extent=(-21.0, -9.8),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Florida Bahamas",
        index={"lath": 25.3},
        extent=(-80.1, -77.9),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Gibraltar Strait",
        index={"lonh": -6.5},
        extent=(34.3, 37.4),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Hormuz Strait",
        index={"lonh": 55.9},
        extent=(25.0, 27.5),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Iceland Norway",
        index={"lath": 65.0},
        extent=(-21.5, 1.5),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Indonesian Throughflow",
        index={"lath": -7.0},
        extent=(-246.5, -220.8),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Mozambique Channel",
        index={"lath": -16.0},
        extent=(39.9, 44.7),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Pacific undercurrent",
        index={"lonh": -155.0},
        extent=(-2, 2),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Taiwan Luzon",
        index={"lonh": -239.0},
        extent=(18.8, 22.5),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Windward Passage",
        index={"lath": 20.39},
        extent=(-74.2, -73.2),
        freq=SECTIONS_FREQ,
    ),
]
sri_lanka_sections = [
    Section(
        name="Sri Lanka South",
        index={"lonh": -80.5},
        extent=(-2, 6),
        freq=SECTIONS_FREQ,
    ),
    Section(
        name="Sri Lanka East", index={"lath": 8}, extent=(81, 85.5), freq=SECTIONS_FREQ
    ),
]

Write file#

import itertools

all_sections = {
    tuple(SECTIONS_VARS): tuple(itertools.chain(default_sections, sri_lanka_sections)),
    tuple(MIXPODS_VARS): tuple(
        itertools.chain(
            tao,
            pirata,
            rama,
        )
    ),
}
towrite = (
    header
    + "\n".join(
        a.generate_header(casename) for a in itertools.chain(*all_sections.values())
    )
    + "\n\n"
    + section2
    + "\n\n"
    + "\n\n".join(
        [
            section.generate_entries(casename, varnames=varnames, geometry=geometry)
            for varnames, sections in all_sections.items()
            for section in sections
        ]
    )
)
with open(
    # f"/glade/work/dcherian/cesm/{casename}/SourceMods/src.mom/diag_table", "w"
    "/glade/scratch/dcherian/diag_table.deepak",
    "w",
) as file:
    file.write(towrite)