From a3b24bbc61d52b90b135253e88de6db156584992 Mon Sep 17 00:00:00 2001 From: Kristen Thyng Date: Wed, 21 Dec 2022 13:58:49 -0600 Subject: [PATCH 1/4] removed cartopy as req --- ci/environment-py3.7.yml | 2 +- ci/environment-py3.8.yml | 2 +- ci/environment-py3.9.yml | 2 +- docs/environment.yml | 1 - environment.yml | 2 +- ocean_model_skill_assessor/main.py | 14 ++++++++++++-- ocean_model_skill_assessor/plot/map.py | 3 ++- pyproject.toml | 2 +- setup.cfg | 9 ++++----- 9 files changed, 23 insertions(+), 14 deletions(-) diff --git a/ci/environment-py3.7.yml b/ci/environment-py3.7.yml index fae8c88..ffd6459 100644 --- a/ci/environment-py3.7.yml +++ b/ci/environment-py3.7.yml @@ -4,7 +4,7 @@ channels: dependencies: - python=3.7 ############## 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..98bbcc9 100644 --- a/ocean_model_skill_assessor/main.py +++ b/ocean_model_skill_assessor/main.py @@ -27,6 +27,13 @@ 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], @@ -415,6 +422,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..66d86b0 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 @@ -39,6 +38,8 @@ def plot_map( ds : Union[DataArray, Dataset] Model output. """ + + import cartopy 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] From ef26603a544d3c1097c6e415589f8c78d8cd3eee Mon Sep 17 00:00:00 2001 From: Kristen Thyng Date: Wed, 21 Dec 2022 14:03:58 -0600 Subject: [PATCH 2/4] precommit --- ocean_model_skill_assessor/main.py | 1 + ocean_model_skill_assessor/plot/map.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ocean_model_skill_assessor/main.py b/ocean_model_skill_assessor/main.py index 98bbcc9..991973a 100644 --- a/ocean_model_skill_assessor/main.py +++ b/ocean_model_skill_assessor/main.py @@ -27,6 +27,7 @@ from .utils import kwargs_search_from_model + try: import cartopy diff --git a/ocean_model_skill_assessor/plot/map.py b/ocean_model_skill_assessor/plot/map.py index 66d86b0..c5cef32 100644 --- a/ocean_model_skill_assessor/plot/map.py +++ b/ocean_model_skill_assessor/plot/map.py @@ -16,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] ): @@ -38,9 +30,16 @@ def plot_map( ds : Union[DataArray, Dataset] 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) From 9718b2b9080a62e86a78405c09d5e7c7af600898 Mon Sep 17 00:00:00 2001 From: Kristen Thyng Date: Wed, 21 Dec 2022 14:19:03 -0600 Subject: [PATCH 3/4] updated ci 3.7 to 3.10 --- ci/{environment-py3.7.yml => environment-py3.10.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename ci/{environment-py3.7.yml => environment-py3.10.yml} (96%) diff --git a/ci/environment-py3.7.yml b/ci/environment-py3.10.yml similarity index 96% rename from ci/environment-py3.7.yml rename to ci/environment-py3.10.yml index ffd6459..a873d85 100644 --- a/ci/environment-py3.7.yml +++ b/ci/environment-py3.10.yml @@ -2,7 +2,7 @@ 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 - cf_xarray From 40a5c37963b561c72638f8b7ffd6198ef409adad Mon Sep 17 00:00:00 2001 From: Kristen Thyng Date: Wed, 21 Dec 2022 14:23:33 -0600 Subject: [PATCH 4/4] updated ci 3.7 to 3.10 --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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