Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Basemap dependency #180

Merged
merged 16 commits into from
Nov 21, 2020
2 changes: 1 addition & 1 deletion pysteps/nowcasts/sseps.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def forecast(
print("dask imported: %s" % ("yes" if dask_imported else "no"))
print("num workers: %d" % num_workers)

if vel_pert_method is "bps":
if vel_pert_method == "bps":
vp_par = vel_pert_kwargs.get(
"p_pert_par", noise.motion.get_default_params_bps_par()
)
Expand Down
30 changes: 16 additions & 14 deletions pysteps/tests/test_plt_cartopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,45 @@
from pysteps.visualization import plot_precip_field
from pysteps.utils import to_rainrate
from pysteps.tests.helpers import get_precipitation_fields
import matplotlib.pyplot as pl
import matplotlib.pyplot as plt

pytest.importorskip("cartopy")

plt_arg_names = ("source", "plot_map", "drawlonlatlines", "lw")
plt_arg_names = ("source", "drawlonlatlines", "lw", "pass_geodata")

plt_arg_values = [
("mch", "cartopy", False, 0.5),
("mch", "cartopy", True, 1.0),
("bom", "cartopy", True, 0.5),
("fmi", "cartopy", True, 0.5),
("knmi", "cartopy", True, 0.5),
("opera", "cartopy", True, 0.5),
("mrms", "cartopy", True, 0.5),
("mch", False, 0.5, False),
("mch", False, 0.5, True),
("mch", True, 1.0, True),
("bom", True, 0.5, True),
("fmi", True, 0.5, True),
("knmi", True, 0.5, True),
("opera", True, 0.5, True),
("mrms", True, 0.5, True),
("saf", True, 0.5, True),
]


@pytest.mark.parametrize(plt_arg_names, plt_arg_values)
def test_visualization_plot_precip_field(source, plot_map, drawlonlatlines, lw):
def test_visualization_plot_precip_field(source, drawlonlatlines, lw, pass_geodata):

field, metadata = get_precipitation_fields(0, 0, True, True, None, source)
field = field.squeeze()
field, __ = to_rainrate(field, metadata)

if not pass_geodata:
metadata = None

ax = plot_precip_field(
field,
type="intensity",
geodata=metadata,
plot_map=plot_map,
drawlonlatlines=drawlonlatlines,
lw=lw,
)
pl.close()


if __name__ == "__main__":

for i, args in enumerate(plt_arg_values):
test_visualization_plot_precip_field(*args)
pl.show()
plt.show()
43 changes: 17 additions & 26 deletions pysteps/tests/test_plt_motionfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,30 @@
"axis",
"step",
"quiver_kwargs",
"plot_map",
"drawlonlatlines",
"lw",
"upscale",
"pass_geodata",
)

arg_values_quiver = [
(None, "off", 10, None, None, False, 0.5, None),
("bom", "on", 10, None, None, False, 0.5, 4000),
("bom", "on", 10, None, "cartopy", True, 0.5, 4000),
("mch", "on", 20, None, "cartopy", False, 0.5, 2000),
("bom", "off", 10, None, "basemap", False, 0.5, 4000),
(None, "off", 10, None, False, 0.5, None, False),
("bom", "on", 10, None, False, 0.5, 4000, False),
("bom", "on", 10, None, True, 0.5, 4000, True),
("mch", "on", 20, None, False, 0.5, 2000, True),
]


@pytest.mark.parametrize(arg_names_quiver, arg_values_quiver)
def test_visualization_motionfields_quiver(
source, axis, step, quiver_kwargs, plot_map, drawlonlatlines, lw, upscale,
source, axis, step, quiver_kwargs, drawlonlatlines, lw, upscale, pass_geodata,
):

if plot_map == "cartopy":
pytest.importorskip("cartopy")
elif plot_map == "basemap":
pytest.importorskip("basemap")

if source is not None:
fields, geodata = get_precipitation_fields(0, 2, False, True, upscale, source)
ax = plot_precip_field(fields[-1], geodata=geodata, plot_map=plot_map,)
if not pass_geodata:
pass_geodata = None
ax = plot_precip_field(fields[-1], geodata=geodata)
oflow_method = motion.get_method("LK")
UV = oflow_method(fields)

