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

ADD: Add cartopy as a dependency #1636

Merged
merged 4 commits into from
Aug 30, 2024
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
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ The required dependencies to install Py-ART in addition to Python are:
* `pooch <https://pypi.org/project/pooch/>`_
* `Cython <https://cython.readthedocs.io/en/latest/>`_
* `setuptools <https://setuptools.pypa.io/en/latest/index.html>`_
* `cartopy <https://scitools.org.uk/cartopy/docs/latest/>`_

A working C/C++ compiler is required for some optional modules. An easy method
to install these dependencies is by using a
Expand Down
13 changes: 1 addition & 12 deletions pyart/graph/gridmapdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@

import warnings

import cartopy
import matplotlib.pyplot as plt
import numpy as np

try:
import cartopy # noqa

_CARTOPY_AVAILABLE = True
except ImportError:
_CARTOPY_AVAILABLE = False

try:
import metpy # noqa

Expand Down Expand Up @@ -76,11 +70,6 @@ class GridMapDisplay:

def __init__(self, grid, debug=False):
"""initalize the object."""
# check that cartopy and xarray are available
if not _CARTOPY_AVAILABLE:
raise MissingOptionalDependency(
"Cartopy is required to use GridMapDisplay but is not installed!"
)
if not _XARRAY_AVAILABLE:
raise MissingOptionalDependency(
"Xarray is required to use GridMapDisplay but is not installed!"
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ xradar>=0.5.0
pandas
mda-xdrlib
xarray!=0.21.0
cartopy
pint
15 changes: 0 additions & 15 deletions tests/graph/test_gridmapdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import pyart


@pytest.mark.skipif(
not pyart.graph.gridmapdisplay._CARTOPY_AVAILABLE, reason="Cartopy is not installed"
)
def test_gridmapdisplay_simple(outfile=None):
# test basic GridMapDisplat functionally.
grid = pyart.testing.make_target_grid()
Expand All @@ -26,9 +23,6 @@ def test_gridmapdisplay_simple(outfile=None):
fig.savefig(outfile)


@pytest.mark.skipif(
not pyart.graph.gridmapdisplay._CARTOPY_AVAILABLE, reason="Cartopy is not installed"
)
def test_gridmapdisplay_fancy(outfile=None):
import cartopy.crs as ccrs

Expand Down Expand Up @@ -79,19 +73,13 @@ def test_gridmapdisplay_fancy(outfile=None):
fig.savefig(outfile)


@pytest.mark.skipif(
not pyart.graph.gridmapdisplay._CARTOPY_AVAILABLE, reason="Cartopy is not installed"
)
def test_generate_filename():
grid = pyart.testing.make_target_grid()
display = pyart.graph.GridMapDisplay(grid)
filename = display.generate_filename("reflectivity", 0)
assert isinstance(filename, str)


@pytest.mark.skipif(
not pyart.graph.gridmapdisplay._CARTOPY_AVAILABLE, reason="Cartopy is not installed"
)
def test_generate_titles():
grid = pyart.testing.make_target_grid()
display = pyart.graph.GridMapDisplay(grid)
Expand All @@ -103,9 +91,6 @@ def test_generate_titles():
assert isinstance(title, str)


@pytest.mark.skipif(
not pyart.graph.gridmapdisplay._CARTOPY_AVAILABLE, reason="Cartopy is not installed"
)
def test_error_raising():
grid = pyart.testing.make_target_grid()
display = pyart.graph.GridMapDisplay(grid)
Expand Down
10 changes: 0 additions & 10 deletions tests/graph/test_plot_maxcappi.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import os

import matplotlib.pyplot as plt
import pytest

import pyart


@pytest.mark.skipif(
not pyart.graph.gridmapdisplay._CARTOPY_AVAILABLE, reason="Cartopy is not installed"
)
def test_plot_maxcappi_simple(outfile=None):
"""
Test the basic functionality of plot_maxcappi.
Expand All @@ -31,9 +27,6 @@ def test_plot_maxcappi_simple(outfile=None):
plt.close()


@pytest.mark.skipif(
not pyart.graph.gridmapdisplay._CARTOPY_AVAILABLE, reason="Cartopy is not installed"
)
def test_plot_maxcappi_with_save(outfile=None):
"""
Test plot_maxcappi and save the output to a file.
Expand Down Expand Up @@ -62,9 +55,6 @@ def test_plot_maxcappi_with_save(outfile=None):
assert os.path.exists(outfile), "The plot was not saved as expected."


@pytest.mark.skipif(
not pyart.graph.gridmapdisplay._CARTOPY_AVAILABLE, reason="Cartopy is not installed"
)
def test_plot_maxcappi_with_all_options(outfile=None):
"""
Test plot_maxcappi with all options enabled.
Expand Down