Learn Python with Talk Python's 270 hours of courses

Python for Astronomy with Dr. Becky

Episode #303, published Fri, Feb 12, 2021, recorded Thu, Feb 4, 2021

If you are involved in science or use computational tools in your work, you should be using code to solve your problem. On this episode, we have Dr. Becky Smethurst who's an astrophysicist at Oxford University. She uses Python to explore galaxies and black holes.

Learn how she's using Python to make new discoveries at the cutting edge of research and dive into a couple of her YouTube videos aimed at spreading scientific truth in an entertaining wrapper.

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

Episode Deep Dive

Guest Introduction and Background

Dr. Becky Smethurst is an astrophysicist at Oxford University whose work focuses on supermassive black holes and the evolution of galaxies. She analyzes enormous datasets, collaborates with international research teams, and uses Python extensively to model, visualize, and interpret astrophysical phenomena. Outside her research, Dr. Becky is deeply dedicated to science communication through her YouTube channel and popular science books. She also shares how hobbyist-friendly tools (like Jupyter notebooks) and open-source libraries (like AstroPy) empower her daily research.

What to Know If You're New to Python

Even if you are a beginner, you can follow many parts of this conversation if you know the essentials of using Python for data handling and visualization. Here are a few tips and points Dr. Becky raised to keep in mind:

  • You should be comfortable writing basic Python code to load, manipulate, and visualize data (e.g., using NumPy and Matplotlib).
  • Familiarity with Jupyter notebooks will help you understand quick explorations and iterative data analysis.
  • Realize that Python is often used with astronomy-specific libraries, such as AstroPy, to process and analyze large sets of astronomical data.

Key Points and Takeaways

  • 1) Why Python Is Essential for Astronomy Dr. Becky highlights that modern astrophysics involves sifting through massive datasets from telescopes and surveys. Python’s extensive scientific ecosystem (NumPy, SciPy, Matplotlib, Pandas, AstroPy) makes it the de facto choice for data cleaning, model fitting, and visualization. Moreover, Python’s readability and the community’s contributions (e.g., AstroPy and other open-source projects) make research and collaboration more efficient.
  • 2) Real-World Image Processing A big portion of astronomy relies on processing images from telescopes. Dr. Becky discussed removing noise from images and handling cosmic rays or satellite trails. She explained how each telescope’s detector has quirks that Python scripts can correct or calibrate using libraries like AstroPy.
  • 3) Handling Large Data Tables and Catalogs Dr. Becky shared examples of working with catalogs of 600,000+ galaxies in custom data formats (like FITS files). The conversation underscored why tools like pandas or NumPy arrays drastically outperform spreadsheets for such tasks, enabling quick queries and transformations without hitting row limits or performance bottlenecks.
  • 4) Jupyter Notebooks for Collaboration The ability to have live code, interactive plots, and textual explanations side-by-side is a game-changer for exploratory research. Dr. Becky often prepares Jupyter notebooks to share new plots or test results with her collaborators so they can quickly reproduce or adapt her code.
  • 5) Citizen Science and Machine Learning Dr. Becky highlighted crowdsourced projects like Galaxy Zoo and Planet Hunters, where people help classify galaxy shapes or exoplanet signals. These classifications feed machine learning algorithms to tackle even larger future surveys with billions of objects.
  • 6) Visualization for Scientific Insight From 2D scatter plots to 3D VR-ready simulations, data visualization allows astronomers to find new structures (e.g., radial flows, black hole activity) and to share them with a wider audience. Dr. Becky specifically mentioned using Plotly and Matplotlib for 2D/3D data explorations.
  • 7) Simulation and Model Fitting Some astrophysics projects revolve around simulating black hole interactions or star “spaghettification.” These rely on numerical methods coded in Python along with specialized libraries. Dr. Becky also called out Bayesian approaches, specifically an MCMC (Markov chain Monte Carlo) library, for improving fits and estimating uncertainties.
  • 8) Communicating Complex Science on YouTube Dr. Becky’s channel breaks down everything from how Python helps find exoplanets to busting space conspiracy theories. By capturing real examples of code (like analyzing star orbits) and astronomy “day in the life” time-lapses, she aims to humanize science and coding.
  • 9) Merging Hobby, Research, and Education A recurring theme was how Dr. Becky’s professional research workflows blend seamlessly with her outreach. She pointed out that a curious mind plus Python is enough to do real astronomy—from amateurs analyzing personal telescope images, to journaling new data from major telescopes.
  • 10) From IT to Pythonic Science Finally, Dr. Becky noted how many educational systems still rely on spreadsheets or minimal coding. Real-world astrophysics, however, thrives on the broad ecosystem of Python libraries, as well as the welcoming nature of the community—providing an excellent path for budding scientists looking to automate, innovate, and discover.

Interesting Quotes and Stories

“Even if you don’t think of yourself as a programmer, once you start writing code to do everyday tasks, you’ve effectively become one.” – Illustrating how necessity in research leads scientists to coding.

“It still blows my mind that we can do all of this in Python, and that I get to do it every day.” – On the excitement of unraveling cosmic mysteries with open-source tools.

Key Definitions and Terms

  • Spaghettification: The stretching effect objects experience near massive gravitational fields, like black holes, where the force at one end can be significantly stronger than the other.
  • Citizen Science: Involving the public in data collection or classification (e.g., Galaxy Zoo) to accelerate and scale scientific projects.
  • Markov chain Monte Carlo (MCMC): A statistical sampling technique to estimate model parameters and quantify uncertainty.

Learning Resources

If you want to strengthen your Python skills in preparation for data-driven projects like astronomy or other science domains, here are some courses that might fit your needs.

Overall Takeaway

Whether you’re running full-blown cosmological simulations or quickly cleaning a few thousand data rows, Python’s ecosystem offers an accessible way to transform raw information into scientific insights. Dr. Becky Smethurst’s experiences highlight how a curious mindset, some numeric fundamentals, and open-source libraries can empower anyone—astrophysicist or otherwise—to discover something truly new about the universe. And along the way, the collaborative spirit of Python (and astronomy) can accelerate learning, build community, and make science more open to everyone.

Links from the show

Dr. Becky on Twitter: @drbecky_
Dr. Becky's YouTube channel: youtube.com
5 ways I use code as an astrophysicist video: youtube.com
Astrophysicist reacts to funny space MEMES video: youtube.com
A day in the life of an Oxford University Astrophysicist: youtube.com
Book: Space: 10 things you should know: amazon.com

SpaceMemes
Apple maps: image
Otter space: image
Eclipses: image
Steals a cow: image
Black holes: image

YouTube live stream: 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