Learn Python with Talk Python's 270 hours of courses

Python and the James Webb Space Telescope

Episode #357, published Mon, Mar 21, 2022, recorded Wed, Feb 23, 2022

Telescopes have been fundamental in our understanding of our place in the universe. And when you think about images that have shaped our modern view of space, you probably think about Hubble. But just this year, the JWST or James Web Space Telescope, was launch. JWST will go far beyond what Hubble has discovered. And did you know Python is used extensively in the whole data pipeline of JWST? We have two great guests here to tell us about it: Megan Sosey and Mike Swam.

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

Guests

Megan Sosey

Mike Swam


Episode Deep Dive

Guests Introduction and Background

Megan Sosey is the technical lead for the data management system of the Nancy Grace Roman Space Telescope at the Space Telescope Science Institute (STScI). She began coding in BASIC on an Osborne computer, developed an early love of programming, and later adopted Python for its power in scientific computing. Her work focuses on overseeing data pipelines and scientific analysis software for future missions.

Mike Swam leads the data processing team for the James Webb Space Telescope (JWST) at STScI. He started programming in Fortran, then moved to Python around 2002 when it became prominent for astronomy and data analysis tasks. Mike’s team monitors the flow of data from the JWST through NASA’s Deep Space Network into STScI, where it’s processed and eventually made available to the scientific community.

What to Know If You're New to Python

Here are a few basics that came up during the episode to help you follow along:

  • Basic familiarity with Python’s syntax is helpful since JWST’s pipelines heavily use Python modules and scripts.
  • Understanding how Python handles file I/O and basic data structures (like lists and NumPy arrays) is key to grasping how telescope data is processed.
  • Many astronomy tools rely on metadata (data about data) alongside raw pixel data, so be prepared to read structured data such as JSON or YAML.

Key Points and Takeaways

  1. Python’s Pivotal Role in JWST’s Data Pipeline The episode highlights how nearly every stage of JWST’s data journey uses Python. From checking data completeness to reconstructing full images out of telemetry packets, Python scripts ensure that information flowing from the observatory is validated, corrected, and distributed efficiently. Astronomers also rely on Python to calibrate and interpret the processed data.
  2. Astronomy Data Flow from JWST to STScI After NASA’s Deep Space Network receives the observatory’s data, it’s transferred to STScI for processing and archiving. Mike described how incoming files are chopped into smaller pieces on the telescope, sent down incrementally, and then validated and reassembled on the ground. This ensures no corruption or missing pieces, allowing scientists to see complete images and detailed telemetry.
  3. Calibration and Data Processing Tools The JWST calibration software, written in Python, handles everything from removing cosmic ray artifacts to adjusting for detector quirks like “instrumental signatures.” With multiple detectors and complex optics, this software accounts for temperature, ephemeris data (where the telescope is in space), and more. It helps create science-ready data that astronomers can trust.
  4. Hubble and JWST Distinctions JWST is not simply a bigger, better Hubble. It orbits around the Sun–Earth L2 point and uses infrared detectors, requiring a sunshield to keep instruments cold. Hubble primarily focuses on UV, visible, and near-infrared wavelengths while JWST goes further into the infrared spectrum, enabling it to see the earliest phases of galaxy formation and peer through dust clouds.
  5. JWST’s Infrared Focus and Science Missions Because JWST observes in infrared wavelengths, it can detect the first galaxies and stars formed after the Big Bang—light that has been “redshifted” over billions of years. JWST is also excellent for exoplanet research, examining planetary atmospheres and potential transit signals from smaller, rocky worlds.
  6. Reprocessing Data to Improve Accuracy Over Time Data coming in from JWST isn’t static. As calibration algorithms evolve and new reference data becomes available, entire archives are reprocessed. Python makes it easier to run large, automated pipelines that apply updated corrections and produce superior final data products for astronomers.
  7. Open Source and GitHub Integration Many of the tools used for JWST are freely accessible on GitHub under the spacetelescope organization. Astronomers and external developers can contribute fixes, features, and run the same pipelines on their own local data. This encourages broad collaboration, faster bug fixes, and an exchange of new ideas.
  8. Nancy Grace Roman Space Telescope Megan works on Roman’s future data pipeline, which will handle even larger amounts of data—300+ megapixels per image and a wide field of view comparable to Hubble’s but at massive scale. Roman is designed for rapid surveys of the cosmos, tackling dark energy research and potentially discovering thousands of exoplanets.
  9. High-Performance Computing and HTCondor Managing enormous data sets requires distributing tasks across many machines. HTCondor is used to harness idle CPU time and run massive processing jobs in parallel, which is crucial for reprocessing data as calibration algorithms change. The cloud also plays a role, letting scientists spin up short-term resources.
  10. World Coordinate Systems with GWCS Astronomy relies on accurately mapping pixels to celestial coordinates. GWCS (Generalized World Coordinate System) is a Python framework that records the optical path from a star to a detector, encoding transformations so users can correlate image pixels with the actual sky. It’s a crucial piece for precision science.

Interesting Quotes and Stories

  • Megan reminisced about growing up in the 1980s, teaching herself programming on an Osborne computer because she wanted to play games—showing how early curiosity can lead to a career in astronomy software.
  • Mike highlighted how the data pipeline must account for multiple re-transmissions from JWST, describing the intricate system that ensures scientists see a complete picture despite data packets arriving out of order.

Key Definitions and Terms

  • Ephemeris: Positional data indicating where the telescope (or another celestial body) is over time. Essential for accurately calibrating observations.
  • Cosmic Rays: High-energy particles that can strike a detector and create spurious signals or “hits” in imagery. The calibration software flags and removes these artifacts.
  • Infrared Wavelengths: Electromagnetic radiation with longer wavelengths than visible light, enabling telescopes to see through dust and observe extremely distant or cool objects.

Learning Resources

If you’d like to develop or deepen your Python skills for astronomy, data science, or general programming, you can check out these courses:

Overall Takeaway

The James Webb Space Telescope embodies a new era of astronomy, fueled by an intricate Python ecosystem to capture, process, and deliver data. Whether monitoring exoplanets or observing the earliest galaxies, Python underpins everything from raw telemetry parsing to high-level scientific analysis. As you heard from Megan and Mike, it’s a testament to how flexible, open, and collaborative the Python community has become—making groundbreaking discoveries more accessible to scientists around the world.

Links from the show

James Web Space Telescope: webbtelescope.org
JWST at NASA: jwst.nasa.gov
JWST's YouTube channel: youtube.com

JWST Repo on GitHub: github.com/spacetelescope/jwst
STSci's AstroConda: ssb.stsci.edu/astroconda
Telescope pointing: github.com/spacetelescope/gwcs
Simulator: github.com/spacetelescope/webbpsf
STSci's Archive and Tools: archive.stsci.edu
htcondor: datasci.danforthcenter.org/htcondor
Silly faker: github.com/cube-drone/silly
Nancy Grace Roman Space Telescope: roman.gsfc.nasa.gov
Myst Parser: myst-parser.readthedocs.io
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