{ "cells": [ { "cell_type": "markdown", "id": "df6b9972-67fd-42b6-8fd4-4d729ce51708", "metadata": {}, "source": [ "# Antarctic Intermediate Water (AAIW)\n", "\n", "## Purpose:\n", "Compute and plot the buoyancy contribution to potential vorticity over the Pacific Sector of the Southern Ocean.\n", "\n", "**Acknowledgment**\n", "\n", "This notebook builds on work by John Krasting (NOAA/GFDL). The original version can be found at:\n", "https://github.com/jkrasting/mar/blob/main/src/gfdlnb/notebooks/ocean/AAIW_PV.ipynb." ] }, { "cell_type": "code", "execution_count": 1, "id": "9d1d46a8-90ef-46bb-9251-c20c58d93555", "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 34, "id": "3a0fc487-aada-4433-baf8-50489e46475b", "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import warnings\n", "warnings.filterwarnings(\"ignore\")\n", "import matplotlib\n", "import numpy as np\n", "import xarray as xr\n", "import momlevel as ml\n", "from ncar_jobqueue import NCARCluster\n", "from dask.distributed import Client\n", "import cartopy.crs as ccrs\n", "from mom6_tools.MOM6grid import MOM6grid\n", "from mom6_tools.m6toolbox import add_global_attrs \n", "from mom6_tools.m6toolbox import cime_xmlquery\n", "from mom6_tools.m6toolbox import weighted_temporal_mean_vars\n", "from mom6_tools.m6toolbox import geoslice\n", "from mom6_tools.aaiw_pv import plot_aaiw_pv, plot_aaiw_pv_obs\n", "import matplotlib.pyplot as plt\n", "import yaml, os, intake" ] }, { "cell_type": "code", "execution_count": 3, "id": "6b5e022f-ac7a-41b5-a872-bfc5606d6957", "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, "id": "14dd4803-6a53-438a-b402-057a8e334503", "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, "id": "06674ecb-b173-420e-9873-b8668a0b044e", "metadata": {}, "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.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.casename = casename\n", "args.label = diag_config_yml['Case']['SNAME']\n", "args.savefigs = False\n", "args.outdir = 'PNG/AAIW_PV/'" ] }, { "cell_type": "code", "execution_count": 6, "id": "077a026d-37a6-42f6-b1cd-0743437d4d75", "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, xrformat=True)\n", "else:\n", " grd = MOM6grid(OUTDIR+'/'+args.static, xrformat=True)\n", "\n", "try:\n", " depth = grd.depth_ocean\n", "except:\n", " depth = grd.deptho" ] }, { "cell_type": "code", "execution_count": 7, "id": "1949a08f-ed1e-49b9-8b66-5d4e363ded58", "metadata": {}, "outputs": [], "source": [ "# Coriolis\n", "coriolis = ml.derived.calc_coriolis(grd.geolat)" ] }, { "cell_type": "code", "execution_count": 8, "id": "d30f94ac-75eb-4eac-aa2c-9229b94bc684", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Client-38959a84-e3e2-11ef-a08c-3cecef1b11fa
\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", " |
bfe8817c
\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-908afe8a-4948-41c8-8958-71cd2f88e652
\n", "| \n", " Comm: tcp://128.117.208.103:38635\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", "