Skip to content

Field.subspace fails to work properly for cyclic field #887

@sws98slg

Description

@sws98slg

On upgrading from a very old version of cfpython (3.7.0) to the latest version (3.18.0) field.subspace no longer seems to work properly for a cyclic field. As an example using the datasets provided with cfplot

f=cf.read('cfplot_data/tas_A1.nc')[0]
f.subspace(X=cf.wi(175,-175))
Gives for the old version:
Out[139]: <CF Field: air_temperature(time(1680), latitude(73), longitude(3)) K> (correct answer)
But for the new version:
ValueError: No indices found from: X=<CF Query: (wi [175, -175])>

f.subspace(X=cf.wi(-5,5))
Gives for both versions
Out[140]: <CF Field: air_temperature(time(1680), latitude(73), longitude(3)) K> (correct answer)

f.subspace(X=cf.wi(355,5))
Gives for the old version:
Out[142]: <CF Field: air_temperature(time(1680), latitude(73), longitude(3)) K>
But for the new version:
ValueError: No indices found from: X=<CF Query: (wi [355, 5])>

I've tried explicitly setting the field to be cyclic

f.cyclic('X',iscyclic=True)
Before doing the subspacing but this doesn't help.

I hope I've explained this fully. I can see there was a previous issue reported (#828) that seems related, but this is marked as closed. For further info my environments are below.

My old environment is
Platform: Linux-3.10.0-1160.119.1.el7.x86_64-x86_64-with-centos-7.9.2009-Core
HDF5 library: 1.10.4
netcdf library: 4.6.3
udunits2 library: libudunits2.so.0
python: 3.7.7
netCDF4: 1.5.3
cftime: 1.2.1
numpy: 1.19.2
psutil: 5.6.3
scipy: 1.4.1
matplotlib: 3.3.2
ESMF: 7.1.0r
cfdm: 1.8.7.0
cfunits: 3.3.0
cfplot: 3.0.38
cf: 3.7.0

And my new one is
Platform: Linux-4.18.0-553.34.1.el8_10.x86_64-x86_64-with-glibc2.28
Python: 3.12.11
packaging: 25.0
numpy: 2.3.2
cfdm.core: 1.12.2.0
udunits2 library: /home/users/sws98slg/.conda/envs/myenv3_RACC2/lib/libudunits2.so.0
HDF5 library: 1.14.6
netcdf library: 4.9.2
netCDF4: 1.7.2
h5netcdf: 1.6.4
h5py: 3.14.0
zarr: 3.1.1
s3fs: 2025.7.0
scipy: 1.16.0
dask: 2025.7.0
cftime: 1.6.4
cfunits: 3.3.7
cfdm: 1.12.2.0
esmpy/ESMF: 8.8.1
psutil: 7.0.0
matplotlib: 3.10.5
cfplot: 3.4.0
cf: 3.18.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions