New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combine cubes from NDCubeSequence using reproject #436
Conversation
Hello @adwaitbhope! Thanks for updating this PR.
Comment last updated at 2022-02-28 12:42:32 UTC |
Will add tests soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a great start. I have only looked at the main stack function at the moment.
By biggest high-level comment would be that we probably want to be a little smarter about how we generate the new combined WCS. I have left a couple of comments inline with specific suggestions. It also might make sense to have a function which generates that new WCS which we can then swap out if/when we add support for other ways of adding WCS dimensions.
ndcube/ndcube_sequence.py
Outdated
axis: `int`, optional | ||
The axis along which the data is to be stacked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little confusing. What this is is the array axis we are stacking along.
I do wonder if we even want this to be a configurable parameter. If we are being purists about it then the slowest varying coordinate should go last (which it is a safe assumption is the sequence dimension). I would propose maybe just dropping this parameter all together. I wonder if @DanRyanIrish or @wtbarnes have differing opinions on that though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I've dropped the axis parameter to make things a little simpler while computing the pixel to world axis mapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is looking good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it's heading in the right direction, I would like to test it out myself tomorrow.
faa3b0a
to
f640ebe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good. I just have a request regarding extracting the physical_types
. See in-line comments.
ndcube/ndcube_sequence.py
Outdated
for axis_name, axis_coords in self.sequence_axis_coords.items(): | ||
if isinstance(axis_coords[0], (u.Quantity, numbers.Number)): | ||
table_coords.append(QuantityTableCoordinate(u.Quantity(axis_coords), | ||
names=axis_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In each case, try to pull the physical_type
of each coord from the first cube in the sequence and use it to set the physical_type
of each TableCoordinate
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adwaitbhope Any progress on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have now. I'm extracting the physical type from global_coords
. But since we're iterating through .items()
of the sequence_axis_coords
dictionary, their order doesn't seem to be the same at every run.
I'm sorting the wcs.world_axis_physical_types
in the tests due to this, is that alright?
This also needs a changelog. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good. I wonder if @wtbarnes has had a chance to test it 🤔
fe8025f
to
dc69a1c
Compare
@wtbarnes have you or are you planning to test this out? |
Sorry I probably won't have time in the next day or two. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great - just needs to be rebased with main.
My only concern is (I'm wearing a map hat here) is that this can take a long time for 2D images. This is of course down to reproject_to
here, but even with like 16 AIA images at 256x256 took 7 mins on my local machine. In this way, I think a user warning or something could be added to warn of this?
but other than taking a long time, its working as expected!
# Reproject all cubes to a common WCS | ||
target_wcs = self[common_wcs_index].wcs | ||
shape_out = self[common_wcs_index].data.shape | ||
reprojected_cubes = [cube.reproject_to(target_wcs, shape_out=shape_out, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a warning or something should be flagged here if this reproject is going to take a long time. Imagine a user has a sequence of a hundred 4Kx4K AIA images and then tried to run this, it will take a looonng time
Co-authored-by: DanRyanIrish <ryand5@tcd.ie>
Co-authored-by: Stuart Mumford <stuart@cadair.com>
Co-authored-by: Stuart Mumford <stuart@cadair.com>
Co-authored-by: Stuart Mumford <stuart@cadair.com>
Co-authored-by: Stuart Mumford <stuart@cadair.com>
dc69a1c
to
8a95305
Compare
Co-authored-by: Laura Hayes <hayesla@tcd.ie>
Hello 👋, Thanks for your contribution to ndcube! |
Hello again 👋, We want to thank you again for your contribution to ndcube! |
Description
Fixes #430.
I'm currently only assuming one sequence axis, that part needs to be handled better.
I'm also exposing an
axis
parameter for stacking data which will affect themapping
passed on to theCompoundLowLevelWCS
.