Skip to content

Commit df7f74d

Browse files
committed
don't add new behavior to netcdf4 backend
1 parent 40a1c5b commit df7f74d

File tree

3 files changed

+3
-18
lines changed

3 files changed

+3
-18
lines changed

xarray/backends/common.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -867,10 +867,6 @@ def _is_likely_dap_url(url: str) -> bool:
867867

868868
url_lower = url.lower()
869869

870-
# Check for explicit DAP protocol schemes - these definitively indicate a DAP service
871-
if url_lower.startswith(("dap2://", "dap4://", "dap://")):
872-
return True
873-
874870
# For remote URIs, check for DAP server software path patterns
875871
if is_remote_uri(url_lower):
876872
dap_path_patterns = (

xarray/backends/netCDF4_.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,6 @@ def open(
463463
if isinstance(filename, os.PathLike):
464464
filename = os.fspath(filename)
465465

466-
# Replace DAP protocol prefixes with https:// - netCDF4 library can't handle them
467-
# These prefixes may be added by users to explicitly indicate DAP protocol
468-
# Following pydap's convention, we convert to https://
469-
# See: https://github.com/pydap/pydap/blob/0a2b0892611abaf0a9762ffd4f2f082cb8e497c2/src/pydap/handlers/dap.py#L103-L107
470-
if isinstance(filename, str):
471-
filename_lower = filename.lower()
472-
if filename_lower.startswith(("dap2://", "dap4://")):
473-
filename = "https://" + filename[7:]
474-
475466
if isinstance(filename, IOBase):
476467
raise TypeError(
477468
f"file objects are not supported by the netCDF4 backend: {filename}"
@@ -724,11 +715,6 @@ def _has_netcdf_ext(path: str | os.PathLike, is_remote: bool = False) -> bool:
724715
_, ext = os.path.splitext(path)
725716
return ext in {".nc", ".nc4", ".cdf"}
726717

727-
# Check for explicit DAP protocol indicators:
728-
# 1. DAP scheme: dap2:// or dap4:// (case-insensitive, may not be recognized by is_remote_uri)
729-
# 2. Remote URI with /dap2/ or /dap4/ in URL path (case-insensitive)
730-
# Note: We intentionally do NOT check for .dap suffix as that would match
731-
# file extensions like .dap which trigger downloads of binary data
732718
if isinstance(filename_or_obj, str):
733719
url_lower = filename_or_obj.lower()
734720
from xarray.backends.common import _is_likely_dap_url

xarray/backends/pydap_.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ class PydapBackendEntrypoint(BackendEntrypoint):
212212
def guess_can_open(self, filename_or_obj: T_PathFileOrDataStore) -> bool:
213213
if not isinstance(filename_or_obj, str):
214214
return False
215+
# Check for explicit DAP protocol schemes - these definitively indicate a DAP service
216+
if filename_or_obj.lower().startswith(("dap2://", "dap4://", "dap://")):
217+
return True
215218

216219
return _is_likely_dap_url(filename_or_obj)
217220

0 commit comments

Comments
 (0)