ebas-plot 0.2.4__py3-none-any.whl → 0.2.6__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.
- {ebas_plot-0.2.4.dist-info → ebas_plot-0.2.6.dist-info}/METADATA +1 -1
- ebas_plot-0.2.6.dist-info/RECORD +7 -0
- ebas_plot.py +12 -4
- ebas_plot-0.2.4.dist-info/RECORD +0 -7
- {ebas_plot-0.2.4.dist-info → ebas_plot-0.2.6.dist-info}/WHEEL +0 -0
- {ebas_plot-0.2.4.dist-info → ebas_plot-0.2.6.dist-info}/entry_points.txt +0 -0
- {ebas_plot-0.2.4.dist-info → ebas_plot-0.2.6.dist-info}/licenses/LICENSE +0 -0
- {ebas_plot-0.2.4.dist-info → ebas_plot-0.2.6.dist-info}/top_level.txt +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.6
|
|
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=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,,
|
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.
|
|
11
|
+
__version__ = "0.2.6"
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class DatasetAccessError(Exception):
|
|
@@ -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
|
|
@@ -210,6 +214,9 @@ def _open_dataset(url: str, token: str | None) -> xr.Dataset:
|
|
|
210
214
|
raise DatasetAccessError(503, f"OPeNDAP server unreachable: {exc}") from exc
|
|
211
215
|
if probe.status_code in (401, 403):
|
|
212
216
|
raise DatasetAccessError(probe.status_code, "Dataset is restricted")
|
|
217
|
+
if probe.status_code == 404:
|
|
218
|
+
# netCDF-C retries a missing dataset for ~50s before giving up.
|
|
219
|
+
raise DatasetAccessError(404, "Dataset not found on the OPeNDAP server")
|
|
213
220
|
if probe.status_code >= 500:
|
|
214
221
|
raise DatasetAccessError(503, f"OPeNDAP server error ({probe.status_code})")
|
|
215
222
|
|
|
@@ -220,14 +227,15 @@ def _open_dataset(url: str, token: str | None) -> xr.Dataset:
|
|
|
220
227
|
dap_url = opendap_url.replace("https://", "dap2://", 1)
|
|
221
228
|
return xr.open_dataset(dap_url, engine="pydap", session=session)
|
|
222
229
|
|
|
230
|
+
nc_url = opendap_url + _NETCDF_DAP_URL_SUFFIX
|
|
223
231
|
try:
|
|
224
|
-
return xr.open_dataset(
|
|
232
|
+
return xr.open_dataset(nc_url, engine="netcdf4")
|
|
225
233
|
except RuntimeError:
|
|
226
234
|
# Driver-level I/O failure -- retrying with decode_times=False would just double the load.
|
|
227
235
|
raise
|
|
228
236
|
except Exception as exc:
|
|
229
237
|
print(f"Standard open failed ({exc}); retrying with decode_times=False")
|
|
230
|
-
return xr.open_dataset(
|
|
238
|
+
return xr.open_dataset(nc_url, engine="netcdf4", decode_times=False)
|
|
231
239
|
|
|
232
240
|
|
|
233
241
|
def get_plot_time(ds: xr.Dataset):
|
|
@@ -1059,4 +1067,4 @@ def main() -> None:
|
|
|
1059
1067
|
|
|
1060
1068
|
|
|
1061
1069
|
if __name__ == "__main__":
|
|
1062
|
-
main()
|
|
1070
|
+
main()
|
ebas_plot-0.2.4.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
ebas_plot.py,sha256=iojf9n5ElxHaYCduwsWUnq1hI-mOUA6deXONW7sBAXY,43764
|
|
2
|
-
ebas_plot-0.2.4.dist-info/licenses/LICENSE,sha256=7ZpO8LOz0uwP0ZXf1VdifRWnVKK6wPAICJ9ULsrndDs,840
|
|
3
|
-
ebas_plot-0.2.4.dist-info/METADATA,sha256=4_BvkRZdzUVOusEHYNAOgsj0rqxi1P9k99yFwIfC1-Y,3758
|
|
4
|
-
ebas_plot-0.2.4.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
5
|
-
ebas_plot-0.2.4.dist-info/entry_points.txt,sha256=pOXlW0kxym2YdjkQw2HxLtHgXoaLOgQBzxZ78uVovn0,45
|
|
6
|
-
ebas_plot-0.2.4.dist-info/top_level.txt,sha256=EcUPwQUC64wFbj_S3eIgWmItisCrkva69sjFY-5ywd4,10
|
|
7
|
-
ebas_plot-0.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|