Skip to content

Commit 76f70ff

Browse files
authored
Merge pull request pyoceans#228 from ocefpaf/fix_failures_227
Fix failures 227
2 parents 3f26f9c + 469b2ca commit 76f70ff

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repos:
1414
files: requirements-dev.txt
1515

1616
- repo: https://github.com/keewis/blackdoc
17-
rev: v0.3.9
17+
rev: v0.4.1
1818
hooks:
1919
- id: blackdoc
2020

@@ -39,7 +39,7 @@ repos:
3939
- id: add-trailing-comma
4040

4141
- repo: https://github.com/astral-sh/ruff-pre-commit
42-
rev: v0.11.12
42+
rev: v0.12.2
4343
hooks:
4444
- id: ruff
4545
args: ["--fix", "--show-fixes"]

README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,31 @@ and then,
3333
from pathlib import Path
3434
import ctd
3535

36-
path = Path('tests', 'data', 'CTD')
37-
fname = path.joinpath('g01l06s01.cnv.gz')
36+
path = Path("tests", "data", "CTD")
37+
fname = path.joinpath("g01l06s01.cnv.gz")
3838

3939
down, up = ctd.from_cnv(fname).split()
40-
ax = down['t090C'].plot_cast()
40+
ax = down["t090C"].plot_cast()
4141
```
4242

4343
![Bad Processing](https://raw.githubusercontent.com/pyoceans/python-ctd/main/docs/readme_01.png)
4444

4545
We can do [better](https://www.go-ship.org/Manual/McTaggart_et_al_CTD.pdf):
4646

4747
```python
48-
temperature = down['t090C']
48+
temperature = down["t090C"]
4949

5050
fig, ax = plt.subplots(figsize=(5.5, 6))
5151
temperature.plot_cast(ax=ax)
52-
temperature.remove_above_water()\
53-
.despike()\
54-
.lp_filter()\
55-
.press_check()\
56-
.interpolate(method='index',
57-
limit_direction='both',
58-
limit_area='inside')\
59-
.bindata(delta=1, method='interpolate')\
60-
.smooth(window_len=21, window='hanning') \
61-
.plot_cast(ax=ax)
62-
ax.set_ylabel('Pressure (dbar)')
63-
ax.set_xlabel('Temperature (°C)')
52+
temperature.remove_above_water().despike().lp_filter().press_check().interpolate(
53+
method="index", limit_direction="both", limit_area="inside"
54+
).bindata(delta=1, method="interpolate").smooth(
55+
window_len=21, window="hanning"
56+
).plot_cast(
57+
ax=ax
58+
)
59+
ax.set_ylabel("Pressure (dbar)")
60+
ax.set_xlabel("Temperature (°C)")
6461
```
6562

6663
![Good Processing](https://raw.githubusercontent.com/pyoceans/python-ctd/main/docs/readme_02.png)

ctd/extras.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def extrap_sec(
6868
Extrapolated variable
6969
7070
"""
71-
from scipy.interpolate import interp1d
71+
from scipy.interpolate import interp1d # noqa: PLC0415
7272

7373
new_data1 = []
7474
for row in data:
@@ -138,8 +138,8 @@ def gen_topomask(
138138
André Palóczy Filho ([email protected]) -- October/2012
139139
140140
"""
141-
import gsw
142-
from scipy.interpolate import interp1d
141+
import gsw # noqa: PLC0415
142+
from scipy.interpolate import interp1d # noqa: PLC0415
143143

144144
h, lon, lat = list(map(np.asanyarray, (h, lon, lat)))
145145
# Distance in km.
@@ -160,7 +160,7 @@ def plot_section( # noqa: PLR0915
160160
**kw: dict,
161161
) -> tuple:
162162
"""Plot a sequence of CTD casts as a section."""
163-
import gsw
163+
import gsw # noqa: PLC0415
164164

165165
lon, lat, data = list(
166166
map(np.asanyarray, (self.lon, self.lat, self.to_numpy())),
@@ -298,7 +298,7 @@ def barrier_layer_thickness(sa: pd.Series, ct: pd.Series) -> pd.Series:
298298
using density.
299299
300300
"""
301-
import gsw
301+
import gsw # noqa: PLC0415
302302

303303
sigma_theta = gsw.sigma0(sa, ct)
304304
mask = mixed_layer_depth(ct)

ctd/processing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def _rolling_window(data: np.ndarray, block: int) -> np.ndarray:
1313
Using strides for an efficient moving average filter.
1414
1515
"""
16-
shape = data.shape[:-1] + (data.shape[-1] - block + 1, block)
16+
shape = *data.shape[:-1], *(data.shape[-1] - block + 1, block)
1717
strides = (*data.strides, data.strides[-1])
1818
return np.lib.stride_tricks.as_strided(data, shape=shape, strides=strides)
1919

@@ -80,7 +80,7 @@ def lp_filter(
8080
https://scipy-cookbook.readthedocs.io/items/FIRFilter.html
8181
8282
"""
83-
from scipy import signal
83+
from scipy import signal # noqa: PLC0415
8484

8585
# Butter is closer to what SBE is doing with their cosine filter.
8686
wn = (1.0 / time_constant) / (sample_rate * 2.0)

0 commit comments

Comments
 (0)