Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion dorado/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
__version__ = "2.7.0"
from importlib.metadata import version, PackageNotFoundError

try:
__version__ = version("pydorado")
except PackageNotFoundError:
__version__ = "unknown"


from . import lagrangian_walker
from . import parallel_routing
Expand Down
12 changes: 10 additions & 2 deletions dorado/routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,11 @@ def show_nourishment_area(visit_freq, grid=None, walk_data=None,
alphas = Normalize(0, amax, clip=True)(visit_freq) # Normalize alphas
alphas = np.clip(alphas, min_alpha, 1)
colors = Normalize(np.nanmin(visit_freq), 1)(visit_freq) # Normalize color
cmap = plt.cm.get_cmap(cmap)
if isinstance(cmap, str):
try:
cmap = matplotlib.colormaps[cmap]
except AttributeError:
cmap = plt.cm.get_cmap(cmap)
colors = cmap(colors)
colors[..., -1] = alphas

Expand Down Expand Up @@ -1390,7 +1394,11 @@ def show_nourishment_time(mean_times, grid=None, walk_data=None,
alphas = np.clip(alphas, min_alpha, 1)
colors = Normalize(np.nanmin(mean_times),
np.nanmax(mean_times))(mean_times) # Normalize colors
cmap = plt.cm.get_cmap(cmap)
if isinstance(cmap, str):
try:
cmap = matplotlib.colormaps[cmap]
except AttributeError:
cmap = plt.cm.get_cmap(cmap)
colors = cmap(colors)
colors[..., -1] = alphas

Expand Down
7 changes: 4 additions & 3 deletions examples/spatial_exposure_time_example_Delft3DFM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"import json\n",
"from pathlib import Path\n",
"import dorado\n",
"import matplotlib\n",
"from matplotlib import pyplot as plt\n",
"import dorado.spatial as spat\n",
"import dorado.particle_track as pt"
Expand Down Expand Up @@ -423,7 +424,7 @@
"outputs": [],
"source": [
"title = 'System-wide exposure time (days)'\n",
"cmap = plt.get_cmap('plasma_r')\n",
"cmap = matplotlib.colormaps['plasma_r'] if hasattr(matplotlib, 'colormaps') else plt.get_cmap('plasma_r')\n",
"max_exposure = 30 # max time in model\n",
"cbar_levels = 7"
]
Expand Down Expand Up @@ -563,7 +564,7 @@
"outputs": [],
"source": [
"title_local = 'Localized exposure time (days)'\n",
"cmap_local = plt.get_cmap('viridis_r')\n",
"cmap_local = matplotlib.colormaps['viridis_r'] if hasattr(matplotlib, 'colormaps') else plt.get_cmap('viridis_r')\n",
"max_exposure_local = 7\n",
"cbar_levels_local = 6"
]
Expand Down Expand Up @@ -655,4 +656,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pydorado"
version = "2.7.0"
version = "2.7.1"
description = "dorado - Lagrangian particle routing routine via weighted random walks"
readme = { file = "README.md", content-type = "text/markdown" }
license = { file = "LICENSE" }
Expand Down
5 changes: 3 additions & 2 deletions tests/test_spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

@author: cturn
"""
import matplotlib
from matplotlib import pyplot as plt
import numpy as np
import pytest
Expand Down Expand Up @@ -100,7 +101,7 @@ def test_plot_spatial(test_grid, walk_data):
elevation=elevation,
max_exposure=7,
cbar_levels=7,
cmap=plt.get_cmap("plasma_r"),
cmap=matplotlib.colormaps["plasma_r"] if hasattr(matplotlib, "colormaps") else plt.get_cmap("plasma_r"),
title="Test System-Wide (s)")
plt.close("all")

Expand All @@ -112,6 +113,6 @@ def test_plot_spatial(test_grid, walk_data):
elevation=elevation,
max_exposure=7,
cbar_levels=7,
cmap=plt.get_cmap("viridis_r"),
cmap=matplotlib.colormaps["viridis_r"] if hasattr(matplotlib, "colormaps") else plt.get_cmap("viridis_r"),
title="Test Localized (s)")
plt.close("all")
Loading