8000 Add example for reproducing the "Where is STEREO Today?" plot by ayshih · Pull Request #6781 · sunpy/sunpy · GitHub
[go: up one dir, main page]

Skip to content

Add example for reproducing the "Where is STEREO Today?" plot #6781

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

Merged
merged 5 commits into from
Apr 18, 2023

Conversation

ayshih
Copy link
Member
@ayshih ayshih commented Feb 16, 2023

Although we already closed #6301 with #6771, this PR adds an example that literally reproduces the "Where is STEREO Today?" plot as requested by #6301. Since this example is complex and particular, it is not intended to be a tutorial or a how-to guide. I have put it into a newly created "Showcase" category of examples, which I envision could house other complex and particular examples.

@ayshih ayshih added the Examples Related to the Example Gallery. label Feb 16, 2023
@ayshih
Copy link
Member Author
ayshih commented Feb 16, 2023

Bleh, the axes label color isn't coming out correct on Matplotlib 3.7.0, but is correct on Matplotlib 3.6.1. I'll have to track that down.

@nabobalis
Copy link
Member

Got to admit, I do like the concept of a showcase.

@ayshih
Copy link
Member Author
ayshih commented Feb 17, 2023

The example HMI Showcase: Cutout would also be a good candidate to move to this new "Showcase" category

@nabobalis
Copy link
Member

The example HMI Showcase: Cutout would also be a good candidate to move to this new "Showcase" category

Lets move it.

@Jett-Code
Copy link
Contributor

Although we already closed #6301 with #6771, this PR adds an example that literally reproduces the "Where is STEREO Today?" plot as requested by #6301. Since this example is complex and particular, it is not intended to be a tutorial or a how-to guide. I have put it into a newly created "Showcase" category of examples, which I envision could house other complex and particular examples.

Since the connection with STEREO-B was lost so is it good to show the location of STEREO-B in the plot?

@nabobalis
Copy link
Member

Since the connection with STEREO-B was lost so is it good to show the location of STEREO-B in the plot?

The goal is to replicate the figure as close as possible and that includes STEREO-B despite that fact its lost to us.

@ayshih
Copy link
Member Author
ayshih commented Feb 22, 2023

I'll pick this PR back up once matplotlib 3.7.1 is released, which should have my bug fix in it (matplotlib/matplotlib#25237)

@ayshih ayshih force-pushed the where_is_stereo branch from 73218b7 to e52acfa Compare March 5, 2023 05:10
@nabobalis

This comment was marked as outdated.

@nabobalis nabobalis added the No Backport A PR that isn't to be backported to any release branch. (To be used as a flag to other maintainers) label Mar 5, 2023
@nabobalis nabobalis added this to the 5.0.0 milestone Mar 5, 2023
@ayshih ayshih force-pushed the where_is_stereo branch from e52acfa to 617b31d Compare March 5, 2023 05:39
@ayshih ayshih marked this pull request as ready for review March 6, 2023 04:31
@ayshih ayshih requested a review from a team as a code owner March 6, 2023 04:31
@dstansby dstansby added the Whats New? Needs a section added to the current Whats New? page. label Mar 23, 2023
Copy link
Member
@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Some suggestions to make code a bit clearer - otherwise looks 👍 , and I like the idea of a showcase gallery section

Showcase
========

Examples that use an advanced combination of capabilities in sunpy
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
Examples that use an advanced combination of capabilities in sunpy
Examples that use an advanced combination of capabilities in sunpy.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not actually a sentence...

< 8000 /div>
Comment on lines 36 to 51
planets = ['Mercury', 'Venus', 'Earth', 'Mars']
periods = [88, 225, 365, 687]
planet_coords = {planet: get_body_heliographic_stonyhurst(planet,
obstime + np.arange(period) * u.d)
for planet, period in zip(planets, periods)}

stereo_a = get_horizons_coord('STEREO-A', obstime)
stereo_b = get_horizons_coord('STEREO-B', obstime)

