oceanarray 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oceanarray/__init__.py +20 -0
- oceanarray/_version.py +1 -0
- oceanarray/cli.py +1343 -0
- oceanarray/clock_offset.py +675 -0
- oceanarray/config/OS1_sensor_attrs.yaml +49 -0
- oceanarray/config/OS1_var_names.yaml +5 -0
- oceanarray/config/OS1_vocab_attrs.yaml +84 -0
- oceanarray/config/legacy/project_RAPID.yaml +69 -0
- oceanarray/config/legacy/rodb_keys.txt +206 -0
- oceanarray/config/legacy/rodb_keys.yaml +1012 -0
- oceanarray/config/logging.yaml +28 -0
- oceanarray/legacy/__init__.py +47 -0
- oceanarray/legacy/caldip.py +753 -0
- oceanarray/legacy/convertOS.py +527 -0
- oceanarray/legacy/find_deployment.py +489 -0
- oceanarray/legacy/mooring_rodb.py +429 -0
- oceanarray/legacy/process_rodb.py +369 -0
- oceanarray/legacy/rodb.py +330 -0
- oceanarray/logger.py +192 -0
- oceanarray/logsheet/__init__.py +60 -0
- oceanarray/logsheet/_columns.py +97 -0
- oceanarray/logsheet/_config.py +245 -0
- oceanarray/logsheet/_firmware.py +43 -0
- oceanarray/logsheet/_latex.py +128 -0
- oceanarray/logsheet/_render.py +126 -0
- oceanarray/logsheet/builders/__init__.py +13 -0
- oceanarray/logsheet/builders/caldip_download.py +195 -0
- oceanarray/logsheet/builders/caldip_setup.py +188 -0
- oceanarray/logsheet/builders/deployment_setup.py +218 -0
- oceanarray/logsheet/builders/mooring_download.py +243 -0
- oceanarray/logsheet/builders/recovery.py +157 -0
- oceanarray/logsheet/data/column_defs.yaml +686 -0
- oceanarray/logsheet/data/latex_templates/_base_instrument.tex.j2 +42 -0
- oceanarray/logsheet/data/latex_templates/caldip_download.tex.j2 +47 -0
- oceanarray/logsheet/data/latex_templates/caldip_setup.tex.j2 +70 -0
- oceanarray/logsheet/data/latex_templates/deployment_setup.tex.j2 +97 -0
- oceanarray/logsheet/data/latex_templates/mooring_download.tex.j2 +54 -0
- oceanarray/logsheet/data/latex_templates/recovery.tex.j2 +103 -0
- oceanarray/mooring_level.py +1368 -0
- oceanarray/oceanarray.mplstyle +18 -0
- oceanarray/parameters.py +270 -0
- oceanarray/plotter.py +942 -0
- oceanarray/plotters/__init__.py +97 -0
- oceanarray/plotters/_animation.py +261 -0
- oceanarray/plotters/_current.py +705 -0
- oceanarray/plotters/_diagnostic.py +667 -0
- oceanarray/plotters/_helpers.py +57 -0
- oceanarray/plotters/_primitives.py +101 -0
- oceanarray/plotters/_section.py +16 -0
- oceanarray/plotters/_timeseries.py +11 -0
- oceanarray/rapid_interp.py +739 -0
- oceanarray/read_rbr_hex.py +541 -0
- oceanarray/readers.py +303 -0
- oceanarray/report/__init__.py +5 -0
- oceanarray/report/_array.py +386 -0
- oceanarray/report/_grid.py +539 -0
- oceanarray/report/_html_helpers.py +1004 -0
- oceanarray/report/_instrument.py +853 -0
- oceanarray/report/_mooring.py +1385 -0
- oceanarray/report/_plots.py +4284 -0
- oceanarray/report/_stack.py +941 -0
- oceanarray/stage1.py +1959 -0
- oceanarray/stage2.py +1160 -0
- oceanarray/stage3.py +2494 -0
- oceanarray/time_gridding.py +958 -0
- oceanarray/tools.py +400 -0
- oceanarray/transports.py +1 -0
- oceanarray/utilities.py +538 -0
- oceanarray/validation.py +389 -0
- oceanarray/writers.py +99 -0
- oceanarray-0.1.0.dist-info/METADATA +503 -0
- oceanarray-0.1.0.dist-info/RECORD +76 -0
- oceanarray-0.1.0.dist-info/WHEEL +5 -0
- oceanarray-0.1.0.dist-info/entry_points.txt +2 -0
- oceanarray-0.1.0.dist-info/licenses/LICENSE +21 -0
- oceanarray-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Shared private helpers for the plotters package.
|
|
2
|
+
|
|
3
|
+
Post-OdB: migrate the following from report/_plots.py:
|
|
4
|
+
_instrument_panels, _CANONICAL_PANELS, _COMPACT_PANEL_VARS,
|
|
5
|
+
_rose_ax, _ts_heatmap_panel, _add_sigma0_contours, _xyz_to_enu_2d.
|
|
6
|
+
|
|
7
|
+
Also migrate _instrument_label from plotter.py.
|
|
8
|
+
|
|
9
|
+
Note: _fig_to_base64 stays in report/_html_helpers.py (called only by
|
|
10
|
+
Tier-3 wrappers in report/_plots.py; plotters/ never serialises to base64).
|
|
11
|
+
|
|
12
|
+
See .claude/plotters_update-20260718.md for migration checklist.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import numpy as np
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def tukey_smooth(arr: np.ndarray, window_n: int) -> np.ndarray:
|
|
21
|
+
"""Zero-phase Tukey (cosine-tapered) smooth, NaN-gap aware.
|
|
22
|
+
|
|
23
|
+
Uses a convolution-based approach so NaN gaps do not propagate: output
|
|
24
|
+
points near gaps are weighted only by the finite neighbours that fall
|
|
25
|
+
within the window. Output is set to NaN where fewer than 10 % of the
|
|
26
|
+
window weights are finite (edges of large data gaps).
|
|
27
|
+
|
|
28
|
+
Requires ``scipy``.
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
arr : np.ndarray
|
|
33
|
+
1-D array, possibly containing NaNs.
|
|
34
|
+
window_n : int
|
|
35
|
+
Window length in samples.
|
|
36
|
+
|
|
37
|
+
Returns
|
|
38
|
+
-------
|
|
39
|
+
np.ndarray
|
|
40
|
+
Smoothed array, same shape as *arr*.
|
|
41
|
+
|
|
42
|
+
"""
|
|
43
|
+
from scipy.signal import windows as scipy_windows
|
|
44
|
+
|
|
45
|
+
if window_n < 3 or window_n >= len(arr):
|
|
46
|
+
return arr.copy()
|
|
47
|
+
win = scipy_windows.tukey(window_n, alpha=0.5)
|
|
48
|
+
win = win / win.sum()
|
|
49
|
+
finite = np.isfinite(arr)
|
|
50
|
+
smoothed = np.convolve(np.where(finite, arr, 0.0), win, mode="same")
|
|
51
|
+
wsum = np.convolve(finite.astype(float), win, mode="same")
|
|
52
|
+
with np.errstate(invalid="ignore"):
|
|
53
|
+
smoothed = np.where(wsum > 0.1, smoothed / wsum, np.nan)
|
|
54
|
+
return smoothed
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# TODO post-OdB: migrate from plotter.py / report/_plots.py
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""Tier-1 data-agnostic plotting primitives.
|
|
2
|
+
|
|
3
|
+
These functions accept pre-processed arrays (not xarray Datasets) and have no
|
|
4
|
+
knowledge of oceanographic variable naming conventions. They are the lowest
|
|
5
|
+
layer in the three-tier plotters architecture:
|
|
6
|
+
|
|
7
|
+
Tier 1: _primitives.py — generic, array-in / Figure-out
|
|
8
|
+
Tier 2: _current.py etc. — domain wrappers (xr.Dataset-in / Figure-out)
|
|
9
|
+
Tier 3: report/_plots.py — thin wrappers (path-in / base64-out)
|
|
10
|
+
|
|
11
|
+
Post-OdB: add plot_vector_heatmap, plot_section, plot_spectrum,
|
|
12
|
+
plot_polar_histogram, plot_timeseries.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from typing import Optional
|
|
18
|
+
|
|
19
|
+
import matplotlib.colors as mcolors
|
|
20
|
+
import matplotlib.pyplot as plt
|
|
21
|
+
import numpy as np
|
|
22
|
+
from matplotlib.collections import LineCollection
|
|
23
|
+
|
|
24
|
+
from ..utilities import _nice_colorbar_bounds
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def plot_trajectory(
|
|
28
|
+
x: np.ndarray,
|
|
29
|
+
y: np.ndarray,
|
|
30
|
+
color_data: Optional[np.ndarray] = None,
|
|
31
|
+
cmap: str = "coolwarm",
|
|
32
|
+
xlabel: str = "East displacement (m)",
|
|
33
|
+
ylabel: str = "North displacement (m)",
|
|
34
|
+
colorbar_label: str = "",
|
|
35
|
+
title: str = "",
|
|
36
|
+
) -> plt.Figure:
|
|
37
|
+
"""Plot a 2D trajectory, optionally coloured per-segment by a scalar field.
|
|
38
|
+
|
|
39
|
+
When *color_data* is provided, segments are drawn as a LineCollection with
|
|
40
|
+
colours mapped through *cmap*. When omitted, a plain line is drawn with
|
|
41
|
+
green and red markers at the start and end respectively.
|
|
42
|
+
|
|
43
|
+
Parameters
|
|
44
|
+
----------
|
|
45
|
+
x, y : ndarray
|
|
46
|
+
Trajectory coordinates (same length).
|
|
47
|
+
color_data : ndarray, optional
|
|
48
|
+
Scalar values to map onto the line (same length as x/y).
|
|
49
|
+
cmap : str
|
|
50
|
+
Matplotlib colormap name used when color_data is provided.
|
|
51
|
+
xlabel, ylabel : str
|
|
52
|
+
Axis labels.
|
|
53
|
+
colorbar_label : str
|
|
54
|
+
Label for the colorbar (only shown when color_data is provided).
|
|
55
|
+
title : str
|
|
56
|
+
Figure title.
|
|
57
|
+
|
|
58
|
+
Returns
|
|
59
|
+
-------
|
|
60
|
+
matplotlib.figure.Figure
|
|
61
|
+
|
|
62
|
+
"""
|
|
63
|
+
fig, ax = plt.subplots(figsize=(7, 6))
|
|
64
|
+
|
|
65
|
+
if color_data is not None:
|
|
66
|
+
points = np.array([x, y]).T.reshape(-1, 1, 2)
|
|
67
|
+
segments = np.concatenate([points[:-1], points[1:]], axis=1)
|
|
68
|
+
vmin = np.nanmin(color_data)
|
|
69
|
+
vmax = np.nanmax(color_data)
|
|
70
|
+
bounds = _nice_colorbar_bounds(vmin, vmax, n=20)
|
|
71
|
+
norm = mcolors.BoundaryNorm(bounds, ncolors=256)
|
|
72
|
+
lc = LineCollection(segments, cmap=cmap, norm=norm, linewidth=1.5)
|
|
73
|
+
lc.set_array(color_data[:-1])
|
|
74
|
+
ax.add_collection(lc)
|
|
75
|
+
fig.colorbar(lc, ax=ax, label=colorbar_label, shrink=0.8, ticks=bounds)
|
|
76
|
+
ax.set_xlim(
|
|
77
|
+
np.nanmin(x) - 0.05 * (np.nanmax(x) - np.nanmin(x) + 1),
|
|
78
|
+
np.nanmax(x) + 0.05 * (np.nanmax(x) - np.nanmin(x) + 1),
|
|
79
|
+
)
|
|
80
|
+
ax.set_ylim(
|
|
81
|
+
np.nanmin(y) - 0.05 * (np.nanmax(y) - np.nanmin(y) + 1),
|
|
82
|
+
np.nanmax(y) + 0.05 * (np.nanmax(y) - np.nanmin(y) + 1),
|
|
83
|
+
)
|
|
84
|
+
else:
|
|
85
|
+
ax.plot(x, y, color="steelblue", linewidth=1.5)
|
|
86
|
+
|
|
87
|
+
# Start/end markers
|
|
88
|
+
ax.plot(x[0], y[0], "o", color="green", markersize=8, label="Start", zorder=5)
|
|
89
|
+
ax.plot(x[-1], y[-1], "s", color="red", markersize=8, label="End", zorder=5)
|
|
90
|
+
ax.legend(fontsize=8)
|
|
91
|
+
|
|
92
|
+
ax.set_xlabel(xlabel)
|
|
93
|
+
ax.set_ylabel(ylabel)
|
|
94
|
+
if title:
|
|
95
|
+
ax.set_title(title)
|
|
96
|
+
ax.axhline(0, color="k", linewidth=0.5, linestyle="--", alpha=0.4)
|
|
97
|
+
ax.axvline(0, color="k", linewidth=0.5, linestyle="--", alpha=0.4)
|
|
98
|
+
ax.set_aspect("equal", adjustable="box")
|
|
99
|
+
ax.grid(True, linestyle="--", linewidth=0.5, alpha=0.4)
|
|
100
|
+
fig.tight_layout()
|
|
101
|
+
return fig
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Tier-2 domain wrappers for time × pressure section plots.
|
|
2
|
+
|
|
3
|
+
Post-OdB: migrate the following from plotter.py and report/_plots.py:
|
|
4
|
+
plot_grid, pcolor_timeseries_by_depth, plot_grid_fig (was _make_grid_fig_b64),
|
|
5
|
+
plot_isopycnal (was _make_isopycnal_fig_b64), plot_grid_n2 (was _make_grid_n2_b64).
|
|
6
|
+
|
|
7
|
+
Tier-1 primitive: plot_section (data-agnostic, contour_da=None for any quantity).
|
|
8
|
+
|
|
9
|
+
Note: _filter_sigma_tukey belongs in tools/ (data pre-treatment), not here.
|
|
10
|
+
Callers pass pre-filtered data; high-level wrappers like plot_isopycnal may
|
|
11
|
+
apply the filter internally but expose it as a parameter.
|
|
12
|
+
|
|
13
|
+
See .claude/plotters_update-20260718.md for migration checklist.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
# TODO post-OdB: migrate from plotter.py / report/_plots.py
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Tier-2 domain wrappers for instrument time-series plots.
|
|
2
|
+
|
|
3
|
+
Post-OdB: migrate the following from plotter.py and report/_plots.py:
|
|
4
|
+
plot_microcat_raw, plot_microcat, plot_aquadopp_raw, plot_aquadopp_quick,
|
|
5
|
+
plot_timeseries_by_depth, plot_mooring_timeseries, plot_trim_windows,
|
|
6
|
+
build_instrument_fig (was _build_fig_from_ds), plot_instrument_windows.
|
|
7
|
+
|
|
8
|
+
See .claude/plotters_update-20260718.md for migration checklist.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
# TODO post-OdB: migrate from plotter.py / report/_plots.py
|