Learn Python with Talk Python's 270 hours of courses

Space Science with Python

Episode #393, published Thu, Dec 8, 2022, recorded Wed, Nov 30, 2022

Space science is one of the few sciences that can spark wonder and imagining in almost anyone. It also happens to be the domain of Python with many missions, telescopes, and analysis happening with Python playing a major role. On this episode we have Thomas Albin who has worked on several recent space missions. He has created a delightful YouTube channel called Space Science with Python. It's approachable and yet concrete and realistic. We are going to dive into some of his videos and see how Python can model things like astroid fly-bys and render comets in 3D.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guests Introduction and Background

Thomas Alvin is an experienced Python developer and former space scientist who has worked on major European Space Agency missions including Rosetta and Cassini. He has contributed to research and instrumentation for studying comet dust and near-Earth objects. Currently, he is a senior machine learning engineer in the automotive industry and remains deeply involved in astronomy and data-driven projects. In his spare time, Thomas runs a popular YouTube channel, Space Science with Python, showcasing how Python can be used to explore and model space data such as asteroid orbits, comet trajectories, and machine learning projects for planetary science.

What to Know If You’re New to Python

Before diving into space science topics, it’s helpful to be comfortable with:

  • Basic Python data structures (lists, dictionaries) so you can work with orbital and trajectory data.
  • Simple plotting and data analysis libraries like matplotlib or pandas to visualize orbit paths and numerical results.
  • A familiarity with reading API or file-based data. NASA/ESA missions often distribute data in specialized formats (“kernels,” CSV, etc.).
  • Awareness that libraries like spicy-pie and VizViz may be less common but are vital for certain astronomy tasks.

Key Points and Takeaways

  1. Python as a Foundation for Space Missions Thomas emphasized that Python is widely used in astronomy and planetary science for everything from data cleaning to advanced modeling. NASA, ESA, and other space agencies share large amounts of public data that can be processed in Python.
  2. Spice and SpicyPy for Orbital Calculations SPICE is a core toolkit from NASA to handle spacecraft orientation and planet/asteroid positions. SpicyPy is the Python wrapper that makes SPICE accessible for Python developers. Although it has a learning curve—especially around “kernels”—it is powerful enough to compute precise planetary trajectories and geometry over time.
  3. Modeling a “Close Flyby” Asteroid Thomas used actual NASA/JPL data on a “close flyby” asteroid to show that terms like “close” are relative in astronomy. By modeling its orbit using SpicyPy and comparing Earth-relative coordinates, he demonstrated how, in reality, even “close” might be tens of lunar distances away.
  4. Comet 67P and 3D Reconstructions The Rosetta mission’s detailed images of Comet 67P/Churyumov–Gerasimenko enabled scientists to create accurate 3D shape models. Thomas showcased how to load polygonal data for Comet 67P into Python and visualize it interactively. The results highlight how stereoscopic images from spacecraft cameras can be mapped into geometry files and then displayed in 3D with Python.
  5. Philae Lander’s Bouncing Landing Thomas’s instrument tracked a dust impact sensor on the Philae lander, part of the Rosetta mission. He combined the comet’s shape model with Philae’s trajectory data, reconstructing how the lander bounced multiple times before settling in a shaded crevice. Even with minimal sunlight, the lander recorded critical science data in its short lifespan.
  6. Interactive 3D Visualization with VisVis For dynamic 3D scenes (like orbit paths or the comet’s surface), Thomas used the VisVis library. Although lesser-known, VisVis simplifies OpenGL rendering and can handle shape-file data, point clouds, and animations with minimal overhead.
  7. Autoencoders and Machine Learning for Asteroid Classification Beyond orbit modeling, Thomas explored how autoencoders could compress asteroid “reflectance spectra” into a latent space, automatically clustering them by composition. This approach highlights how modern ML techniques can unearth patterns in large sets of historical space data.
    • Links and Tools:
      • AstroML library for machine learning in astronomy
      • scikit-learn for clustering and dimensionality reduction
  8. Legacy Data: A Goldmine for New Techniques Missions like Cassini and Rosetta produced gigabytes of data stored in public archives. Many of these observations have not yet been fully explored with modern ML, deep learning, or advanced analytics. Thomas encouraged the community to look at heritage data and apply new, more powerful methods.
  9. Practical Tips for Astronomy Python Projects Thomas stressed that working with space data often requires domain-specific coordinate transformations (e.g., transitioning from Sun-centered coordinates to Earth-centered ones). He uses carefully documented code, step-by-step transitions, and consistent reference frames to stay accurate.
  10. Engaging the Community and Educators Teachers and enthusiasts have found Thomas’s Python-based tutorials useful for education, bridging the gap between imaginative space themes and concrete coding. Rather than dry datasets, space topics are inherently motivating for students learning to program.

Interesting Quotes and Stories

  • On the breadth of data: “We have more data than we know what to do with. Missions like Cassini produce hundreds of gigabytes of raw data, which turn into terabytes once decompressed—and this is all out there to explore.”
  • On combining Python and astronomy: “Astronomy can seem daunting, but if you learn some Python, you can actually grab real space mission data and do amazing projects at home.”

Key Definitions and Terms

  • Near-Earth Object (NEO): An asteroid or comet whose orbit brings it into proximity with Earth, sometimes described by how many lunar distances away it passes.
  • Sphere of Influence: A region around a planet within which that planet’s gravitational pull is dominant over the Sun’s or other celestial bodies.
  • SPICE Kernel: Files that contain planetary and spacecraft ephemerides, time constants, and other geometry data used by NASA’s SPICE toolkit.
  • Reflectance Spectrum: The pattern of wavelengths of light reflected from an object, used to infer its composition.
  • Autoencoder: A neural network that compresses input data into a lower-dimensional “latent space” and then reconstructs it. Often used for clustering and anomaly detection.

Learning Resources

Below are some resources from Talk Python Training and beyond for those who want to deepen their knowledge in Python and data visualization:

Overall Takeaway

Astronomy is a field that uniquely captures the imagination, and Python offers straightforward, powerful tools to dive into it. From modeling asteroid flybys and comet landings in 3D to applying machine learning on legacy mission data, Python lets anyone—from curious beginners to space-industry professionals—gain fresh insights into the cosmos.

Links from the show

Thomas Albin: astrodon.social/@ThomasAlbin
Thomas on Twitter: @MrAstroThomas

YouTube Channels
Thomas' Space Science Channel: youtube.com
Dr Becky's Channel: youtube.com
Astrum Channel: youtube.com/@astrumspace
Talk Python's Channel: youtube.comyoutube.com/@talkpython
Michael's Channel: youtube.com/@mikeckennedy

Cassini Mission: nasa.gov
Comet: 67P/Churyumov–Gerasimenko: wikipedia.org
Code from the series: github.com

Space Science with Python Play List: youtube.com
Video: Comet in 3D: youtube.com
Video: Philae's Landing: youtube.com
Video: Support Vector Machines - Intro: youtube.com
Video: Autoencoder Latent Space Visualization: youtube.com

Packages
spiceypy: pypi.org
imageio: pypi.org
visvis: github.com
astropy: astropy.org
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm

--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy

Talk Python's Mastodon Michael Kennedy's Mastodon