Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest]
fail-fast: false

Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-ast
- id: end-of-file-fixer
Expand All @@ -23,23 +23,23 @@ repos:
# args: [--config=pyproject.toml]

- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
rev: v0.3.9
hooks:
- id: blackdoc

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.287
rev: v0.3.5
hooks:
- id: ruff

- repo: https://github.com/psf/black
rev: 23.7.0
rev: 24.3.0
hooks:
- id: black
language_version: python3

- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
args:
Expand All @@ -51,6 +51,6 @@ repos:
- id: add-trailing-comma

- repo: https://github.com/tox-dev/pyproject-fmt
rev: "1.1.0"
rev: "1.7.0"
hooks:
- id: pyproject-fmt
15 changes: 13 additions & 2 deletions oceans/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import warnings

import numpy as np
import pooch
from netCDF4 import Dataset

from oceans.ocfis import get_profile, wrap_lon180
Expand Down Expand Up @@ -227,6 +228,16 @@ def woa_subset(
return ds[[f"{v}_mn"]] # always return a dataset


def _download_etopo2():
url = "https://github.com/pyoceans/python-oceans/releases/download"
version = "v2024.04"

return pooch.retrieve(
url=f"{url}/{version}/ETOPO2v2c_f4.nc",
known_hash="sha256:30159a3f15a06398db3cae4ec75986bedc3317dda8e89d049ddc92ba1c352ff1",
)


@functools.lru_cache(maxsize=256)
def etopo_subset(min_lon, max_lon, min_lat, max_lat, tfile=None, smoo=False):
"""
Expand All @@ -245,7 +256,7 @@ def etopo_subset(min_lon, max_lon, min_lat, max_lat, tfile=None, smoo=False):
Based on trondkristiansen contourICEMaps.py
"""
if tfile is None:
tfile = "https://gamone.whoi.edu/thredds/dodsC/usgs/data0/bathy/ETOPO2v2c_f4.nc"
tfile = _download_etopo2()

with Dataset(tfile, "r") as etopo:
lons = etopo.variables["x"][:]
Expand Down Expand Up @@ -276,7 +287,7 @@ def get_depth(lon, lat, tfile=None):
>>> station_lon = [-40, -32]
>>> station_lat = [-20, -20]
>>> get_depth(station_lon, station_lat)
array([ -32.98816423, -4275.63374601])
array([ -32.988163, -4275.634 ], dtype=float32)

"""
lon, lat = list(map(np.atleast_1d, (lon, lat)))
Expand Down
7 changes: 5 additions & 2 deletions oceans/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,10 @@ def medfilt1(x, L=3):
>>> L = 103
>>> xout = medfilt1(x=x, L=L)
>>> ax = plt.subplot(212)
>>> (l1, l2,) = ax.plot(
>>> (
... l1,
... l2,
... ) = ax.plot(
... x
... ), ax.plot(xout)
>>> ax.grid(True)
Expand Down Expand Up @@ -608,7 +611,7 @@ def pl33tn(x, dt=1.0, T=33.0, mode="valid", t=None):
import pandas as pd
import xarray as xr

if isinstance(x, (xr.Dataset, pd.DataFrame)):
if isinstance(x, xr.Dataset | pd.DataFrame):
raise TypeError("Input a DataArray not a Dataset, or a Series not a DataFrame.")

if isinstance(x, pd.Series) and not isinstance(
Expand Down
2 changes: 1 addition & 1 deletion oceans/sw_extras/sw_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def cph(bvfr2):
Returns
-------
cph : array_like
Brünt-Väisälä Frequency [ cylcles hour :sup:`-1`]
Brünt-Väisälä Frequency [ cycles hour :sup:`-1`]

Examples
--------
Expand Down
33 changes: 16 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ maintainers = [
{name = "Arnaldo Russo"},
{name = "Filipe Fernandes", email = "ocefpaf+oceans@gmail.com"},
]
requires-python = ">=3.8"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = [
"dependencies",
Expand Down Expand Up @@ -57,7 +56,7 @@ write_to = "oceans/_version.py"
write_to_template = "__version__ = '{version}'"

[tool.ruff]
select = [
lint.select = [
"A", # flake8-builtins
"B", # flake8-bugbear
"C4", # flake8-comprehensions
Expand All @@ -68,14 +67,25 @@ select = [
]
target-version = "py311"
line-length = 79
ignore = [
lint.ignore = [
"B905", # zip ztrict arg, enable only for py310
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"docs/source/conf.py" = ["E402", "A001"]
"oceans/plotting.py" = ["T201"] # `print` found

[tool.check-manifest]
ignore = [
".coveragerc",
"docs",
"docs/*",
"notebooks",
"notebooks/*",
"tests",
"tests/*",
]

[tool.pytest.ini_options]
markers = [
"web: marks tests require connection (deselect with '-m \"not web\"')"
Expand All @@ -93,14 +103,3 @@ exclude = ["docs", "tests"]
verbose = 1
quiet = false
color = true

[tool.check-manifest]
ignore = [
".coveragerc",
"docs",
"docs/*",
"notebooks",
"notebooks/*",
"tests",
"tests/*",
]
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
black
cartopy
cf_xarray
check-manifest
nbsphinx
netcdf4
pandas
pooch
pytest
pytest-cov
pytest-xdist
Expand Down