ebas-plot 0.2.6__py3-none-any.whl → 0.2.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ebas-plot
3
- Version: 0.2.6
3
+ Version: 0.2.7
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
@@ -0,0 +1,7 @@
1
+ ebas_plot.py,sha256=E0QA_uITucp94bZQe0WgloLvVkBeJPUeR4JZFdVwwxk,44473
2
+ ebas_plot-0.2.7.dist-info/licenses/LICENSE,sha256=7ZpO8LOz0uwP0ZXf1VdifRWnVKK6wPAICJ9ULsrndDs,840
3
+ ebas_plot-0.2.7.dist-info/METADATA,sha256=tyfVwwGOfE8ewAIrmtXhyXzp4ESOS91CjfH4n_B0mLg,3758
4
+ ebas_plot-0.2.7.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
5
+ ebas_plot-0.2.7.dist-info/entry_points.txt,sha256=pOXlW0kxym2YdjkQw2HxLtHgXoaLOgQBzxZ78uVovn0,45
6
+ ebas_plot-0.2.7.dist-info/top_level.txt,sha256=EcUPwQUC64wFbj_S3eIgWmItisCrkva69sjFY-5ywd4,10
7
+ ebas_plot-0.2.7.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (84.0.0)
2
+ Generator: setuptools (84.2.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
ebas_plot.py CHANGED
@@ -8,7 +8,7 @@ import requests
8
8
  from netCDF4 import date2num, num2date
9
9
  import pandas as pd
10
10
 
11
- __version__ = "0.2.6"
11
+ __version__ = "0.2.7"
12
12
 
13
13
 
14
14
  class DatasetAccessError(Exception):
@@ -60,7 +60,7 @@ _CUSTOM_COLORS_VARIABLES = [
60
60
  "#D45500", # Burnt Orange
61
61
  ]
62
62
 
63
- _AUXILIARY = {"v_pressure", "v_relative_humidity", "v_temperature", "v_pH", "v_conductivity"}
63
+ _AUXILIARY = {"v_pressure", "v_relative_humidity", "v_temperature", "v_pH", "v_conductivity", "v_sample_count", "v_water_vapor_amean"}
64
64
  _STATISTICS = {
65
65
  "_prec1587", "_perc1587", "_perc8413", "_prec8413",
66
66
  "_uncertainty", "_stddev", "_det_lim", "_ExpUnc2s",
@@ -582,16 +582,24 @@ def _isolated_points_mask(y: np.ndarray) -> np.ndarray:
582
582
  return finite & ~left_finite & ~right_finite
583
583
 
584
584
 
585
- def _fill_small_gaps(y: np.ndarray, max_gap_steps: int) -> np.ndarray:
586
- """Linearly interpolate over NaN runs of <= max_gap_steps for line plots; keep longer runs as NaN.
587
-
588
- Filled values are not real measurements, only used so Plotly draws a connecting line across the gap.
589
- """
590
- if max_gap_steps <= 0:
591
- return y
592
- return pd.Series(y, dtype=float).interpolate(
593
- method="linear", limit=max_gap_steps, limit_area="inside"
594
- ).to_numpy()
585
+ def _remove_single_gaps(
586
+ x_time: np.ndarray, y: np.ndarray,
587
+ ) -> tuple[np.ndarray, np.ndarray]:
588
+ """Remove isolated NaNs bounded by finite observations less than three hours apart."""
589
+ x_time = np.asarray(x_time)
590
+ if len(y) < 3:
591
+ return x_time, y
592
+ timestamps = pd.DatetimeIndex(x_time)
593
+ finite = np.isfinite(y)
594
+ keep = np.ones(len(y), dtype=bool)
595
+ keep[1:-1] = ~(
596
+ np.isnan(y[1:-1])
597
+ & finite[:-2] & finite[2:]
598
+ & (timestamps[1:-1] > timestamps[:-2])
599
+ & (timestamps[2:] > timestamps[1:-1])
600
+ & (timestamps[2:] - timestamps[:-2] < pd.Timedelta(hours=3))
601
+ )
602
+ return x_time[keep], y[keep]
595
603
 
596
604
 
597
605
  def _time_valid_mask(da: xr.DataArray, arr: np.ndarray) -> np.ndarray:
@@ -669,8 +677,8 @@ def _add_timeseries_trace(
669
677
  marker=dict(color=color, size=6),
670
678
  hovertemplate="%{y:.4g}<br>%{customdata}<extra></extra>", customdata=hovertexts)
671
679
  else:
672
- y_line = _fill_small_gaps(y, max_gap_steps)
673
- x_line, y_line = _break_temporal_gaps(x_time, y_line, max_gap_steps, time_step)
680
+ x_line, y_line = _remove_single_gaps(x_time, y)
681
+ x_line, y_line = _break_temporal_gaps(x_line, y_line, max_gap_steps, time_step)
674
682
  isolated_points = _isolated_points_mask(y_line)
675
683
  kw = dict(x=x_line, y=y_line, mode="lines",
676
684
  line=dict(color=color, width=2),
@@ -1,7 +0,0 @@
1
- ebas_plot.py,sha256=s9LIEvaGYl_z6R6sNr7Pa0CluS-CrlPQIN8Ek37Hzn8,44235
2
- ebas_plot-0.2.6.dist-info/licenses/LICENSE,sha256=7ZpO8LOz0uwP0ZXf1VdifRWnVKK6wPAICJ9ULsrndDs,840
3
- ebas_plot-0.2.6.dist-info/METADATA,sha256=xToO1SkNu2grM24xgx1DUFg6vwDO9mG4TuolFIviqPA,3758
4
- ebas_plot-0.2.6.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
5
- ebas_plot-0.2.6.dist-info/entry_points.txt,sha256=pOXlW0kxym2YdjkQw2HxLtHgXoaLOgQBzxZ78uVovn0,45
6
- ebas_plot-0.2.6.dist-info/top_level.txt,sha256=EcUPwQUC64wFbj_S3eIgWmItisCrkva69sjFY-5ywd4,10
7
- ebas_plot-0.2.6.dist-info/RECORD,,