Support fancy indexing
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with NDCube.axis_world_coords and NDCube.wcs.world_to_array_indices, then review sunpy/map/maputils.py and its pixelate_coord_path workflow. Implement the decided option 1 using tabular coordinate transformations for the tuple of slices and index arrays, returning a new NDCube that supports the motivating path-extraction workflow.
Written by the indexing model from the issue text.
Description
Describe the feature
Provide a function that takes an NDCube and a tuple of slice items and/or arrays of array indices and returns a new NDCube. As fancy indexing is not suitable for all underlying data array representations (e.g. dask), this should be a function rather than a method on NDCube.
Proposed solution
The bulk of the work in developing this functionality is building the new WCS. Fancy indexing enables discontinuities in the coordinate transformations. We foresee the following paths forward:
- Use
NDCube.axis_world_coordsto get tables of all the coordinates, and then produce a tabular gWCS object using the fancy index inputs. Do this for all axes, even if the original transformation could be maintained in some cases. This makes the implementation easier, but inefficient for large resultant cubes. - Only produce tabular transformations for the axes that are fancy indexed. Use
CompositeWCSto combine the fancy indexed tabulated transformations with the those unaffected by the fancy indexing.CompositeWCSis slow, but may be more memory efficient in some cases. - Develop a new WCS implementation that wraps a FITS-WCS within a gWCS model. @Cadair thinks this is a tractable amount of work, but is probably a longer term goal.
Decision
For the first version of this functionality, pursue option 1.
Motivating Use Case
Ability to produce N-D time/frequency/polarisation-distance plots. This functionality will enable this to be acheived by the following work-flow:
- Use
sunpy.map.maputils.pixelate_coord_pathto get the world coordinates of all pixels along a path in the spatial plane of anNDCube. - Use
NDCube.wcs.world_to_array_indicesto get the array indices of the path - Build a slice item tuple valid of the cube, e.g.
(path_indices_x, path_indices_y, slice(None),...)(assuming the spatial dimensions are the first two array axes) - Extract pixels along path, retaining other dimensions in new (N-1)-D cube:
new_cube = fancy_index_ndcube(old_cube, (path_indices, slice(None),...))
- Dominant language
- Python
- Stars
- 49
- Forks
- 56
- Avg merge
- 5h 54m
- Merged PRs (30d)
- 9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sunpy/ndcube
-
Bug
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Feature Request
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Feature Request
Difficulty 4/5 3-5 days Newbie friendliness 42/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100