issue_comments: 855710036
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/3620#issuecomment-855710036 | https://api.github.com/repos/pydata/xarray/issues/3620 | 855710036 | MDEyOklzc3VlQ29tbWVudDg1NTcxMDAzNg== | 4160723 | 2021-06-07T08:16:35Z | 2021-06-07T08:16:35Z | MEMBER | This looks like a nice use case for the forthcoming Xarray's custom index feature. How I see CRS/WCS-aware Xarray datasets with custom indexes:
For this use case a possible workflow would then be something like this: ```python create or open an Xarray dataset with x, y, z "pixel" (possibly lazy) coordinatesand set a WCS indexdataset = ( xr.Dataset(...) .set_index(['x', 'y', 'z'], WCSIndex, wcs_params={...}) ) select data using pixel coordinatesdataset.sel(x=..., y=..., z=...) select data using world coordinates (via the "astro" accessor,which may access methods/attributes of the WCS index)dataset.astro.sel_world(x=..., y=..., z=...) return a new dataset where the x,y,z "pixel" coordnates are replaced by the "world" coordinates(again using the WCS index, and propagating it to the returned dataset)world_dataset = dataset.astro.pixel_to_world(['x', 'y', 'z']) select data using world coordinatesworld_dataset.sel(x=..., y=..., z=...) select data using pixel coordinates (via the "astro" accessor)world_dataset.astro.sel_pixel(x=..., y=..., z=...) this could be revertedpixel_dataset = world_dataset.astro.world_to_pixel(['x', 'y', 'z']) assert pixel_dataset.identical(dataset) depending on the implementation in WCSIndex, would either raise an erroror implicitly convert to either pixel or world coordinatesxr.merge([world_dataset, another_pixel_dataset]) ``` |
{ "total_count": 2, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 2, "rocket": 0, "eyes": 0 } |
537772490 |