Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Add bounds fails with coordinates crossing the antimeridian or the Greenwich meridian.

Aperta
#384 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@aulemahal ci sta già lavorando.

Dal 14/12/2022.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug

Yet another bug with .cf.add_bounds... This one was already present before the 2D addition, but it would have been quite infrequent with 1D coordinates.

The interpolation / extrapolation estimates are not aware of the cyclic nature of the longitude.

MWE:

import xarray as xr
import cf_xarray

ds = xr.Dataset(
    {'data': (('x', 'y'), np.ones((3, 3)))},
    coords={
        'x': [1, 2, 3],
        'y': [1, 2, 3],
        'lon': (('x',), [170, -170, -150], {'units': 'degrees_east'}),
        'lat': (('y',), [-10, 0, 10], {'units': 'degrees_north'}),
    },
)

ds.cf.add_bounds(('lon', 'lat')).lon_bounds

yields:

array([[ 340.,    0.],
       [   0., -340.],
       [-160., -140.]])

but we would expect:

array([[ 160.,    0.],
       [   0., -160.],
       [-160., -140.]])

Sadly, a quick internet search hasn't given me any pointers towards tools that already take this into account, except for projection-based tools (like pyproj).

We could have a check for "longitude" that looks for jumps and wraps the coordinates, but that jump threshold would be arbitrary. It's nonetheless the simplest way out I see, before parsing grid_mapping into pyproj objects.

Lingua principale
Python
Stelle
181
Fork
49
Merge medio
43m
PR unite (30g)
1

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di xarray-contrib/cf-xarray

Tutte le issue di xarray-contrib/cf-xarray

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.