missions = ['Parker Solar Probe', 'Solar Orbiter', 'BepiColombo']
mission_labels = {'Parker Solar Probe': 'PSP', 'Solar Orbiter': 'SO', 'BepiColombo': 'BEPICOLOMBO'}
periods = [100, 180, 120] # may need to be updated as orbits evolve
mission_coords = {mission: get_horizons_coord(mission, {'start': obstime,
'stop': obstime + period * u.d,
'step': '1d'})
for mission, period in zip(missions, periods)}
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
planets = ['Mercury', 'Venus', 'Earth', 'Mars']
periods = [88, 225, 365, 687]
planet_coords = {planet: get_body_heliographic_stonyhurst(planet,
obstime + np.arange(period) * u.d)
for planet, period in zip(planets, periods)}
stereo_a = get_horizons_coord('STEREO-A', obstime)
stereo_b = get_horizons_coord('STEREO-B', obstime)
missions = ['Parker Solar Probe', 'Solar Orbiter', 'BepiColombo']
mission_labels = {'Parker Solar Probe': 'PSP', 'Solar Orbiter': 'SO', 'BepiColombo': 'BEPICOLOMBO'}
periods = [100, 180, 120] # may need to be updated as orbits evolve
mission_coords = {mission: get_horizons_coord(mission, {'start': obstime,
'stop': obstime + period * u.d,
'step': '1d'})
for mission, period in zip(missions, periods)}
# Times to sample each orbit at from today, chosen to span at least a full
# orbit of every body plotted
times = np.arange(1000) * u.day
planets = ['Mercury', 'Venus', 'Earth', 'Mars']
planet_coords = {planet: get_body_heliographic_stonyhurst(planet,
obstime + times)
for planet in planets}
stereo_a = get_horizons_coord('STEREO-A', obstime)
stereo_b = get_horizons_coord('STEREO-B', obstime)
missions = ['Parker Solar Probe', 'Solar Orbiter', 'BepiColombo']
mission_labels = {'Parker Solar Probe': 'PSP', 'Solar Orbiter': 'SO', 'BepiColombo': 'BEPICOLOMBO'}
mission_coords = {mission: get_horizons_coord(mission, {'start': obstime,
'stop': obstime + times,
'step': '1d'})
for mission in missions}

I got very confused about periods for a while here, so would suggest the above to simplify and clarify things.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I don't like the idea of plotting multiple orbits just to make the code simpler. It won't matter much for planets, but it could look bad for spacecraft.

An alternative approach that'd be more robust than hard-coding orbital periods, but would mean even more code, is to grab 1000 days as you have done here, but then figure out how many elements make up the first orbit (by looking for when the ecliptic longitude passes the starting point) and then plotting just that first orbit.

Copy link
Member

Choose a reason for hiding this comment

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

Ah fair enough, I'm guessing it would look bad because of the dashed lines? In that case hardcoding is probably best, but maybe with a clarifying comment along the lines of # Orbital period in days above where periods is defined?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah fair enough, I'm guessing it would look bad because of the dashed lines?

Not just that, but orbital precession means that successive orbits of spacecraft – most notably BepiColombo – do not lie on top of each other.

I've added a function to automatically determine the first full orbit in a trajectory.

@nabobalis nabobalis removed this from the 5.0.0 milestone Mar 24, 2023
# Set Matplotlib settings to the desired appearance and initialize the axes.


mpl.rcParams.update({'figure.facecolor': 'black',
Copy link
Member

Choose a reason for hiding this comment

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

Oh god, why are we making it so ugly! 😆

@nabobalis nabobalis merged commit 4fbcc58 into sunpy:main Apr 18, 2023
@ayshih ayshih deleted the where_is_stereo branch November 3, 2023 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Examples Related to the Example Gallery. No Backport A PR that isn't to be backported to any release branch. (To be used as a flag to other maintainers) Whats New? Needs a section added to the current Whats New? page.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reproduce the "Where is STEREO?" plot in SunPy
5 participants
0