{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "import numpy as np\n", "import cmocean" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "OUTPUT_FILES = {\n", " \"snapshot\": \"acc.snapshot.nc\",\n", " \"averages\": \"acc.averages.nc\",\n", " \"overturning\": \"acc.overturning.nc\",\n", " \"energy\": \"acc.energy.nc\",\n", "}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds_avg = xr.open_dataset(OUTPUT_FILES[\"averages\"])\n", "ds_avg" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds_avg[\"psi\"] = ds_avg.psi / 1e6\n", "ds_avg[\"psi\"].attrs[\"units\"] = \"Sv\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds_avg[\"psi\"].isel(Time=-1).plot.contourf(levels=50, cmap=\"cmo.balance\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "(\n", " ds_avg[\"salt\"]\n", " .isel(Time=slice(-1,None))\n", " .mean(dim=(\"Time\", \"xt\"))\n", " .plot.contourf(levels=50, cmap=\"cmo.haline\")\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds_snap = xr.open_dataset(OUTPUT_FILES[\"snapshot\"])\n", "weights = ds_snap[\"area_t\"].fillna(0)\n", "\n", "temp_weighted = (\n", " ds_avg[\"temp\"]\n", " .isel(Time=-1)\n", " .weighted(weights)\n", " .mean(dim=\"yt\")\n", " .plot.contourf(vmin=-2, vmax=22, levels=25, cmap=\"cmo.thermal\")\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds_ovr = xr.open_dataset(OUTPUT_FILES[\"overturning\"])\n", "\n", "ds_ovr" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds_ovr[\"vsf_depth\"] = ds_ovr.vsf_depth / 1e6\n", "\n", "ds_ovr.vsf_depth.attrs[\"long_name\"] = \"MOC\"\n", "\n", "ds_ovr.vsf_depth.attrs[\"units\"] = \"Sv\"\n", "\n", "ds_ovr.vsf_depth.isel(Time=-1).plot.contourf(levels=50, cmap=\"cmo.balance\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 2 }