xcdat icon indicating copy to clipboard operation
xcdat copied to clipboard

[Bug]: Duplicate longitude using lon_orient

Open pochedls opened this issue 1 year ago • 0 comments

What happened?

I noticed that when using the lon_orient flag set to (0, 360) there is an extra longitude value when 0 exists in lon. This value is repeated as 0 and 360 (but only 0 exists in the original dataset).

Notice the length of lon in the example below (with and without lon_orient).

What did you expect to happen?

The value should not be repeated.

Minimal Complete Verifiable Example

fn = '/p/css03/esgf_publish/CMIP6/CMIP/CNRM-CERFACS/CNRM-CM6-1/historical/r3i1p1f2/Amon/ts/gr/v20190125/' 
ds = xc.open_mfdataset(fn)
print(ds.lon)
ds = xc.open_mfdataset(fn, lon_orient=(0, 360))
print()
print(ds.lon)

<xarray.DataArray 'lon' (lon: 256)>
array([ 0. , 1.40625, 2.8125 , ..., 355.78125, 357.1875 , 358.59375]) Coordinates:

  • lon (lon) float64 0.0 1.406 2.812 4.219 ... 354.4 355.8 357.2 358.6 Attributes: axis: X standard_name: longitude long_name: Longitude units: degrees_east bounds: lon_bnds /home/pochedley1/bin/anaconda3/envs/xcdat/lib/python3.10/site-packages/cf_xarray/accessor.py:1638: UserWarning: Variables {'areacella', ''} not found in object but are referred to in the CF attributes. warnings.warn(

<xarray.DataArray 'lon' (lon: 257)> array([ 0. , 1.40625, 2.8125 , ..., 357.1875 , 358.59375, 360. ]) Coordinates:

  • lon (lon) float64 0.0 1.406 2.812 4.219 ... 355.8 357.2 358.6 360.0 Attributes: axis: X standard_name: longitude long_name: Longitude units: degrees_east bounds: lon_bnds

Relevant log output

No response

Anything else we need to know?

I think we could probably deal with this by filtering for transformed longitude values [0, 360).

Environment

xcdat 0.5.0

pochedls avatar Apr 26 '23 21:04 pochedls