home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1110101560

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/4995#issuecomment-1110101560 https://api.github.com/repos/pydata/xarray/issues/4995 1110101560 IC_kwDOAMm_X85CKs44 8699967 2022-04-26T18:09:18Z 2022-04-26T18:12:14Z CONTRIBUTOR

Example using nearest & tolerance with reindex & sel when dims don't match based on the example in sel:

```python import numpy import xarray

da = xarray.DataArray( numpy.arange(25).reshape(5, 5), coords={"x": numpy.arange(5), "y": numpy.arange(5)}, dims=("x", "y"), ) tgt_x = numpy.linspace(0, 4, num=5) + 0.5 tgt_y = numpy.linspace(0, 4, num=5) + 0.5 da = da.reindex( x=tgt_x, y=tgt_y, method="nearest", tolerance=0.2, fill_value=numpy.nan ).sel( x=xarray.DataArray(tgt_x, dims="points"), y=xarray.DataArray(tgt_y, dims="points"), ) Output: <xarray.DataArray (points: 5)> array([nan, nan, nan, nan, nan]) Coordinates: x (points) float64 0.5 1.5 2.5 3.5 4.5 y (points) float64 0.5 1.5 2.5 3.5 4.5 Dimensions without coordinates: points `` Side note: I don't think it makes sense to addfill_valuetoselas it would require adding new coordinates that didn't exist previously. Callingreindex` first makes that more clear in my opinion.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  822320976
Powered by Datasette · Queries took 2.046ms · About: xarray-datasette