-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
I have tried using the latest version of pint-xarray==0.5.0
which includes units in the coordinates which is exciting but I believe I have found an issue when using .sel
and the kwarg method="nearest"
, which would be used when selecting data nearest to the coordinate value specified but not exactly on the grid.
My guess is that the kwargs
are not being passed correctly. Maintaining this functionality would be incredibly useful and hopefully an easy fix.
See a minimal working example below
import xarray as xr
import pint_xarray
ureg = pint_xarray.unit_registry
ds = xr.tutorial.open_dataset("air_temperature")
q = ds.pint.quantify({"lat": "degrees", "lon": "degrees"})
q_75 = q.sel(lat=75 * ureg.degrees)
q_74 = q.sel(lat=74 * ureg.degrees, method="nearest")
which fails with this error
Traceback (most recent call last):
File "/home/ir-pate3/pyro_testing/mwe_pint_xarray.py", line 10, in <module>
q_74 = q.sel(lat=74 * ureg.degrees, method="nearest")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ir-pate3/.local/lib/python3.11/site-packages/xarray/core/dataset.py", line 3249, in sel
query_results = map_index_queries(
^^^^^^^^^^^^^^^^^^
File "/home/ir-pate3/.local/lib/python3.11/site-packages/xarray/core/indexing.py", line 194, in map_index_queries
results.append(index.sel(labels, **options))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: PintIndex.sel() got an unexpected keyword argument 'method'
Currently using pint-xarray=0.5.0
and xarray=2024.11.0
.
See related issue here where this breaks our CI tests.
pyro-kinetics/pyrokinetics#446
Metadata
Metadata
Assignees
Labels
No labels