Skip to content
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

Closed
wants to merge 29 commits into from

Conversation

adwaitbhope
Copy link
Contributor

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 the mapping passed on to the CompoundLowLevelWCS.

@pep8speaks
Copy link

pep8speaks commented Jul 4, 2021

Hello @adwaitbhope! Thanks for updating this PR.

Line 123:25: W503 line break before binary operator

Comment last updated at 2022-02-28 12:42:32 UTC

@adwaitbhope
Copy link
Contributor Author

Will add tests soon.

Copy link
Member

@Cadair Cadair left a 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 Show resolved Hide resolved
ndcube/ndcube_sequence.py Outdated Show resolved Hide resolved
ndcube/ndcube_sequence.py Outdated Show resolved Hide resolved
ndcube/ndcube_sequence.py Outdated Show resolved Hide resolved
Comment on lines 252 to 253
axis: `int`, optional
The axis along which the data is to be stacked.
Copy link
Member

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.

Copy link
Contributor Author

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.

ndcube/ndcube_sequence.py Show resolved Hide resolved
Copy link
Member

@DanRyanIrish DanRyanIrish left a 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.

ndcube/ndcube_sequence.py Outdated Show resolved Hide resolved
Copy link
Member

@Cadair Cadair left a 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.

ndcube/ndcube_sequence.py Outdated Show resolved Hide resolved
ndcube/ndcube_sequence.py Outdated Show resolved Hide resolved
ndcube/ndcube_sequence.py Outdated Show resolved Hide resolved
ndcube/ndcube_sequence.py Outdated Show resolved Hide resolved
ndcube/ndcube_sequence.py Outdated Show resolved Hide resolved
Copy link
Member

@DanRyanIrish DanRyanIrish left a 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 Show resolved Hide resolved
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))
Copy link
Member

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.

Copy link
Member

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?

Copy link
Contributor Author

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?

@DanRyanIrish
Copy link
Member

This also needs a changelog.

@DanRyanIrish DanRyanIrish added this to the 2.1 milestone Aug 2, 2021
Copy link
Member

@Cadair Cadair left a 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 🤔

changelog/436.feature.rst Outdated Show resolved Hide resolved
ndcube/ndcube_sequence.py Outdated Show resolved Hide resolved
ndcube/ndcube_sequence.py Outdated Show resolved Hide resolved
@DanRyanIrish
Copy link
Member

@wtbarnes have you or are you planning to test this out?

@wtbarnes
Copy link
Member

@wtbarnes have you or are you planning to test this out?

Sorry I probably won't have time in the next day or two.

Copy link
Member

@hayesla hayesla left a 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!

ndcube/ndcube_sequence.py Outdated Show resolved Hide resolved
# 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,
Copy link
Member

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: Laura Hayes <hayesla@tcd.ie>
@github-actions
Copy link

Hello 👋, Thanks for your contribution to ndcube!
I have marked this pull request as stale because there hasn't had any activity in five months. If you are still working on this, or if it's waiting on a maintainer to look at it then please let us know and we will keep it open. Please add a comment with: @sunpy/ndcube-developers to get someone's attention.
If nobody comments on this pull request for another month, it will be closed.

@github-actions github-actions bot added the stale label Jul 29, 2022
@github-actions
Copy link

Hello again 👋, We want to thank you again for your contribution to ndcube!
This pull request has had no activity since my last reminder, so I am going to close it. If at any time you want to come back to this please feel free to reopen it! If you want to discuss this, please add a comment with: @sunpy/ndcube-developers and someone will get back to you soon.

@github-actions github-actions bot closed this Aug 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reproject NDCubeSequence to NDCube
6 participants