From e54d87bc9b1573075c15448a8c2bc3cfe6b3ec62 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Tue, 4 Feb 2025 14:49:54 -0700 Subject: [PATCH 01/11] Further plot updates and fix observed contour lines --- .../Hemis_seaice_visual_compare_contour.ipynb | 8 +- ...Hemis_seaice_visual_compare_obs_lens.ipynb | 11 ++- nblibrary/ice/plot_diff.py | 89 +++---------------- 3 files changed, 26 insertions(+), 82 deletions(-) diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb index f7ca899..0a7c911 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb @@ -218,8 +218,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(-climo_nyears, None)).mean(\"time\").squeeze()\n", - " field2 = ds2_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + " field1 = ds1[var].isel(time=slice(-climo_nyears * 12, None))\n", + " field2 = ds2[var].isel(time=slice(-climo_nyears * 12, None))\n", " plot_diff(field1, field2, levels, case_name, base_case_name, title, \"N\", TLAT, TLON)" ] }, @@ -243,8 +243,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(-climo_nyears, None)).mean(\"time\").squeeze()\n", - " field2 = ds2_ann[var].isel(time=slice(-climo_nyears, None)).mean(\"time\").squeeze()\n", + " field1 = ds1[var].isel(time=slice(-climo_nyears * 12, None))\n", + " field2 = ds2[var].isel(time=slice(-climo_nyears * 12, None))\n", " plot_diff(field1, field2, levels, case_name, base_case_name, title, \"S\", 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 7a9e0e2..dcc9e9a 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -38,7 +38,8 @@ "import yaml\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", - "import matplotlib.lines as mlines" + "import matplotlib.lines as mlines\n", + "import nc_time_axis" ] }, { @@ -961,8 +962,12 @@ "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", + "ds1_lab = (mask * tarea * ds1.aice).sum(dim=[\"nj\", \"ni\"]).sel(\n", + " time=(ds1.time.dt.month == 3)\n", + ") * 1.0e-12\n", + "ds2_lab = (mask * tarea * ds2.aice).sum(dim=[\"nj\", \"ni\"]).sel(\n", + " time=(ds2.time.dt.month == 3)\n", + ") * 1.0e-12\n", "\n", "ds1_lab.plot(color=\"red\")\n", "ds2_lab.plot(color=\"blue\")\n", diff --git a/nblibrary/ice/plot_diff.py b/nblibrary/ice/plot_diff.py index 4fc1701..7db8b32 100644 --- a/nblibrary/ice/plot_diff.py +++ b/nblibrary/ice/plot_diff.py @@ -10,69 +10,6 @@ from matplotlib.gridspec import GridSpec -def add_cyclic(ds): - - ni = ds.tlon.shape[1] - - xL = int(ni / 2 - 1) - xR = int(xL + ni) - - tlon = ds.tlon.data - tlat = ds.tlat.data - - tlon = np.where(np.greater_equal(tlon, min(tlon[:, 0])), tlon - 360.0, tlon) - lon = np.concatenate((tlon, tlon + 360.0), 1) - lon = lon[:, xL:xR] - - if ni == 320: - lon[367:-3, 0] = lon[367:-3, 0] + 360.0 - lon = lon - 360.0 - - lon = np.hstack((lon, lon[:, 0:1] + 360.0)) - if ni == 320: - lon[367:, -1] = lon[367:, -1] - 360.0 - - # -- trick cartopy into doing the right thing: - # it gets confused when the cyclic coords are identical - lon[:, 0] = lon[:, 0] - 1e-8 - - # -- periodicity - lat = np.concatenate((tlat, tlat), 1) - lat = lat[:, xL:xR] - lat = np.hstack((lat, lat[:, 0:1])) - - TLAT = xr.DataArray(lat, dims=("nlat", "nlon")) - TLONG = xr.DataArray(lon, dims=("nlat", "nlon")) - - dso = xr.Dataset({"TLAT": TLAT, "TLONG": TLONG}) - # copy vars - varlist = [v for v in ds.data_vars if v not in ["TLAT", "TLONG"]] - for v in varlist: - v_dims = ds[v].dims - if not ("nlat" in v_dims and "nlon" in v_dims): - dso[v] = ds[v] - else: - # determine and sort other dimensions - other_dims = set(v_dims) - {"nlat", "nlon"} - other_dims = tuple([d for d in v_dims if d in other_dims]) - lon_dim = ds[v].dims.index("nlon") - field = ds[v].data - field = np.concatenate((field, field), lon_dim) - field = field[..., :, xL:xR] - field = np.concatenate((field, field[..., :, 0:1]), lon_dim) - dso[v] = xr.DataArray( - field, - dims=other_dims + ("nlat", "nlon"), - attrs=ds[v].attrs, - ) - # copy coords - for v, da in ds.coords.items(): - if not ("nlat" in da.dims and "nlon" in da.dims): - dso = dso.assign_coords(**{v: da}) - - return dso - - def plot_diff(field1, field2, levels, case1, case2, title, proj, TLAT, TLON): # make circular boundary for polar stereographic circular plots theta = np.linspace(0, 2 * np.pi, 100) @@ -84,9 +21,7 @@ def plot_diff(field1, field2, levels, case1, case2, title, proj, TLAT, TLON): path_nsidc = "/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/" - ds_obs = xr.open_dataset(path_nsidc + "SSMI.ifrac.1981-2005monthlymean.gx1v5.nc") - - ds_pop = add_cyclic(ds_obs) + ds_obs = xr.open_dataset(path_nsidc + "sst_HadOIBl_bc_1x1_climo_1980_2019.nc") aice = title.find("Concentration") @@ -102,31 +37,35 @@ def plot_diff(field1, field2, levels, case1, case2, title, proj, TLAT, TLON): ax = fig.add_subplot(gs[0, :2], projection=ccrs.NorthPolarStereo()) # sets the latitude / longitude boundaries of the plot ax.set_extent([0.005, 360, 90, 45], crs=ccrs.PlateCarree()) - ifrac_obs = ds_pop["monthly_ifrac"].isel(month=2) + ifrac_obs = ds_obs.ice_cov_prediddle.isel(month=3) + field1_tmp = field1.sel(time=(field1.time.dt.month == 3)).mean(dim="time") + field2_tmp = field2.sel(time=(field2.time.dt.month == 3)).mean(dim="time") if proj == "S": ax = fig.add_subplot(gs[0, :2], projection=ccrs.SouthPolarStereo()) # sets the latitude / longitude boundaries of the plot ax.set_extent([0.005, 360, -90, -45], crs=ccrs.PlateCarree()) - ifrac_obs = ds_pop["monthly_ifrac"].isel(month=8) + ifrac_obs = ds_obs.ice_cov_prediddle.isel(month=9) + field1_tmp = field1.sel(time=(field1.time.dt.month == 9)).mean(dim="time") + field2_tmp = field2.sel(time=(field2.time.dt.month == 9)).mean(dim="time") ax.set_boundary(circle, transform=ax.transAxes) ax.add_feature(cfeature.LAND, zorder=100, edgecolor="k") - field_diff = field2.values - field1.values + field_diff = field2_tmp.values - field1_tmp.values field_std = field_diff.std() this = ax.pcolormesh( TLON, TLAT, - field1, + field1_tmp, norm=norm, cmap="ocean", transform=ccrs.PlateCarree(), ) if aice > 0: plt.contour( - ds_pop.tlon, - ds_pop.tlat, + ds_obs.lon, + ds_obs.lat, ifrac_obs, levels=[0.15], colors="magenta", @@ -150,15 +89,15 @@ def plot_diff(field1, field2, levels, case1, case2, title, proj, TLAT, TLON): this = ax.pcolormesh( TLON, TLAT, - field2, + field2_tmp, norm=norm, cmap="ocean", transform=ccrs.PlateCarree(), ) if aice > 0: plt.contour( - ds_pop.tlon, - ds_pop.tlat, + ds_obs.lon, + ds_obs.lat, ifrac_obs, levels=[0.15], colors="magenta", From 78a8a700bf329082cd41fe2354aa9fe172eaf56c Mon Sep 17 00:00:00 2001 From: David Bailey Date: Wed, 5 Feb 2025 11:14:58 -0700 Subject: [PATCH 02/11] Fix path names and axes for pre-industrial cases --- examples/coupled_model/config.yml | 5 +- examples/key_metrics/config.yml | 3 +- .../Hemis_seaice_visual_compare_contour.ipynb | 35 +++++- ...Hemis_seaice_visual_compare_obs_lens.ipynb | 116 +++++++++++------- nblibrary/ice/plot_diff.py | 17 ++- 5 files changed, 122 insertions(+), 54 deletions(-) diff --git a/examples/coupled_model/config.yml b/examples/coupled_model/config.yml index 1a581e2..337e742 100644 --- a/examples/coupled_model/config.yml +++ b/examples/coupled_model/config.yml @@ -159,12 +159,15 @@ compute_notebooks: none: climo_nyears: 35 grid_file: '/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc' - path_nsidc: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/analysis_datasets/hemispheric_data/NSIDC_SeaIce_extent' + path_obs: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/' + path_model: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/' Hemis_seaice_visual_compare_contour: parameter_groups: none: climo_nyears: 35 grid_file: '/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc' + path_obs: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/' + path_model: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/' ########### JUPYTER BOOK CONFIG ########### diff --git a/examples/key_metrics/config.yml b/examples/key_metrics/config.yml index 18b42a5..80235bd 100644 --- a/examples/key_metrics/config.yml +++ b/examples/key_metrics/config.yml @@ -170,7 +170,8 @@ compute_notebooks: none: climo_nyears: 35 grid_file: '/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc' - path_nsidc: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/analysis_datasets/hemispheric_data/NSIDC_SeaIce_extent' + path_obs: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/' + path_model: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/' lnd: Global_TerrestrialCouplingIndex_VisualCompareObs: diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb index 0a7c911..3a5b09f 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb @@ -33,7 +33,8 @@ "source": [ "import xarray as xr\n", "import numpy as np\n", - "import yaml" + "import yaml\n", + "import os" ] }, { @@ -65,7 +66,7 @@ "\n", "climo_nyears = 35\n", "grid_file = \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", - "path_nsidc = (\n", + "path_obs = (\n", " \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/\"\n", ")\n", "\n", @@ -176,7 +177,9 @@ " cice_masks = yaml.safe_load(file)\n", "\n", "with open(\"cice_vars.yml\", \"r\") as file:\n", - " cice_vars = yaml.safe_load(file)" + " cice_vars = yaml.safe_load(file)\n", + "\n", + "path_HadleyOI = os.path.join(path_obs, \"analysis_datasets\", \"1x1d/\")" ] }, { @@ -220,7 +223,18 @@ " title = cice_vars[var][1][\"title\"]\n", " field1 = ds1[var].isel(time=slice(-climo_nyears * 12, None))\n", " field2 = ds2[var].isel(time=slice(-climo_nyears * 12, None))\n", - " plot_diff(field1, field2, levels, case_name, base_case_name, title, \"N\", TLAT, TLON)" + " plot_diff(\n", + " field1,\n", + " field2,\n", + " levels,\n", + " case_name,\n", + " base_case_name,\n", + " title,\n", + " \"N\",\n", + " TLAT,\n", + " TLON,\n", + " path_HadleyOI,\n", + " )" ] }, { @@ -245,7 +259,18 @@ " title = cice_vars[var][1][\"title\"]\n", " field1 = ds1[var].isel(time=slice(-climo_nyears * 12, None))\n", " field2 = ds2[var].isel(time=slice(-climo_nyears * 12, None))\n", - " plot_diff(field1, field2, levels, case_name, base_case_name, title, \"S\", TLAT, TLON)" + " plot_diff(\n", + " field1,\n", + " field2,\n", + " levels,\n", + " case_name,\n", + " base_case_name,\n", + " title,\n", + " \"S\",\n", + " TLAT,\n", + " TLON,\n", + " path_HadleyOI,\n", + " )" ] }, { diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb index dcc9e9a..2f92a83 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -71,11 +71,10 @@ "\n", "climo_nyears = 35\n", "grid_file = \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", - "path_nsidc = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/analysis_datasets/hemispheric_data/NSIDC_SeaIce_extent\"\n", - "\n", - "model_path = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/\"\n", - "path_lens1 = model_path + \"cesm_lens1\"\n", - "path_lens2 = model_path + \"cesm_lens2\"\n", + "path_obs = (\n", + " \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/\"\n", + ")\n", + "path_model = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/\"\n", "\n", "lc_kwargs = {}" ] @@ -184,7 +183,14 @@ "first_year = int(start_date.split(\"-\")[0])\n", "base_first_year = int(base_start_date.split(\"-\")[0])\n", "end_year = int(end_date.split(\"-\")[0])\n", - "base_end_year = int(base_end_date.split(\"-\")[0])" + "base_end_year = int(base_end_date.split(\"-\")[0])\n", + "\n", + "path_lens1 = os.path.join(path_model, \"cesm_lens1\")\n", + "path_lens2 = os.path.join(path_model, \"cesm_lens2\")\n", + "\n", + "path_nsidc = os.path.join(\n", + " path_obs, \"analysis_datasets\", \"hemispheric_data\", \"NSIDC_SeaIce_extent/\"\n", + ")" ] }, { @@ -220,7 +226,14 @@ "cesm1_hitot_sh_ann = ds_cesm1_hitot_sh[\"hi_monthly\"].mean(dim=\"nmonth\")\n", "cesm1_hstot_sh_ann = ds_cesm1_hstot_sh[\"hs_monthly\"].mean(dim=\"nmonth\")\n", "\n", - "cesm1_years = xr.cftime_range(start=\"1920\", end=\"2100\", freq=\"YS\", calendar=\"noleap\")\n", + "if first_year > 1:\n", + " cesm1_years = xr.cftime_range(\n", + " start=\"1920\", end=\"2100\", freq=\"YS\", calendar=\"noleap\"\n", + " )\n", + "else:\n", + " cesm1_years = xr.cftime_range(\n", + " start=\"0001\", end=\"0181\", freq=\"YS\", calendar=\"noleap\"\n", + " )\n", "\n", "cesm1_aicetot_nh_month = ds_cesm1_aicetot_nh[\"aice_monthly\"][:, 60:95, :].mean(\n", " dim=\"nyr\"\n", @@ -249,7 +262,14 @@ "cesm2_hitot_sh_ann = ds_cesm2_hitot_sh[\"hi_monthly\"].mean(dim=\"nmonth\")\n", "cesm2_hstot_sh_ann = ds_cesm2_hstot_sh[\"hs_monthly\"].mean(dim=\"nmonth\")\n", "\n", - "cesm2_years = xr.cftime_range(start=\"1870\", end=\"2100\", freq=\"YS\", calendar=\"noleap\")\n", + "if first_year > 1:\n", + " cesm2_years = xr.cftime_range(\n", + " start=\"1870\", end=\"2100\", freq=\"YS\", calendar=\"noleap\"\n", + " )\n", + "else:\n", + " cesm2_years = xr.cftime_range(\n", + " start=\"0001\", end=\"0231\", freq=\"YS\", calendar=\"noleap\"\n", + " )\n", "\n", "cesm2_aicetot_nh_month = ds_cesm2_aicetot_nh[\"aice_monthly\"][:, 110:145, :].mean(\n", " dim=\"nyr\"\n", @@ -335,17 +355,18 @@ "\n", "fig = plt.figure(figsize=(10, 10), tight_layout=True)\n", "\n", + "x1 = cesm1_years[0:95]\n", + "x2 = cesm2_years[0:145]\n", + "\n", "ax = fig.add_subplot(3, 1, 1)\n", "for i in range(0, 38):\n", " plt.plot(\n", - " cesm1_years[0:95],\n", + " x1,\n", " cesm1_hitot_nh_ann[i, 0:95] * 1.0e-13,\n", " color=\"lightgrey\",\n", " )\n", "for i in range(0, 49):\n", - " plt.plot(\n", - " cesm2_years[0:145], cesm2_hitot_nh_ann[i, 0:145] * 1.0e-13, color=\"lightblue\"\n", - " )\n", + " plt.plot(x2, cesm2_hitot_nh_ann[i, 0:145] * 1.0e-13, color=\"lightblue\")\n", "da_plot_len_time_might_be_one(ds1_vhi_ann, alt_time=ds2_ann.time, color=\"red\")\n", "da_plot_len_time_might_be_one(ds2_vhi_ann, alt_time=ds1_ann.time, color=\"blue\")\n", "\n", @@ -358,14 +379,12 @@ "ax = fig.add_subplot(3, 1, 2)\n", "for i in range(0, 38):\n", " plt.plot(\n", - " cesm1_years[0:95],\n", + " x1,\n", " cesm1_hstot_nh_ann[i, 0:95] * 1.0e-13,\n", " color=\"lightgrey\",\n", " )\n", "for i in range(0, 49):\n", - " plt.plot(\n", - " cesm2_years[0:145], cesm2_hstot_nh_ann[i, 0:145] * 1.0e-13, color=\"lightblue\"\n", - " )\n", + " plt.plot(x2, cesm2_hstot_nh_ann[i, 0:145] * 1.0e-13, color=\"lightblue\")\n", "da_plot_len_time_might_be_one(ds1_vhs_ann, alt_time=ds2_ann.time, color=\"red\")\n", "da_plot_len_time_might_be_one(ds2_vhs_ann, alt_time=ds1_ann.time, color=\"blue\")\n", "\n", @@ -377,14 +396,12 @@ "ax = fig.add_subplot(3, 1, 3)\n", "for i in range(0, 38):\n", " plt.plot(\n", - " cesm1_years[0:95],\n", + " x1,\n", " cesm1_aicetot_nh_ann[i, 0:95] * 1.0e-12,\n", " color=\"lightgrey\",\n", " )\n", "for i in range(0, 49):\n", - " plt.plot(\n", - " cesm2_years[0:145], cesm2_aicetot_nh_ann[i, 0:145] * 1.0e-12, color=\"lightblue\"\n", - " )\n", + " plt.plot(x2, cesm2_aicetot_nh_ann[i, 0:145] * 1.0e-12, color=\"lightblue\")\n", "da_plot_len_time_might_be_one(ds1_area_ann, alt_time=ds2_ann.time, color=\"red\")\n", "da_plot_len_time_might_be_one(ds2_area_ann, alt_time=ds1_ann.time, color=\"blue\")\n", "\n", @@ -423,14 +440,12 @@ "ax = fig.add_subplot(3, 1, 1)\n", "for i in range(0, 38):\n", " plt.plot(\n", - " cesm1_years[0:95],\n", + " x1,\n", " cesm1_hitot_sh_ann[i, 0:95] * 1.0e-13,\n", " color=\"lightgrey\",\n", " )\n", "for i in range(0, 49):\n", - " plt.plot(\n", - " cesm2_years[0:145], cesm2_hitot_sh_ann[i, 0:145] * 1.0e-13, color=\"lightblue\"\n", - " )\n", + " plt.plot(x2, cesm2_hitot_sh_ann[i, 0:145] * 1.0e-13, color=\"lightblue\")\n", "da_plot_len_time_might_be_one(ds1_vhi_ann, alt_time=ds2_ann.time, color=\"red\")\n", "da_plot_len_time_might_be_one(ds2_vhi_ann, alt_time=ds1_ann.time, color=\"blue\")\n", "\n", @@ -443,14 +458,12 @@ "ax = fig.add_subplot(3, 1, 2)\n", "for i in range(0, 38):\n", " plt.plot(\n", - " cesm1_years[0:95],\n", + " x1,\n", " cesm1_hstot_sh_ann[i, 0:95] * 1.0e-13,\n", " color=\"lightgrey\",\n", " )\n", "for i in range(0, 49):\n", - " plt.plot(\n", - " cesm2_years[0:145], cesm2_hstot_sh_ann[i, 0:145] * 1.0e-13, color=\"lightblue\"\n", - " )\n", + " plt.plot(x2, cesm2_hstot_sh_ann[i, 0:145] * 1.0e-13, color=\"lightblue\")\n", "da_plot_len_time_might_be_one(ds1_vhs_ann, alt_time=ds2_ann.time, color=\"red\")\n", "da_plot_len_time_might_be_one(ds2_vhs_ann, alt_time=ds1_ann.time, color=\"blue\")\n", "\n", @@ -462,14 +475,12 @@ "ax = fig.add_subplot(3, 1, 3)\n", "for i in range(0, 38):\n", " plt.plot(\n", - " cesm1_years[0:95],\n", + " x1,\n", " cesm1_aicetot_sh_ann[i, 0:95] * 1.0e-12,\n", " color=\"lightgrey\",\n", " )\n", "for i in range(0, 49):\n", - " plt.plot(\n", - " cesm2_years[0:145], cesm2_aicetot_sh_ann[i, 0:145] * 1.0e-12, color=\"lightblue\"\n", - " )\n", + " plt.plot(x2, cesm2_aicetot_sh_ann[i, 0:145] * 1.0e-12, color=\"lightblue\")\n", "da_plot_len_time_might_be_one(ds1_area_ann, alt_time=ds2_ann.time, color=\"red\")\n", "da_plot_len_time_might_be_one(ds2_area_ann, alt_time=ds1_ann.time, color=\"blue\")\n", "\n", @@ -721,13 +732,13 @@ "source": [ "aice1_month = (\n", " ds1[\"aice\"]\n", - " .isel(time=slice(-climo_nyears, None))\n", + " .isel(time=slice(-climo_nyears * 12, 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", + " .isel(time=slice(-climo_nyears * 12, None))\n", " .groupby(\"time.month\")\n", " .mean(dim=\"time\", skipna=True)\n", ")\n", @@ -842,10 +853,30 @@ "cesm1_aicetot_nh_sep = ds_cesm1_aicetot_nh[\"aice_monthly\"].isel(nmonth=8)\n", "cesm2_aicetot_nh_sep = ds_cesm2_aicetot_nh[\"aice_monthly\"].isel(nmonth=8)\n", "\n", - "x1 = np.linspace(end_year - len(ds1_sep.time), end_year, len(ds1_sep.time))\n", - "x2 = np.linspace(end_year - len(ds2_sep.time), base_end_year, len(ds2_sep.time))\n", - "x3 = np.linspace(ds_cesm1_aicetot_nh.year[60], ds_cesm1_aicetot_nh.year[95], 36)\n", - "x4 = np.linspace(ds_cesm2_aicetot_nh.year[110], ds_cesm2_aicetot_nh.year[145], 36)\n", + "if first_year > 1:\n", + " model_start_year1 = end_year - len(ds1_sep.time)\n", + " model_end_year1 = end_year\n", + " model_start_year2 = base_end_year - len(ds2_sep.time)\n", + " model_end_year2 = base_end_year\n", + " lens1_start_year = ds_cesm1_aicetot_nh.year[60]\n", + " lens1_end_year = ds_cesm1_aicetot_nh.year[95]\n", + " lens2_start_year = ds_cesm2_aicetot_nh.year[110]\n", + " lens2_end_year = ds_cesm2_aicetot_nh.year[145]\n", + "else:\n", + " model_start_year1 = 1\n", + " model_end_year1 = climo_nyears\n", + " model_start_year2 = 1\n", + " model_end_year2 = climo_nyears\n", + " lens1_start_year = 1\n", + " lens1_end_year = 36\n", + " lens2_start_year = 1\n", + " lens2_end_year = 36\n", + "\n", + "x1 = np.linspace(model_start_year1, model_end_year1, len(ds1_sep.time))\n", + "x2 = np.linspace(model_start_year2, model_end_year2, len(ds2_sep.time))\n", + "x3 = np.linspace(lens1_start_year, lens1_end_year, 36)\n", + "x4 = np.linspace(lens2_start_year, lens2_end_year, 36)\n", + "\n", "obs_first_year = 0\n", "if first_year > 1:\n", " obs_first_year = 1979\n", @@ -905,11 +936,10 @@ "cesm1_aicetot_sh_sep = ds_cesm1_aicetot_sh[\"aice_monthly\"].isel(nmonth=8)\n", "cesm2_aicetot_sh_sep = ds_cesm2_aicetot_sh[\"aice_monthly\"].isel(nmonth=8)\n", "\n", - "x1 = np.linspace(end_year - len(ds1_sep.time), end_year, len(ds1_sep.time))\n", - "x2 = np.linspace(end_year - len(ds2_sep.time), base_end_year, len(ds2_sep.time))\n", - "x3 = np.linspace(ds_cesm1_aicetot_nh.year[60], ds_cesm1_aicetot_nh.year[95], 36)\n", - "x4 = np.linspace(ds_cesm2_aicetot_nh.year[110], ds_cesm2_aicetot_nh.year[145], 36)\n", - "\n", + "x1 = np.linspace(model_start_year1, model_end_year1, len(ds1_sep.time))\n", + "x2 = np.linspace(model_start_year2, model_end_year2, len(ds2_sep.time))\n", + "x3 = np.linspace(lens1_start_year, lens1_end_year, 36)\n", + "x4 = np.linspace(lens2_start_year, lens2_end_year, 36)\n", "\n", "obs_first_year = 0\n", "if first_year > 1:\n", diff --git a/nblibrary/ice/plot_diff.py b/nblibrary/ice/plot_diff.py index 7db8b32..e1a063e 100644 --- a/nblibrary/ice/plot_diff.py +++ b/nblibrary/ice/plot_diff.py @@ -10,7 +10,18 @@ from matplotlib.gridspec import GridSpec -def plot_diff(field1, field2, levels, case1, case2, title, proj, TLAT, TLON): +def plot_diff( + field1, + field2, + levels, + case1, + case2, + title, + proj, + TLAT, + TLON, + path_HadleyOI, +): # make circular boundary for polar stereographic circular plots theta = np.linspace(0, 2 * np.pi, 100) center, radius = [0.5, 0.5], 0.5 @@ -19,9 +30,7 @@ def plot_diff(field1, field2, levels, case1, case2, title, proj, TLAT, TLON): # Read in observed sea ice concentration - path_nsidc = "/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/" - - ds_obs = xr.open_dataset(path_nsidc + "sst_HadOIBl_bc_1x1_climo_1980_2019.nc") + ds_obs = xr.open_dataset(path_HadleyOI + "sst_HadOIBl_bc_1x1_climo_1980_2019.nc") aice = title.find("Concentration") From 68d033f5d29faa5fdbdfdea1df39ab60463abdbc Mon Sep 17 00:00:00 2001 From: David Bailey Date: Wed, 12 Feb 2025 16:17:05 -0700 Subject: [PATCH 03/11] Fix some more merge conflicts --- ...Hemis_seaice_visual_compare_obs_lens.ipynb | 495 ++++-------------- 1 file changed, 103 insertions(+), 392 deletions(-) diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb index e4beca8..b321af0 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -142,7 +142,7 @@ "id": "7e9d81ec-f6f6-4c21-ad45-3d4e6c2377eb", "metadata": {}, "source": [ - "### New CESM cases to compare" + "# New CESM cases to compare" ] }, { @@ -211,10 +211,73 @@ }, { "cell_type": "markdown", - "id": "e1e1cf81-d595-48de-8ca8-c47b408e105d", + "id": "a22875e2-3257-4ae7-aab9-bc138fe01183", "metadata": {}, "source": [ - "### CESM1 and CESM2 large ensemble data" + "# Define Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b590d77c-f5b9-4b36-b67d-464759adb268", + "metadata": {}, + "outputs": [], + "source": [ + "# Two functions to help draw plots even if only one year of data is available\n", + "# If one year is present, horizontal line will be dotted instead of solid\n", + "\n", + "\n", + "def da_plot_len_time_might_be_one(da_in, alt_time, color):\n", + " # If da_in.time only has 1 value, draw horizontal line across range of alt_time\n", + " if len(da_in.time) > 1:\n", + " da_in.plot(color=color)\n", + " else:\n", + " time_arr = [alt_time.data[0], alt_time.data[-1]]\n", + " plt.plot(time_arr, [da_in.data[0], da_in.data[0]], linestyle=\":\", color=color)\n", + "\n", + "\n", + "def plt_plot_len_x_might_be_one(da_in, x_in, alt_x, color):\n", + " # If x_in only has one value, draw horizontal line across range of alt_x\n", + " if len(x_in) > 1:\n", + " plt.plot(x_in, da_in, color=color)\n", + " else:\n", + " plt.plot(\n", + " [alt_x[0], alt_x[-1]],\n", + " [da_in.data[0], da_in.data[0]],\n", + " linestyle=\":\",\n", + " color=color,\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9499f101-4c85-4244-b3c6-2f327e64107a", + "metadata": {}, + "outputs": [], + "source": [ + "def setBoxColor(boxplot, colors):\n", + "\n", + " # Set edge color of the outside and median lines of the boxes\n", + " for element in [\"boxes\", \"medians\"]:\n", + " for box, color in zip(boxplot[element], colors):\n", + " plt.setp(box, color=color, linewidth=3)\n", + "\n", + " # Set the color of the whiskers and caps of the boxes\n", + " for element in [\"whiskers\", \"caps\"]:\n", + " for box, color in zip(\n", + " zip(boxplot[element][::2], boxplot[element][1::2]), colors\n", + " ):\n", + " plt.setp(box, color=color, linewidth=3)" + ] + }, + { + "cell_type": "markdown", + "id": "c6cdca29-1770-47fa-86e6-82c09c6d1658", + "metadata": {}, + "source": [ + "# Read in CESM LENS Data" ] }, { @@ -309,175 +372,10 @@ }, { "cell_type": "markdown", - "id": "5a26f440-0425-4b42-a380-7e0609dc1adf", + "id": "49a75b16-6772-47a1-b395-f08265768b8b", "metadata": {}, "source": [ - "### NSIDC data" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "370ad77d-303f-4b8e-946e-1278d413c963", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "### Read in the NH NSIDC data from files\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", - "p1 = mlines.Line2D([], [], color=\"lightgrey\", label=\"CESM1-LENS\")\n", - "p2 = mlines.Line2D([], [], color=\"lightblue\", label=\"CESM2-LENS\")\n", - "p3 = mlines.Line2D([], [], color=\"red\", label=case_name)\n", - "p4 = mlines.Line2D([], [], color=\"blue\", label=base_case_name)\n", - "\n", - "fig = plt.figure(figsize=(10, 10), tight_layout=True)\n", - "\n", - "x1 = cesm1_years[0:95]\n", - "x2 = cesm2_years[0:145]\n", - "\n", - "ax = fig.add_subplot(3, 1, 1)\n", - "for i in range(0, 38):\n", - " plt.plot(\n", - " x1,\n", - " cesm1_hitot_nh_ann[i, 0:95] * 1.0e-13,\n", - " color=\"lightgrey\",\n", - " )\n", - "for i in range(0, 49):\n", - " plt.plot(x2, cesm2_hitot_nh_ann[i, 0:145] * 1.0e-13, color=\"lightblue\")\n", - "da_plot_len_time_might_be_one(ds1_vhi_ann, alt_time=ds2_ann.time, color=\"red\")\n", - "da_plot_len_time_might_be_one(ds2_vhi_ann, alt_time=ds1_ann.time, color=\"blue\")\n", - "\n", - "plt.title(\"NH Annual Mean Integrated Timeseries\")\n", - "plt.ylim((0, 5))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"NH Annual Mean Sea Ice Volume $m x 10^{13}$\")\n", - "plt.legend(handles=[p1, p2, p3, p4])\n", - "\n", - "ax = fig.add_subplot(3, 1, 2)\n", - "for i in range(0, 38):\n", - " plt.plot(\n", - " x1,\n", - " cesm1_hstot_nh_ann[i, 0:95] * 1.0e-13,\n", - " color=\"lightgrey\",\n", - " )\n", - "for i in range(0, 49):\n", - " plt.plot(x2, cesm2_hstot_nh_ann[i, 0:145] * 1.0e-13, color=\"lightblue\")\n", - "da_plot_len_time_might_be_one(ds1_vhs_ann, alt_time=ds2_ann.time, color=\"red\")\n", - "da_plot_len_time_might_be_one(ds2_vhs_ann, alt_time=ds1_ann.time, color=\"blue\")\n", - "\n", - "plt.ylim((0, 0.5))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"NH Annual Mean Snow Volume $m x 10^{13}$\")\n", - "plt.legend(handles=[p1, p2, p3, p4])\n", - "\n", - "ax = fig.add_subplot(3, 1, 3)\n", - "for i in range(0, 38):\n", - " plt.plot(\n", - " x1,\n", - " cesm1_aicetot_nh_ann[i, 0:95] * 1.0e-12,\n", - " color=\"lightgrey\",\n", - " )\n", - "for i in range(0, 49):\n", - " plt.plot(x2, cesm2_aicetot_nh_ann[i, 0:145] * 1.0e-12, color=\"lightblue\")\n", - "da_plot_len_time_might_be_one(ds1_area_ann, alt_time=ds2_ann.time, color=\"red\")\n", - "da_plot_len_time_might_be_one(ds2_area_ann, alt_time=ds1_ann.time, color=\"blue\")\n", - "\n", - "plt.ylim((0, 15))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"NH Annual Mean Sea Ice Area $m x 10^{12}$\")\n", - "plt.legend(handles=[p1, p2, p3, p4])" - ] - }, - { - "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_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", - "for i in range(0, 38):\n", - " plt.plot(\n", - " x1,\n", - " cesm1_hitot_sh_ann[i, 0:95] * 1.0e-13,\n", - " color=\"lightgrey\",\n", - " )\n", - "for i in range(0, 49):\n", - " plt.plot(x2, cesm2_hitot_sh_ann[i, 0:145] * 1.0e-13, color=\"lightblue\")\n", - "da_plot_len_time_might_be_one(ds1_vhi_ann, alt_time=ds2_ann.time, color=\"red\")\n", - "da_plot_len_time_might_be_one(ds2_vhi_ann, alt_time=ds1_ann.time, color=\"blue\")\n", - "\n", - "plt.title(\"SH Annual Mean Integrated Timeseries\")\n", - "plt.ylim((0, 3))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"SH Annual Mean Sea Ice Volume $m x 10^{13}$\")\n", - "plt.legend(handles=[p1, p2, p3, p4])\n", - "\n", - "ax = fig.add_subplot(3, 1, 2)\n", - "for i in range(0, 38):\n", - " plt.plot(\n", - " x1,\n", - " cesm1_hstot_sh_ann[i, 0:95] * 1.0e-13,\n", - " color=\"lightgrey\",\n", - " )\n", - "for i in range(0, 49):\n", - " plt.plot(x2, cesm2_hstot_sh_ann[i, 0:145] * 1.0e-13, color=\"lightblue\")\n", - "da_plot_len_time_might_be_one(ds1_vhs_ann, alt_time=ds2_ann.time, color=\"red\")\n", - "da_plot_len_time_might_be_one(ds2_vhs_ann, alt_time=ds1_ann.time, color=\"blue\")\n", - "\n", - "plt.ylim((0, 0.5))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"SH Annual Mean Snow Volume $m x 10^{13}$\")\n", - "plt.legend(handles=[p1, p2, p3, p4])\n", - "\n", - "ax = fig.add_subplot(3, 1, 3)\n", - "for i in range(0, 38):\n", - " plt.plot(\n", - " x1,\n", - " cesm1_aicetot_sh_ann[i, 0:95] * 1.0e-12,\n", - " color=\"lightgrey\",\n", - " )\n", - "for i in range(0, 49):\n", - " plt.plot(x2, cesm2_aicetot_sh_ann[i, 0:145] * 1.0e-12, color=\"lightblue\")\n", - "da_plot_len_time_might_be_one(ds1_area_ann, alt_time=ds2_ann.time, color=\"red\")\n", - "da_plot_len_time_might_be_one(ds2_area_ann, alt_time=ds1_ann.time, color=\"blue\")\n", - "\n", - "plt.ylim((0, 20))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"SH Annual Mean Sea Ice Area $m x 10^{12}$\")\n", - "plt.legend(handles=[p1, p2, p3, p4])" + "# Read in the NSIDC data from files" ] }, { @@ -495,9 +393,7 @@ }, "outputs": [], "source": [ - "### Read in the NSIDC data from files\n", - "\n", - "jan_nsidc = pd.read_csv(\n", + "jan_nsidc_nh = pd.read_csv(\n", " os.path.join(path_nsidc, \"N_01_extent_v3.0.csv\"), na_values=[\"-99.9\"]\n", ")\n", "feb_nsidc_nh = pd.read_csv(\n", @@ -588,9 +484,15 @@ " np.nanmean(oct_area_nh[0:35]),\n", " np.nanmean(nov_area_nh[0:35]),\n", " np.nanmean(dec_area_nh[0:35]),\n", - "]\n", - "\n", - "# plt.plot(nsidc_clim_nh_area)" + "]" + ] + }, + { + "cell_type": "markdown", + "id": "0980418b-7f41-4522-bd48-5fac8e8c3d59", + "metadata": {}, + "source": [ + "# Read in the SH NSIDC data from files" ] }, { @@ -608,8 +510,6 @@ }, "outputs": [], "source": [ - "### Read in the SH NSIDC data from files\n", - "\n", "jan_nsidc_sh = pd.read_csv(\n", " os.path.join(path_nsidc, \"S_01_extent_v3.0.csv\"), na_values=[\"-99.9\"]\n", ")\n", @@ -701,88 +601,7 @@ " np.nanmean(oct_area_sh[0:35]),\n", " np.nanmean(nov_area_sh[0:35]),\n", " np.nanmean(dec_area_sh[0:35]),\n", - "]\n", - "\n", - "# plt.plot(nsidc_clim_sh_area)" - ] - }, - { - "cell_type": "markdown", - "id": "230e78fa-4e86-499f-89ef-60605e2ab170", - "metadata": {}, - "source": [ - "# Define functions" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "4986f64d-9753-4904-a7b9-a98cc8947a98", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "# Two functions to help draw plots even if only one year of data is available\n", - "# If one year is present, horizontal line will be dotted instead of solid\n", - "\n", - "\n", - "def da_plot_len_time_might_be_one(da_in, alt_time, color):\n", - " # If da_in.time only has 1 value, draw horizontal line across range of alt_time\n", - " if len(da_in.time) > 1:\n", - " da_in.plot(color=color)\n", - " else:\n", - " time_arr = [alt_time.data[0], alt_time.data[-1]]\n", - " plt.plot(time_arr, [da_in.data[0], da_in.data[0]], linestyle=\":\", color=color)\n", - "\n", - "\n", - "def plt_plot_len_x_might_be_one(da_in, x_in, alt_x, color):\n", - " # If x_in only has one value, draw horizontal line across range of alt_x\n", - " if len(x_in) > 1:\n", - " plt.plot(x_in, da_in, color=color)\n", - " else:\n", - " plt.plot(\n", - " [alt_x[0], alt_x[-1]],\n", - " [da_in.data[0], da_in.data[0]],\n", - " linestyle=\":\",\n", - " color=color,\n", - " )" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6510f578-bebb-41d3-99d6-296d3c0e5f84", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "def setBoxColor(boxplot, colors):\n", - "\n", - " # Set edge color of the outside and median lines of the boxes\n", - " for element in [\"boxes\", \"medians\"]:\n", - " for box, color in zip(boxplot[element], colors):\n", - " plt.setp(box, color=color, linewidth=3)\n", - "\n", - " # Set the color of the whiskers and caps of the boxes\n", - " for element in [\"whiskers\", \"caps\"]:\n", - " for box, color in zip(\n", - " zip(boxplot[element][::2], boxplot[element][1::2]), colors\n", - " ):\n", - " plt.setp(box, color=color, linewidth=3)" + "]" ] }, { @@ -1272,16 +1091,8 @@ { "cell_type": "code", "execution_count": null, - "id": "2d116d72-6ae4-4480-89f4-dc9333d909aa", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [ - "hide-input" - ] - }, + "id": "1327dccc-0065-43dc-874d-4404c07f6eba", + "metadata": {}, "outputs": [], "source": [ "ds1_area = (tarea * ds1.aice).isel(time=slice(-climo_nyears * 12, None)).where(\n", @@ -1289,64 +1100,7 @@ ").sum(dim=[\"nj\", \"ni\"]) * 1.0e-12\n", "ds2_area = (tarea * ds2.aice).isel(time=slice(-climo_nyears * 12, None)).where(\n", " TLAT > 0\n", - ").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", - "cesm1_aicetot_nh_sep = ds_cesm1_aicetot_nh[\"aice_monthly\"].isel(nmonth=8)\n", - "cesm2_aicetot_nh_sep = ds_cesm2_aicetot_nh[\"aice_monthly\"].isel(nmonth=8)\n", - "\n", - "if first_year > 1:\n", - " model_start_year1 = end_year - len(ds1_sep.time)\n", - " model_end_year1 = end_year\n", - " model_start_year2 = base_end_year - len(ds2_sep.time)\n", - " model_end_year2 = base_end_year\n", - " lens1_start_year = ds_cesm1_aicetot_nh.year[60]\n", - " lens1_end_year = ds_cesm1_aicetot_nh.year[95]\n", - " lens2_start_year = ds_cesm2_aicetot_nh.year[110]\n", - " lens2_end_year = ds_cesm2_aicetot_nh.year[145]\n", - "else:\n", - " model_start_year1 = 1\n", - " model_end_year1 = climo_nyears\n", - " model_start_year2 = 1\n", - " model_end_year2 = climo_nyears\n", - " lens1_start_year = 1\n", - " lens1_end_year = 36\n", - " lens2_start_year = 1\n", - " lens2_end_year = 36\n", - "\n", - "x1 = np.linspace(model_start_year1, model_end_year1, len(ds1_sep.time))\n", - "x2 = np.linspace(model_start_year2, model_end_year2, len(ds2_sep.time))\n", - "x3 = np.linspace(lens1_start_year, lens1_end_year, 36)\n", - "x4 = np.linspace(lens2_start_year, lens2_end_year, 36)\n", - "\n", - "obs_first_year = 0\n", - "if first_year > 1:\n", - " obs_first_year = 1979\n", - "x5 = np.linspace(1, 36, 36) + obs_first_year\n", - "\n", - "for i in range(0, 38):\n", - " plt.plot(\n", - " x3,\n", - " cesm1_aicetot_nh_sep.isel(n_members=i, nyr=slice(60, 96)) * 1.0e-12,\n", - " color=\"lightgrey\",\n", - " )\n", - "for i in range(0, 49):\n", - " plt.plot(\n", - " x4,\n", - " cesm2_aicetot_nh_sep.isel(n_members=i, nyr=slice(110, 146)) * 1.0e-12,\n", - " color=\"lightblue\",\n", - " )\n", - "plt_plot_len_x_might_be_one(ds1_sep, x1, x2, color=\"red\")\n", - "plt_plot_len_x_might_be_one(ds2_sep, x2, x1, color=\"blue\")\n", - "plt.plot(x5, sep_area[0:36], color=\"black\")\n", - "\n", - "plt.title(\"NH September Mean Sea Ice Area\")\n", - "plt.ylim((0, 25))\n", - "plt.xlabel(\"Year\")\n", - "plt.ylabel(\"Sea Ice Area $mx10^{12}$\")\n", - "plt.legend(handles=[p1, p2, p3, p4, p5])" + ").sum(dim=[\"nj\", \"ni\"]) * 1.0e-12" ] }, { @@ -1375,8 +1129,27 @@ "cesm1_aicetot_sh_sep = ds_cesm1_aicetot_sh[\"aice_monthly\"].isel(nmonth=8)\n", "cesm2_aicetot_sh_sep = ds_cesm2_aicetot_sh[\"aice_monthly\"].isel(nmonth=8)\n", "\n", - "x1 = np.linspace(model_start_year1, model_end_year1, len(ds1_sep.time))\n", - "x2 = np.linspace(model_start_year2, model_end_year2, len(ds2_sep.time))\n", + "if first_year > 1:\n", + " model_start_year1 = end_year - len(ds1_mar_nh.time)\n", + " model_end_year1 = end_year\n", + " model_start_year2 = base_end_year - len(ds2_mar_nh.time)\n", + " model_end_year2 = base_end_year\n", + " lens1_start_year = ds_cesm1_aicetot_nh.year[60]\n", + " lens1_end_year = ds_cesm1_aicetot_nh.year[95]\n", + " lens2_start_year = ds_cesm2_aicetot_nh.year[110]\n", + " lens2_end_year = ds_cesm2_aicetot_nh.year[145]\n", + "else:\n", + " model_start_year1 = 1\n", + " model_end_year1 = climo_nyears\n", + " model_start_year2 = 1\n", + " model_end_year2 = climo_nyears\n", + " lens1_start_year = 1\n", + " lens1_end_year = 36\n", + " lens2_start_year = 1\n", + " lens2_end_year = 36\n", + "\n", + "x1 = np.linspace(model_start_year1, model_end_year1, len(ds1_mar_nh.time))\n", + "x2 = np.linspace(model_start_year2, model_end_year2, len(ds2_mar_nh.time))\n", "x3 = np.linspace(lens1_start_year, lens1_end_year, 36)\n", "x4 = np.linspace(lens2_start_year, lens2_end_year, 36)\n", "\n", @@ -1472,16 +1245,6 @@ "cesm1_aicetot_nh_sep = ds_cesm1_aicetot_nh[\"aice_monthly\"].isel(nmonth=8)\n", "cesm2_aicetot_nh_sep = ds_cesm2_aicetot_nh[\"aice_monthly\"].isel(nmonth=8)\n", "\n", - "x1 = np.linspace(end_year - len(ds1_sep_nh.time), end_year, len(ds1_sep_nh.time))\n", - "x2 = np.linspace(end_year - len(ds2_sep_nh.time), base_end_year, len(ds2_sep_nh.time))\n", - "x3 = np.linspace(ds_cesm1_aicetot_nh.year[60], ds_cesm1_aicetot_nh.year[95], 36)\n", - "x4 = np.linspace(ds_cesm2_aicetot_nh.year[110], ds_cesm2_aicetot_nh.year[145], 36)\n", - "obs_first_year = 0\n", - "if first_year > 1:\n", - " obs_first_year = 1979\n", - "x5 = np.linspace(1, 36, 36) + obs_first_year\n", - "\n", - "\n", "# Make Plot - two subplots - note it's nrow x ncol x index (starting upper left)\n", "fig = plt.figure(figsize=(20, 7))\n", "\n", @@ -1599,14 +1362,6 @@ "cesm1_hitot_nh_mar = ds_cesm1_hitot_nh[\"hi_monthly\"].isel(nmonth=2)\n", "cesm2_hitot_nh_mar = ds_cesm2_hitot_nh[\"hi_monthly\"].isel(nmonth=2)\n", "\n", - "x1 = np.linspace(end_year - len(ds1_mar_nh.time), end_year, len(ds1_mar_nh.time))\n", - "x2 = np.linspace(end_year - len(ds2_mar_nh.time), base_end_year, len(ds2_mar_nh.time))\n", - "x3 = np.linspace(ds_cesm1_aicetot_nh.year[60], ds_cesm1_aicetot_nh.year[95], 36)\n", - "x4 = np.linspace(ds_cesm2_aicetot_nh.year[110], ds_cesm2_aicetot_nh.year[145], 36)\n", - "obs_first_year = 0\n", - "if first_year > 1:\n", - " obs_first_year = 1979\n", - "\n", "# Make Plot - two subplots - note it's nrow x ncol x index (starting upper left)\n", "fig = plt.figure(figsize=(20, 7))\n", "\n", @@ -1687,14 +1442,6 @@ "cesm1_hitot_nh_sep = ds_cesm1_hitot_nh[\"hi_monthly\"].isel(nmonth=8)\n", "cesm2_hitot_nh_sep = ds_cesm2_hitot_nh[\"hi_monthly\"].isel(nmonth=8)\n", "\n", - "x1 = np.linspace(end_year - len(ds1_sep_nh.time), end_year, len(ds1_sep_nh.time))\n", - "x2 = np.linspace(end_year - len(ds2_sep_nh.time), base_end_year, len(ds2_sep_nh.time))\n", - "x3 = np.linspace(ds_cesm1_aicetot_nh.year[60], ds_cesm1_aicetot_nh.year[95], 36)\n", - "x4 = np.linspace(ds_cesm2_aicetot_nh.year[110], ds_cesm2_aicetot_nh.year[145], 36)\n", - "obs_first_year = 0\n", - "if first_year > 1:\n", - " obs_first_year = 1979\n", - "\n", "# Make Plot - two subplots - note it's nrow x ncol x index (starting upper left)\n", "fig = plt.figure(figsize=(20, 7))\n", "\n", @@ -1816,16 +1563,6 @@ "cesm1_aicetot_sh_mar = ds_cesm1_aicetot_sh[\"aice_monthly\"].isel(nmonth=1)\n", "cesm2_aicetot_sh_mar = ds_cesm2_aicetot_sh[\"aice_monthly\"].isel(nmonth=1)\n", "\n", - "x1 = np.linspace(end_year - len(ds1_feb_sh.time), end_year, len(ds1_feb_sh.time))\n", - "x2 = np.linspace(end_year - len(ds2_feb_sh.time), base_end_year, len(ds2_feb_sh.time))\n", - "x3 = np.linspace(ds_cesm1_aicetot_sh.year[60], ds_cesm1_aicetot_sh.year[95], 36)\n", - "x4 = np.linspace(ds_cesm2_aicetot_sh.year[110], ds_cesm2_aicetot_sh.year[145], 36)\n", - "obs_first_year = 0\n", - "if first_year > 1:\n", - " obs_first_year = 1979\n", - "x5 = np.linspace(1, 36, 36) + obs_first_year\n", - "\n", - "\n", "# Make Plot - two subplots - note it's nrow x ncol x index (starting upper left)\n", "fig = plt.figure(figsize=(20, 7))\n", "\n", @@ -1912,16 +1649,6 @@ "cesm1_aicetot_sh_sep = ds_cesm1_aicetot_sh[\"aice_monthly\"].isel(nmonth=8)\n", "cesm2_aicetot_sh_sep = ds_cesm2_aicetot_sh[\"aice_monthly\"].isel(nmonth=8)\n", "\n", - "x1 = np.linspace(end_year - len(ds1_sep_sh.time), end_year, len(ds1_sep_sh.time))\n", - "x2 = np.linspace(end_year - len(ds2_sep_sh.time), base_end_year, len(ds2_sep_sh.time))\n", - "x3 = np.linspace(ds_cesm1_aicetot_sh.year[60], ds_cesm1_aicetot_sh.year[95], 36)\n", - "x4 = np.linspace(ds_cesm2_aicetot_sh.year[110], ds_cesm2_aicetot_sh.year[145], 36)\n", - "obs_first_year = 0\n", - "if first_year > 1:\n", - " obs_first_year = 1979\n", - "x5 = np.linspace(1, 36, 36) + obs_first_year\n", - "\n", - "\n", "# Make Plot - two subplots - note it's nrow x ncol x index (starting upper left)\n", "fig = plt.figure(figsize=(20, 7))\n", "\n", @@ -2039,14 +1766,6 @@ "cesm1_hitot_sh_mar = ds_cesm1_hitot_sh[\"hi_monthly\"].isel(nmonth=2)\n", "cesm2_hitot_sh_mar = ds_cesm2_hitot_sh[\"hi_monthly\"].isel(nmonth=2)\n", "\n", - "x1 = np.linspace(end_year - len(ds1_feb_sh.time), end_year, len(ds1_feb_sh.time))\n", - "x2 = np.linspace(end_year - len(ds2_feb_sh.time), base_end_year, len(ds2_feb_sh.time))\n", - "x3 = np.linspace(ds_cesm1_aicetot_sh.year[60], ds_cesm1_aicetot_sh.year[95], 36)\n", - "x4 = np.linspace(ds_cesm2_aicetot_sh.year[110], ds_cesm2_aicetot_sh.year[145], 36)\n", - "obs_first_year = 0\n", - "if first_year > 1:\n", - " obs_first_year = 1979\n", - "\n", "# Make Plot - two subplots - note it's nrow x ncol x index (starting upper left)\n", "fig = plt.figure(figsize=(20, 7))\n", "\n", @@ -2127,14 +1846,6 @@ "cesm1_hitot_sh_sep = ds_cesm1_hitot_sh[\"hi_monthly\"].isel(nmonth=8)\n", "cesm2_hitot_sh_sep = ds_cesm2_hitot_sh[\"hi_monthly\"].isel(nmonth=8)\n", "\n", - "x1 = np.linspace(end_year - len(ds1_sep_sh.time), end_year, len(ds1_sep_sh.time))\n", - "x2 = np.linspace(end_year - len(ds2_sep_sh.time), base_end_year, len(ds2_sep_sh.time))\n", - "x3 = np.linspace(ds_cesm1_aicetot_sh.year[60], ds_cesm1_aicetot_sh.year[95], 36)\n", - "x4 = np.linspace(ds_cesm2_aicetot_sh.year[110], ds_cesm2_aicetot_sh.year[145], 36)\n", - "obs_first_year = 0\n", - "if first_year > 1:\n", - " obs_first_year = 1979\n", - "\n", "# Make Plot - two subplots - note it's nrow x ncol x index (starting upper left)\n", "fig = plt.figure(figsize=(20, 7))\n", "\n", From f76459ab37ab9607ea831890bec1031343eedb7a Mon Sep 17 00:00:00 2001 From: David Bailey Date: Thu, 13 Feb 2025 09:56:23 -0700 Subject: [PATCH 04/11] Clean up some axes stuff --- ...Hemis_seaice_visual_compare_obs_lens.ipynb | 64 ++++++++++--------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb index b321af0..c4d0c55 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -370,6 +370,30 @@ "cesm2_hstot_sh_month = ds_cesm2_hstot_sh[\"hs_monthly\"][:, 110:145, :].mean(dim=\"nyr\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "cb4ae820-af6b-4c46-a814-a43cc687f3d5", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [], + "source": [ + "# Set up legends\n", + "\n", + "p1 = mlines.Line2D([], [], color=\"lightgrey\", label=\"CESM1-LENS\")\n", + "p2 = mlines.Line2D([], [], color=\"lightblue\", label=\"CESM2-LENS\")\n", + "p3 = mlines.Line2D([], [], color=\"red\", label=case_name)\n", + "p4 = mlines.Line2D([], [], color=\"blue\", label=base_case_name)\n", + "p5 = mlines.Line2D([], [], color=\"black\", label=\"NSIDC\")" + ] + }, { "cell_type": "markdown", "id": "49a75b16-6772-47a1-b395-f08265768b8b", @@ -639,11 +663,6 @@ "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", - "p1 = mlines.Line2D([], [], color=\"lightgrey\", label=\"CESM1-LENS\")\n", - "p2 = mlines.Line2D([], [], color=\"lightblue\", label=\"CESM2-LENS\")\n", - "p3 = mlines.Line2D([], [], color=\"red\", label=case_name)\n", - "p4 = mlines.Line2D([], [], color=\"blue\", label=base_case_name)\n", - "\n", "fig = plt.figure(figsize=(10, 10), tight_layout=True)\n", "\n", "ax = fig.add_subplot(3, 1, 1)\n", @@ -732,11 +751,6 @@ "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", - "p1 = mlines.Line2D([], [], color=\"lightgrey\", label=\"CESM1-LENS\")\n", - "p2 = mlines.Line2D([], [], color=\"lightblue\", label=\"CESM2-LENS\")\n", - "p3 = mlines.Line2D([], [], color=\"red\", label=case_name)\n", - "p4 = mlines.Line2D([], [], color=\"blue\", label=base_case_name)\n", - "\n", "fig = plt.figure(figsize=(10, 10), tight_layout=True)\n", "\n", "ax = fig.add_subplot(3, 1, 1)\n", @@ -863,12 +877,6 @@ "area1 = (aice1_month * mask_nh).sum([\"ni\", \"nj\"]) * 1.0e-12\n", "area2 = (aice2_month * mask_nh).sum([\"ni\", \"nj\"]) * 1.0e-12\n", "\n", - "p1 = mlines.Line2D([], [], color=\"lightgrey\", label=\"CESM1-LENS\")\n", - "p2 = mlines.Line2D([], [], color=\"lightblue\", label=\"CESM2-LENS\")\n", - "p3 = mlines.Line2D([], [], color=\"red\", label=case_name)\n", - "p4 = mlines.Line2D([], [], color=\"blue\", label=base_case_name)\n", - "p5 = mlines.Line2D([], [], color=\"black\", label=\"NSIDC\")\n", - "\n", "months = np.linspace(1, 12, 12)\n", "\n", "for i in range(0, 38):\n", @@ -993,11 +1001,6 @@ "vol1 = (hi1_month * mask_nh).sum([\"ni\", \"nj\"]) * 1.0e-13\n", "vol2 = (hi2_month * mask_nh).sum([\"ni\", \"nj\"]) * 1.0e-13\n", "\n", - "p1 = mlines.Line2D([], [], color=\"lightgrey\", label=\"CESM1-LENS\")\n", - "p2 = mlines.Line2D([], [], color=\"lightblue\", label=\"CESM2-LENS\")\n", - "p3 = mlines.Line2D([], [], color=\"red\", label=case_name)\n", - "p4 = mlines.Line2D([], [], color=\"blue\", label=base_case_name)\n", - "\n", "months = np.linspace(1, 12, 12)\n", "\n", "for i in range(0, 38):\n", @@ -1041,11 +1044,6 @@ "vol1 = (hi1_month * mask_sh).sum([\"ni\", \"nj\"]) * 1.0e-13\n", "vol2 = (hi2_month * mask_sh).sum([\"ni\", \"nj\"]) * 1.0e-13\n", "\n", - "p1 = mlines.Line2D([], [], color=\"lightgrey\", label=\"CESM1-LENS\")\n", - "p2 = mlines.Line2D([], [], color=\"lightblue\", label=\"CESM2-LENS\")\n", - "p3 = mlines.Line2D([], [], color=\"red\", label=case_name)\n", - "p4 = mlines.Line2D([], [], color=\"blue\", label=base_case_name)\n", - "\n", "months = np.linspace(1, 12, 12)\n", "\n", "for i in range(0, 38):\n", @@ -1092,7 +1090,15 @@ "cell_type": "code", "execution_count": null, "id": "1327dccc-0065-43dc-874d-4404c07f6eba", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, "outputs": [], "source": [ "ds1_area = (tarea * ds1.aice).isel(time=slice(-climo_nyears * 12, None)).where(\n", @@ -1129,6 +1135,7 @@ "cesm1_aicetot_sh_sep = ds_cesm1_aicetot_sh[\"aice_monthly\"].isel(nmonth=8)\n", "cesm2_aicetot_sh_sep = ds_cesm2_aicetot_sh[\"aice_monthly\"].isel(nmonth=8)\n", "\n", + "# Set up axes\n", "if first_year > 1:\n", " model_start_year1 = end_year - len(ds1_mar_nh.time)\n", " model_end_year1 = end_year\n", @@ -1158,11 +1165,10 @@ " obs_first_year = 1979\n", "x5 = np.linspace(1, 36, 36) + obs_first_year\n", "\n", - "\n", "# Make Plot - two subplots - note it's nrow x ncol x index (starting upper left)\n", "fig = plt.figure(figsize=(20, 7))\n", "\n", - "### First panel, timeseries\n", + "# First panel, timeseries\n", "ax = fig.add_subplot(1, 2, 1)\n", "for i in range(0, 38):\n", " ax.plot(\n", From 6f5c9a67b87e619c322d72da98399e83581ef918 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Thu, 13 Feb 2025 13:11:36 -0700 Subject: [PATCH 05/11] Annual annual cycles of snow --- ...Hemis_seaice_visual_compare_obs_lens.ipynb | 134 +++++++++++++++++- 1 file changed, 132 insertions(+), 2 deletions(-) diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb index c4d0c55..7ffd5bf 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -962,13 +962,13 @@ "# get monthly means from test data\n", "hi1_month = (\n", " ds1[\"hi\"]\n", - " .isel(time=slice(-climo_nyears, None))\n", + " .isel(time=slice(-climo_nyears * 12, None))\n", " .groupby(\"time.month\")\n", " .mean(dim=\"time\", skipna=True)\n", ")\n", "hi2_month = (\n", " ds2[\"hi\"]\n", - " .isel(time=slice(-climo_nyears, None))\n", + " .isel(time=slice(-climo_nyears * 12, None))\n", " .groupby(\"time.month\")\n", " .mean(dim=\"time\", skipna=True)\n", ")" @@ -1060,6 +1060,136 @@ "plt.legend(handles=[p1, p2, p3, p4])" ] }, + { + "cell_type": "markdown", + "id": "dc6c30d3-5259-4bb9-835d-56e0ab275da0", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "source": [ + "# Annual cycle plots - Snow volume" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7b04bb7b-7870-4695-8aaa-d95be1ba2e58", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [], + "source": [ + "# get monthly means from test data\n", + "hs1_month = (\n", + " ds1[\"hs\"]\n", + " .isel(time=slice(-climo_nyears * 12, None))\n", + " .groupby(\"time.month\")\n", + " .mean(dim=\"time\", skipna=True)\n", + ")\n", + "hs2_month = (\n", + " ds2[\"hs\"]\n", + " .isel(time=slice(-climo_nyears * 12, None))\n", + " .groupby(\"time.month\")\n", + " .mean(dim=\"time\", skipna=True)\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5f3425f9-2426-4c68-9d1e-060e4c472b5d", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [], + "source": [ + "# Northern hemisphere annual cycle plot\n", + "tag = \"NH\"\n", + "\n", + "mask_tmp1_nh = np.where(np.logical_and(hs1_month > 0, ds1[\"TLAT\"] > 0), 1.0, 0.0)\n", + "mask_tmp2_nh = np.where(np.logical_and(hs2_month > 0, ds1[\"TLAT\"] > 0), 1.0, 0.0)\n", + "\n", + "mask_nh_tmp = np.where(ds1[\"TLAT\"] > 0, tarea, 0.0)\n", + "mask_nh = xr.DataArray(data=mask_nh_tmp, dims=[\"nj\", \"ni\"])\n", + "\n", + "vol1 = (hs1_month * mask_nh).sum([\"ni\", \"nj\"]) * 1.0e-13\n", + "vol2 = (hs2_month * mask_nh).sum([\"ni\", \"nj\"]) * 1.0e-13\n", + "\n", + "months = np.linspace(1, 12, 12)\n", + "\n", + "for i in range(0, 38):\n", + " plt.plot(months, cesm1_hstot_nh_month[i, :] * 1.0e-13, color=\"lightgrey\")\n", + "for i in range(0, 49):\n", + " plt.plot(months, cesm2_hstot_nh_month[i, :] * 1.0e-13, color=\"lightblue\")\n", + "plt.plot(months, vol1, color=\"red\")\n", + "plt.plot(months, vol2, color=\"blue\")\n", + "\n", + "plt.title(tag + \" Climatological Seasonal Cycle\")\n", + "plt.ylim((0, 1))\n", + "plt.xlabel(\"Month\")\n", + "plt.ylabel(\"Snow Volume $m^{3} x 10^{13}$\")\n", + "plt.legend(handles=[p1, p2, p3, p4])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "15919063-38c8-4213-92ca-c021745fc456", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [], + "source": [ + "# Southern hemisphere annual cycle plot\n", + "tag = \"SH\"\n", + "\n", + "mask_tmp1_sh = np.where(np.logical_and(hs1_month > 0, ds1[\"TLAT\"] < 0), 1.0, 0.0)\n", + "mask_tmp2_sh = np.where(np.logical_and(hs2_month > 0, ds1[\"TLAT\"] < 0), 1.0, 0.0)\n", + "\n", + "mask_sh_tmp = np.where(ds1[\"TLAT\"] < 0, tarea, 0.0)\n", + "mask_sh = xr.DataArray(data=mask_sh_tmp, dims=[\"nj\", \"ni\"])\n", + "\n", + "vol1 = (hs1_month * mask_sh).sum([\"ni\", \"nj\"]) * 1.0e-13\n", + "vol2 = (hs2_month * mask_sh).sum([\"ni\", \"nj\"]) * 1.0e-13\n", + "\n", + "months = np.linspace(1, 12, 12)\n", + "\n", + "for i in range(0, 38):\n", + " plt.plot(months, cesm1_hstot_sh_month[i, :] * 1.0e-13, color=\"lightgrey\")\n", + "for i in range(0, 49):\n", + " plt.plot(months, cesm2_hstot_sh_month[i, :] * 1.0e-13, color=\"lightblue\")\n", + "plt.plot(months, vol1, color=\"red\")\n", + "plt.plot(months, vol2, color=\"blue\")\n", + "\n", + "plt.title(tag + \" Climatological Seasonal Cycle\")\n", + "plt.ylim((0, 1))\n", + "plt.xlabel(\"Month\")\n", + "plt.ylabel(\"Snow Volume $m^{3} x 10^{13}$\")\n", + "plt.legend(handles=[p1, p2, p3, p4])" + ] + }, { "cell_type": "markdown", "id": "160a9f24-49af-4900-81cf-389c09583fb4", From 04d761a0ee7cd6aee425c3f7fee786b21327cc37 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Thu, 13 Feb 2025 13:47:21 -0700 Subject: [PATCH 06/11] Hide some more code cells --- ...Hemis_seaice_visual_compare_obs_lens.ipynb | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb index 7ffd5bf..adaba37 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -221,7 +221,15 @@ "cell_type": "code", "execution_count": null, "id": "b590d77c-f5b9-4b36-b67d-464759adb268", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, "outputs": [], "source": [ "# Two functions to help draw plots even if only one year of data is available\n", @@ -254,7 +262,15 @@ "cell_type": "code", "execution_count": null, "id": "9499f101-4c85-4244-b3c6-2f327e64107a", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, "outputs": [], "source": [ "def setBoxColor(boxplot, colors):\n", From 6c5d1cb0304a656ac9a6009d9cd8392a316ae971 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Mon, 24 Feb 2025 13:04:04 -0700 Subject: [PATCH 07/11] Update parameters to comments --- .../Hemis_seaice_visual_compare_contour.ipynb | 33 +++++++++-------- ...Hemis_seaice_visual_compare_obs_lens.ipynb | 35 +++++++++++-------- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb index 3a5b09f..9ab16cd 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb @@ -53,24 +53,25 @@ }, "outputs": [], "source": [ - "CESM_output_dir = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing\"\n", - "serial = False # use dask LocalCluster\n", + "# These parameters are needed when running interactively\n", + "\n", + "# CESM_output_dir = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing\"\n", "\n", - "case_name = \"b.e30_beta04.BLT1850.ne30_t232_wgx3.121congel\"\n", - "base_case_name = \"b.e30_beta04.BLT1850.ne30_t232_wgx3.121\"\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 = \"0100-01-01\"\n", - "base_start_date = \"0001-01-01\"\n", - "base_end_date = \"0100-01-01\"\n", + "# start_date = \"0001-01-01\"\n", + "# end_date = \"0100-01-01\"\n", + "# base_start_date = \"0001-01-01\"\n", + "# base_end_date = \"0100-01-01\"\n", "\n", - "climo_nyears = 35\n", - "grid_file = \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", - "path_obs = (\n", - " \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/\"\n", - ")\n", + "# climo_nyears = 35\n", + "# grid_file = \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", + "# path_obs = (\n", + "# \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/\"\n", + "# )\n", "\n", - "lc_kwargs = {}" + "# lc_kwargs = {}" ] }, { @@ -88,7 +89,11 @@ }, "outputs": [], "source": [ + "# When running interactively, cupid_run should be set to 0 for\n", + "# a DASK cluster\n", + "\n", "cupid_run = 1\n", + "serial = False # use dask LocalCluster\n", "\n", "if cupid_run == 1:\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 adaba37..c9ada3e 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -58,25 +58,26 @@ }, "outputs": [], "source": [ - "CESM_output_dir = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing\"\n", - "serial = False # use dask LocalCluster\n", + "# These parameters are needed when running interactively\n", "\n", - "case_name = \"b.e30_beta02.BLT1850.ne30_t232.104\"\n", - "base_case_name = \"b.e23_alpha17f.BLT1850.ne30_t232.092\"\n", + "# CESM_output_dir = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing\"\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", + "# case_name = \"b.e30_beta02.BLT1850.ne30_t232.104\"\n", + "# base_case_name = \"b.e23_alpha17f.BLT1850.ne30_t232.092\"\n", "\n", - "climo_nyears = 35\n", - "grid_file = \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", - "path_obs = (\n", - " \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/\"\n", - ")\n", - "path_model = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/\"\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", + "# grid_file = \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", + "# path_obs = (\n", + "# \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/\"\n", + "# )\n", + "# path_model = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/\"\n", "\n", - "lc_kwargs = {}" + "# lc_kwargs = {}" ] }, { @@ -94,7 +95,11 @@ }, "outputs": [], "source": [ + "# When running interactively, cupid_run should be set to 0 for\n", + "# a DASK cluster\n", + "\n", "cupid_run = 1\n", + "serial = False # use dask LocalCluster\n", "\n", "if cupid_run == 1:\n", "\n", From 473bb0b08d3eb447a319495cf26e406205b06ae4 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Mon, 24 Feb 2025 14:40:15 -0700 Subject: [PATCH 08/11] Update parameters again --- .../Hemis_seaice_visual_compare_contour.ipynb | 24 ++++++++---------- ...Hemis_seaice_visual_compare_obs_lens.ipynb | 25 ++++++++----------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb index 9ab16cd..a111597 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb @@ -55,23 +55,21 @@ "source": [ "# These parameters are needed when running interactively\n", "\n", - "# CESM_output_dir = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing\"\n", + "CESM_output_dir = \"\" # \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing\"\n", "\n", - "# case_name = \"b.e30_beta04.BLT1850.ne30_t232_wgx3.121congel\"\n", - "# base_case_name = \"b.e30_beta04.BLT1850.ne30_t232_wgx3.121\"\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 = \"0100-01-01\"\n", - "# base_start_date = \"0001-01-01\"\n", - "# base_end_date = \"0100-01-01\"\n", + "start_date = \"\" # \"0001-01-01\"\n", + "end_date = \"\" # \"0100-01-01\"\n", + "base_start_date = \"\" # \"0001-01-01\"\n", + "base_end_date = \"\" # \"0100-01-01\"\n", "\n", - "# climo_nyears = 35\n", - "# grid_file = \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", - "# path_obs = (\n", - "# \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/\"\n", - "# )\n", + "climo_nyears = 35\n", + "grid_file = \"\" # \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", + "path_obs = \"\" # \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/\"\n", "\n", - "# lc_kwargs = {}" + "lc_kwargs = {}" ] }, { diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb index c9ada3e..fa267c3 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -60,24 +60,21 @@ "source": [ "# These parameters are needed when running interactively\n", "\n", - "# CESM_output_dir = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing\"\n", + "CESM_output_dir = \"\" # \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing\"\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", - "# base_start_date = \"0001-01-01\"\n", - "# base_end_date = \"0101-01-01\"\n", + "start_date = \"\" # \"0001-01-01\"\n", + "end_date = \"\" # \"0100-01-01\"\n", + "base_start_date = \"\" # \"0001-01-01\"\n", + "base_end_date = \"\" # \"0100-01-01\"\n", "\n", - "# climo_nyears = 35\n", - "# grid_file = \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", - "# path_obs = (\n", - "# \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/\"\n", - "# )\n", - "# path_model = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/\"\n", + "climo_nyears = 35\n", + "grid_file = \"\" # \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", + "path_obs = \"\" # \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/\"\n", "\n", - "# lc_kwargs = {}" + "lc_kwargs = {}" ] }, { From c83d21de144f6c5b95157128a7de74b856b86cf2 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Tue, 25 Feb 2025 10:19:23 -0700 Subject: [PATCH 09/11] Fix the path in config.yml --- examples/key_metrics/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/key_metrics/config.yml b/examples/key_metrics/config.yml index 28c45d9..6558227 100644 --- a/examples/key_metrics/config.yml +++ b/examples/key_metrics/config.yml @@ -172,7 +172,7 @@ compute_notebooks: none: climo_nyears: 35 grid_file: '/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc' - path_nsdic: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/' + path_obs: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/' path_model: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/' From f69c7c93b0288fd6134fcf291e70b8639e5ad3cb Mon Sep 17 00:00:00 2001 From: David Bailey Date: Tue, 25 Feb 2025 11:26:11 -0700 Subject: [PATCH 10/11] Use obs_data_dir and clean up the parameter boxes in the notebooks. --- examples/coupled_model/config.yml | 3 +-- examples/key_metrics/config.yml | 1 - .../ice/Hemis_seaice_visual_compare_contour.ipynb | 9 +++++---- .../ice/Hemis_seaice_visual_compare_obs_lens.ipynb | 12 ++++-------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/examples/coupled_model/config.yml b/examples/coupled_model/config.yml index 337e742..34d872d 100644 --- a/examples/coupled_model/config.yml +++ b/examples/coupled_model/config.yml @@ -49,6 +49,7 @@ global_params: end_date: '0100-01-01' base_start_date: '0001-01-01' base_end_date: '0100-01-01' + obs_data_dir: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data' lc_kwargs: threads_per_worker: 1 @@ -159,14 +160,12 @@ compute_notebooks: none: climo_nyears: 35 grid_file: '/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc' - path_obs: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/' path_model: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/' Hemis_seaice_visual_compare_contour: parameter_groups: none: climo_nyears: 35 grid_file: '/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc' - path_obs: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/' path_model: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/' diff --git a/examples/key_metrics/config.yml b/examples/key_metrics/config.yml index 6558227..e4ba2cf 100644 --- a/examples/key_metrics/config.yml +++ b/examples/key_metrics/config.yml @@ -172,7 +172,6 @@ compute_notebooks: none: climo_nyears: 35 grid_file: '/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc' - path_obs: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/' path_model: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/' diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb index a111597..7d05fdd 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_contour.ipynb @@ -65,9 +65,11 @@ "base_start_date = \"\" # \"0001-01-01\"\n", "base_end_date = \"\" # \"0100-01-01\"\n", "\n", - "climo_nyears = 35\n", + "obs_data_dir = \"\" # \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data\"\n", "grid_file = \"\" # \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", - "path_obs = \"\" # \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/\"\n", + "climo_nyears = 35\n", + "\n", + "serial = False # use dask LocalCluster\n", "\n", "lc_kwargs = {}" ] @@ -91,7 +93,6 @@ "# a DASK cluster\n", "\n", "cupid_run = 1\n", - "serial = False # use dask LocalCluster\n", "\n", "if cupid_run == 1:\n", "\n", @@ -182,7 +183,7 @@ "with open(\"cice_vars.yml\", \"r\") as file:\n", " cice_vars = yaml.safe_load(file)\n", "\n", - "path_HadleyOI = os.path.join(path_obs, \"analysis_datasets\", \"1x1d/\")" + "path_HadleyOI = os.path.join(obs_data_dir, \"ice\", \"analysis_datasets\", \"1x1d/\")" ] }, { diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb index bf1ebfb..c0e8822 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -67,14 +67,11 @@ "base_start_date = \"\" # \"0001-01-01\"\n", "base_end_date = \"\" # \"0101-01-01\"\n", "\n", - "climo_nyears = 35\n", - "grid_file = \"\" # \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", "obs_data_dir = \"\" # \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data\"\n", - "path_nsidc = \"\" # \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/analysis_datasets/hemispheric_data/NSIDC_SeaIce_extent\"\n", - "\n", - "climo_nyears = 35\n", "grid_file = \"\" # \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", - "path_obs = \"\" # \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data/ice/\"\n", + "climo_nyears = 35\n", + "\n", + "serial = False # use dask LocalCluster\n", "\n", "lc_kwargs = {}" ] @@ -98,7 +95,6 @@ "# a DASK cluster\n", "\n", "cupid_run = 1\n", - "serial = False # use dask LocalCluster\n", "\n", "if cupid_run == 1:\n", "\n", @@ -209,7 +205,7 @@ "path_lens2 = os.path.join(path_model, \"cesm_lens2\")\n", "\n", "path_nsidc = os.path.join(\n", - " path_obs, \"analysis_datasets\", \"hemispheric_data\", \"NSIDC_SeaIce_extent/\"\n", + " obs_data_dir, \"ice\", \"analysis_datasets\", \"hemispheric_data\", \"NSIDC_SeaIce_extent/\"\n", ")" ] }, From 5f4d3f940f443c78c1ac8051e219d1e6daba1fe4 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Tue, 25 Feb 2025 13:05:36 -0700 Subject: [PATCH 11/11] Fix path_model and path_nsidc --- examples/coupled_model/config.yml | 1 - nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/coupled_model/config.yml b/examples/coupled_model/config.yml index 34d872d..42cd27f 100644 --- a/examples/coupled_model/config.yml +++ b/examples/coupled_model/config.yml @@ -166,7 +166,6 @@ compute_notebooks: none: climo_nyears: 35 grid_file: '/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc' - path_model: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/' ########### JUPYTER BOOK CONFIG ########### diff --git a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb index c0e8822..896a242 100644 --- a/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb +++ b/nblibrary/ice/Hemis_seaice_visual_compare_obs_lens.ipynb @@ -68,6 +68,7 @@ "base_end_date = \"\" # \"0101-01-01\"\n", "\n", "obs_data_dir = \"\" # \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data\"\n", + "path_model = \"\" # \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_model_data/ice/\"\n", "grid_file = \"\" # \"/glade/campaign/cesm/community/omwg/grids/tx2_3v2_grid.nc\"\n", "climo_nyears = 35\n", "\n", @@ -205,7 +206,7 @@ "path_lens2 = os.path.join(path_model, \"cesm_lens2\")\n", "\n", "path_nsidc = os.path.join(\n", - " obs_data_dir, \"ice\", \"analysis_datasets\", \"hemispheric_data\", \"NSIDC_SeaIce_extent/\"\n", + " \"ice\", \"analysis_datasets\", \"hemispheric_data\", \"NSIDC_SeaIce_extent/\"\n", ")" ] },