Skip to content

Commit

Permalink
Merge pull request #37 from kthyng/main
Browse files Browse the repository at this point in the history
Removed cartopy as dependency
  • Loading branch information
kthyng authored Dec 21, 2022
2 parents 6c478e9 + 40a5c37 commit 69caae0
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ci/environment-py3.7.yml → ci/environment-py3.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ci/environment-py3.8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ci/environment-py3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies:
- numpy
- pandas
- xarray
# - xarray
# These are needed for the docs themselves
- jupytext
- numpydoc
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
- pytest
# Examples (remove and add as needed)
- aiohttp
- cartopy
# - cartopy
- cf_pandas
- cf_xarray
- extract_model
Expand Down
15 changes: 13 additions & 2 deletions ocean_model_skill_assessor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)}.")
18 changes: 9 additions & 9 deletions ocean_model_skill_assessor/plot/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
):
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 4 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [email protected]
author_email = [email protected]


[aliases]
Expand All @@ -62,7 +62,6 @@ include_package_data = True
install_requires =
aiohttp
alphashape
cartopy
cf_pandas
cf_xarray
extract_model
Expand All @@ -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]
Expand Down

0 comments on commit 69caae0

Please sign in to comment.