Astro Teaching: Coding

Teaching Astronomy Remotely Using Coding

Here you will find information about my astronomy coding activities meant to be done in a high school astronomy course and were designed with remote learning in mind.


How can computing positively impact learning in astronomy classes? The term computational thinking is still not well defined, but we will use the constructs by Weintrop et al.,

  • data practices
  • modeling and simulation practices
  • computational problem solving practices,
  • systems thinking practices. ​1​

Note that only one of these constructs explicitly addresses writing code, where as all of them are a part of what science students should experience.

Weintrop, et al. 2016​1​


These lessons are intended to use guided inquiry and scaffolded experiences to let students interact with authentic data sets in meaningful scientific ways. The text is meant to allow inexperienced students to get a foothold without being left behind. Experienced students can be encouraged to explore and expand the code and the skeletal algorithms provided.

  • Use of authentic datasets
  • Basic data reduction techniques
  • Well-known visualization tools
  • Data science processes
  • Guided inquiry model: interactive learning by coding
Students work on a computing task.


CS Pedagogy Applied in Science Teaching

Well-researched computer science pedagogy can enhance the use of coding as an inquiry technique. Cognitive load theory explains how worked examples and easy-to-read code can lower barriers to understanding the use of code in a scientific context. ​2,3​

Using Markdown via the Google Colab interface in the labs allows the use of mixed-media such that students can type directly into the document where their code lives.


Cluster Distance with Photometry

Determine the distance to a globular cluster using time series photometry for an RR Lyrae variable star.

Portion of Cluster Lab

Equivalent Width with Spectroscopy

Investigate the relative abundances for nickel and europium in some advanced-stage stars using spectroscopy and the equivalent width measurement.

Portion of Spectroscopy Lab

Hubble’s Law with SDSS Galaxies

For a given set of galaxies associated with a particular plate, students can create and explore a Hubble’s Law plot of the actual data and use basic data science tools to explore the population of targets.

Portion of SDSS Lab


All of the labs used here were developed using Google Colab and published via GitHub. Google Colab uses a web-based Jupyter notebook implementation for Python coding.

Visit GitHub for code

Projects scaffolded with new coders in mind Cloud computing allows for collaboration
Only a browser and Internet connection required No software installation or configuration needed GitHub facilitates version control & open source

Virtual Teaching Means Cloud Coding


The data used in these labs was collected by the author using common astronomical techniques. The equipment required and the basic data reduction methods make this sort of data collection difficult for high school astronomy students.

Line of Best Fit in Hubble’s Law Lab with SDSS Data

Students are asked to visualize and interpret datasets using modern data science techniques in statistics and plotting. Common libraries and established algorithmic processes were used in the labs: Jupyter Notebook​4​, AstroPy​5,6​, AstroQuery​7​, MatPlotLib​8​, NumPy​9​, Seaborn​10​, SciPy​11​, SciKitLearn,​12​

Histogram Analysis in Hubble’s Law Lab with SDSS Data
Visualization of Galaxies by z Distance
Equivalent Width Lab – Data collected via Otto Struve Telescope and Sandiford Echelle Spectrograph at McDonald Observatory.
Cluster Distance Lab – Photometric time series of RR Lyrae stars in NGC 3201 collected via Skynet Robotic Telescope Network.
Hubble’s Law Lab – SDSS Baryon Oscillation Spectroscopic Survey combined galaxy spectra and photometry legacy data.


As science education attempts to increase the role of computation, researchers and educators increasingly need to develop better tools and techniques. If you are looking for ways to get involved in computing in science education, explore these resources.

I would like to share the work of a few people specifically that led to the labs published here and offer them my personal thanks.

Adam LaMee – Created ( which uses Google Colab projects published via GitHub for science teachers and students to use coding in specific scientific contexts. Adam’s work led directly to my attempts to use Google Colab for web-based coding labs. Stars Lab

Chris Orban – Co-created STEMcoding ( labs and the STEM coding YouTube channel for teaching introductory physics and astronomy topics using a coding with a modeling pedagogy.

STEMcoding Astronomy Lab

Stephen Shadle – My sometimes-collaborator and a physics and astronomy pre-service teacher created some web-based astronomy labs and simulations ( using real-world data sets. Be sure to check out the HR diagram simulation which improves on the UNL flash-based simulation.

H-R Diagram Simulation


These labs were developed as part of my graduate research in astronomy education using coding at the University of Houston in the College of Education. Thank you to Dr. Chris Sneden and Dr. Keely Finkelstein for their guidance and support. Thanks also to Eileen Grzybowski, Justin Hickey, and Olivia Kuper for help with data reduction and observing. Additionally, thanks to Dr. Sean Johnson and Dr. Britt Lundgren for help reducing the SDSS data. I would like to acknowledge the work of Stephen Shadle, Adam LaMee, Dr. Tor Odden, and Dr. Chris Orban as inspiration for my own work shown here.


  1. 1.
    Weintrop D, Beheshti E, Horn M, et al. Defining Computational Thinking for Mathematics and Science Classrooms. Journal of Science Education and Technology. 2016;25:127–147. doi:10.1007/s10956-015-9581-5
  2. 2.
    Morrison BB, Dorn B, Guzdial M. Measuring cognitive load in introductory CS. In: Proceedings of the Tenth Annual Conference on International Computing Education Research – ICER ’14. ACM Press; 2014:131–138. doi:10.1145/2632320.2632348
  3. 3.
    Skudder B, Luxton-Reilly A. Worked examples in computer science. In: Conferences in Research and Practice in Information Technology Series. ; 2014.
  4. 4.
    Kluyver T, Ragan-kelley B, Pérez F, et al. Jupyter Notebooks—a publishing format for reproducible computational workflows. Positioning and Power in Academic Publishing: Players, Agents and Agendas. Published online 2016:87–90. doi:10.3233/978-1-61499-649-1-87
  5. 5.
    Price-Whelan AM, Sipőcz BM, Günther HM, et al. The Astropy Project: Building an Open-science Project and Status of the v2.0 Core Package. The Astronomical Journal. 2018;156:123. doi:10.3847/1538-3881/aabc4f
  6. 6.
    Robitaille TP, Tollerud EJ, Greenfield P, et al. Astropy: A community Python package for astronomy. Astronomy and Astrophysics. 2013;558:1–9. doi:10.1051/0004-6361/201322068
  7. 7.
    Ginsburg A, Sipőcz BM, Brasseur CE, et al. astroquery : An Astronomical Web-querying Package in Python. The Astronomical Journal. 2019;157:98. doi:10.3847/1538-3881/aafc33
  8. 8.
    Hunter JD. Matplotlib: A 2D Graphics Environment. Computing in Science & Engineering. 2007;9:90–95. doi:10.1109/MCSE.2007.55
  9. 9.
    van der Walt S, Colbert SC, Varoquaux G. The NumPy Array: A Structure for Efficient Numerical Computation. Computing in Science Engineering. 2011;13:22–30. doi:10.1109/MCSE.2011.37
  10. 10.
    Waskom M, The seaborn development team. mwaskom/seaborn. Published online 2020. doi:10.5281/zenodo.592845
  11. 11.
    Virtanen P, Gommers R, Oliphant TE, et al. SciPy 1.0: fundamental algorithms for scientific computing in Python. Nature Methods. 2020;17:261–272. doi:10.1038/s41592-019-0686-2
  12. 12.
    Li H, Phung D. Journal of Machine Learning Research: Preface. Journal of Machine Learning Research. 2014;39:i–ii.

Leave a Reply