ebas-plot 0.2.5__tar.gz → 0.2.7__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.2.5 → ebas_plot-0.2.7}/PKG-INFO +1 -1
- {ebas_plot-0.2.5 → ebas_plot-0.2.7}/ebas_plot.egg-info/PKG-INFO +1 -1
- {ebas_plot-0.2.5 → ebas_plot-0.2.7}/ebas_plot.py +29 -16
- {ebas_plot-0.2.5 → ebas_plot-0.2.7}/LICENSE +0 -0
- {ebas_plot-0.2.5 → ebas_plot-0.2.7}/README.md +0 -0
- {ebas_plot-0.2.5 → ebas_plot-0.2.7}/ebas_plot.egg-info/SOURCES.txt +0 -0
- {ebas_plot-0.2.5 → ebas_plot-0.2.7}/ebas_plot.egg-info/dependency_links.txt +0 -0
- {ebas_plot-0.2.5 → ebas_plot-0.2.7}/ebas_plot.egg-info/entry_points.txt +0 -0
- {ebas_plot-0.2.5 → ebas_plot-0.2.7}/ebas_plot.egg-info/requires.txt +0 -0
- {ebas_plot-0.2.5 → ebas_plot-0.2.7}/ebas_plot.egg-info/top_level.txt +0 -0
- {ebas_plot-0.2.5 → ebas_plot-0.2.7}/pyproject.toml +0 -0
- {ebas_plot-0.2.5 → ebas_plot-0.2.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ebas-plot
|
|
3
|
-
Version: 0.2.
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ebas-plot
|
|
3
|
-
Version: 0.2.
|
|
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
|
|
@@ -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.
|
|
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",
|
|
@@ -185,6 +185,10 @@ def open_dataset(
|
|
|
185
185
|
# Known hosts only: the user's Bearer token is forwarded to the dataset host.
|
|
186
186
|
_THREDDS_HOSTS = ("https://thredds.nilu.no", "https://dev-thredds.nilu.no")
|
|
187
187
|
|
|
188
|
+
# netCDF-C's DAP2 prefetch packs every small variable into one constraint URL; wide EBAS datasets
|
|
189
|
+
# (~500 vars) exceed lb.nilu.no's ~16 KB request limit -> "NetCDF: Access failure" after ~40s of retries.
|
|
190
|
+
_NETCDF_DAP_URL_SUFFIX = "#noprefetch"
|
|
191
|
+
|
|
188
192
|
|
|
189
193
|
def _open_dataset(url: str, token: str | None) -> xr.Dataset:
|
|
190
194
|
if not url.startswith("http"): # local file
|
|
@@ -223,14 +227,15 @@ def _open_dataset(url: str, token: str | None) -> xr.Dataset:
|
|
|
223
227
|
dap_url = opendap_url.replace("https://", "dap2://", 1)
|
|
224
228
|
return xr.open_dataset(dap_url, engine="pydap", session=session)
|
|
225
229
|
|
|
230
|
+
nc_url = opendap_url + _NETCDF_DAP_URL_SUFFIX
|
|
226
231
|
try:
|
|
227
|
-
return xr.open_dataset(
|
|
232
|
+
return xr.open_dataset(nc_url, engine="netcdf4")
|
|
228
233
|
except RuntimeError:
|
|
229
234
|
# Driver-level I/O failure -- retrying with decode_times=False would just double the load.
|
|
230
235
|
raise
|
|
231
236
|
except Exception as exc:
|
|
232
237
|
print(f"Standard open failed ({exc}); retrying with decode_times=False")
|
|
233
|
-
return xr.open_dataset(
|
|
238
|
+
return xr.open_dataset(nc_url, engine="netcdf4", decode_times=False)
|
|
234
239
|
|
|
235
240
|
|
|
236
241
|
def get_plot_time(ds: xr.Dataset):
|
|
@@ -577,16 +582,24 @@ def _isolated_points_mask(y: np.ndarray) -> np.ndarray:
|
|
|
577
582
|
return finite & ~left_finite & ~right_finite
|
|
578
583
|
|
|
579
584
|
|
|
580
|
-
def
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
if
|
|
586
|
-
return y
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
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]
|
|
590
603
|
|
|
591
604
|
|
|
592
605
|
def _time_valid_mask(da: xr.DataArray, arr: np.ndarray) -> np.ndarray:
|
|
@@ -664,8 +677,8 @@ def _add_timeseries_trace(
|
|
|
664
677
|
marker=dict(color=color, size=6),
|
|
665
678
|
hovertemplate="%{y:.4g}<br>%{customdata}<extra></extra>", customdata=hovertexts)
|
|
666
679
|
else:
|
|
667
|
-
y_line =
|
|
668
|
-
x_line, y_line = _break_temporal_gaps(
|
|
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)
|
|
669
682
|
isolated_points = _isolated_points_mask(y_line)
|
|
670
683
|
kw = dict(x=x_line, y=y_line, mode="lines",
|
|
671
684
|
line=dict(color=color, width=2),
|
|
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
|