diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7381c35..9adc734 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,7 +9,7 @@ jobs: fail-fast: false matrix: os: ["macos-latest", "ubuntu-latest", "windows-latest"] - python-version: ["3.7", "3.8", "3.9"] + python-version: ["3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v3 - name: Cache conda diff --git a/ci/environment-py3.7.yml b/ci/environment-py3.10.yml similarity index 93% rename from ci/environment-py3.7.yml rename to ci/environment-py3.10.yml index fae8c88..a873d85 100644 --- a/ci/environment-py3.7.yml +++ b/ci/environment-py3.10.yml @@ -2,9 +2,9 @@ name: test_env_model_assessor channels: - conda-forge dependencies: - - python=3.7 + - python=3.10 ############## These will have to be adjusted to your specific project - - cartopy + # - cartopy - cf_xarray - extract_model - intake diff --git a/ci/environment-py3.8.yml b/ci/environment-py3.8.yml index ece116e..1290aef 100644 --- a/ci/environment-py3.8.yml +++ b/ci/environment-py3.8.yml @@ -4,7 +4,7 @@ channels: dependencies: - python=3.8 ############## These will have to be adjusted to your specific project - - cartopy + # - cartopy # - cf_pandas - cf_xarray - extract_model diff --git a/ci/environment-py3.9.yml b/ci/environment-py3.9.yml index fdf9646..4d68f19 100644 --- a/ci/environment-py3.9.yml +++ b/ci/environment-py3.9.yml @@ -4,7 +4,7 @@ channels: dependencies: - python=3.9 ############## These will have to be adjusted to your specific project - - cartopy + # - cartopy # - cf_pandas - cf_xarray - extract_model diff --git a/docs/environment.yml b/docs/environment.yml index 3debb4b..27b0bc6 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -20,7 +20,6 @@ dependencies: - numpy - pandas - xarray - # - xarray # These are needed for the docs themselves - jupytext - numpydoc diff --git a/environment.yml b/environment.yml index 201c6ce..47d4127 100644 --- a/environment.yml +++ b/environment.yml @@ -6,7 +6,7 @@ dependencies: - pytest # Examples (remove and add as needed) - aiohttp - - cartopy + # - cartopy - cf_pandas - cf_xarray - extract_model diff --git a/ocean_model_skill_assessor/main.py b/ocean_model_skill_assessor/main.py index 8ea15f8..991973a 100644 --- a/ocean_model_skill_assessor/main.py +++ b/ocean_model_skill_assessor/main.py @@ -28,6 +28,14 @@ from .utils import kwargs_search_from_model +try: + import cartopy + + CARTOPY_AVAILABLE = True +except ImportError: # pragma: no cover + CARTOPY_AVAILABLE = False # pragma: no cover + + def make_local_catalog( filenames: List[str], name: str = "local_catalog", @@ -415,6 +423,9 @@ def run( count += 1 # map of model domain with data locations - figname = omsa.PROJ_DIR(project_name) / "map.png" - omsa.plot.map.plot_map(np.asarray(maps), figname, dam) + if CARTOPY_AVAILABLE: + figname = omsa.PROJ_DIR(project_name) / "map.png" + omsa.plot.map.plot_map(np.asarray(maps), figname, dam) + else: + print("Not plotting map since cartopy is not installed.") print(f"Finished analysis. Find plots in {omsa.PROJ_DIR(project_name)}.") diff --git a/ocean_model_skill_assessor/plot/map.py b/ocean_model_skill_assessor/plot/map.py index aa5fc1a..c5cef32 100644 --- a/ocean_model_skill_assessor/plot/map.py +++ b/ocean_model_skill_assessor/plot/map.py @@ -7,7 +7,6 @@ from pathlib import PurePath from typing import Union -import cartopy import matplotlib.patches as mpatches import matplotlib.pyplot as plt import numpy as np @@ -17,14 +16,6 @@ from ..utils import find_bbox -pc = cartopy.crs.PlateCarree() -col_label = "k" # "r" -land_10m = cartopy.feature.NaturalEarthFeature( - "physical", "land", "10m", edgecolor="face", facecolor="0.8" -) -res = "10m" - - def plot_map( maps: np.array, figname: Union[str, PurePath], ds: Union[DataArray, Dataset] ): @@ -40,6 +31,15 @@ def plot_map( Model output. """ + import cartopy + + pc = cartopy.crs.PlateCarree() + col_label = "k" # "r" + land_10m = cartopy.feature.NaturalEarthFeature( + "physical", "land", "10m", edgecolor="face", facecolor="0.8" + ) + res = "10m" + min_lons, max_lons = maps[:, 0].astype(float), maps[:, 1].astype(float) min_lats, max_lats = maps[:, 2].astype(float), maps[:, 3].astype(float) diff --git a/pyproject.toml b/pyproject.toml index 3d103bf..5e05d39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ quiet = false color = true [tool.isort] -known_third_party = ["aiohttp", "alphashape", "cartopy", "cf_pandas", "cf_xarray", "extract_model", "intake", "intake-axds", "intake-erddap", "matplotlib", "numpy", "pandas", "pkg_resources", "requests", "setuptools", "tqdm", "xarray", "yaml"] +known_third_party = ["aiohttp", "alphashape", "cf_pandas", "cf_xarray", "extract_model", "intake", "intake-axds", "intake-erddap", "matplotlib", "numpy", "pandas", "pkg_resources", "requests", "setuptools", "tqdm", "xarray", "yaml"] [tool.pytest.ini_options] minversion = "6.0" diff --git a/setup.cfg b/setup.cfg index db803eb..07d15e6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,14 +43,14 @@ classifiers = Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 # Dont change this one License :: OSI Approved :: MIT License ## Add your email here -author_email = AUTHOR@EMAIL.COM +author_email = kristen@axds.co [aliases] @@ -62,7 +62,6 @@ include_package_data = True install_requires = aiohttp alphashape - cartopy cf_pandas cf_xarray extract_model @@ -79,7 +78,7 @@ install_requires = xarray setup_requires= setuptools_scm -python_requires = >=3.6 +python_requires = >=3.8 ################ Up until here [options.package_data]