Bug: Can't cf.read('https://psl.noaa.gov/thredds/fileServer/Datasets/gistemp/landmask_2deg.nc')

Open
#405 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
data, networking

Research direction

Reproduce the failure with the HTTPS source shown in the issue and compare it with the local copy. Start in cfdm/read_write/read.py at the read and post-read paths, then inspect how the HTTPFileSystem object is passed to the dataset backends. Done means the remote source is handled consistently with the local netCDF file, with coverage for the reported URL behavior.

Written by the indexing model from the issue text.

Description

bug?

I tried:

import cfdm
cfdm.environment(paths=False)
import cf
#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

to get

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
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or SCAN_ERROR
context: <!doctype^ html><html lang="en"><head><title>HTTP Status 404 – Not Found<[/title](http://localhost:8888/title)><style type="text[/css](http://localhost:8888/css)">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}<[/style](http://localhost:8888/style)><[/head](http://localhost:8888/head)><body><h1>HTTP Status 404 – Not Found<[/h1](http://localhost:8888/h1)><hr class="line" [/](http://localhost:8888/)><p><b>Type<[/b](http://localhost:8888/b)> Status Report<[/p](http://localhost:8888/p)><p><b>Message<[/b](http://localhost:8888/b)> Could not find file with URL path: Datasets&#47;gistemp&#47;landmask_2deg.nc.dds<[/p](http://localhost:8888/p)><p><b>Description<[/b](http://localhost:8888/b)> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.<[/p](http://localhost:8888/p)><hr class="line" [/](http://localhost:8888/)><h3>Apache Tomcat[/9.0.104](http://localhost:8888/9.0.104)<[/h3](http://localhost:8888/h3)><[/body](http://localhost:8888/body)><[/html](http://localhost:8888/html)>
---------------------------------------------------------------------------
DatasetTypeError                          Traceback (most recent call last)
Cell In[53], line 8
      5 source="https://psl.noaa.gov/thredds/fileServer/Datasets/gistemp/landmask_2deg.nc"
      6 #source="http://localhost/~drf/JUNK/landmask_2deg.nc"
      7 #source="[/Users/drf/Sites/JUNK/landmask_2deg.nc](http://localhost:8888/lab/tree/2025/work/shoreline/Sites/JUNK/landmask_2deg.nc)"
----> 8 x=cf.read(source)
      9 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 <File-like object HTTPFileSystem, https://psl.noaa.gov/thredds/fileServer/Datasets/gistemp/landmask_2deg.nc> as a netCDF dataset with any of the backends ('h5netcdf-pyfive', 'h5netcdf-h5py', 'netCDF4', 'netcdf_file'):

h5netcdf-pyfive:
InvalidHDF5File: Incorrect file signature

h5netcdf-h5py:
OSError: Unable to synchronously open file (file signature not found)

netCDF4:
OSError: [Errno -90] NetCDF: file not found: 'https://psl.noaa.gov/thredds/fileServer/Datasets/gistemp/landmask_2deg.nc'

netcdf_file:
UnsupportedOperation: fileno

Can't interpret https://psl.noaa.gov/thredds/fileServer/Datasets/gistemp/landmask_2deg.nc as a PP or UM dataset

When I would expect similar output to what I get from a local copy of the file:

import cfdm
cfdm.environment(paths=False)
import cf
#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:

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
[<CF Field: land_area_fraction(latitude(90), longitude(180)) 1>]

I raised a issue on cf-python at https://github.com/NCAS-CMS/cf-python/issues/948 which might be related to https://github.com/NCAS-CMS/cf-python/issues/699

[red herring elided]

Dominant language
Python
Stars
32
Forks
14
Avg merge
3d 20h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NCAS-CMS/cfdm

All issues in NCAS-CMS/cfdm

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.