From 26b00a06f782143d6a7802e30d3cdbb87c3bdada Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Thu, 22 Feb 2024 09:31:22 -0700 Subject: [PATCH 01/13] add note on taylor size --- src/geocat/viz/taylor.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/geocat/viz/taylor.py b/src/geocat/viz/taylor.py index 66670ac..69acc26 100644 --- a/src/geocat/viz/taylor.py +++ b/src/geocat/viz/taylor.py @@ -44,6 +44,11 @@ class TaylorDiagram(object): stdLevel : list Optional list of tick locations for stddev axis + Notes + ----- + Rendering of Taylor Diagrams looks best with a figure that is at least 10x10. If you make your figure size too small, + legends, lagels, and other text items might overlap in undesired ways. + References ---------- - https://validate-climate-model-validation.readthedocs.io/en/latest/_modules/validate/taylor.html From 917ff3e312ce8bf0598e9c96bd4e836f560658e6 Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Mon, 18 Mar 2024 07:32:32 -0600 Subject: [PATCH 02/13] add name alias --- docs/examples/taylor.ipynb | 2 +- docs/release-notes.rst | 9 +++++++++ src/geocat/viz/taylor.py | 41 ++++++++++++++++++++++++++++++++------ src/geocat/viz/util.py | 2 ++ 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/docs/examples/taylor.ipynb b/docs/examples/taylor.ipynb index 3b69683..1f51d21 100644 --- a/docs/examples/taylor.ipynb +++ b/docs/examples/taylor.ipynb @@ -57,7 +57,7 @@ "\n", "# Draw diagonal dashed lines from origin to correlation values\n", "# Also enforces proper X-Y ratio\n", - "taylor.add_xgrid(np.array([0.6, 0.9]))\n", + "taylor.add_corr_grid(np.array([0.6, 0.9]))\n", "\n", "# Add models to Taylor diagram\n", "taylor.add_model_set(a_sdev,\n", diff --git a/docs/release-notes.rst b/docs/release-notes.rst index f77142c..e63f551 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -5,6 +5,15 @@ Release Notes ============= +v2024.04.1 (April 1, 2024) +------------------------------ +This release ... + +Documentation +^^^^^^^^^^^^^ +* Document known quark for using `suptitle` argument of ``set_titles_and_labels`` with a Cartopy plot by `Julia Kent`_ in (:pr:`219`) +* Add alias to ``Taylor_Diagram`` to have more meaningful keyword arguments by by `Julia Kent`_ in (:pr:`219`) + v2024.02.1 (February 28, 2024) ------------------------------ This release changes to implicit namespace packaging and addresses a bug in the Taylor diagram functionality when disabling ``annotate_on``. diff --git a/src/geocat/viz/taylor.py b/src/geocat/viz/taylor.py index 75d2295..f92e744 100644 --- a/src/geocat/viz/taylor.py +++ b/src/geocat/viz/taylor.py @@ -382,13 +382,13 @@ def add_model_set(self, return modelTexts, modelset - def add_xgrid(self, + def add_corr_grid(self, arr: typing.Union[xr.DataArray, np.ndarray, list, float], color: str = 'lightgray', linestyle=(0, (9, 5)), linewidth: float = 0.5, **kwargs): - """Add gridlines to the X axis (correlation) specified by array *arr* + """Add gridlines to the correlation axis specified by array *arr* Parameters ---------- @@ -416,7 +416,7 @@ def add_xgrid(self, -------- All usage examples are within the GeoCAT-Examples Gallery. To see more usage cases, search the function on the `website `_. - - `NCL_taylor_2.py `_ + - `NCL_taylor_2.py `_ """ for value in arr: @@ -428,13 +428,27 @@ def add_xgrid(self, linewidth=linewidth, **kwargs) - def add_ygrid(self, + def add_xgrid(self, + arr: typing.Union[xr.DataArray, np.ndarray, list, float], + color: str = 'lightgray', + linestyle=(0, (9, 5)), + linewidth: float = 0.5, + **kwargs): + + return add_corr_grid(self, + arr: typing.Union[xr.DataArray, np.ndarray, list, float], + color: str = 'lightgray', + linestyle=(0, (9, 5)), + linewidth: float = 0.5, + **kwargs) + + def add_stdev_grid(self, arr: typing.Union[xr.DataArray, np.ndarray, list, float], color: str = 'lightgray', linestyle=(0, (9, 5)), linewidth: int = 1, **kwargs): - """Add gridlines (radii) to the Y axis (standard deviation) specified + """Add gridlines (radii) to the stard deviation axis specified by array *arr* Parameters @@ -463,7 +477,7 @@ def add_ygrid(self, -------- All usage examples are within the GeoCAT-Examples Gallery. To see more usage cases, search the function on the `website `_. - - `NCL_taylor_2.py `_ + - `NCL_taylor_2.py `_ """ t_array = np.linspace(0, np.pi / 2) @@ -476,6 +490,21 @@ def add_ygrid(self, linewidth=linewidth, **kwargs) + def add_ygrid(self, + arr: typing.Union[xr.DataArray, np.ndarray, list, float], + color: str = 'lightgray', + linestyle=(0, (9, 5)), + linewidth: int = 1, + **kwargs): + + return add_stdev_grid(self, + arr: typing.Union[xr.DataArray, np.ndarray, list, float], + color: str = 'lightgray', + linestyle=(0, (9, 5)), + linewidth: int = 1, + **kwargs) + + def add_grid(self, *args, **kwargs): """Add a grid. diff --git a/src/geocat/viz/util.py b/src/geocat/viz/util.py index a0e30e2..397c9ea 100644 --- a/src/geocat/viz/util.py +++ b/src/geocat/viz/util.py @@ -556,6 +556,8 @@ def set_titles_and_labels(ax: typing.Union[matplotlib.axes.Axes, >>> | Axes | >>> | | + Be aware that the `suptitle` functionality does not automaticallly render well for Cartopy plots. Recommended fixes are to iterate on your figure size until it does not extend as far past your plot OR to use string manipulation to add enough spaces to center your left or right title keyword argument. + Examples -------- All usage examples are within the GeoCAT-Examples Gallery. To see more usage cases, search the function on the From 31d5912082c5da051dc07ca197bf45e687e38bfa Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Mon, 18 Mar 2024 07:39:49 -0600 Subject: [PATCH 03/13] docstrings --- src/geocat/viz/taylor.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/geocat/viz/taylor.py b/src/geocat/viz/taylor.py index f92e744..8be079e 100644 --- a/src/geocat/viz/taylor.py +++ b/src/geocat/viz/taylor.py @@ -434,22 +434,28 @@ def add_xgrid(self, linestyle=(0, (9, 5)), linewidth: float = 0.5, **kwargs): - + """Add gridlines to the correlation axis specified by array *arr*. + + This function will be deprecated in favor of `add_corr_grid()` + """ + return add_corr_grid(self, arr: typing.Union[xr.DataArray, np.ndarray, list, float], color: str = 'lightgray', linestyle=(0, (9, 5)), linewidth: float = 0.5, **kwargs) - + def add_stdev_grid(self, arr: typing.Union[xr.DataArray, np.ndarray, list, float], color: str = 'lightgray', linestyle=(0, (9, 5)), linewidth: int = 1, **kwargs): - """Add gridlines (radii) to the stard deviation axis specified - by array *arr* + """Add gridlines (radii) to the stard deviation axis specified by + array. + + *arr* Parameters ---------- @@ -496,7 +502,13 @@ def add_ygrid(self, linestyle=(0, (9, 5)), linewidth: int = 1, **kwargs): - + """Add gridlines to the standard deviation axis specified by array. + + *arr*. + + This function will be deprecated in favor of `add_stdev_grid()` + """ + return add_stdev_grid(self, arr: typing.Union[xr.DataArray, np.ndarray, list, float], color: str = 'lightgray', From a313f1c2d2068ce337b2b275b2bcd591701c97f9 Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Mon, 18 Mar 2024 07:47:18 -0600 Subject: [PATCH 04/13] fix calls to add_corr_grid and add_stdev_grid --- src/geocat/viz/taylor.py | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/geocat/viz/taylor.py b/src/geocat/viz/taylor.py index 8be079e..9a235b6 100644 --- a/src/geocat/viz/taylor.py +++ b/src/geocat/viz/taylor.py @@ -383,11 +383,11 @@ def add_model_set(self, return modelTexts, modelset def add_corr_grid(self, - arr: typing.Union[xr.DataArray, np.ndarray, list, float], - color: str = 'lightgray', - linestyle=(0, (9, 5)), - linewidth: float = 0.5, - **kwargs): + arr: typing.Union[xr.DataArray, np.ndarray, list, float], + color: str = 'lightgray', + linestyle=(0, (9, 5)), + linewidth: float = 0.5, + **kwargs): """Add gridlines to the correlation axis specified by array *arr* Parameters @@ -439,19 +439,14 @@ def add_xgrid(self, This function will be deprecated in favor of `add_corr_grid()` """ - return add_corr_grid(self, - arr: typing.Union[xr.DataArray, np.ndarray, list, float], - color: str = 'lightgray', - linestyle=(0, (9, 5)), - linewidth: float = 0.5, - **kwargs) + return self.add_corr_grid(arr, color, linestyle, linewidth, **kwargs) def add_stdev_grid(self, - arr: typing.Union[xr.DataArray, np.ndarray, list, float], - color: str = 'lightgray', - linestyle=(0, (9, 5)), - linewidth: int = 1, - **kwargs): + arr: typing.Union[xr.DataArray, np.ndarray, list, float], + color: str = 'lightgray', + linestyle=(0, (9, 5)), + linewidth: int = 1, + **kwargs): """Add gridlines (radii) to the stard deviation axis specified by array. @@ -509,13 +504,7 @@ def add_ygrid(self, This function will be deprecated in favor of `add_stdev_grid()` """ - return add_stdev_grid(self, - arr: typing.Union[xr.DataArray, np.ndarray, list, float], - color: str = 'lightgray', - linestyle=(0, (9, 5)), - linewidth: int = 1, - **kwargs) - + return self.add_stdev_grid(arr, color, linestyle, linewidth, **kwargs) def add_grid(self, *args, **kwargs): """Add a grid. From 3193201a2bab62d55bc5619fe25717af9abd3d52 Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:24:13 -0600 Subject: [PATCH 05/13] Update docs/release-notes.rst Co-authored-by: Katelyn FitzGerald <7872563+kafitzgerald@users.noreply.github.com> --- docs/release-notes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release-notes.rst b/docs/release-notes.rst index e63f551..bacff23 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -11,7 +11,7 @@ This release ... Documentation ^^^^^^^^^^^^^ -* Document known quark for using `suptitle` argument of ``set_titles_and_labels`` with a Cartopy plot by `Julia Kent`_ in (:pr:`219`) +* Document known issue with `suptitle` argument of ``set_titles_and_labels`` and Cartopy plots by `Julia Kent`_ in (:pr:`219`) * Add alias to ``Taylor_Diagram`` to have more meaningful keyword arguments by by `Julia Kent`_ in (:pr:`219`) v2024.02.1 (February 28, 2024) From 4bbb49e7116200f26415b4247e0c27de1e767d66 Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:24:28 -0600 Subject: [PATCH 06/13] Update docs/release-notes.rst Co-authored-by: Katelyn FitzGerald <7872563+kafitzgerald@users.noreply.github.com> --- docs/release-notes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release-notes.rst b/docs/release-notes.rst index bacff23..0428c2d 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -12,7 +12,7 @@ This release ... Documentation ^^^^^^^^^^^^^ * Document known issue with `suptitle` argument of ``set_titles_and_labels`` and Cartopy plots by `Julia Kent`_ in (:pr:`219`) -* Add alias to ``Taylor_Diagram`` to have more meaningful keyword arguments by by `Julia Kent`_ in (:pr:`219`) +* Add alias to ``Taylor_Diagram`` to have more meaningful keyword arguments by `Julia Kent`_ in (:pr:`219`) v2024.02.1 (February 28, 2024) ------------------------------ From a202cf2c8b5c01ac58df0f50ce6af512bc3db317 Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:24:36 -0600 Subject: [PATCH 07/13] Update src/geocat/viz/taylor.py Co-authored-by: Katelyn FitzGerald <7872563+kafitzgerald@users.noreply.github.com> --- src/geocat/viz/taylor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/geocat/viz/taylor.py b/src/geocat/viz/taylor.py index 9a235b6..cd9da1e 100644 --- a/src/geocat/viz/taylor.py +++ b/src/geocat/viz/taylor.py @@ -46,7 +46,7 @@ class TaylorDiagram(object): Notes ----- - Rendering of Taylor Diagrams looks best with a figure that is at least 10x10. If you make your figure size too small, + Rendering of Taylor Diagrams looks best with a figure that is at least 10x10 inches. If you make your figure size too small, legends, lagels, and other text items might overlap in undesired ways. References From 68b86afc34f03554833a54abe93c860aeba73e36 Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:25:35 -0600 Subject: [PATCH 08/13] Update src/geocat/viz/taylor.py Co-authored-by: Katelyn FitzGerald <7872563+kafitzgerald@users.noreply.github.com> --- src/geocat/viz/taylor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/geocat/viz/taylor.py b/src/geocat/viz/taylor.py index cd9da1e..bae923e 100644 --- a/src/geocat/viz/taylor.py +++ b/src/geocat/viz/taylor.py @@ -447,7 +447,7 @@ def add_stdev_grid(self, linestyle=(0, (9, 5)), linewidth: int = 1, **kwargs): - """Add gridlines (radii) to the stard deviation axis specified by + """Add radial gridlines to the standard deviation axis specified by array. *arr* From 741f7cd3ae3bf9346ea88ada702790f84184f06f Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:39:30 -0600 Subject: [PATCH 09/13] respond to pr review --- .gitignore | 3 +++ src/geocat/viz/taylor.py | 18 +++++++++--------- src/geocat/viz/util.py | 7 +++++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index c7aefe8..700f18d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ docs/_build/ dist/ .eggs/ *egg-info + +# IDEs +settings.json diff --git a/src/geocat/viz/taylor.py b/src/geocat/viz/taylor.py index bae923e..d463486 100644 --- a/src/geocat/viz/taylor.py +++ b/src/geocat/viz/taylor.py @@ -441,12 +441,12 @@ def add_xgrid(self, return self.add_corr_grid(arr, color, linestyle, linewidth, **kwargs) - def add_stdev_grid(self, - arr: typing.Union[xr.DataArray, np.ndarray, list, float], - color: str = 'lightgray', - linestyle=(0, (9, 5)), - linewidth: int = 1, - **kwargs): + def add_std_grid(self, + arr: typing.Union[xr.DataArray, np.ndarray, list, float], + color: str = 'lightgray', + linestyle=(0, (9, 5)), + linewidth: int = 1, + **kwargs): """Add radial gridlines to the standard deviation axis specified by array. @@ -478,7 +478,7 @@ def add_stdev_grid(self, -------- All usage examples are within the GeoCAT-Examples Gallery. To see more usage cases, search the function on the `website `_. - - `NCL_taylor_2.py `_ + - `NCL_taylor_2.py `_ """ t_array = np.linspace(0, np.pi / 2) @@ -501,10 +501,10 @@ def add_ygrid(self, *arr*. - This function will be deprecated in favor of `add_stdev_grid()` + This function will be deprecated in favor of `add_std_grid()` """ - return self.add_stdev_grid(arr, color, linestyle, linewidth, **kwargs) + return self.add_std_grid(arr, color, linestyle, linewidth, **kwargs) def add_grid(self, *args, **kwargs): """Add a grid. diff --git a/src/geocat/viz/util.py b/src/geocat/viz/util.py index 397c9ea..d0a3bb1 100644 --- a/src/geocat/viz/util.py +++ b/src/geocat/viz/util.py @@ -556,7 +556,7 @@ def set_titles_and_labels(ax: typing.Union[matplotlib.axes.Axes, >>> | Axes | >>> | | - Be aware that the `suptitle` functionality does not automaticallly render well for Cartopy plots. Recommended fixes are to iterate on your figure size until it does not extend as far past your plot OR to use string manipulation to add enough spaces to center your left or right title keyword argument. + Be aware that the `suptitle` functionality does not always render well for Cartopy plots. If your main title appears too far above your plot, the recommended fix is to decrease the y-dimension of your figure size. Examples -------- @@ -573,7 +573,10 @@ def set_titles_and_labels(ax: typing.Union[matplotlib.axes.Axes, if maintitle is not None: if subtitle is not None: fig = ax.get_figure() - fig.suptitle(maintitle, fontsize=maintitlefontsize, y=1.04) + fig.suptitle(maintitle, + fontsize=maintitlefontsize, + y=1.04, + ha='center') elif lefttitle is not None or righttitle is not None: ax.set_title(maintitle, fontsize=maintitlefontsize + 2, y=1.12) else: From 6bcf8a85238d3005724462c461e0a27ec6c1849b Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Fri, 22 Mar 2024 17:03:55 -0600 Subject: [PATCH 10/13] add deprecation warnings --- src/geocat/viz/taylor.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/geocat/viz/taylor.py b/src/geocat/viz/taylor.py index d463486..0e9bb76 100644 --- a/src/geocat/viz/taylor.py +++ b/src/geocat/viz/taylor.py @@ -1,5 +1,5 @@ """Taylor Diagrams.""" - +import warnings import typing import numpy as np @@ -439,6 +439,10 @@ def add_xgrid(self, This function will be deprecated in favor of `add_corr_grid()` """ + warnings.warn( + 'This function is deprecated. Call `add_corr_grid` instead.', + PendingDeprecationWarning) + return self.add_corr_grid(arr, color, linestyle, linewidth, **kwargs) def add_std_grid(self, @@ -504,6 +508,10 @@ def add_ygrid(self, This function will be deprecated in favor of `add_std_grid()` """ + warnings.warn( + 'This function is deprecated. Call `add_std_grid` instead.', + PendingDeprecationWarning) + return self.add_std_grid(arr, color, linestyle, linewidth, **kwargs) def add_grid(self, *args, **kwargs): From 73ecd64f21ddd3bfd9ddac8d87d1be35ccf1eeba Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Fri, 22 Mar 2024 22:29:09 -0600 Subject: [PATCH 11/13] add note to docstring and specify class --- src/geocat/viz/taylor.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/geocat/viz/taylor.py b/src/geocat/viz/taylor.py index 0e9bb76..547c24c 100644 --- a/src/geocat/viz/taylor.py +++ b/src/geocat/viz/taylor.py @@ -436,11 +436,12 @@ def add_xgrid(self, **kwargs): """Add gridlines to the correlation axis specified by array *arr*. - This function will be deprecated in favor of `add_corr_grid()` + This function will be deprecated in favor of + `TaylorDiagram.add_corr_grid()` """ warnings.warn( - 'This function is deprecated. Call `add_corr_grid` instead.', + '`TaylorDiagram.add_xgrid` will be deprecated in the future. Please use `TaylorDiagram.add_corr_grid` instead.', PendingDeprecationWarning) return self.add_corr_grid(arr, color, linestyle, linewidth, **kwargs) @@ -505,11 +506,11 @@ def add_ygrid(self, *arr*. - This function will be deprecated in favor of `add_std_grid()` + This function will be deprecated in favor of `TaylorDiagram.add_std_grid()` """ warnings.warn( - 'This function is deprecated. Call `add_std_grid` instead.', + '`TaylorDiagram.add_ygrid` will be deprecated in the future. Please use `TaylorDiagram.add_std_grid` instead.', PendingDeprecationWarning) return self.add_std_grid(arr, color, linestyle, linewidth, **kwargs) From d3ffe40e6ea95ae9298835ccf13dc184d08dab0a Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Fri, 22 Mar 2024 22:41:31 -0600 Subject: [PATCH 12/13] Update docs/release-notes.rst Co-authored-by: Katelyn FitzGerald <7872563+kafitzgerald@users.noreply.github.com> --- docs/release-notes.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 0428c2d..aaa7114 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -12,7 +12,11 @@ This release ... Documentation ^^^^^^^^^^^^^ * Document known issue with `suptitle` argument of ``set_titles_and_labels`` and Cartopy plots by `Julia Kent`_ in (:pr:`219`) -* Add alias to ``Taylor_Diagram`` to have more meaningful keyword arguments by `Julia Kent`_ in (:pr:`219`) + +Deprecations +^^^^^^^^^^ +* Pending deprecation warnings added for ``TaylorDiagram`` methods ``add_xgrid`` and ``add_ygrid`` which are changing to the new ``add_corr_grid`` and ``add_std_grid`` by `Julia Kent`_ in (:pr:`219`) + v2024.02.1 (February 28, 2024) ------------------------------ From c2d1c30d6f1c454ea4f24450aec1db527050daf0 Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Fri, 22 Mar 2024 22:42:48 -0600 Subject: [PATCH 13/13] function to method --- src/geocat/viz/taylor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/geocat/viz/taylor.py b/src/geocat/viz/taylor.py index 547c24c..ee77fc4 100644 --- a/src/geocat/viz/taylor.py +++ b/src/geocat/viz/taylor.py @@ -436,7 +436,7 @@ def add_xgrid(self, **kwargs): """Add gridlines to the correlation axis specified by array *arr*. - This function will be deprecated in favor of + This method will be deprecated in favor of `TaylorDiagram.add_corr_grid()` """ @@ -506,7 +506,7 @@ def add_ygrid(self, *arr*. - This function will be deprecated in favor of `TaylorDiagram.add_std_grid()` + This method will be deprecated in favor of `TaylorDiagram.add_std_grid()` """ warnings.warn(