{ "cells": [ { "cell_type": "markdown", "metadata": { "toc-hr-collapsed": false }, "source": [ "# Temperature and Salinity at Depth Levels\n", "\n", "Goals of this notebook:\n", "\n", "1) serve as an example of how to post-process CESM/MOM6 output;\n", "\n", "2) create time averages of T/S fields at depth levels and compared agains observations (WOA18).\n", "\n", "Temprature and salinity comparisons (model vs obs) at selected depth levels are grouped into the following regions: Global, Antarctic, and Arctic." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Basemap module not found. Some regional plots may not function properly\n" ] } ], "source": [ "%matplotlib inline\n", "\n", "import warnings\n", "warnings.filterwarnings(\"ignore\")\n", "from mom6_tools.MOM6grid import MOM6grid\n", "from mom6_tools.m6plot import xycompare, polarcomparison\n", "from mom6_tools.m6toolbox import cime_xmlquery, weighted_temporal_mean_vars\n", "from mom6_tools import m6toolbox\n", "from ncar_jobqueue import NCARCluster\n", "from dask.distributed import Client\n", "import yaml, intake, os\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import xarray as xr\n", "from IPython.display import display, Markdown, Latex" ] }, { "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", "\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.start_date = avg['start_date']\n", "args.end_date = avg['end_date']\n", "args.casename = casename\n", "args.obs = \"woa-2018-tx2_3v2-annual-all\"\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.savefigs = False\n", "args.nw = 6 # requesting 6 workers" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "MOM6 grid successfully loaded... \n", "\n", "MOM6 grid successfully loaded... \n", "\n" ] } ], "source": [ "# load mom6 grid\n", "# read grid info\n", "geom_file = OUTDIR+'/'+args.geom\n", "if os.path.exists(geom_file):\n", " grd_xr = MOM6grid(OUTDIR+'/'+args.static, geom_file, xrformat=True)\n", " grd = MOM6grid(OUTDIR+'/'+args.static, geom_file)\n", "else:\n", " grd_xr = MOM6grid(OUTDIR+'/'+args.static, xrformat=True)\n", " grd = MOM6grid(OUTDIR+'/'+args.static)\n", "\n", "try:\n", " area = grd_xr.area_t.where(grd_xr.wet > 0).values\n", "except:\n", " area = grd_xr.areacello.where(grd_xr.wet > 0).values" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "parallel = False\n", "if args.nw > 1:\n", " parallel = True\n", " cluster = NCARCluster()\n", " cluster.scale(args.nw)\n", " client = Client(cluster)\n", " client" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Client-56976830-9e36-11ef-ae1d-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", " |
c08fb1f4
\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-b432bac2-44aa-4d46-a7ee-eac6a5026a84
\n", "| \n", " Comm: tcp://128.117.208.100:36763\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", "