Expand All @@ -61,7 +57,6 @@ def test_visualization_motionfields_quiver(
axis,
step,
quiver_kwargs,
plot_map=plot_map,
drawlonlatlines=drawlonlatlines,
lw=lw,
)
Expand All @@ -71,32 +66,29 @@ def test_visualization_motionfields_quiver(
"source",
"axis",
"streamplot_kwargs",
"plot_map",
"drawlonlatlines",
"lw",
"upscale",
"pass_geodata",
)

arg_values_streamplot = [
(None, "off", None, None, False, 0.5, None),
("bom", "on", None, None, False, 0.5, 4000),
("bom", "on", {"density": 0.1}, "cartopy", True, 0.5, 4000),
(None, "off", None, False, 0.5, None, False),
("bom", "on", None, False, 0.5, 4000, False),
("bom", "on", {"density": 0.5}, True, 0.5, 4000, True),
]


@pytest.mark.parametrize(arg_names_streamplot, arg_values_streamplot)
def test_visualization_motionfields_streamplot(
source, axis, streamplot_kwargs, plot_map, drawlonlatlines, lw, upscale,
source, axis, streamplot_kwargs, drawlonlatlines, lw, upscale, pass_geodata
):

if plot_map == "cartopy":
pytest.importorskip("cartopy")
elif plot_map == "basemap":
pytest.importorskip("basemap")

if source is not None:
fields, geodata = get_precipitation_fields(0, 2, False, True, upscale, source)
ax = plot_precip_field(fields[-1], geodata=geodata, plot_map=plot_map,)
if not pass_geodata:
pass_geodata = None
ax = plot_precip_field(fields[-1], geodata=geodata)
oflow_method = motion.get_method("LK")
UV = oflow_method(fields)

Expand All @@ -115,7 +107,6 @@ def test_visualization_motionfields_streamplot(
geodata,
axis,
streamplot_kwargs,
plot_map=plot_map,
drawlonlatlines=drawlonlatlines,
lw=lw,
)
Expand Down
18 changes: 4 additions & 14 deletions pysteps/tests/test_plt_precipfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pysteps.utils import conversion
from pysteps.postprocessing import ensemblestats
from pysteps.tests.helpers import get_precipitation_fields
import matplotlib.pyplot as pl
import matplotlib.pyplot as plt

plt_arg_names = (
"source",
Expand All @@ -28,16 +28,7 @@
("bom", "intensity", None, "pysteps", None, None, True, "on"),
("fmi", "intensity", None, "pysteps", None, None, True, "on"),
("knmi", "intensity", None, "pysteps", None, None, True, "on"),
(
"knmi",
"intensity",
[2e2, -4.1e3, 5e2, -3.8e3],
"pysteps",
None,
None,
True,
"on",
),
("knmi", "intensity", [300, 300, 500, 500], "pysteps", None, None, True, "on",),
("opera", "intensity", None, "pysteps", None, None, True, "on"),
("saf", "intensity", None, "pysteps", None, None, True, "on"),
]
Expand Down Expand Up @@ -70,19 +61,18 @@ def test_visualization_plot_precip_field(
field,
type=type,
bbox=bbox,
geodata=metadata,
geodata=None,
colorscale=colorscale,
probthr=probthr,
units=metadata["unit"],
title=title,
colorbar=colorbar,
axis=axis,
)
pl.close()


if __name__ == "__main__":

for i, args in enumerate(plt_arg_values):
test_visualization_plot_precip_field(*args)
pl.show()
plt.show()
2 changes: 1 addition & 1 deletion pysteps/visualization/animations.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def animate(
Optional, the motion field used for the forecast.
motion_plot : string
The method to plot the motion field.
geodata : dictionary
geodata : dictionary or None
Optional dictionary containing geographical information about
the field.
If geodata is not None, it must contain the following key-value pairs:
Expand Down
Loading