From 44fe9e6a147a2e7374c781b187445960c78cda51 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Tue, 14 Jan 2025 10:45:17 -0700 Subject: [PATCH 1/8] Fix some titles and get the full sea ice diagnostics working again --- examples/coupled_model/config.yml | 8 ++-- .../Hemis_seaice_visual_compare_full.ipynb | 42 +++++++++++-------- ...Hemis_seaice_visual_compare_obs_lens.ipynb | 2 +- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/examples/coupled_model/config.yml b/examples/coupled_model/config.yml index c88ed43..f69b37f 100644 --- a/examples/coupled_model/config.yml +++ b/examples/coupled_model/config.yml @@ -76,11 +76,11 @@ timeseries: level: 'lev' ice: - vars: ['hi', 'hs', 'snowfrac', 'Tsfc'] #['process_all'] + vars: ['aice','hi', 'hs'] #['process_all'] derive_vars: [] hist_str: 'h' - start_years: [2] - end_years: [102] + start_years: [1] + end_years: [100] level: 'lev' glc: @@ -196,7 +196,7 @@ book_toc: - caption: Sea Ice chapters: - - file: ice/seaice + - file: ice/Hemis_seaice_visual_compare_full ##################################### # Keys for Jupyter Book _config.yml # diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_full.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_full.ipynb index dc7f758..66f96d6 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_full.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_full.ipynb @@ -67,7 +67,7 @@ "endyr1 = 2013\n", "begyr2 = 1850\n", "endyr2 = 2013\n", - "nyears = 35" + "climo_nyears = 35" ] }, { @@ -160,7 +160,7 @@ " + cbegyr1\n", " + \"01-\"\n", " + cendyr1\n", - " + \"02.nc\",\n", + " + \"12.nc\",\n", " data_vars=\"minimal\",\n", " compat=\"override\",\n", " coords=\"minimal\",\n", @@ -258,8 +258,8 @@ " vmax = cice_vars[var][0][\"levels\"][-1]\n", " levels = np.array(cice_vars[var][0][\"levels\"])\n", " title = cice_vars[var][1][\"title\"]\n", - " field1 = ds1_ann[var].isel(time=slice(-nyears, None)).mean(\"time\").squeeze()\n", - " field2 = ds2_ann[var].isel(time=slice(-nyears, None)).mean(\"time\").squeeze()\n", + " field1 = ds1_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + " field2 = ds2_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", " plot_diff(field1, field2, levels, case1, case2, title, \"N\", TLAT, TLON)" ] }, @@ -283,8 +283,8 @@ " vmax = cice_vars[var][0][\"levels\"][1]\n", " levels = np.array(cice_vars[var][0][\"levels\"])\n", " title = cice_vars[var][1][\"title\"]\n", - " field1 = ds1_ann[var].isel(time=slice(-nyears, None)).mean(\"time\").squeeze()\n", - " field2 = ds2_ann[var].isel(time=slice(-nyears, None)).mean(\"time\").squeeze()\n", + " field1 = ds1_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + " field2 = ds2_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", " plot_diff(field1, field2, levels, case1, case2, title, \"S\", TLAT, TLON)" ] }, @@ -644,10 +644,16 @@ "print(ds1[\"aice\"])\n", "\n", "aice1_month = (\n", - " ds1[\"aice\"][1535:1955, :, :].groupby(\"time.month\").mean(dim=\"time\", skipna=True)\n", + " ds1[\"aice\"]\n", + " .isel(time=slice(-climo_nyears, None))\n", + " .groupby(\"time.month\")\n", + " .mean(dim=\"time\", skipna=True)\n", ")\n", "aice2_month = (\n", - " ds2[\"aice\"][923:1343, :, :].groupby(\"time.month\").mean(dim=\"time\", skipna=True)\n", + " ds2[\"aice\"]\n", + " .isel(time=slice(-climo_nyears, None))\n", + " .groupby(\"time.month\")\n", + " .mean(dim=\"time\", skipna=True)\n", ")\n", "mask_tmp1 = np.where(np.logical_and(aice1_month > 0.15, ds1[\"TLAT\"] > 0), 1.0, 0.0)\n", "mask_tmp2 = np.where(np.logical_and(aice2_month > 0.15, ds1[\"TLAT\"] > 0), 1.0, 0.0)\n", @@ -725,9 +731,9 @@ "ds1_sep = ds1_area.sel(time=(ds1_area.time.dt.month == 9))\n", "ds2_sep = ds2_area.sel(time=(ds2_area.time.dt.month == 9))\n", "\n", - "x1 = np.linspace(1850, 2012, 163)\n", - "x2 = np.linspace(1850, 2013, 164)\n", - "x3 = np.linspace(1979, 2014, 36)\n", + "x1 = np.linspace(1, 18, 18)\n", + "x2 = np.linspace(1, 100, 100)\n", + "x3 = np.linspace(1, 36, 36)\n", "\n", "plt.plot(x1, ds1_sep)\n", "plt.plot(x2, ds2_sep)\n", @@ -763,9 +769,9 @@ "ds1_sep_sh = ds1_area_sh.sel(time=(ds1_area_sh.time.dt.month == 9))\n", "ds2_sep_sh = ds2_area_sh.sel(time=(ds2_area_sh.time.dt.month == 9))\n", "\n", - "x1 = np.linspace(1850, 2013, 163)\n", - "x2 = np.linspace(1850, 2014, 164)\n", - "x3 = np.linspace(1979, 2014, 36)\n", + "x1 = np.linspace(1, 18, 18)\n", + "x2 = np.linspace(1, 100, 100)\n", + "x3 = np.linspace(1, 36, 36)\n", "\n", "plt.plot(x1, ds1_sep_sh)\n", "plt.plot(x2, ds2_sep_sh)\n", @@ -827,10 +833,10 @@ }, "outputs": [], "source": [ - "uvel1 = ds1_ann[\"uvel\"].isel(time=slice(-nyears, None)).mean(\"time\").squeeze()\n", - "vvel1 = ds1_ann[\"vvel\"].isel(time=slice(-nyears, None)).mean(\"time\").squeeze()\n", - "uvel2 = ds2_ann[\"uvel\"].isel(time=slice(-nyears, None)).mean(\"time\").squeeze()\n", - "vvel2 = ds2_ann[\"vvel\"].isel(time=slice(-nyears, None)).mean(\"time\").squeeze()\n", + "uvel1 = ds1_ann[\"uvel\"].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + "vvel1 = ds1_ann[\"vvel\"].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + "uvel2 = ds2_ann[\"uvel\"].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + "vvel2 = ds2_ann[\"vvel\"].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", "\n", "vect_diff(uvel1, vvel1, uvel2, vvel2, angle, \"N\", case1, case2, TLAT, TLON)" ] diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb index 56cbefd..a63d4ed 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -574,7 +574,7 @@ "plt.plot(ext2_sh)\n", "plt.plot(nsidc_clim_sh)\n", "\n", - "plt.title(\"NH Climatological Seasonal Cycle\")\n", + "plt.title(\"SH Climatological Seasonal Cycle\")\n", "plt.ylim((0, 25))\n", "plt.xlabel(\"Month\")\n", "plt.ylabel(\"Climatological Seasonal Cycle Ice Extent $m x 10^{12}$\")\n", From 239ee576da2c7e928624252878e36bbc3d02b74d Mon Sep 17 00:00:00 2001 From: David Bailey Date: Thu, 16 Jan 2025 10:05:57 -0700 Subject: [PATCH 2/8] Rework coupled_model example to run key_metrics plus contour plots --- examples/coupled_model/config.yml | 34 +- .../Hemis_seaice_visual_compare_contour.ipynb | 324 +++++++ .../Hemis_seaice_visual_compare_full.ipynb | 892 ------------------ 3 files changed, 344 insertions(+), 906 deletions(-) create mode 100644 nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb delete mode 100644 nblibrary/ice/Hemis_seaice_visual_compare_full.ipynb diff --git a/examples/coupled_model/config.yml b/examples/coupled_model/config.yml index f69b37f..985a30b 100644 --- a/examples/coupled_model/config.yml +++ b/examples/coupled_model/config.yml @@ -41,7 +41,14 @@ computation_config: # All parameters under global_params get passed to all the notebooks global_params: + case_name: 'b.e30_beta04.BLT1850.ne30_t232_wgx3.121wave' + base_case_name: 'b.e30_beta04.BLT1850.ne30_t232_wgx3.121' CESM_output_dir: /glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing + base_case_output_dir: /glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing + start_date: '0001-01-01' + end_date: '0018-01-01' + base_start_date: '0001-01-01' + base_end_date: '0100-01-01' lc_kwargs: threads_per_worker: 1 @@ -49,7 +56,7 @@ timeseries: num_procs: 8 ts_done: [False] overwrite_ts: [False] - case_name: 'b.e23_alpha16b.BLT1850.ne30_t232.054' + case_name: ['b.e30_beta04.BLT1850.ne30_t232_wgx3.121wave', 'b.e30_beta04.BLT1850.ne30_t232_wgx3.121'] atm: vars: ['ACTNI', 'ACTNL', 'ACTREI', 'ACTREL', 'AODDUST'] @@ -76,11 +83,11 @@ timeseries: level: 'lev' ice: - vars: ['aice','hi', 'hs'] #['process_all'] + vars: ['aice','hi', 'hs','uvel','vvel'] #['process_all'] derive_vars: [] hist_str: 'h' - start_years: [1] - end_years: [100] + start_years: [1,1] + end_years: [100,100] level: 'lev' glc: @@ -147,17 +154,15 @@ compute_notebooks: - 1850pSASU ice: - seaice: + Hemis_seaice_visual_compare_obs_lens: parameter_groups: none: - cases: - - b.e23_alpha17f.BLTHIST.ne30_t232.092 - - b.e30_beta02.BLTHIST.ne30_t232.104 - begyr1: 1850 - endyr1: 2013 - begyr2: 1850 - endyr2: 2013 - nyears: 35 + climo_nyears: 17 + Hemis_seaice_visual_compare_contour: + parameter_groups: + none: + climo_nyears: 17 + ########### JUPYTER BOOK CONFIG ########### @@ -196,7 +201,8 @@ book_toc: - caption: Sea Ice chapters: - - file: ice/Hemis_seaice_visual_compare_full + - file: ice/Hemis_seaice_visual_compare_obs_lens + - file: ice/Hemis_seaice_visual_compare_contour ##################################### # Keys for Jupyter Book _config.yml # diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb new file mode 100644 index 0000000..eb59a15 --- /dev/null +++ b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb @@ -0,0 +1,324 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "351f2902-54b0-463c-9d61-23574844481f", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "source": [ + "### Sea Ice Diagnostics for two CESM3 runs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7e7f10ae-61c8-45f1-9d5c-9be60632b556", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [], + "source": [ + "import xarray as xr\n", + "import numpy as np\n", + "import yaml\n", + "import pandas as pd\n", + "import matplotlib.pyplot as plt" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "270b0ff5-779c-4293-8d06-bd91eb8eee2b", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "parameters", + "hide-input" + ] + }, + "outputs": [], + "source": [ + "CESM_output_dir = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing\"\n", + "serial = False # use dask LocalCluster\n", + "\n", + "case_name = \"b.e30_beta02.BLT1850.ne30_t232.104\"\n", + "base_case_name = \"b.e23_alpha17f.BLT1850.ne30_t232.092\"\n", + "\n", + "start_date = \"0001-01-01\"\n", + "end_date = \"0101-01-01\"\n", + "base_start_date = \"0001-01-01\"\n", + "base_end_date = \"0101-01-01\"\n", + "\n", + "climo_nyears = 35\n", + "\n", + "lc_kwargs = {}\n", + "\n", + "hist = 0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "03782fa0-3224-4c2d-8355-b89d1b5f57c1", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [], + "source": [ + "cupid_run = 1\n", + "\n", + "if cupid_run == 1:\n", + "\n", + " from dask.distributed import Client, LocalCluster\n", + "\n", + " # Spin up cluster (if running in parallel)\n", + " # client = None\n", + " if not serial:\n", + " cluster = LocalCluster(**lc_kwargs)\n", + " client = Client(cluster)\n", + "\n", + " client\n", + "\n", + "else:\n", + "\n", + " from dask.distributed import Client\n", + " from dask_jobqueue import PBSCluster\n", + "\n", + " cluster = PBSCluster(\n", + " cores=16,\n", + " processes=16,\n", + " memory=\"100GB\",\n", + " account=\"P93300065\",\n", + " queue=\"casper\",\n", + " walltime=\"02:00:00\",\n", + " )\n", + "\n", + " client = Client(cluster)\n", + "\n", + " cluster.scale(1)\n", + "\n", + " print(cluster)\n", + " print(client)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d3f591cc-dd67-4a3f-abe7-bfc740743db1", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [], + "source": [ + "# Read in two cases. The ADF timeseries are needed here.\n", + "\n", + "ds1 = xr.open_mfdataset(\n", + " CESM_output_dir\n", + " + \"/\"\n", + " + case_name\n", + " + \"/ice/proc/tseries/month_1/\"\n", + " + case_name\n", + " + \".cice.h.\"\n", + " + \"*.nc\",\n", + " data_vars=\"minimal\",\n", + " compat=\"override\",\n", + " coords=\"minimal\",\n", + ").sel(time=slice(start_date, end_date))\n", + "ds2 = xr.open_mfdataset(\n", + " CESM_output_dir\n", + " + \"/\"\n", + " + base_case_name\n", + " + \"/ice/proc/tseries/month_1/\"\n", + " + base_case_name\n", + " + \".cice.h.\"\n", + " + \"*.nc\",\n", + " data_vars=\"minimal\",\n", + " compat=\"override\",\n", + " coords=\"minimal\",\n", + ").sel(time=slice(base_start_date, base_end_date))\n", + "\n", + "ds_grid = xr.open_dataset(\"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\")\n", + "TLAT = ds_grid[\"TLAT\"]\n", + "TLON = ds_grid[\"TLONG\"]\n", + "tarea = ds_grid[\"TAREA\"] * 1.0e-4\n", + "angle = ds_grid[\"ANGLE\"]\n", + "\n", + "ds1_ann = ds1.resample(time=\"YS\").mean(dim=\"time\")\n", + "ds2_ann = ds2.resample(time=\"YS\").mean(dim=\"time\")\n", + "\n", + "with open(\"cice_masks.yml\", \"r\") as file:\n", + " cice_masks = yaml.safe_load(file)\n", + "\n", + "with open(\"cice_vars.yml\", \"r\") as file:\n", + " cice_vars = yaml.safe_load(file)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "da24abe2-7b48-4c3d-b8a5-95847029bd74", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [], + "source": [ + "from plot_diff import plot_diff\n", + "from vect_diff import vect_diff" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "28a0da20-6bad-45d7-a61a-43d55ea2acd2", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [], + "source": [ + "for var in cice_vars:\n", + " vmin = cice_vars[var][0][\"levels\"][0]\n", + " vmax = cice_vars[var][0][\"levels\"][-1]\n", + " levels = np.array(cice_vars[var][0][\"levels\"])\n", + " title = cice_vars[var][1][\"title\"]\n", + " field1 = ds1_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + " field2 = ds2_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + " plot_diff(field1, field2, levels, case_name, base_case_name, title, \"N\", TLAT, TLON)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "17591ebc-5360-479f-93bc-6ba8847df5c1", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [], + "source": [ + "for var in cice_vars:\n", + " vmin = cice_vars[var][0][\"levels\"][0]\n", + " vmax = cice_vars[var][0][\"levels\"][1]\n", + " levels = np.array(cice_vars[var][0][\"levels\"])\n", + " title = cice_vars[var][1][\"title\"]\n", + " field1 = ds1_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + " field2 = ds2_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + " plot_diff(field1, field2, levels, case_name, base_case_name, title, \"S\", TLAT, TLON)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cfc18c63-fc78-45c3-a402-cfa57a6827cd", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [], + "source": [ + "uvel1 = ds1_ann[\"uvel\"].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + "vvel1 = ds1_ann[\"vvel\"].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + "uvel2 = ds2_ann[\"uvel\"].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + "vvel2 = ds2_ann[\"vvel\"].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + "\n", + "vect_diff(uvel1, vvel1, uvel2, vvel2, angle, \"N\", case_name, base_case_name, TLAT, TLON)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8116dbe6-6052-4d4e-8cf1-8a9feaf7d48e", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [], + "source": [ + "vect_diff(uvel1, vvel1, uvel2, vvel2, angle, \"S\", case_name, base_case_name, TLAT, TLON)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5199b36e-614d-4242-9dd0-a402a7a24fa9", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "NPL 2024a", + "language": "python", + "name": "npl-2024a" + }, + "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.11.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_full.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_full.ipynb deleted file mode 100644 index 66f96d6..0000000 --- a/nblibrary/ice/Hemis_seaice_visual_compare_full.ipynb +++ /dev/null @@ -1,892 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "351f2902-54b0-463c-9d61-23574844481f", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "source": [ - "## Sea Ice Diagnostics for two CESM3 runs" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "7e7f10ae-61c8-45f1-9d5c-9be60632b556", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "import xarray as xr\n", - "import numpy as np\n", - "import yaml\n", - "import pandas as pd\n", - "import matplotlib.pyplot as plt" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "270b0ff5-779c-4293-8d06-bd91eb8eee2b", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "parameters", - "hide-input" - ] - }, - "outputs": [], - "source": [ - "CESM_output_dir = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing\"\n", - "serial = False # use dask LocalCluster\n", - "cases = [\n", - " \"b.e23_alpha17f.BLTHIST.ne30_t232.092\",\n", - " \"b.e30_beta02.BLTHIST.ne30_t232.104\",\n", - "]\n", - "\n", - "lc_kwargs = {}\n", - "\n", - "begyr1 = 1850\n", - "endyr1 = 2013\n", - "begyr2 = 1850\n", - "endyr2 = 2013\n", - "climo_nyears = 35" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "dfbdb3ea-b818-44be-aafa-1dd9be54715d", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "# from dask.distributed import Client\n", - "# from dask_jobqueue import PBSCluster\n", - "\n", - "# cluster = PBSCluster(cores=16,processes=16,memory='100GB',project='P93300665',queue='casper',walltime='02:00:00')\n", - "\n", - "# client = Client(cluster)\n", - "\n", - "# cluster.scale(1)\n", - "\n", - "# print(cluster)\n", - "# print(client)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "03782fa0-3224-4c2d-8355-b89d1b5f57c1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "from dask.distributed import Client, LocalCluster\n", - "\n", - "# Spin up cluster (if running in parallel)\n", - "# client = None\n", - "if not serial:\n", - " cluster = LocalCluster(**lc_kwargs)\n", - " client = Client(cluster)\n", - "\n", - "client" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d3f591cc-dd67-4a3f-abe7-bfc740743db1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "# Read in two cases. The ADF timeseries are needed here.\n", - "\n", - "case1 = cases[0]\n", - "case2 = cases[1]\n", - "\n", - "cbegyr1 = f\"{begyr1:04d}\"\n", - "cendyr1 = f\"{endyr1:04d}\"\n", - "cbegyr2 = f\"{begyr2:04d}\"\n", - "cendyr2 = f\"{endyr2:04d}\"\n", - "\n", - "ds1 = xr.open_mfdataset(\n", - " CESM_output_dir\n", - " + \"/\"\n", - " + case1\n", - " + \"/ice/proc/tseries/month_1/\"\n", - " + case1\n", - " + \".cice.h.\"\n", - " + \"*.\"\n", - " + cbegyr1\n", - " + \"01-\"\n", - " + cendyr1\n", - " + \"12.nc\",\n", - " data_vars=\"minimal\",\n", - " compat=\"override\",\n", - " coords=\"minimal\",\n", - ")\n", - "ds2 = xr.open_mfdataset(\n", - " CESM_output_dir\n", - " + \"/\"\n", - " + case2\n", - " + \"/ice/proc/tseries/month_1/\"\n", - " + case2\n", - " + \".cice.h.\"\n", - " + \"*.\"\n", - " + cbegyr2\n", - " + \"01-\"\n", - " + cendyr2\n", - " + \"12.nc\",\n", - " data_vars=\"minimal\",\n", - " compat=\"override\",\n", - " coords=\"minimal\",\n", - ")\n", - "\n", - "ds_grid = xr.open_dataset(\"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\")\n", - "TLAT = ds_grid[\"TLAT\"]\n", - "TLON = ds_grid[\"TLONG\"]\n", - "tarea = ds_grid[\"TAREA\"] * 1.0e-4\n", - "angle = ds_grid[\"ANGLE\"]\n", - "\n", - "# Make a DataArray with the number of days in each month, size = len(time)\n", - "month_length = ds1.time.dt.days_in_month\n", - "weights_monthly = (\n", - " month_length.groupby(\"time.year\") / month_length.groupby(\"time.year\").sum()\n", - ")\n", - "\n", - "\n", - "# seasons = xr.full_like(months, fill_value=\"none\", dtype=\"U4\")\n", - "# seasons.name = \"season\"\n", - "# seasons[months.isin([1, 2, 3])] = \"JFM\"\n", - "# seasons[months.isin([4, 5, 6])] = \"AMJ\"\n", - "# seasons[months.isin([7, 8, 9])] = \"JAS\"\n", - "# seasons[months.isin([10, 11, 12])] = \"OND\"\n", - "# weights_season = month_length.groupby(seasons) / month_length.groupby(seasons).sum()\n", - "\n", - "ds1_ann = (ds1 * weights_monthly).resample(time=\"YS\").sum(dim=\"time\")\n", - "ds2_ann = (ds2 * weights_monthly).resample(time=\"YS\").sum(dim=\"time\")\n", - "\n", - "\n", - "# ds1_seas = (ds1 * weights_season).resample(time=\"QS-JAN\").sum(dim=\"time\")\n", - "# ds2_seas = (ds2 * weights_season).resample(time=\"QS-JAN\").sum(dim=\"time\")\n", - "\n", - "with open(\"cice_masks.yml\", \"r\") as file:\n", - " cice_masks = yaml.safe_load(file)\n", - "\n", - "with open(\"cice_vars.yml\", \"r\") as file:\n", - " cice_vars = yaml.safe_load(file)\n", - "\n", - "print(ds1[\"aice\"])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "da24abe2-7b48-4c3d-b8a5-95847029bd74", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "from plot_diff import plot_diff\n", - "from vect_diff import vect_diff" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "28a0da20-6bad-45d7-a61a-43d55ea2acd2", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "for var in cice_vars:\n", - " vmin = cice_vars[var][0][\"levels\"][0]\n", - " vmax = cice_vars[var][0][\"levels\"][-1]\n", - " levels = np.array(cice_vars[var][0][\"levels\"])\n", - " title = cice_vars[var][1][\"title\"]\n", - " field1 = ds1_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", - " field2 = ds2_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", - " plot_diff(field1, field2, levels, case1, case2, title, \"N\", TLAT, TLON)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "17591ebc-5360-479f-93bc-6ba8847df5c1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "for var in cice_vars:\n", - " vmin = cice_vars[var][0][\"levels\"][0]\n", - " vmax = cice_vars[var][0][\"levels\"][1]\n", - " levels = np.array(cice_vars[var][0][\"levels\"])\n", - " title = cice_vars[var][1][\"title\"]\n", - " field1 = ds1_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", - " field2 = ds2_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", - " plot_diff(field1, field2, levels, case1, case2, title, \"S\", TLAT, TLON)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ab1c8910-677e-4345-8f06-ec3f7a4a9f07", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "ds1_area = (tarea * ds1.aice).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "ds2_area = (tarea * ds2.aice).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "\n", - "ds1_vhi = (tarea * ds1.hi).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-13\n", - "ds2_vhi = (tarea * ds2.hi).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-13\n", - "\n", - "ds1_vhs = (tarea * ds1.hs).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-13\n", - "ds2_vhs = (tarea * ds2.hs).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-13\n", - "\n", - "fig = plt.figure(figsize=(10, 10), tight_layout=True)\n", - "\n", - "ax = fig.add_subplot(3, 1, 1)\n", - "ds1_vhi.plot()\n", - "ds2_vhi.plot()\n", - "\n", - "plt.ylim((0, 10))\n", - "plt.xlabel(\"Month\")\n", - "plt.ylabel(\"NH Sea Ice Volume $m x 10^{13}$\")\n", - "plt.legend([case1, case2])\n", - "\n", - "ax = fig.add_subplot(3, 1, 2)\n", - "ds1_vhs.plot()\n", - "ds2_vhs.plot()\n", - "\n", - "plt.ylim((0, 1))\n", - "plt.xlabel(\"Month\")\n", - "plt.ylabel(\"NH Snow Volume $m x 10^{13}$\")\n", - "plt.legend([case1, case2])\n", - "\n", - "ax = fig.add_subplot(3, 1, 3)\n", - "ds1_area.plot()\n", - "ds2_area.plot()\n", - "\n", - "plt.ylim((0, 25))\n", - "plt.xlabel(\"Month\")\n", - "plt.ylabel(\"NH Sea Ice Area $m x 10^{12}$\")\n", - "plt.legend([case1, case2])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "cbf46c87-c3be-4a9e-90e8-e2a6633109e3", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "ds1_area_ann = (tarea * ds1_ann[\"aice\"]).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "ds2_area_ann = (tarea * ds2_ann[\"aice\"]).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "\n", - "ds1_vhi_ann = (tarea * ds1_ann[\"hi\"]).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-13\n", - "ds2_vhi_ann = (tarea * ds2_ann[\"hi\"]).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-13\n", - "\n", - "ds1_vhs_ann = (tarea * ds1_ann[\"hs\"]).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-13\n", - "ds2_vhs_ann = (tarea * ds2_ann[\"hs\"]).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-13\n", - "\n", - "fig = plt.figure(figsize=(10, 10), tight_layout=True)\n", - "\n", - "ax = fig.add_subplot(3, 1, 1)\n", - "ds1_vhi_ann.plot()\n", - "ds2_vhi_ann.plot()\n", - "\n", - "plt.ylim((0, 10))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"NH Annual Mean Sea Ice Volume $m x 10^{13}$\")\n", - "plt.legend([case1, case2])\n", - "\n", - "ax = fig.add_subplot(3, 1, 2)\n", - "ds1_vhs_ann.plot()\n", - "ds2_vhs_ann.plot()\n", - "\n", - "plt.ylim((0, 1))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"NH Annual Mean Snow Volume $m x 10^{13}$\")\n", - "plt.legend([case1, case2])\n", - "\n", - "ax = fig.add_subplot(3, 1, 3)\n", - "ds1_area_ann.plot()\n", - "ds2_area_ann.plot()\n", - "\n", - "plt.ylim((0, 25))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"NH Annual Mean Sea Ice Area $m x 10^{12}$\")\n", - "plt.legend([case1, case2])" - ] - }, - { - "cell_type": "markdown", - "id": "dad0ad61-9566-4e49-8262-1516174fe322", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "source": [ - "ds1_area.sel(time=ds1_area.time.dt.month.isin([10])).plot()\n", - "ds2_area.sel(time=ds2_area.time.dt.month.isin([10])).plot()\n", - "\n", - "plt.ylim((0,25))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"NH September Sea Ice Area $m x 10^{12}$\")\n", - "plt.legend([case1,case2])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "45366ccd-555b-49aa-93a2-51b83e802d16", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "ds1_area = (tarea * ds1.aice).where(TLAT < 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "ds2_area = (tarea * ds2.aice).where(TLAT < 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "\n", - "ds1_area.plot()\n", - "ds2_area.plot()\n", - "\n", - "plt.ylim((0, 25))\n", - "plt.xlabel(\"Month\")\n", - "plt.ylabel(\"SH Sea Ice Area $m x 10^{12}$\")\n", - "plt.legend([case1, case2])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "68400aca-aa0c-47f1-b7de-2c34dca5ac70", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "ds1_area_ann = (tarea * ds1_ann.aice).where(TLAT < 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "ds2_area_ann = (tarea * ds2_ann.aice).where(TLAT < 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "\n", - "ds1_area_ann.plot()\n", - "ds2_area_ann.plot()\n", - "\n", - "plt.ylim((0, 25))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"SH Annual Mean Sea Ice Area $m x 10^{12}$\")\n", - "plt.legend([case1, case2])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "de2232e9-2705-4894-b98a-a93082ae7f79", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "### Read in the NSIDC data from files\n", - "\n", - "path_nsidc = \"/glade/campaign/cesm/development/pcwg/ice/data/NSIDC_SeaIce_extent/\"\n", - "\n", - "jan_nsidc = pd.read_csv(path_nsidc + \"N_01_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "feb_nsidc = pd.read_csv(path_nsidc + \"N_02_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "mar_nsidc = pd.read_csv(path_nsidc + \"N_03_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "apr_nsidc = pd.read_csv(path_nsidc + \"N_04_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "may_nsidc = pd.read_csv(path_nsidc + \"N_05_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "jun_nsidc = pd.read_csv(path_nsidc + \"N_06_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "jul_nsidc = pd.read_csv(path_nsidc + \"N_07_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "aug_nsidc = pd.read_csv(path_nsidc + \"N_08_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "sep_nsidc = pd.read_csv(path_nsidc + \"N_09_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "oct_nsidc = pd.read_csv(path_nsidc + \"N_10_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "nov_nsidc = pd.read_csv(path_nsidc + \"N_11_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "dec_nsidc = pd.read_csv(path_nsidc + \"N_12_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "\n", - "jan_area = jan_nsidc.iloc[:, 5].values\n", - "feb_area = feb_nsidc.iloc[:, 5].values\n", - "mar_area = mar_nsidc.iloc[:, 5].values\n", - "apr_area = apr_nsidc.iloc[:, 5].values\n", - "may_area = may_nsidc.iloc[:, 5].values\n", - "jun_area = jun_nsidc.iloc[:, 5].values\n", - "jul_area = jul_nsidc.iloc[:, 5].values\n", - "aug_area = aug_nsidc.iloc[:, 5].values\n", - "sep_area = sep_nsidc.iloc[:, 5].values\n", - "oct_area = oct_nsidc.iloc[:, 5].values\n", - "nov_area = nov_nsidc.iloc[:, 5].values\n", - "dec_area = dec_nsidc.iloc[:, 5].values\n", - "\n", - "jan_ext = jan_nsidc.iloc[:, 4].values\n", - "feb_ext = feb_nsidc.iloc[:, 4].values\n", - "mar_ext = mar_nsidc.iloc[:, 4].values\n", - "apr_ext = apr_nsidc.iloc[:, 4].values\n", - "may_ext = may_nsidc.iloc[:, 4].values\n", - "jun_ext = jun_nsidc.iloc[:, 4].values\n", - "jul_ext = jul_nsidc.iloc[:, 4].values\n", - "aug_ext = aug_nsidc.iloc[:, 4].values\n", - "sep_ext = sep_nsidc.iloc[:, 4].values\n", - "oct_ext = oct_nsidc.iloc[:, 4].values\n", - "nov_ext = nov_nsidc.iloc[:, 4].values\n", - "dec_ext = dec_nsidc.iloc[:, 4].values\n", - "\n", - "print(dec_ext)\n", - "nsidc_clim = [\n", - " np.nanmean(jan_ext[0:35]),\n", - " np.nanmean(feb_ext[0:35]),\n", - " np.nanmean(mar_ext[0:35]),\n", - " np.nanmean(apr_ext[0:35]),\n", - " np.nanmean(may_ext[0:35]),\n", - " np.nanmean(jun_ext[0:35]),\n", - " np.nanmean(jul_ext[0:35]),\n", - " np.nanmean(aug_ext[0:35]),\n", - " np.nanmean(sep_ext[0:35]),\n", - " np.nanmean(oct_ext[0:35]),\n", - " np.nanmean(nov_ext[0:35]),\n", - " np.nanmean(dec_ext[0:35]),\n", - "]\n", - "\n", - "plt.plot(nsidc_clim)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "23ab7224-a908-4efd-9a79-45e50e2841b1", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "### Read in the SH NSIDC data from files\n", - "\n", - "path_nsidc = \"/glade/campaign/cesm/development/pcwg/ice/data/NSIDC_SeaIce_extent/\"\n", - "\n", - "jan_nsidc_sh = pd.read_csv(path_nsidc + \"S_01_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "feb_nsidc_sh = pd.read_csv(path_nsidc + \"S_02_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "mar_nsidc_sh = pd.read_csv(path_nsidc + \"S_03_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "apr_nsidc_sh = pd.read_csv(path_nsidc + \"S_04_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "may_nsidc_sh = pd.read_csv(path_nsidc + \"S_05_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "jun_nsidc_sh = pd.read_csv(path_nsidc + \"S_06_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "jul_nsidc_sh = pd.read_csv(path_nsidc + \"S_07_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "aug_nsidc_sh = pd.read_csv(path_nsidc + \"S_08_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "sep_nsidc_sh = pd.read_csv(path_nsidc + \"S_09_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "oct_nsidc_sh = pd.read_csv(path_nsidc + \"S_10_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "nov_nsidc_sh = pd.read_csv(path_nsidc + \"S_11_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "dec_nsidc_sh = pd.read_csv(path_nsidc + \"S_12_extent_v3.0.csv\", na_values=[\"-99.9\"])\n", - "\n", - "jan_area_sh = jan_nsidc_sh.iloc[:, 5].values\n", - "feb_area_sh = feb_nsidc_sh.iloc[:, 5].values\n", - "mar_area_sh = mar_nsidc_sh.iloc[:, 5].values\n", - "apr_area_sh = apr_nsidc_sh.iloc[:, 5].values\n", - "may_area_sh = may_nsidc_sh.iloc[:, 5].values\n", - "jun_area_sh = jun_nsidc_sh.iloc[:, 5].values\n", - "jul_area_sh = jul_nsidc_sh.iloc[:, 5].values\n", - "aug_area_sh = aug_nsidc_sh.iloc[:, 5].values\n", - "sep_area_sh = sep_nsidc_sh.iloc[:, 5].values\n", - "oct_area_sh = oct_nsidc_sh.iloc[:, 5].values\n", - "nov_area_sh = nov_nsidc_sh.iloc[:, 5].values\n", - "dec_area_sh = dec_nsidc_sh.iloc[:, 5].values\n", - "\n", - "jan_ext_sh = jan_nsidc_sh.iloc[:, 4].values\n", - "feb_ext_sh = feb_nsidc_sh.iloc[:, 4].values\n", - "mar_ext_sh = mar_nsidc_sh.iloc[:, 4].values\n", - "apr_ext_sh = apr_nsidc_sh.iloc[:, 4].values\n", - "may_ext_sh = may_nsidc_sh.iloc[:, 4].values\n", - "jun_ext_sh = jun_nsidc_sh.iloc[:, 4].values\n", - "jul_ext_sh = jul_nsidc_sh.iloc[:, 4].values\n", - "aug_ext_sh = aug_nsidc_sh.iloc[:, 4].values\n", - "sep_ext_sh = sep_nsidc_sh.iloc[:, 4].values\n", - "oct_ext_sh = oct_nsidc_sh.iloc[:, 4].values\n", - "nov_ext_sh = nov_nsidc_sh.iloc[:, 4].values\n", - "dec_ext_sh = dec_nsidc_sh.iloc[:, 4].values\n", - "\n", - "print(dec_ext_sh)\n", - "nsidc_clim_sh = [\n", - " np.nanmean(jan_ext_sh[0:35]),\n", - " np.nanmean(feb_ext_sh[0:35]),\n", - " np.nanmean(mar_ext_sh[0:35]),\n", - " np.nanmean(apr_ext_sh[0:35]),\n", - " np.nanmean(may_ext_sh[0:35]),\n", - " np.nanmean(jun_ext_sh[0:35]),\n", - " np.nanmean(jul_ext_sh[0:35]),\n", - " np.nanmean(aug_ext_sh[0:35]),\n", - " np.nanmean(sep_ext_sh[0:35]),\n", - " np.nanmean(oct_ext_sh[0:35]),\n", - " np.nanmean(nov_ext_sh[0:35]),\n", - " np.nanmean(dec_ext_sh[0:35]),\n", - "]\n", - "\n", - "plt.plot(nsidc_clim_sh)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "dcfc33a9-1dce-4dc7-95e3-dbdccee3575a", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "print(ds1[\"aice\"])\n", - "\n", - "aice1_month = (\n", - " ds1[\"aice\"]\n", - " .isel(time=slice(-climo_nyears, None))\n", - " .groupby(\"time.month\")\n", - " .mean(dim=\"time\", skipna=True)\n", - ")\n", - "aice2_month = (\n", - " ds2[\"aice\"]\n", - " .isel(time=slice(-climo_nyears, None))\n", - " .groupby(\"time.month\")\n", - " .mean(dim=\"time\", skipna=True)\n", - ")\n", - "mask_tmp1 = np.where(np.logical_and(aice1_month > 0.15, ds1[\"TLAT\"] > 0), 1.0, 0.0)\n", - "mask_tmp2 = np.where(np.logical_and(aice2_month > 0.15, ds1[\"TLAT\"] > 0), 1.0, 0.0)\n", - "\n", - "mask_ext1 = xr.DataArray(data=mask_tmp1, dims=[\"month\", \"nj\", \"ni\"])\n", - "mask_ext2 = xr.DataArray(data=mask_tmp2, dims=[\"month\", \"nj\", \"ni\"])\n", - "\n", - "\n", - "ext1 = (mask_ext1 * tarea).sum([\"ni\", \"nj\"]) * 1.0e-12\n", - "ext2 = (mask_ext2 * tarea).sum([\"ni\", \"nj\"]) * 1.0e-12\n", - "\n", - "plt.plot(ext1)\n", - "plt.plot(ext2)\n", - "plt.plot(nsidc_clim)\n", - "\n", - "plt.ylim((0, 25))\n", - "plt.xlabel(\"Month\")\n", - "plt.ylabel(\"Climatological Seasonal Cycle Ice Extent $m x 10^{12}$\")\n", - "plt.legend([case1, case2, \"NSIDC\"])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bdcfc214-ab3c-4444-86ff-6cb9bea19236", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "mask_tmp1_sh = np.where(np.logical_and(aice1_month > 0.15, ds1[\"TLAT\"] < 0), 1.0, 0.0)\n", - "mask_tmp2_sh = np.where(np.logical_and(aice2_month > 0.15, ds1[\"TLAT\"] < 0), 1.0, 0.0)\n", - "\n", - "mask_ext1_sh = xr.DataArray(data=mask_tmp1_sh, dims=[\"month\", \"nj\", \"ni\"])\n", - "mask_ext2_sh = xr.DataArray(data=mask_tmp2_sh, dims=[\"month\", \"nj\", \"ni\"])\n", - "\n", - "\n", - "ext1_sh = (mask_ext1_sh * tarea).sum([\"ni\", \"nj\"]) * 1.0e-12\n", - "ext2_sh = (mask_ext2_sh * tarea).sum([\"ni\", \"nj\"]) * 1.0e-12\n", - "\n", - "plt.plot(ext1_sh)\n", - "plt.plot(ext2_sh)\n", - "plt.plot(nsidc_clim_sh)\n", - "\n", - "plt.ylim((0, 25))\n", - "plt.xlabel(\"Month\")\n", - "plt.ylabel(\"Climatological Seasonal Cycle Ice Extent $m x 10^{12}$\")\n", - "plt.legend([case1, case2, \"NSIDC\"])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "00fc5097-af7d-4cf2-94ab-bb4e0a63960c", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "ds1_area = (tarea * ds1.aice).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "ds2_area = (tarea * ds2.aice).where(TLAT > 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "\n", - "ds1_sep = ds1_area.sel(time=(ds1_area.time.dt.month == 9))\n", - "ds2_sep = ds2_area.sel(time=(ds2_area.time.dt.month == 9))\n", - "\n", - "x1 = np.linspace(1, 18, 18)\n", - "x2 = np.linspace(1, 100, 100)\n", - "x3 = np.linspace(1, 36, 36)\n", - "\n", - "plt.plot(x1, ds1_sep)\n", - "plt.plot(x2, ds2_sep)\n", - "plt.plot(x3, sep_area[0:36])\n", - "\n", - "plt.ylim((0, 25))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"Sea Ice Area $mx10^{12}$\")\n", - "plt.legend([case1, case2, \"NSIDC\"])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "2f26a3f2-6a7c-4878-a352-f289a7efbd81", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "ds1_area_sh = (tarea * ds1.aice).where(TLAT < 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "ds2_area_sh = (tarea * ds2.aice).where(TLAT < 0).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "\n", - "ds1_feb_sh = ds1_area_sh.sel(time=(ds1_area_sh.time.dt.month == 2))\n", - "ds2_feb_sh = ds2_area_sh.sel(time=(ds2_area_sh.time.dt.month == 2))\n", - "\n", - "ds1_sep_sh = ds1_area_sh.sel(time=(ds1_area_sh.time.dt.month == 9))\n", - "ds2_sep_sh = ds2_area_sh.sel(time=(ds2_area_sh.time.dt.month == 9))\n", - "\n", - "x1 = np.linspace(1, 18, 18)\n", - "x2 = np.linspace(1, 100, 100)\n", - "x3 = np.linspace(1, 36, 36)\n", - "\n", - "plt.plot(x1, ds1_sep_sh)\n", - "plt.plot(x2, ds2_sep_sh)\n", - "plt.plot(x3, sep_area_sh[0:36])\n", - "\n", - "plt.ylim((0, 25))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"Sea Ice Area $mx10^{12}$\")\n", - "plt.legend([case1, case2, \"NSIDC\"])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b9a9ad99-e580-4188-a328-950c84eb1b62", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "latm = cice_masks[\"Lab_lat\"]\n", - "lonm = cice_masks[\"Lab_lon\"]\n", - "\n", - "lon = np.where(TLON < 0, TLON + 360.0, TLON)\n", - "mask1 = np.where(np.logical_and(TLAT > latm[0], TLAT < latm[1]), 1.0, 0.0)\n", - "mask2 = np.where(np.logical_or(lon > lonm[0], lon < lonm[1]), 1.0, 0.0)\n", - "mask = mask1 * mask2\n", - "\n", - "ds1_lab = (mask * tarea * ds1.aice).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "ds2_lab = (mask * tarea * ds2.aice).sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", - "\n", - "ds1_lab.plot()\n", - "ds2_lab.plot()\n", - "\n", - "plt.ylim((0, 10))\n", - "plt.xlabel(\"Month\")\n", - "plt.ylabel(\"Labrador Sea Ice Area $m x 10^{12}$\")\n", - "plt.legend([case1, case2])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "cfc18c63-fc78-45c3-a402-cfa57a6827cd", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "uvel1 = ds1_ann[\"uvel\"].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", - "vvel1 = ds1_ann[\"vvel\"].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", - "uvel2 = ds2_ann[\"uvel\"].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", - "vvel2 = ds2_ann[\"vvel\"].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", - "\n", - "vect_diff(uvel1, vvel1, uvel2, vvel2, angle, \"N\", case1, case2, TLAT, TLON)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8116dbe6-6052-4d4e-8cf1-8a9feaf7d48e", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "vect_diff(uvel1, vvel1, uvel2, vvel2, angle, \"S\", case1, case2, TLAT, TLON)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5199b36e-614d-4242-9dd0-a402a7a24fa9", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "NPL 2024a", - "language": "python", - "name": "npl-2024a" - }, - "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.11.6" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} From 856a9d7212c9bd482e55bea134394b787aa35e8d Mon Sep 17 00:00:00 2001 From: Teagan King <98482480+TeaganKing@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:09:06 -0700 Subject: [PATCH 3/8] remove unused imports in Hemis_seaice_visual_compare_contour.ipynb --- nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb index eb59a15..403241b 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb @@ -33,9 +33,7 @@ "source": [ "import xarray as xr\n", "import numpy as np\n", - "import yaml\n", - "import pandas as pd\n", - "import matplotlib.pyplot as plt" + "import yaml\n" ] }, { From 87174e35f1f37337adc088dd53d690c6d0a9ca85 Mon Sep 17 00:00:00 2001 From: Teagan King <98482480+TeaganKing@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:11:38 -0700 Subject: [PATCH 4/8] remove new line after yaml --- nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb index 403241b..2d0887f 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb @@ -33,7 +33,7 @@ "source": [ "import xarray as xr\n", "import numpy as np\n", - "import yaml\n" + "import yaml" ] }, { From 772407d8456de53ef8dd53d268fe7d14ff2267c6 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Fri, 17 Jan 2025 12:50:48 -0700 Subject: [PATCH 5/8] Fix the timeseries in the coupled model config --- examples/coupled_model/config.yml | 16 ++--- .../Hemis_seaice_visual_compare_contour.ipynb | 66 +++++++++++++++---- 2 files changed, 63 insertions(+), 19 deletions(-) diff --git a/examples/coupled_model/config.yml b/examples/coupled_model/config.yml index 985a30b..2d46a7e 100644 --- a/examples/coupled_model/config.yml +++ b/examples/coupled_model/config.yml @@ -41,12 +41,12 @@ computation_config: # All parameters under global_params get passed to all the notebooks global_params: - case_name: 'b.e30_beta04.BLT1850.ne30_t232_wgx3.121wave' + case_name: 'b.e30_beta04.BLT1850.ne30_t232_wgx3.121min' base_case_name: 'b.e30_beta04.BLT1850.ne30_t232_wgx3.121' CESM_output_dir: /glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing base_case_output_dir: /glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing start_date: '0001-01-01' - end_date: '0018-01-01' + end_date: '0100-01-01' base_start_date: '0001-01-01' base_end_date: '0100-01-01' lc_kwargs: @@ -54,9 +54,9 @@ global_params: timeseries: num_procs: 8 - ts_done: [False] - overwrite_ts: [False] - case_name: ['b.e30_beta04.BLT1850.ne30_t232_wgx3.121wave', 'b.e30_beta04.BLT1850.ne30_t232_wgx3.121'] + ts_done: [False,False] + overwrite_ts: [False,False] + case_name: ['b.e30_beta04.BLT1850.ne30_t232_wgx3.121min', 'b.e30_beta04.BLT1850.ne30_t232_wgx3.121'] atm: vars: ['ACTNI', 'ACTNL', 'ACTREI', 'ACTREL', 'AODDUST'] @@ -85,7 +85,7 @@ timeseries: ice: vars: ['aice','hi', 'hs','uvel','vvel'] #['process_all'] derive_vars: [] - hist_str: 'h' + hist_str: 'cice.h' start_years: [1,1] end_years: [100,100] level: 'lev' @@ -157,11 +157,11 @@ compute_notebooks: Hemis_seaice_visual_compare_obs_lens: parameter_groups: none: - climo_nyears: 17 + climo_nyears: 35 Hemis_seaice_visual_compare_contour: parameter_groups: none: - climo_nyears: 17 + climo_nyears: 35 ########### JUPYTER BOOK CONFIG ########### diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb index eb59a15..a1daff8 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "7e7f10ae-61c8-45f1-9d5c-9be60632b556", "metadata": { "editable": true, @@ -40,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "270b0ff5-779c-4293-8d06-bd91eb8eee2b", "metadata": { "editable": true, @@ -57,13 +57,13 @@ "CESM_output_dir = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing\"\n", "serial = False # use dask LocalCluster\n", "\n", - "case_name = \"b.e30_beta02.BLT1850.ne30_t232.104\"\n", - "base_case_name = \"b.e23_alpha17f.BLT1850.ne30_t232.092\"\n", + "case_name = \"b.e30_beta04.BLT1850.ne30_t232_wgx3.121congel\"\n", + "base_case_name = \"b.e30_beta04.BLT1850.ne30_t232_wgx3.121\"\n", "\n", "start_date = \"0001-01-01\"\n", - "end_date = \"0101-01-01\"\n", + "end_date = \"0100-01-01\"\n", "base_start_date = \"0001-01-01\"\n", - "base_end_date = \"0101-01-01\"\n", + "base_end_date = \"0100-01-01\"\n", "\n", "climo_nyears = 35\n", "\n", @@ -74,7 +74,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "03782fa0-3224-4c2d-8355-b89d1b5f57c1", "metadata": { "editable": true, @@ -85,9 +85,18 @@ "hide-input" ] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "PBSCluster(a97e1d22, 'tcp://128.117.208.105:41121', workers=0, threads=0, memory=0 B)\n", + "\n" + ] + } + ], "source": [ - "cupid_run = 1\n", + "cupid_run = 0\n", "\n", "if cupid_run == 1:\n", "\n", @@ -125,7 +134,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "d3f591cc-dd67-4a3f-abe7-bfc740743db1", "metadata": { "editable": true, @@ -136,7 +145,40 @@ "hide-input" ] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Dimensions: (time: 50, nj: 480, ni: 540, nvertices: 4)\n", + "Coordinates:\n", + " TLON (nj, ni) float32 dask.array\n", + " TLAT (nj, ni) float32 dask.array\n", + " * time (time) object 0001-01-01 00:00:00 ... 0050-01-01 00:00:00\n", + "Dimensions without coordinates: nj, ni, nvertices\n", + "Data variables:\n", + " aice (time, nj, ni) float32 dask.array\n", + " hi (time, nj, ni) float32 dask.array\n", + " hs (time, nj, ni) float32 dask.array\n", + " tarea (time, nj, ni) float32 dask.array\n", + " lont_bounds (time, nj, ni, nvertices) float32 dask.array\n", + " latt_bounds (time, nj, ni, nvertices) float32 dask.array\n", + "Attributes:\n", + " title: b.e30_beta04.BLT1850.ne30_t232_wgx3.121congel\n", + " contents: Diagnostic and Prognostic Variables\n", + " source: CICE Sea Ice Model, unknown_version_name\n", + " comment: All years have exactly 365 days\n", + " comment2: File written on model date 00010201\n", + " comment3: seconds elapsed into model date: 0\n", + " time_period_freq: month_1\n", + " time_axis_position: middle\n", + " conventions: CF-1.0\n", + " history: This dataset was created on 2024-12-31 at 13:19\n", + " io_flavor: io_pio2 cdf1\n" + ] + } + ], "source": [ "# Read in two cases. The ADF timeseries are needed here.\n", "\n", @@ -174,6 +216,8 @@ "ds1_ann = ds1.resample(time=\"YS\").mean(dim=\"time\")\n", "ds2_ann = ds2.resample(time=\"YS\").mean(dim=\"time\")\n", "\n", + "print(ds1_ann)\n", + "\n", "with open(\"cice_masks.yml\", \"r\") as file:\n", " cice_masks = yaml.safe_load(file)\n", "\n", From 1883a77291bc3ae3ee81749af35d0d1d5940b7a2 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Fri, 17 Jan 2025 13:09:39 -0700 Subject: [PATCH 6/8] Cleat outputs --- nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb index 071d691..1f7e0a7 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb @@ -94,7 +94,7 @@ } ], "source": [ - "cupid_run = 0\n", + "cupid_run = 1\n", "\n", "if cupid_run == 1:\n", "\n", From aac0c500a7b65247b7462d7984b6606c53dc2b7d Mon Sep 17 00:00:00 2001 From: David Bailey Date: Fri, 17 Jan 2025 13:27:22 -0700 Subject: [PATCH 7/8] Clear output --- .../Hemis_seaice_visual_compare_contour.ipynb | 56 ++----------------- ...Hemis_seaice_visual_compare_obs_lens.ipynb | 22 -------- 2 files changed, 6 insertions(+), 72 deletions(-) diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb index 1f7e0a7..a1404ac 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "7e7f10ae-61c8-45f1-9d5c-9be60632b556", "metadata": { "editable": true, @@ -38,7 +38,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "270b0ff5-779c-4293-8d06-bd91eb8eee2b", "metadata": { "editable": true, @@ -72,7 +72,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "03782fa0-3224-4c2d-8355-b89d1b5f57c1", "metadata": { "editable": true, @@ -83,16 +83,7 @@ "hide-input" ] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "PBSCluster(a97e1d22, 'tcp://128.117.208.105:41121', workers=0, threads=0, memory=0 B)\n", - "\n" - ] - } - ], + "outputs": [], "source": [ "cupid_run = 1\n", "\n", @@ -132,7 +123,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "d3f591cc-dd67-4a3f-abe7-bfc740743db1", "metadata": { "editable": true, @@ -143,40 +134,7 @@ "hide-input" ] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Dimensions: (time: 50, nj: 480, ni: 540, nvertices: 4)\n", - "Coordinates:\n", - " TLON (nj, ni) float32 dask.array\n", - " TLAT (nj, ni) float32 dask.array\n", - " * time (time) object 0001-01-01 00:00:00 ... 0050-01-01 00:00:00\n", - "Dimensions without coordinates: nj, ni, nvertices\n", - "Data variables:\n", - " aice (time, nj, ni) float32 dask.array\n", - " hi (time, nj, ni) float32 dask.array\n", - " hs (time, nj, ni) float32 dask.array\n", - " tarea (time, nj, ni) float32 dask.array\n", - " lont_bounds (time, nj, ni, nvertices) float32 dask.array\n", - " latt_bounds (time, nj, ni, nvertices) float32 dask.array\n", - "Attributes:\n", - " title: b.e30_beta04.BLT1850.ne30_t232_wgx3.121congel\n", - " contents: Diagnostic and Prognostic Variables\n", - " source: CICE Sea Ice Model, unknown_version_name\n", - " comment: All years have exactly 365 days\n", - " comment2: File written on model date 00010201\n", - " comment3: seconds elapsed into model date: 0\n", - " time_period_freq: month_1\n", - " time_axis_position: middle\n", - " conventions: CF-1.0\n", - " history: This dataset was created on 2024-12-31 at 13:19\n", - " io_flavor: io_pio2 cdf1\n" - ] - } - ], + "outputs": [], "source": [ "# Read in two cases. The ADF timeseries are needed here.\n", "\n", @@ -214,8 +172,6 @@ "ds1_ann = ds1.resample(time=\"YS\").mean(dim=\"time\")\n", "ds2_ann = ds2.resample(time=\"YS\").mean(dim=\"time\")\n", "\n", - "print(ds1_ann)\n", - "\n", "with open(\"cice_masks.yml\", \"r\") as file:\n", " cice_masks = yaml.safe_load(file)\n", "\n", diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb index a63d4ed..29f03cc 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -268,28 +268,6 @@ "plt.legend([case_name, base_case_name])" ] }, - { - "cell_type": "markdown", - "id": "dad0ad61-9566-4e49-8262-1516174fe322", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "source": [ - "ds1_area.sel(time=ds1_area.time.dt.month.isin([10])).plot()\n", - "ds2_area.sel(time=ds2_area.time.dt.month.isin([10])).plot()\n", - "\n", - "plt.ylim((0,25))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"NH September Sea Ice Area $m x 10^{12}$\")\n", - "plt.legend([case_name,base_case_name])" - ] - }, { "cell_type": "code", "execution_count": null, From 7da2503a645dbebb11b12526cdcaba2602a4274b Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Sat, 25 Jan 2025 11:56:14 -0700 Subject: [PATCH 8/8] Need to define client for --serial Also, we want to print(client) for both CUPiD and non-CUPiD runs --- nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb | 6 ++---- nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb index a1404ac..6322def 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb @@ -92,13 +92,11 @@ " from dask.distributed import Client, LocalCluster\n", "\n", " # Spin up cluster (if running in parallel)\n", - " # client = None\n", + " client = None\n", " if not serial:\n", " cluster = LocalCluster(**lc_kwargs)\n", " client = Client(cluster)\n", "\n", - " client\n", - "\n", "else:\n", "\n", " from dask.distributed import Client\n", @@ -118,7 +116,7 @@ " cluster.scale(1)\n", "\n", " print(cluster)\n", - " print(client)" + "print(client)" ] }, { diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb index 29f03cc..c760403 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -94,13 +94,11 @@ " from dask.distributed import Client, LocalCluster\n", "\n", " # Spin up cluster (if running in parallel)\n", - " # client = None\n", + " client = None\n", " if not serial:\n", " cluster = LocalCluster(**lc_kwargs)\n", " client = Client(cluster)\n", "\n", - " client\n", - "\n", "else:\n", "\n", " from dask.distributed import Client\n", @@ -120,7 +118,8 @@ " cluster.scale(1)\n", "\n", " print(cluster)\n", - " print(client)" + "\n", + "client" ] }, {