Skip to content

[Bug]: lon_orient=(0, 360) tacking on an extra longitude #790

@mzelinka

Description

@mzelinka

What happened?

I am reading in a dataset with 360 longitudes that span -179.5 to 179.5 by 1 degree. Instead I want the data to run from 0.5 to 359.5 by 1 degree. Using ds = xc.open_dataset(filename, use_cftime = True, lon_orient=(0, 360)), it successfully reorients the longitudes to be positive definite (in degrees East), but it adds an additional longitude such that I have both 359.5 and 360.

What did you expect to happen? Are there are possible answers you came across?

I expected this to keep the same longitudes, but orient the data from 0.5 to 359.5 without adding that 360 degree point.

Minimal Complete Verifiable Example (MVCE)

On NERSC:

filename='/global/cfs/cdirs/m4581/obs4MIPs/obs4MIPs_input/MOHC/HadISST1-1/v20231114/HadISST.1.1.sst.nc'
ds0 = xc.open_mfdataset(filename, use_cftime = True)
ds1 = xc.open_mfdataset(filename, use_cftime = True, lon_orient=(0, 360))
ds0.longitude,ds1.longitude

Relevant log output

(<xarray.DataArray 'longitude' (longitude: 360)> Size: 1kB
 array([-179.5, -178.5, -177.5, ...,  177.5,  178.5,  179.5], dtype=float32)
 Coordinates:
   * longitude  (longitude) float32 1kB -179.5 -178.5 -177.5 ... 178.5 179.5
 Attributes:
     units:          degrees_east
     long_name:      Longitude
     standard_name:  longitude
     bounds:         longitude_bnds,
 <xarray.DataArray 'longitude' (longitude: 361)> Size: 1kB

 array([  0.5,   1.5,   2.5, ..., 358.5, 359.5, 360. ], dtype=float32)
 Coordinates:
   * longitude  (longitude) float32 1kB 0.5 1.5 2.5 3.5 ... 358.5 359.5 360.0
 Attributes:
     units:          degrees_east
     long_name:      Longitude
     standard_name:  longitude
     bounds:         longitude_bnds)

Anything else we need to know?

No response

Environment

xCDAT version 0.8.0

INSTALLED VERSIONS

commit: None
python: 3.13.2 | packaged by conda-forge | (main, Feb 17 2025, 14:10:22) [GCC 13.3.0]
python-bits: 64
OS: Linux
OS-release: 5.14.21-150500.55.97_13.0.78-cray_shasta_c
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.14.4
libnetcdf: 4.9.2

xarray: 2025.3.0
pandas: 2.2.3
numpy: 2.1.3
scipy: 1.15.2
netCDF4: 1.7.2
pydap: None
h5netcdf: None
h5py: None
zarr: None
cftime: 1.6.4
nc_time_axis: 1.4.1
iris: None
bottleneck: 1.4.2
dask: 2025.3.0
distributed: 2025.3.0
matplotlib: 3.10.1
cartopy: 0.24.1
seaborn: None
numbagg: None
fsspec: 2025.3.2
cupy: None
pint: 0.24.4
sparse: 0.15.4
flox: None
numpy_groupies: None
setuptools: 78.1.1
pip: 25.1
conda: None
pytest: None
mypy: None
IPython: 9.0.2
sphinx: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugInconsistencies or issues which will cause an issue or problem for users or implementors.

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions