Skip to content

Commit 8fa8f80

Browse files
authored
Merge pull request #96 from ocefpaf/do_not_fail_without_pr
2 parents eed2d06 + 984d58d commit 8fa8f80

File tree

10 files changed

+156
-1289
lines changed

10 files changed

+156
-1289
lines changed

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[settings]
2-
known_third_party = matplotlib,numpy,pandas,pandas_flavor,pytest,setuptools
2+
known_third_party = gsw,matplotlib,numpy,pandas,pandas_flavor,pytest,setuptools

.pre-commit-config.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v3.1.0
3+
rev: v3.3.0
44
hooks:
55
- id: trailing-whitespace
66
exclude: tests/data
@@ -14,46 +14,46 @@ repos:
1414
files: requirements-dev.txt
1515

1616
- repo: https://github.com/econchick/interrogate
17-
rev: 1.2.0
17+
rev: 1.3.1
1818
hooks:
1919
- id: interrogate
2020
exclude: ^(docs|setup.py|tests)
2121
args: [--config=pyproject.toml]
2222

2323
- repo: https://gitlab.com/pycqa/flake8
24-
rev: 3.7.9
24+
rev: 3.8.4
2525
hooks:
2626
- id: flake8
2727
exclude: docs/source/conf.py
28-
args: [--max-line-length=105, --ignore=E203,E501,W503, --select=select=C,E,F,W,B,B950]
28+
args: [--max-line-length=105, --ignore=E203]
2929

3030
- repo: https://github.com/pre-commit/mirrors-isort
31-
rev: v4.3.21
31+
rev: v5.6.4
3232
hooks:
3333
- id: isort
3434
additional_dependencies: [toml]
3535
args: [--project=ctd, --multi-line=3, --lines-after-imports=2, --lines-between-types=1, --trailing-comma, --force-grid-wrap=0, --use-parentheses, --line-width=88]
3636

3737
- repo: https://github.com/asottile/seed-isort-config
38-
rev: v2.1.1
38+
rev: v2.2.0
3939
hooks:
4040
- id: seed-isort-config
4141

4242
- repo: https://github.com/psf/black
43-
rev: stable
43+
rev: 20.8b1
4444
hooks:
4545
- id: black
4646
language_version: python3
4747

4848
- repo: https://github.com/pre-commit/mirrors-mypy
49-
rev: v0.770
49+
rev: v0.790
5050
hooks:
5151
- id: mypy
5252
exclude: docs/source/conf.py
5353
args: [--ignore-missing-imports]
5454

5555
- repo: https://github.com/codespell-project/codespell
56-
rev: v1.16.0
56+
rev: v1.17.1
5757
hooks:
5858
- id: codespell
5959
args:

.travis.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ matrix:
2828
env: PY=3
2929

3030
before_install:
31-
# Install miniconda and create TEST env.
31+
# Install micromamba and create TEST env.
3232
- |
33-
wget http://bit.ly/miniconda -O miniconda.sh
34-
bash miniconda.sh -b -p $HOME/miniconda
35-
export PATH="$HOME/miniconda/bin:$PATH"
36-
conda config --set always_yes yes --set changeps1 no --set show_channel_urls true
37-
conda update conda --quiet
38-
conda config --add channels conda-forge --force
39-
conda config --set channel_priority strict
40-
conda create --name TEST python=$PY --file requirements.txt --file requirements-dev.txt
41-
source activate TEST
33+
wget -qO- https://micromamba.snakepit.net/api/micromamba/linux-64/latest | tar -xvj bin/micromamba --strip-components=1
34+
./micromamba shell init -s bash -p ~/micromamba
35+
export MAMBA_ROOT_PREFIX=~/micromamba
36+
export MAMBA_EXE=$(pwd)/micromamba
37+
. ${MAMBA_ROOT_PREFIX}/etc/profile.d/mamba.sh
38+
39+
echo "micromamba version $(micromamba --version)"
40+
micromamba create --yes --name TEST python=$PY pip --file requirements.txt --file requirements-dev.txt --channel conda-forge
41+
micromamba activate TEST
4242
4343
install:
4444
- pip install -e . --no-deps --force-reinstall
@@ -67,7 +67,8 @@ script:
6767
- |
6868
if [[ $TRAVIS_JOB_NAME == 'docs' ]]; then
6969
set -e
70-
cp notebooks/quick_intro.ipynb docs/source/
70+
travis_wait jupyter nbconvert --to notebook --execute notebooks/quick_intro.ipynb --output=quick_intro-output.ipynb
71+
mv notebooks/quick_intro-output.ipynb docs/source/
7172
pushd docs
7273
make clean html linkcheck
7374
popd

ctd/extras.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def gen_topomask(h, lon, lat, dx=1.0, kind="linear", plot=False):
137137
"""
138138

139139
import gsw
140+
140141
from scipy.interpolate import interp1d
141142

142143
h, lon, lat = list(map(np.asanyarray, (h, lon, lat)))
@@ -176,7 +177,8 @@ def plot_section(self, reverse=False, filled=False, **kw):
176177
labelsize = kw.pop("labelsize", 11)
177178
cmap = kw.pop("cmap", plt.cm.rainbow)
178179
levels = kw.pop(
179-
"levels", np.arange(np.floor(data.min()), np.ceil(data.max()) + 0.5, 0.5),
180+
"levels",
181+
np.arange(np.floor(data.min()), np.ceil(data.max()) + 0.5, 0.5),
180182
)
181183

182184
# Colorbar key words.
@@ -226,7 +228,14 @@ def plot_section(self, reverse=False, filled=False, **kw):
226228

227229
# Color version.
228230
cs = ax.contourf(
229-
x, z, data, cmap=cmap, levels=levels, alpha=1.0, extend=extend, zorder=2,
231+
x,
232+
z,
233+
data,
234+
cmap=cmap,
235+
levels=levels,
236+
alpha=1.0,
237+
extend=extend,
238+
zorder=2,
230239
) # manual=True
231240
# Colorbar.
232241
cb = fig.colorbar(

ctd/read.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from io import StringIO
1515
from pathlib import Path
1616

17+
import gsw
1718
import numpy as np
1819
import pandas as pd
1920

@@ -390,12 +391,24 @@ def from_cnv(fname):
390391
)
391392
f.close()
392393

393-
prkeys = ["prM ", "prE", "prDM", "pr50M", "pr50M1", "prSM", "prdM", "pr"]
394+
prkeys = ["prM ", "prE", "prDM", "pr50M", "pr50M1", "prSM", "prdM", "pr", "depSM"]
394395
prkey = [key for key in prkeys if key in df.columns]
395396
if len(prkey) != 1:
396-
raise ValueError(f"Expected one pressure column, got {prkey}.")
397+
raise ValueError(f"Expected one pressure/depth column, got {prkey}.")
397398
df.set_index(prkey, drop=True, inplace=True)
398399
df.index.name = "Pressure [dbar]"
400+
if prkey == "depSM":
401+
lat = metadata.get("lat", None)
402+
if lat is not None:
403+
df.index = gsw.p_from_z(
404+
df.index, lat, geo_strf_dyn_height=0, sea_surface_geopotential=0
405+
)
406+
else:
407+
warnings.war(
408+
f"Missing latitude information. Cannot compute pressure! Your index is {prkey}, "
409+
"please compute pressure manually with `gsw.p_from_z` and overwrite your index."
410+
)
411+
df.index.name = prkey
399412

400413
name = _basename(fname)[1]
401414

docs/source/conf.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@
155155
# (source start file, target name, title,
156156
# author, documentclass [howto, manual, or own class]).
157157
latex_documents = [
158-
(master_doc, "ctd.tex", "ctd Documentation", "Filipe Fernandes", "manual",)
158+
(
159+
master_doc,
160+
"ctd.tex",
161+
"ctd Documentation",
162+
"Filipe Fernandes",
163+
"manual",
164+
)
159165
]
160166

161167

0 commit comments

Comments
 (0)