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

Change "Reprojecting Images to Different Observers" example to avoid using custom wcs header until necessary #6853

Merged
merged 4 commits into from
May 11, 2023

Conversation

alasdairwilson
Copy link
Member

@alasdairwilson alasdairwilson commented Mar 16, 2023

This changes the Reprojecting Images to Different Observers example to avoid making a custom wcs until necessary (doesn't use it for euvi but does for mars).

I think there has been repeated confusion amongst users that see this example and assume a custom output wcs is necessary.

To avoid the reprojected image having NaNs on the limb, we still force the rsun for the two maps to match before reprojecting.

This however only partly deals with #6585 , I think a diataxis style explanation page is still needed, this example is now begging for a: "for a full explanation of why this is necessary go here" kind of deal but I am not sure I am the man for that page. I can definitely start it if people want, get the ball rolling (in a new PR,) but will probably need help from more savy reprojecters to weigh in.

# properties to do it.
# Due to a mismatch between the solar radius as defined in ``map_aia``
# and ``map_euvi``, our reprojection will not behave correctly on pixels
# very near the limb. This can be prevented by equating the two radii.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# very near the limb. This can be prevented by equating the two radii.
# very near the limb. This can be prevented by assuming that the emission
# observed by EUVI was emitted at the same radius from the centre of the Sun
# as the emission observed by AIA.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit clearer on exactly what the line of code means in terms of assumption

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it is clearer as to what an assumption about rsun means in general but I think there might be a danger there that readers leave with the idea that the mismatch between EUVI (or really the sunpy default rsun value) and AIA rsun is because of different emission heights.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it all clear, how about:

Data providers can set the radius at which emission in the map is assumed to have come from. Most maps set this to the standard photospheric radius (including EUI maps), but some maps (including AIA maps) set it to a slightly larger value. This mismatch means our reprojection won't work correctly on pixels near the limb. This can be prevented by assuming that the emission observed by EUVI was emitted at the same radius from the centre of the Sun as the emission observed by AIA.

? I think it's not a bad thing if users go away understanding that emission can come from different heights, and there has to be an assumption about those heights somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this paragraph, I think I was being stupid: my thought was this needs an explanation page for what rsun is, how it can have different values and why that can cause problems with reproject.

Now I have realised that this text can go in here now and when the page is made, be removed or reduced in place of a link, will make the change.

@ayshih
Copy link
Member

ayshih commented Mar 22, 2023

Instead of suggesting to a user to modify the EUVI metadata (map_euvi.meta['rsun_ref']), what if we suggested to the user:

map_aia.wcs.wcs.aux.rsun_ref = sunpy.sun.constants.radius.to_value('m')

@alasdairwilson alasdairwilson force-pushed the simplify_reproject_eg branch from 9d37682 to eb76521 Compare April 13, 2023 15:23
@dstansby
Copy link
Member

Instead of suggesting to a user to modify the EUVI metadata (map_euvi.meta['rsun_ref']), what if we suggested to the user:

map_aia.wcs.wcs.aux.rsun_ref = sunpy.sun.constants.radius.to_value('m')

What's the motivation for doing this instead of modifying the metadata? Because GenericMap.wcs is a property (not an attribute), this change will not persist if any of the other metadata is changed and .wcs is re-cached. I think it's safer and cleaner to change the metadata directly, since the current model of GenericMap is using the metadata as ground truth for deriving the properties.

@nabobalis nabobalis added this to the 5.0.0 milestone Apr 19, 2023
@dstansby
Copy link
Member

Removing this from 5.0 milestone, we can backport this to a bugfix release if it doesn't get in 5.0.0

@dstansby dstansby removed this from the 5.0.0 milestone Apr 23, 2023
@alasdairwilson
Copy link
Member Author

Instead of suggesting to a user to modify the EUVI metadata (map_euvi.meta['rsun_ref']), what if we suggested to the user:

map_aia.wcs.wcs.aux.rsun_ref = sunpy.sun.constants.radius.to_value('m')

What's the motivation for doing this instead of modifying the metadata? Because GenericMap.wcs is a property (not an attribute), this change will not persist if any of the other metadata is changed and .wcs is re-cached. I think it's safer and cleaner to change the metadata directly, since the current model of GenericMap is using the metadata as ground truth for deriving the properties.

So I agree, and without any opposing argument: I am going to revert this change and the surrounding text to represent that change.

In addition to your point, it makes sense because it is not a generic change, if the maps were reversed then setting the map_eui metadata to the default value would not fix it (since it is already the default sunpy value) whereas equating the two meta values will always work.

@alasdairwilson alasdairwilson requested a review from dstansby May 4, 2023 15:04
@nabobalis nabobalis removed request for a team and ayshih May 11, 2023 17:26
@nabobalis nabobalis merged commit d372700 into sunpy:main May 11, 2023
@lumberbot-app
Copy link

lumberbot-app bot commented May 11, 2023

Something went wrong ... Please have a look at my logs.

It seems that the branch you are trying to backport to does not exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants