Skip to content

Time Labels in "Plotting satellite altitude during re-entry" do not match #493

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

Closed
prisemut opened this issue Nov 30, 2020 · 6 comments
Closed

Comments

@prisemut
Copy link

In the example plot, the labeling of the time axis is wrong. The 11th of Nov 2013 is not a Thursday. The year is set wrongly, too.
Matplotlib is not converting the time from .toordinal() correctly. When changing it to .utc_datetime() the times are correct.

@brandon-rhodes
Copy link
Member

Thanks for letting me know! I should have time to investigate maybe by late next week, and I'll post any updates here as I look for the root problem.

@brandon-rhodes
Copy link
Member

Oddly enough the plot here has the correct dates!

https://rhodesmill.org/skyfield/earth-satellites.html#detecting-propagation-errors

So we'll need to look into the difference between how its x axis is plotted versus the plot you've noted has problems:

https://rhodesmill.org/skyfield/example-plots.html#plotting-satellite-altitude-during-re-entry

@prisemut
Copy link
Author

prisemut commented Dec 1, 2020

The example gets it right by accident. Look at your year, it's 3894 or something like that.

@brandon-rhodes
Copy link
Member

I have returned from travel and taken a look — the difference is in matplotlib! It changed internally how it represents dates with numbers. In 3.1.1, they were measured from the year 1:

https://matplotlib.org/3.1.1/api/dates_api.html#matplotlib.dates.date2num

But now are measured by default from 1970:

https://matplotlib.org/3.3.1/api/dates_api.html#matplotlib.dates.date2num

So exactly as you advise, I'll switch to Python datetimes. They would be inefficient for huge amounts of data (since they need an object-per-datapoint), but hopefully folks don't use this example script as their basis if they need big volumes of data.

@brandon-rhodes
Copy link
Member

And that almost worked.
When executed as a stand-alone script.
But when run in the doctests, where Pandas is also imported, it broke because of:
matplotlib/matplotlib#12310
pandas-dev/pandas#22859
So I upgraded Pandas.
And now the date is inexplicably back to 3982 Thursday the 11th, even though toordinal() is no longer involved.
I think I’ll now sleep and try again in the morning. 🙂

@brandon-rhodes
Copy link
Member

A further Pandas upgrade got things working. Thanks again for pointing out the effect of matplotlib's breaking change; this will now be a stronger example for users to work from!

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

No branches or pull requests

2 participants