From 8307c6e4c602ca21d4d55eb659221fba3bfba9a0 Mon Sep 17 00:00:00 2001 From: Ana Ordonez Date: Thu, 9 May 2024 11:37:35 -0700 Subject: [PATCH 1/5] update figures --- .../sea_ice/scripts/sea_ice_figures.py | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/pcmdi_metrics/sea_ice/scripts/sea_ice_figures.py b/pcmdi_metrics/sea_ice/scripts/sea_ice_figures.py index e235e825b..99d05f757 100644 --- a/pcmdi_metrics/sea_ice/scripts/sea_ice_figures.py +++ b/pcmdi_metrics/sea_ice/scripts/sea_ice_figures.py @@ -37,10 +37,12 @@ metrics = {"RESULTS": {}} for metrics_file in glob.glob(filelist): with open(metrics_file) as mf: - results = json.load(mf)["RESULTS"] - model_list.append(list(results.keys())[0]) - metrics["RESULTS"].update(results) + results = json.load(mf) + for item in results["DIMENSIONS"]["model"]: + model_list.append(item) + metrics["RESULTS"].update(results["RESULTS"]) +model_list.sort() tmp = model_list[0] reference_data_set = list(metrics["RESULTS"][tmp]["arctic"]["model_mean"].keys())[0] @@ -115,27 +117,18 @@ mark_size = 1 ax7[inds].bar(ind - width / 2.0, mse_clim, width, color="b", label="Ann. Cycle") ax7[inds].bar(ind, mse_ext, width, color="r", label="Ann. Mean") - if len(clim_err_x) > 0: - ax7[inds].scatter( - [x - width / 2.0 for x in clim_err_x], - clim_err_y, - marker="D", - s=mark_size, - color="k", - ) - ax7[inds].scatter(clim_err_x, ext_err_y, marker="D", s=mark_size, color="k") - # xticks + + # X axis label if inds == len(sector_list) - 1: ax7[inds].set_xticks(ind + width / 2.0, mlabels, rotation=90, size=7) else: ax7[inds].set_xticks(ind + width / 2.0, labels="") - # yticks - if len(clim_err_y) > 0: - datamax = np.max(np.array(clim_err_y)) - else: - datamax = np.max(np.array(mse_clim)) + + # Y axis + datamax = np.nanmax(np.concatenate((np.array(mse_clim), np.array(mse_ext)))) ymax = (datamax) * 1.3 ax7[inds].set_ylim(0.0, ymax) + print(ymax) if ymax < 0.1: ticks = np.linspace(0, 0.1, 6) labels = [str(round(x, 3)) for x in ticks] @@ -151,8 +144,8 @@ else: ticks = range(0, round(ymax)) labels = [str(round(x, 0)) for x in ticks] - ax7[inds].set_yticks(ticks, labels, fontsize=8) + # labels etc ax7[inds].set_ylabel("10${^1}{^2}$km${^4}$", size=8) ax7[inds].grid(True, linestyle=":") @@ -162,6 +155,8 @@ xycoords="axes fraction", size=9, ) + aw = 0.07 + # Add legend, save figure ax7[0].legend(loc="upper right", fontsize=6) plt.suptitle("Mean Square Error relative to " + reference_data_set, y=0.91) From 175be2d02202bc35523a0f4caff69ae34e9adb32 Mon Sep 17 00:00:00 2001 From: Ana Ordonez Date: Thu, 9 May 2024 11:39:57 -0700 Subject: [PATCH 2/5] delete extraneous --- pcmdi_metrics/sea_ice/scripts/sea_ice_figures.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pcmdi_metrics/sea_ice/scripts/sea_ice_figures.py b/pcmdi_metrics/sea_ice/scripts/sea_ice_figures.py index 99d05f757..468dfc74d 100644 --- a/pcmdi_metrics/sea_ice/scripts/sea_ice_figures.py +++ b/pcmdi_metrics/sea_ice/scripts/sea_ice_figures.py @@ -128,7 +128,7 @@ datamax = np.nanmax(np.concatenate((np.array(mse_clim), np.array(mse_ext)))) ymax = (datamax) * 1.3 ax7[inds].set_ylim(0.0, ymax) - print(ymax) + if ymax < 0.1: ticks = np.linspace(0, 0.1, 6) labels = [str(round(x, 3)) for x in ticks] @@ -155,7 +155,6 @@ xycoords="axes fraction", size=9, ) - aw = 0.07 # Add legend, save figure ax7[0].legend(loc="upper right", fontsize=6) From 71e4d38906e4643b3147e5d2b46509578bd3b750 Mon Sep 17 00:00:00 2001 From: Ana Ordonez Date: Thu, 9 May 2024 11:45:14 -0700 Subject: [PATCH 3/5] add figure script --- pcmdi_metrics/sea_ice/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pcmdi_metrics/sea_ice/README.md b/pcmdi_metrics/sea_ice/README.md index e7858173c..4a2c630fa 100644 --- a/pcmdi_metrics/sea_ice/README.md +++ b/pcmdi_metrics/sea_ice/README.md @@ -64,6 +64,16 @@ A [demo parameter file](https://github.com/PCMDI/pcmdi_metrics/blob/405_sic_ao/p * **obs_cell_area**: For equal area grids, the area of a single grid cell in units of km2. Only required if obs area file is not available. * **pole**: Set the maximum latitude for the Central Arctic and Arctic regions to exclude ice over the pole. Default is 90.1 to include all ice. +## Postprocessing + +A script is provided to create a multi-model bar chart using results from multiple runs of the sea ice driver. This script can be found in `./scripts/sea_ice_figures.py`. + +To run, use: +``` +python sea_ice_figures.py --filelist 'path/to/models/*/sea_ice_metrics.json' --output_path '.' +``` + +A wildcard `*` can be used to glob multiple folders of results. The final path in the `--filelist` parameter must be the sea_ice_metrics.json file. The `--output_path` parameter can be any valid path. ## Reference From 448ab8f70d634b27a365ed58dac245c432c6f903 Mon Sep 17 00:00:00 2001 From: Ana Ordonez Date: Thu, 9 May 2024 11:46:42 -0700 Subject: [PATCH 4/5] edit postproc --- pcmdi_metrics/sea_ice/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcmdi_metrics/sea_ice/README.md b/pcmdi_metrics/sea_ice/README.md index 4a2c630fa..12c0c9262 100644 --- a/pcmdi_metrics/sea_ice/README.md +++ b/pcmdi_metrics/sea_ice/README.md @@ -68,7 +68,7 @@ A [demo parameter file](https://github.com/PCMDI/pcmdi_metrics/blob/405_sic_ao/p A script is provided to create a multi-model bar chart using results from multiple runs of the sea ice driver. This script can be found in `./scripts/sea_ice_figures.py`. -To run, use: +Example command: ``` python sea_ice_figures.py --filelist 'path/to/models/*/sea_ice_metrics.json' --output_path '.' ``` From 77bbaf43b8b50143d96ede4e3c8f667e11a4358c Mon Sep 17 00:00:00 2001 From: Ana Ordonez Date: Thu, 9 May 2024 11:50:09 -0700 Subject: [PATCH 5/5] add postproc --- docs/metrics_sea_ice.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/metrics_sea_ice.rst b/docs/metrics_sea_ice.rst index ef0b99b05..b8085b6dd 100644 --- a/docs/metrics_sea_ice.rst +++ b/docs/metrics_sea_ice.rst @@ -68,6 +68,18 @@ A `demo parameter file`_ is provided in the sea ice code. * **obs_cell_area**: For equal area grids, the area of a single grid cell in units of km :sup:`2` . Only required if obs area file is not available. * **pole**: Set the maximum latitude for the Central Arctic and Arctic regions to exclude ice over the pole. Default is 90.1 to include all ice. +Postprocessing +============== + +A script is provided to create a multi-model bar chart using results from multiple runs of the sea ice driver. This script can be found in ./scripts/sea_ice_figures.py. + +Example command: :: + + python sea_ice_figures.py --filelist 'path/to/models/*/sea_ice_metrics.json' --output_path '.' + + +A wildcard '*' can be used to glob multiple folders of results. The final path in the --filelist parameter must be the sea_ice_metrics.json file. The --output_path parameter can be any valid path. + Reference ========= Ivanova, D. P., P. J. Gleckler, K. E. Taylor, P. J. Durack, and K. D. Marvel, 2016: Moving beyond the Total Sea Ice Extent in Gauging Model Biases. J. Climate, 29, 8965–8987, https://doi.org/10.1175/JCLI-D-16-0026.1.