Make it so we can use broadcasting even if input WCS is same dimension as data #539
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is very much a WIP and not ready for usage but just opening this to not lose my progress.
I think we need to write down the rules for block sizes, and broadcasted reprojection, and I think it's ok to not cover all arbitrary cases. I'm now using the terminology 'reprojected dimensions' and 'non-reprojected dimensions', where the latter are essentially dimensions where we assume the mapping is 1-to-1 between input and output.
Proposed rules:
ndim
.wcs_in
has fewer pixel dimensions thanndim
, then we assume that the input WCS applies to the lastwcs_in.pixel_n_dim
dimensions of the input data, and that leading dimensions are the non-reprojected ones. The same applies towcs_out
.shape_out
should either havendim
elements, or match the number of reprojected dimensions. If the latter, then any missing elements for non-reprojected dimensions should be set to be the same as the input.block_size
, if specified, should also either havendim
elements, or match the number of reprojected dimensions. If the latter, then any missing elements for non-reprojected dimensions should be either set to1
ifblock_size
equalsshape_out
for reprojected dimensions, or-1
otherwiseblock_size
should either matchshape_out
for reprojected or for non-reprojected dimensions (that is, we either chunk over non-reprojected dimensions only, or over reprojected dimensions only). If it matchesshape_out
for reprojected dimensions, then the remaining block_size should be 1 so that only a single slice is reprojected at a time (yes there may be cases where someone wants to process slices in e.g. time or spectral slices, but this is going to introduce more complexity when the input WCS has dimensionndim
so we punt on this for now).non_reprojected_dims
should for now be only leading dimensions starting from0
, so e.g.(0,)
,(0, 1)
and so on.(1,2)
is not allowed for now. This could be relaxed in future potentially at the cost of more complexity.non_reprojected_dims
option could take a list of tuples where each tuple gives the(input_dim, output_dim)
correspondence.non_reprojected_dims
is specified, then ifwcs_in
orwcs_out
have fewer dimensions thanndim
, the difference in the number of dimensions should match the length ofnon_reprojected_dims
.For cases where the third axis is completely decoupled from the spatial axes in cubes,
non_reprojected_dims
isn't strictly needed because the WCSes could be easily sliced down to 2D. However, we do need that option for cases where the input WCS is 3D in the sense that each spatial slice might be different (for example due to drift at different times) but where each time still corresponds cleanly to one 2D slice and there is no dependence of e.g. time position on spatial position.Complex examples that should work:
non_reprojected_dims=(0,)
, it should work and basically only care about the spatial to spatial conversion. This example doesn't make a huge amount of sense, but another more realistic example is that if one wants to align two spectral cubes spatially without touching the spectral axis,non_reprojected_dims=(0,)
could do this.