dev-resources.site
for different kinds of informations.
Introducing Ephem
tl;dr at the end
I am glad to announce a new Ruby gem on astronomy has been published: Ephem, a library that produces ephemerides from NASA's JPL Development Ephemeris series.
JPL DE4XX
The Jet Propulsion Laboratory (JPL) produces a series of mathematical models called Development Ephemeris (DE), which are used for spacecraft navigation and astronomy.
Such an ephemeris is available through a SPK file, or SPICE Kernel file, a complex binary file containing mathematical parameters to compute the position of Solar System bodies based on time.
The precision delivered by these models is so high that space agencies use it to send spacecraft into space. As an order of magnitude, while the planet Mars is usually located within a range of 50 to 250 million kilometres from the Earth, they are expected to predict its location with a margin error of one kilometre.
These kernels are large and complex and follow an arbitrary format of headers, segments, and coefficients that is unfriendly to beginners. However, once the right coefficients are found and used in the right mathematical formula, barycentric Cartesian coordinates are produced.
Solar System Cartesian coordinates
While we are used to coordinates relative to one's town, country or even the Earth, a DE kernel produces a more absolute series of coordinates, relative to barycentres in the Solar System.
A [barycentre] is the centre of mass of two or more bodies. In the same way, the point of balance for two different objects on a plank depends on their mass, Solar System bodies such as planets or even the Sun are related to their barycentre.
Also, Cartesian coordinates are a 3-D space coordinate system of three axes going through a single origin. Often named x, y, z, these are coordinates where an object is located in space relative to the origin.
Here is an example in more practical words: JPL DE405 enables us to compute the Earth-Moon system's (barycentre) location from the Solar System's barycentre. It can also calculate the Earth's location from the Earth-Moon barycentre. Therefore, through a simple formula, it is possible to compute the Earth's location from the Solar System's barycentre.
How to use these coordinates
Now the question is: What can we do with such raw data?
As we can see these coordinates as absolute, we can then convert them into coordinates that are useful to an observer.
Through a list of trigonometry functions, time and referential conversions and many corrections due to how complex the motion of celestial bodies is, the barycentric coordinates can be converted into topocentric coordinates, also known as geodetic coordinates or even horizontal coordinates. From Ephem's data, it is possible to calculate the altitude and azimuth of a celestial object in the sky for a given time and place on Earth.
The coordinates produced by Ephem can be used to observe the sky with extreme precision.
While Ephem remains its own gem so that the community can access raw data, it will become a dependency of Astronoby to exploit its full potential. Having access to such precise and accurate data will open the door to all possible computations of celestial events with the greatest accuracy available to the public. This will enable Astronoby to truly become a scientific library.
Usage
Here is a common use case of the library:
# Download and store the SPICE binary kernel file
Ephem::IO::Download.call(name: "de421.bsp", target: "tmp/de421.bsp")
# Load the kernel
spk = Ephem::SPK.open("tmp/de421.bsp")
# Define the center and target bodies
center = 0 # Solar system barycenter
target = 5 # Jupiter
# Get the right segment
segment = spk[center, target]
# Get the position and velocity of the target body at a given time
# The time is expressed in Julian Date TDB
time = 2460676.5 # 2025-01-01 00:00 UTC
state = segment.compute_and_differentiate(time)
# Display the position and velocity vectors
puts "Position: #{state.position}"
# => Position: Vector[157123190.6507038, 684298787.8592143, 289489366.7262833]
# The position is expressed in km
puts "Velocity: #{state.velocity}"
# => Velocity: Vector[-1117315.1437825128, 254177.26336095092, 136149.03901534996]
# The velocity is expressed in km/day
What if I want to use it right now?
If you want to use this data immediately and not wait for Astronoby to use it, or if you don't want to rely on Astronoby at all, I got you covered. You will find here a simple Ruby script that computes the position of Saturn on a specified date and time and displays the horizontal coordinates (altitude and azimuth) for an observer on Earth.
Please be aware the results will be approximate. Many tiny corrections should be added to the calculations to compute accurate coordinates. However, for amateur purposes, you will probably find the results accurate enough.
Conclusion
Access to astronomical data with this level of precision is a first time in the Ruby ecosystem. While Ephem is only v0.1, the main usage is covered and accurate data can already be used by the community.
It will help Astronoby reach its full potential and provide more and more features while ensuring accuracy and precision.
Check out the GitHub repository for more usage information and please spread the word so that we can improve the library from feedback.
tl;dr
- Ephem v0.1 is out: https://rubygems.org/gems/ephem
- Supports computing Solar System's planets Cartesian coordinates
- Based on NASA JPL Development Ephemeris files
- Accuracy from our point of view is estimated to be below 0.1 arcseconds
- Will be used in Astronoby to compute geocentric coordinates
- Such accuracy allows for computing any astronomical event and data with confidence
Credit cover picture: https://www.highpointscientific.com/astronomy-hub/post/astronomy-101/8-things-you-need-to-know-about-the-8-planets-in-our-solar-system
Credit JPL center: https://www.jpl.nasa.gov/annual-report/today-tomorrow/
Credit barycenter animation: https://en.wikipedia.org/wiki/Barycenter_(astronomy)
Credit Cartesian coordinates: https://fr.m.wikiversity.org/wiki/Fichier:3D_coordinate_system.svg
Featured ones: