Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Skyfield: Elegant Astronomy for Python (rhodesmill.org)
199 points by stefankuehnel on Dec 1, 2023 | hide | past | favorite | 32 comments


Skyfield is very cool. For my wedding, I wanted to give my groomspeople personalised thank you gifts. The idea I came up with was to find or ask for precise dates significant to them each (their own anniversaries, birthdays, special events...) and convert that into an abstraction of the relative positions of the planets on that day using Skyfield: https://imgur.com/l7G0att (and with the moon's orbit if they wanted: https://imgur.com/CYqfLR4).

I then got them engraved onto cufflinks https://imgur.com/bhxJVGo

They were super happy with the result, and we all looked great on the day. I wonder if there's a market for these but it feels a little niche, I'm glad skyfield exists to help projects like these.


Very nice. I love this kind of thing.

I make multispectral Sun images (https://imgur.com/UMQhcw6) for people occasionally based on a time & date, I started messing around with the idea for my son, and then as a gift for a friend and she then helped me get a page up https://www.theremarkablz.com/thesun

It's often for sciency people who have just had a kid, because with the SDO images you can get really close to the specific time of birth.


That is a very cool gift.

While not exactly the same, I got my wife a framed print of the stars over our wedding day as an anniversary gift a few years after we were married. It may be a little niche, but I think there is a market for that kind of thing.


If anyone wants a fun story, Brandon Rhodes is a wonderful storyteller, and this talk involves the linked library as well: https://www.youtube.com/watch?v=cYHP3oRGjG8


he is! ive learnt so much from his talks


This was great, thank you for posting!


Users interested in a broader range of astronomical tools beyond coordinate transformations may be interested in https://www.astropy.org/ and its affiliated packages.


Thanks- I was wondering if this was a useful tool compared to astropy.

I've used astropy for a couple things: 1) to automatically locate the angle of the sun in the sky in alt and az, and send motor commands to keep my telescope pointed at it for hours

2) to compute the moon and sun locations around a solar eclipse so I could simulate an eclipse in blender

When you use libraries like this you realize you are taking advantage of hundreds, if not thousands of years of technological development and discovery, turbocharged by modern math and software engineering.


Cool, it sounds like Skyfield is intentionally made interoperable with AstroPy:

> While Skyfield itself has no dependency on the AstroPy library, it’s willing to accept AstroPy time objects as input and return results in native AstroPy units


I will definitely check this out!

For anyone that could offer thoughts:

I have a ~1985 celestron c8 with the skysensor computer.

The skysensor uses and 1950 epoch and is definitely not y2k compliant :D

What is the best way to find a 19xx year that closely matches 202x so i can use the GOTO mode? I have been adjusting bright stars by some crude guesstimates by looking at average change in times between 1950 and 1990 and then again between 1990 and 2023 and working out the RA and Dec which can get me close.

But it would be nice to figure out if there is a year that would match real close. Maybe i can use this library to do a brute force search.


One possibility is to replace your SkySensor computer with OnStep. This is an Arduino-based system for GOTO scope control. It has ASCOM (Windows) and Indi (Linux) drivers so can control it from a PC or - if you add wifi - a phone app. It also has autoguiding support. It can run on most common microcontrollers and even cheap 3D printer control boards.

IIRC the C8 was often sold with a Super Polaris mount, or something similar. There are many builds for this mount.[1]

If you're not in to DIYing a solution there are companies that sell pre-built conversion kits.

[1] https://onstep.groups.io/g/main/wiki/4414


Thank you! I have only done cursory searches around a conversion.

I LOVE the retro feel of chonky skysensor so I would love to figure out how to keep the original motors and 5 pin plug. I have the original manuals and since the circuits are chonky too I suspect it would not be hard to make something compatible even without a bench scope.

This is a great link, I will dig through and see if someone has done what I want already.


It's quite possible that it has a ST-4 style guide port, which simply has 4 pins for slewing in each of the 4 directions + 1 common pin.

https://astrophotosite.com/tiki-index.php?page=ST-4


