Repository navigation
cf.read(opendapUrl) isnt recognized as NetCDF #948
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workingdataset readRelating to reading datasetsRelating to reading datasets
Description
To report a bug, please provide:
- A description of the issue with, if possible,
The issue #699 test case does not appear to work with cf.version=="3.20.0":
x = cf.read('https://data.pmel.noaa.gov/aclim/thredds/dodsC/B10K-K20_Level2_CORECFS_integrated_collection.nc')
x
gives:
---------------------------------------------------------------------------
DatasetTypeError Traceback (most recent call last)
Cell In[38], line 1
----> 1 x = cf.read('https://data.pmel.noaa.gov/aclim/thredds/dodsC/B10K-K20_Level2_CORECFS_integrated_collection.nc')
2 x
File [~/anaconda3/envs/conda-forge-env/lib/python3.13/site-packages/cfdm/decorators.py:171](http://localhost:8888/lab/tree/2025/work/shoreline/~/anaconda3/envs/conda-forge-env/lib/python3.13/site-packages/cfdm/decorators.py#line=170), in _manage_log_level_via_verbosity.<locals>.verbose_override_wrapper(*args, **kwargs)
168 # After method completes, re-set any changes to log level or
169 # enabling
170 try:
--> 171 return method_with_verbose_kwarg(*args, **kwargs)
172 except Exception:
173 raise
File [~/anaconda3/envs/conda-forge-env/lib/python3.13/site-packages/cf/read_write/read.py:544](http://localhost:8888/lab/tree/2025/work/shoreline/~/anaconda3/envs/conda-forge-env/lib/python3.13/site-packages/cf/read_write/read.py#line=543), in read.__new__(cls, datasets, external, verbose, warnings, aggregate, nfields, squeeze, unsqueeze, dataset_type, cdl_string, select, extra, recursive, followlinks, um, chunk, field, height_at_top_of_model, select_options, follow_symlinks, mask, unpack, warn_valid, dask_chunks, store_dataset_chunks, store_dataset_shards, domain, cfa, cfa_write, to_memory, netcdf_backend, storage_options, cache, chunks, ignore_read_error, fmt, file_type, group_dimension_search, filesystem)
535 if file_type is not None:
536 _DEPRECATION_ERROR_FUNCTION_KWARGS(
537 "cf.read",
538 {"file_type": file_type},
(...)
541 removed_at="5.0.0",
542 ) # pragma: no cover
--> 544 return super().__new__(**kwargs)
File [~/anaconda3/envs/conda-forge-env/lib/python3.13/site-packages/cfdm/decorators.py:171](http://localhost:8888/lab/tree/2025/work/shoreline/~/anaconda3/envs/conda-forge-env/lib/python3.13/site-packages/cfdm/decorators.py#line=170), in _manage_log_level_via_verbosity.<locals>.verbose_override_wrapper(*args, **kwargs)
168 # After method completes, re-set any changes to log level or
169 # enabling
170 try:
--> 171 return method_with_verbose_kwarg(*args, **kwargs)
172 except Exception:
173 raise
File [~/anaconda3/envs/conda-forge-env/lib/python3.13/site-packages/cfdm/read_write/read.py:299](http://localhost:8888/lab/tree/2025/work/shoreline/~/anaconda3/envs/conda-forge-env/lib/python3.13/site-packages/cfdm/read_write/read.py#line=298), in read.__new__(cls, datasets, external, extra, verbose, warnings, warn_valid, mask, unpack, domain, netcdf_backend, storage_options, filesystem, cache, dask_chunks, store_dataset_chunks, store_dataset_shards, cfa, cfa_write, to_memory, squeeze, unsqueeze, dataset_type, recursive, followlinks, cdl_string, extra_read_vars, group_dimension_search, **kwargs)
297 self._pre_read(dataset)
298 self._read(dataset)
--> 299 self._post_read(dataset)
301 # Add the dataset contents to the output list
302 self.n_datasets += 1
File [~/anaconda3/envs/conda-forge-env/lib/python3.13/site-packages/cfdm/read_write/read.py:536](http://localhost:8888/lab/tree/2025/work/shoreline/~/anaconda3/envs/conda-forge-env/lib/python3.13/site-packages/cfdm/read_write/read.py#line=535), in read._post_read(self, dataset)
534 if self.dataset_format_errors:
535 error = "\n".join(map(str, self.dataset_format_errors))
--> 536 raise DatasetTypeError(f"\n{error}")
538 self.dataset_contents = []
DatasetTypeError:
Can't interpret https://data.pmel.noaa.gov/aclim/thredds/dodsC/B10K-K20_Level2_CORECFS_integrated_collection.nc as a dataset of one of the valid types: ('netCDF', 'CDL', 'Zarr', 'Kerchunk')
Can't interpret https://data.pmel.noaa.gov/aclim/thredds/dodsC/B10K-K20_Level2_CORECFS_integrated_collection.nc as a PP or UM dataset
cf.version = "3.20.0"
I had a similar error on the links provided by https://psl.noaa.gov/thredds/catalog/Datasets/gistemp/catalog.html?dataset=Datasets/gistemp/landmask_2deg.nc Thredds/OpenDAP page:
https://psl.noaa.gov/thredds/fileServer/Datasets/gistemp/landmask_2deg.nc -- HTTPS access
http://psl.noaa.gov/thredds/dodsC/Datasets/gistemp/landmask_2deg.nc -- The opendap endpoint
If I copied the file to my laptop and I expose the file in my local webserver and try http://localhost/~drf/JUNK/elev_latest.nc it fails similarly but if I use local access on the file path landmask_2deg.nc it works:
#source="http://psl.noaa.gov/thredds/dodsC/Datasets/gistemp/landmask_2deg.nc"
#source="https://psl.noaa.gov/thredds/fileServer/Datasets/gistemp/landmask_2deg.nc"
#source="http://localhost/~drf/JUNK/landmask_2deg.nc"
source="/Users/drf/Sites/JUNK/landmask_2deg.nc"
x=cf.read(source)
x
gives
[<CF Field: land_area_fraction(latitude(90), longitude(180)) 1>]
- The version of the software and the environment in which you are encountering an issue. The output of
cf.environment(paths=False)is useful for this.
Platform: macOS-15.3.1-x86_64-i386-64bit-Mach-O
Python: 3.13.2
packaging: 25.0
numpy: 2.3.4
cfdm.core: 1.13.1.0
udunits2 library: /Users/drf/anaconda3/envs/conda-forge-env/bin/../lib/libudunits2.dylib
HDF5 library: 2.0.0
netcdf library: 4.9.2
netCDF4: 1.7.2
h5netcdf: 1.8.1
h5py: 3.16.0
pyfive: 1.1.2
zarr: 3.2.1
fsspec: 2026.4.0
scipy: 1.16.3
dask: 2026.3.0
distributed: 2026.3.0
cftime: 1.6.4
cfunits: 3.3.7
cfdm: 1.13.1.0
esmpy/ESMF: not available
psutil: 7.1.3
matplotlib: 3.10.7
activestorage: not available
cartopy: 0.25.0
cfplot: 3.4.0
cf: 3.20.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdataset readRelating to reading datasetsRelating to reading datasets
Activity
drf5n commentedon May 21, 2026
Maybe https://github.com/NCAS-CMS/cfdm NCAS-CMS/cfdm#268 has hints?
Perhaps this chunk should set
patharound line 129?https://github.com/NCAS-CMS/cfdm/blob/693294ae4b03dde2abcf7621e18e85fa0b52e81f/cfdm/read_write/abstract/abstractio.py#L117-L130
davidhassell commentedon May 27, 2026
Hi - thanks for the report. I can confirm that this is a bug - in
cfdm- introduced in the last version (1.13.1.0). We'll get a fix into themainbranch ofcfdmquickly, with a public release happening sometime in June.So, for now, you'll have to either downgrade to cf-python 3.19.0, or pick up the new
mainofcfdmwhen it appears.I'll link this issue to the
cfdmissue that I'll create shortly.Sorry for the bother!
David
davidhassell commentedon May 30, 2026
This fix has now gone into
cfdm(NCAS-CMS/cfdm#406) - to get at it before the next release, you just need to update yourcfdminstallation from the cfdmmainbranch, and cf-python will pick it up from there. The public release is due in the second half of June 2026 (definitely before July).