ebas-plot 0.1.4__tar.gz → 0.1.5__tar.gz
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.
- {ebas_plot-0.1.4 → ebas_plot-0.1.5}/PKG-INFO +1 -1
- {ebas_plot-0.1.4 → ebas_plot-0.1.5}/ebas_plot.egg-info/PKG-INFO +1 -1
- {ebas_plot-0.1.4 → ebas_plot-0.1.5}/ebas_plot.py +28 -6
- {ebas_plot-0.1.4 → ebas_plot-0.1.5}/LICENSE +0 -0
- {ebas_plot-0.1.4 → ebas_plot-0.1.5}/README.md +0 -0
- {ebas_plot-0.1.4 → ebas_plot-0.1.5}/ebas_plot.egg-info/SOURCES.txt +0 -0
- {ebas_plot-0.1.4 → ebas_plot-0.1.5}/ebas_plot.egg-info/dependency_links.txt +0 -0
- {ebas_plot-0.1.4 → ebas_plot-0.1.5}/ebas_plot.egg-info/entry_points.txt +0 -0
- {ebas_plot-0.1.4 → ebas_plot-0.1.5}/ebas_plot.egg-info/requires.txt +0 -0
- {ebas_plot-0.1.4 → ebas_plot-0.1.5}/ebas_plot.egg-info/top_level.txt +0 -0
- {ebas_plot-0.1.4 → ebas_plot-0.1.5}/pyproject.toml +0 -0
- {ebas_plot-0.1.4 → ebas_plot-0.1.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ebas-plot
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: Plotting utilities for EBAS netCDF datasets.
|
|
5
5
|
Author-email: Lise Eder Murberg <lemu@nilu.no>, Marthe Brevig <mbre@nilu.no>, Jonathan Elias Holme <jhol@nilu.no>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ebas-plot
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: Plotting utilities for EBAS netCDF datasets.
|
|
5
5
|
Author-email: Lise Eder Murberg <lemu@nilu.no>, Marthe Brevig <mbre@nilu.no>, Jonathan Elias Holme <jhol@nilu.no>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
@@ -7,7 +7,7 @@ import requests
|
|
|
7
7
|
from netCDF4 import num2date
|
|
8
8
|
import pandas as pd
|
|
9
9
|
|
|
10
|
-
__version__ = "0.1.
|
|
10
|
+
__version__ = "0.1.5"
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class DatasetAccessError(Exception):
|
|
@@ -361,6 +361,27 @@ def _group_vars_by_physical_quantity(ds: xr.Dataset, plot_vars: list[str]) -> li
|
|
|
361
361
|
return list(groups.items())
|
|
362
362
|
|
|
363
363
|
|
|
364
|
+
def _break_heatmap_time_gaps(x_time: np.ndarray, z: np.ndarray, gap_multiplier: float = 3.0) -> tuple[np.ndarray, np.ndarray]:
|
|
365
|
+
"""Insert a NaN sentinel column at each large x_time gap.
|
|
366
|
+
|
|
367
|
+
Plotly's Heatmap draws a cell spanning the midpoint to each of its
|
|
368
|
+
neighbors, so a single big jump in x (e.g. a real data outage of weeks or
|
|
369
|
+
months) gets rendered as one wide cell stretching the surrounding color
|
|
370
|
+
across the whole gap instead of leaving it blank. Inserting a NaN column
|
|
371
|
+
at the gap's midpoint gives Plotly a blank cell to render there instead.
|
|
372
|
+
"""
|
|
373
|
+
times = pd.DatetimeIndex(x_time)
|
|
374
|
+
diffs = np.diff(times)
|
|
375
|
+
if not len(diffs) or (median_step := np.median(diffs)) <= pd.Timedelta(0):
|
|
376
|
+
return x_time, z
|
|
377
|
+
gap_idx = np.flatnonzero(diffs > gap_multiplier * median_step) + 1
|
|
378
|
+
if not len(gap_idx):
|
|
379
|
+
return x_time, z
|
|
380
|
+
midpoints = times[gap_idx - 1] + diffs[gap_idx - 1] / 2
|
|
381
|
+
return (np.insert(np.asarray(x_time), gap_idx, midpoints),
|
|
382
|
+
np.insert(z, gap_idx, np.nan, axis=1))
|
|
383
|
+
|
|
384
|
+
|
|
364
385
|
def plot_pnsd(ds: xr.Dataset) -> go.Figure:
|
|
365
386
|
"""Plot particle number size distribution (PNSD) as a heatmap."""
|
|
366
387
|
var_name = _pnsd_var(ds)
|
|
@@ -382,6 +403,11 @@ def plot_pnsd(ds: xr.Dataset) -> go.Figure:
|
|
|
382
403
|
x_time = get_plot_time(ds)
|
|
383
404
|
y_d = ds["d_D"].values
|
|
384
405
|
|
|
406
|
+
# Heatmap stretches a single cell across any large gap in x rather than
|
|
407
|
+
# leaving it blank; insert a NaN sentinel column at the gap midpoint so
|
|
408
|
+
# Plotly renders the gap as blank instead of smearing the boundary color.
|
|
409
|
+
x_time, z = _break_heatmap_time_gaps(x_time, z)
|
|
410
|
+
|
|
385
411
|
# Fixed logarithmic scale from -1.0 to 5.0 with 0.2 interval; APS instruments cap lower (max 3.0).
|
|
386
412
|
log_min = -1.0
|
|
387
413
|
log_max = 3.0 if ds.attrs.get("ebas_instrument_type", "").strip().lower() == "aps" else 5.0
|
|
@@ -402,11 +428,7 @@ def plot_pnsd(ds: xr.Dataset) -> go.Figure:
|
|
|
402
428
|
z=z,
|
|
403
429
|
zmin=log_min,
|
|
404
430
|
zmax=log_max,
|
|
405
|
-
|
|
406
|
-
# interpolates between cells, which can paint spurious solid-color
|
|
407
|
-
# blocks at data gaps or resolution boundaries that don't match
|
|
408
|
-
# the underlying data (confirmed via hover z-value mismatch).
|
|
409
|
-
zsmooth=False,
|
|
431
|
+
zsmooth='best',
|
|
410
432
|
colorscale=plotly_discrete_colorscale,
|
|
411
433
|
showscale=True,
|
|
412
434
|
colorbar=dict(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|