{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Meridional Overturning\n", "\n", "`mom6_tools.moc` collection of functions for computing and plotting meridional overturning circulation. \n", "\n", "The goal of this notebook is the following:\n", "\n", "1) server as an example on to compute a meridional overturning streamfunction (global and Atalntic) from CESM/MOM output; \n", "\n", "2) evaluate model experiments by comparing transports against observed estimates and other model results.\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Basemap module not found. Some regional plots may not function properly\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "ERROR 1: PROJ: proj_create_from_database: Open of /glade/work/gmarques/conda-envs/mom6-tools/share/proj failed\n" ] } ], "source": [ "%matplotlib inline\n", "import warnings\n", "warnings.filterwarnings(\"ignore\")\n", "import matplotlib\n", "import numpy as np\n", "import xarray as xr\n", "# mom6_tools\n", "from mom6_tools.MOM6grid import MOM6grid\n", "from mom6_tools.moc import *\n", "from ncar_jobqueue import NCARCluster\n", "from dask.distributed import Client\n", "from mom6_tools.m6toolbox import genBasinMasks, add_global_attrs \n", "from mom6_tools.m6toolbox import cime_xmlquery\n", "import matplotlib.pyplot as plt\n", "import yaml, os, intake" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Read in the yaml file\n", "diag_config_yml_path = \"diag_config.yml\"\n", "diag_config_yml = yaml.load(open(diag_config_yml_path,'r'), Loader=yaml.Loader)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Output directory is: /glade/derecho/scratch/gmarques/archive/g.e30_a03c.GJRAv4.TL319_t232_wgx3_hycom1_N75.2024.079/ocn/hist/\n", "Casename is: g.e30_a03c.GJRAv4.TL319_t232_wgx3_hycom1_N75.2024.079\n" ] } ], "source": [ "caseroot = diag_config_yml['Case']['CASEROOT']\n", "casename = cime_xmlquery(caseroot, 'CASE')\n", "DOUT_S = cime_xmlquery(caseroot, 'DOUT_S')\n", "if DOUT_S:\n", " OUTDIR = cime_xmlquery(caseroot, 'DOUT_S_ROOT')+'/ocn/hist/'\n", "else:\n", " OUTDIR = cime_xmlquery(caseroot, 'RUNDIR')\n", "\n", "print('Output directory is:', OUTDIR)\n", "print('Casename is:', casename)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "tags": [ "parameters" ] }, "outputs": [], "source": [ "# The following parameters must be set accordingly\n", "######################################################\n", "# add your name and email address below\n", "author = 'Gustavo Marques (gmarques@ucar.edu)'\n", "######################################################\n", "# create an empty class object\n", "class args:\n", " pass\n", "\n", "# load avg dates\n", "avg = diag_config_yml['Avg']\n", "\n", "args.infile = OUTDIR\n", "args.monthly = casename+diag_config_yml['Fnames']['z']\n", "args.sigma2 = casename+diag_config_yml['Fnames']['rho2']\n", "args.static = casename+diag_config_yml['Fnames']['static']\n", "args.geom = casename+diag_config_yml['Fnames']['geom']\n", "args.start_date = avg['start_date']\n", "args.end_date = avg['end_date']\n", "args.case_name = casename\n", "args.label = ''\n", "args.savefigs = False" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "MOM6 grid successfully loaded... \n", "\n" ] } ], "source": [ "# read grid info\n", "geom_file = OUTDIR+'/'+args.geom\n", "if os.path.exists(geom_file):\n", " grd = MOM6grid(OUTDIR+'/'+args.static, geom_file)\n", "else:\n", " grd = MOM6grid(OUTDIR+'/'+args.static)\n", "\n", "try:\n", " depth = grd.depth_ocean\n", "except:\n", " depth = grd.deptho" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "# remove Nan's, otherwise genBasinMasks won't work\n", "depth[np.isnan(depth)] = 0.0\n", "basin_code = genBasinMasks(grd.geolon, grd.geolat, depth, verbose=False)\n", "basin_code_xr = genBasinMasks(grd.geolon, grd.geolat, depth, verbose=False, xda=True)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Client-57b39531-9e42-11ef-9c8d-3cecef1b11de
\n", "| Connection method: Cluster object | \n", "Cluster type: dask_jobqueue.PBSCluster | \n", " \n", "
| \n", " Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/gmarques/High-mem/proxy/8787/status\n", " | \n", "\n", " |
c453635d
\n", "| \n", " Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/gmarques/High-mem/proxy/8787/status\n", " | \n", "\n", " Workers: 0\n", " | \n", "
| \n", " Total threads: 0\n", " | \n", "\n", " Total memory: 0 B\n", " | \n", "
Scheduler-c8eb8703-0316-4aeb-a750-8ffb964c4d7c
\n", "| \n", " Comm: tcp://128.117.208.100:40609\n", " | \n", "\n", " Workers: 0\n", " | \n", "
| \n", " Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/gmarques/High-mem/proxy/8787/status\n", " | \n", "\n", " Total threads: 0\n", " | \n", "
| \n", " Started: Just now\n", " | \n", "\n", " Total memory: 0 B\n", " | \n", "