It has two 5 pin DIN ports, one to each motor and an RS232C for connecting to a PC so I dont think that is compatible.

I appreciate the link since that gives me more to research. I am going to have to tear down the mount and see if the motors are marked with their ratios and such based on what I am reading this morning.


The examples and tutorials for these libraries were an ideal introduction to me in astronomy, astrodynamics and satellite orbits. As part of my Ph.D., I was able to build a multiple orbit simulation and validation tools for smaller satellite missions thanks to Skyfield.


Brandon helped me solve an interesting problem during my PhD. I was building a sun-tracking sensor for a solar-powered lunar rover, and I needed to calculate the vector from the robot to the sun.

Brandon showed me how to use skyfield to solve the problem for a robot on Earth, and then he went back and forth via email to show me how to solve the problem on the moon.

In the end, we used skyfield to generate lookup tables for the places and times that we cared about, and it worked out great!


Brandon Rhodes has made such a wonderful contribution to the aerospace and python fields with Skyfield, pyephem, his port of sgp4, and astropy. Really wonderful helpful stuff.


Looking at the GitHub, there are a lot of non-trivial, yet seemingly approachable feature requests. For someone looking to contribute to scientific open source software, this seems like a great package.


I ask as a complete non expert in the field, please be patient: Wouldn't this require either downloading and maintaining a large database of ephemeri or connecting online to some server, say at NASA? Or is everything calculated from first principles.


Good question! I use Skyfield library for my project, it does require downloading NASA ephemeris, but it is only <200MB, unless you want a very long time period and you need to do it once every few years.

(DE430 got published in 2014 and most current version is DE440, released in 2021.


It may be worth adding that the planetary ephemeris are computed by NASA (JPL) by integrating the equations of motion forward in time numerically.

Then the results (e.g. planet centroid as a function of time) are encoded in a file, as noted above.

That file is then read by the ephemeris software to obtain the position at the desired time.

I haven’t checked in a few years, but there used to be multiple files to choose from depending on the time range you needed to cover.

It’s free — “your taxpayer dollars at work.”


That's what I thought must be necessary, thank you.


Skyfield is so well maintained and documented that we actually use it to process tracking data for our own satellites and plot additional orbit parameters like beta angle, altitude, etc.


That's really cool, astropy is well baked into our python codebase but may need to experiment more with Skyfield since it's coordinate transformations and timing and positions functionality look good.


A question for someone who already knows how to wrangle Skyfield: what is its answer for the "dawning of the age of Aquarius" ca. 2150?

(see Chap.16 "Of Sky and Time" in "When They Severed Earth From Sky", esp. Table 2, for the prevalence of —or at least ascription to— mentions of precession of the equinoxes in ancient mythology)


Very impressive. Great job.


Lovely project. Ive wanted to do similar for years but never got around to it. Now i just need to think of a project to use it for. Thank you to the author.


It’s been a while since I’ve seen a project advertise Python 2.6 compatibility.

This looks cool, and most of the code would look nearly right at home in a modern code base!


Very cool. How does this differ from pyephem?


It is from the same author. He semi-retired pyephem with the release of this project¹: "The Skyfield astronomy library should be preferred over PyEphem for new projects. Its modern design encourages better Python code, and uses NumPy to accelerate its calculations."

I switched a few toys I'd written from pyephem to skyfield, and it felt like a large improvement. (Must note that they really were toys though, so the amount of work wasn't huge in my case).

¹ https://rhodesmill.org/pyephem/


In many ways. Pyephem uses the ancient xephem linux C library for its astronomical calculations for both satellites and solar bodies. Skyfield uses the modern NASA SDG4 tables for a more accurate calculation of satellite positions and JPL’s ephemeris tables for planetary positions, yielding much greater accuracy and precision. It is written in pure Python and uses Numpy for speed enhancement. Finally, its API is completely different so knowing pyephem won’t be of much help in learning skyfield.


That's really cool. I also really like the minimal requirements for installing plain python, plus numpy).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: