From 98b4ea43b60ad076ed3dfe62aae8803dc49915f8 Mon Sep 17 00:00:00 2001 From: Mostafa Farrag Date: Wed, 26 Apr 2023 03:25:53 +0200 Subject: [PATCH 1/2] pass the kwargs to __init__ to get the vmin and vmax if passed from pyramids plot method, copy the default dict in order not to update it inplace --- cleopatra/array.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cleopatra/array.py b/cleopatra/array.py index 7e64637..6bbb54a 100644 --- a/cleopatra/array.py +++ b/cleopatra/array.py @@ -37,6 +37,7 @@ def __init__( rgb: List[int] = None, surface_reflectance: int = 10000, cutoff: List = None, + **kwargs, ): """Plot array. @@ -91,8 +92,14 @@ def __init__( self.rgb = False self._exclude_value = exclude_value - self._vmin = np.nanmin(array) - self._vmax = np.nanmax(array) + + self._vmax = ( + np.nanmax(array) if kwargs.get("vmax") is None else kwargs.get("vmax") + ) + self._vmin = ( + np.nanmin(array) if kwargs.get("vmin") is None else kwargs.get("vmin") + ) + self.arr = array # get the tick spacing that have 10 ticks only self.ticks_spacing = (self._vmax - self._vmin) / 10 @@ -105,7 +112,7 @@ def __init__( no_elem = np.size(array[:, :]) - np.count_nonzero((array[np.isnan(array)])) self.no_elem = no_elem - self._default_options = DEFAULT_OPTIONS + self._default_options = DEFAULT_OPTIONS.copy() def _prepare_rgb( self, @@ -191,7 +198,7 @@ def get_ticks(self) -> np.ndarray: except ValueError: raise ValueError( "The number of ticks exceeded the max allowed size, possible errors" - f"is the value of the NodataValue you entered-{self.exclude_value}" + f" is the value of the NodataValue you entered-{self.exclude_value}" ) ticks = np.append( ticks, From 9ecae1a61d3d4cd38920e8cd2e4f12f3f56ecebc Mon Sep 17 00:00:00 2001 From: Mostafa Farrag Date: Wed, 26 Apr 2023 23:19:35 +0200 Subject: [PATCH 2/2] update check list files --- HISTORY.rst | 4 ++++ README.md | 2 +- setup.py | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index e1eaf11..36ee2db 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -47,3 +47,7 @@ History 0.3.3 (2023-04-25) ------------------ * change the default value for the color bar label. + +0.3.4 (2023-04-26) +------------------ +* pass the plot kwargs to the init of the array to scale the color bar using the vmin and vmax. diff --git a/README.md b/README.md index 9a747aa..6b5feaf 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ pip install git+https://github.com/MAfarrag/cleopatra ## pip to install the last release you can easly use pip ``` -pip install cleopatra==0.3.3 +pip install cleopatra==0.3.4 ``` Quick start diff --git a/setup.py b/setup.py index 8504d57..58bc042 100644 --- a/setup.py +++ b/setup.py @@ -11,12 +11,12 @@ setup( name="cleopatra", - version="0.3.3", + version="0.3.4", description="visualization package", author="Mostafa Farrag", author_email="moah.farag@gmail.come", url="https://github.com/MAfarrag/cleopatra", - keywords=["matplotlib", "arrays", "visualization"], + keywords=["matplotlib", "visualization"], long_description=readme + "\n\n" + history, repository="https://github.com/MAfarrag/celopatra", documentation="https://celopatra.readthedocs.io/",