ebas-plot 0.2.5__tar.gz → 0.2.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ebas-plot
3
- Version: 0.2.5
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ebas-plot
3
- Version: 0.2.5
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
@@ -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.5"
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
@@ -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(opendap_url, engine="netcdf4")
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(opendap_url, engine="netcdf4", decode_times=False)
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):
File without changes
File without changes
File without changes
File without changes