{ "cells": [ { "cell_type": "markdown", "metadata": { "toc-hr-collapsed": true }, "source": [ "# Equatorial Upperocean model vs. obs comparison\n", "\n", "The goal of this notebook is the following:\n", "\n", "1) serve as an example of how to post-process CESM/MOM6 output;\n", "\n", "2) create time averages of T, S and VEL fields and compared agains observations (PHC2 and Johnson et al, 2002);" ] }, { "cell_type": "code", "execution_count": 1, "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", "import warnings\n", "warnings.filterwarnings(\"ignore\")\n", "from mom6_tools.MOM6grid import MOM6grid\n", "from mom6_tools.m6toolbox import shiftgrid\n", "from mom6_tools.m6plot import yzcompare, yzplot\n", "from mom6_tools.m6toolbox import cime_xmlquery\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": 2, "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": 3, "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": 4, "metadata": {}, "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": 5, "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)" ] }, { "cell_type": "code", "execution_count": 6, "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": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Client-aa3ec30c-9e42-11ef-a150-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/41335/status\n", " | \n", "\n", " |
b04eeeea
\n", "| \n", " Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/gmarques/High-mem/proxy/41335/status\n", " | \n", "\n", " Workers: 0\n", " | \n", "
| \n", " Total threads: 0\n", " | \n", "\n", " Total memory: 0 B\n", " | \n", "
Scheduler-ff977a57-41fe-4437-a742-83c7fdf17850
\n", "| \n", " Comm: tcp://128.117.208.100:34243\n", " | \n", "\n", " Workers: 0\n", " | \n", "
| \n", " Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/gmarques/High-mem/proxy/41335/status\n", " | \n", "\n", " Total threads: 0\n", " | \n", "
| \n", " Started: Just now\n", " | \n", "\n", " Total memory: 0 B\n", " | \n", "
<xarray.Dataset> Size: 103GB\n",
"Dimensions: (time: 732, z_l: 34, yh: 480, xh: 540, xq: 540, z_i: 35)\n",
"Coordinates:\n",
" * z_i (z_i) float64 280B 0.0 5.0 15.0 25.0 ... 5.25e+03 5.75e+03 6.25e+03\n",
" * xq (xq) float64 4kB -286.3 -285.7 -285.0 -284.3 ... 71.67 72.33 73.0\n",
" * yh (yh) float64 4kB -81.56 -81.46 -81.36 -81.26 ... 87.65 87.71 87.74\n",
" * z_l (z_l) float64 272B 2.5 10.0 20.0 32.5 ... 5e+03 5.5e+03 6e+03\n",
" * time (time) object 6kB 0001-01-16 12:00:00 ... 0061-12-16 12:00:00\n",
" * xh (xh) float64 4kB -286.7 -286.0 -285.3 -284.7 ... 71.33 72.0 72.67\n",
"Data variables:\n",
" thetao (time, z_l, yh, xh) float32 26GB dask.array<chunksize=(1, 34, 480, 540), meta=np.ndarray>\n",
" so (time, z_l, yh, xh) float32 26GB dask.array<chunksize=(1, 34, 480, 540), meta=np.ndarray>\n",
" uo (time, z_l, yh, xq) float32 26GB dask.array<chunksize=(1, 34, 480, 540), meta=np.ndarray>\n",
" h (time, z_l, yh, xh) float32 26GB dask.array<chunksize=(1, 34, 480, 540), meta=np.ndarray>\n",
"Attributes:\n",
" NumFilesInSet: 1\n",
" title: MOM6 diagnostic fields table for CESM case: g.e30_a03c...\n",
" associated_files: areacello: g.e30_a03c.GJRAv4.TL319_t232_wgx3_hycom1_N7...\n",
" grid_type: regular\n",
" grid_tile: N/A<xarray.Dataset> Size: 1MB\n",
"Dimensions: (XLON: 10, XLONedges: 11, YLAT11_101: 91, ZDEP1_50: 50)\n",
"Coordinates:\n",
" * XLON (XLON) float64 80B 143.0 156.0 165.0 180.0 ... 235.0 250.0 265.0\n",
" * XLONedges (XLONedges) float64 88B 136.5 149.5 160.5 ... 242.5 257.5 272.5\n",
" * YLAT11_101 (YLAT11_101) float64 728B -8.0 -7.8 -7.6 -7.4 ... 9.6 9.8 10.0\n",
" * ZDEP1_50 (ZDEP1_50) float64 400B 5.0 15.0 25.0 35.0 ... 475.0 485.0 495.0\n",
"Data variables:\n",
" POTEMPM (ZDEP1_50, YLAT11_101, XLON) float32 182kB dask.array<chunksize=(50, 91, 10), meta=np.ndarray>\n",
" SALINITYM (ZDEP1_50, YLAT11_101, XLON) float32 182kB dask.array<chunksize=(50, 91, 10), meta=np.ndarray>\n",
" SIGMAM (ZDEP1_50, YLAT11_101, XLON) float32 182kB dask.array<chunksize=(50, 91, 10), meta=np.ndarray>\n",
" UM (ZDEP1_50, YLAT11_101, XLON) float32 182kB dask.array<chunksize=(50, 91, 10), meta=np.ndarray>\n",
" TSPTS (ZDEP1_50, YLAT11_101, XLON) float32 182kB dask.array<chunksize=(50, 91, 10), meta=np.ndarray>\n",
" UPTS (ZDEP1_50, YLAT11_101, XLON) float32 182kB dask.array<chunksize=(50, 91, 10), meta=np.ndarray>\n",
"Attributes:\n",
" history: FERRET V5.41 1-Oct-02