Code

This page has documentation for the coding activities you can find on my GitHub here. More detailed info for each activity can be found in the individual activity README files on GitHub.


Coding Activities


My GitHub repository Astronomy has python activities on various topics in astronomy. They are in the form of interactive Jupyter notebooks which can be accessed and run online. They are intended to take 1-2 hours.

Each code has a teacher version with all outputs and completed code. These have the suffix Teacher. The student file is much smaller as it is missing the outputs and has code completition tasks for the students to complete.

At the start of the code is the Aim of the activity along with a Predict section which encourages the students to think about the topic before starting the activity.

The goal of the coding activities are to process and visualise data, and to extract physical insights from them (as described in the AAPT report below). However by performing the activities students will inevitably also learn debugging, how to convert theory/models into code, and how to present data formally in a document or presentation.

The outputs (images, movies etc) were designed to be a starting point for my students to put their own data and visualisations in their reports and presentations. My hope is this will promote a deeper understanding of the topic and better engage the students, encouraging ownership and pride in their work.


Running the Code


Try the Code: You can now test some of the activities on our JupyterHub. If you would like to do this please email me! Since Oct 2021 the server is no longer running continuously to reduce running costs. I will set it up for 48 hrs if you would like to test some activities.

When the server is running sign up here with a username and password then head over to hub.astropython.com and log in! (It's important to use the second link after signing up so you get sent to the Welcome document) The welcome document has links which pull the activities you want to try from my GitHub. If something doesn't work please let me know! The server is built for my students so it can only handle 20-30 people at a time. If you do test out some of the activities let me know what you think.

NOTE: Since the server is not running continuously, if you want to keep your work please download it to your local computer, do NOT assume it is safe forever on the hub.

Otherwise you can send individual notebooks (with the required files) to students and they can upload them to jupyter.org/try. If you have your own JupyterHub setup clone the repository and do as you will!

You can also use Google Colab which is free to use!


Adapting the Activities


You can adapt and use the activities how you like! Just remember to reference the original activity on GitHub.

You can make activities easier by:

  • Filling in more blanks for the students. Add more hints.
  • Doing a walkthrough with students or record you completing it if they're stuck.
  • Group students up to pair code activities or check each others work.
  • Fill in all the blanks. Have students simply run the code and answer text questions based on what they are doing!

You can make activites harder by:

  • Removing code and hints so there is more to complete.
  • Altering the instructions so the students have to do more independent research.
  • Use the challenges at the end of the activities as assessments.

Make activities easier for younger students and harder for older ones. Or maybe change the focus of an activity from code completion to data analysis with the figures the code creates, or perhaps a bug hunting exercise. The activities can be adapted endlessly.

This Jupyter Book has a treasure trove of tools and ideas for using notebooks in the classroom.


Inspiration from:

Adam LaMee, Scientific Computing Resources, Url: adamlamee.github.io/CODINGinK12/

Thomas Albin, Space Science with Python series, Url: https://twitter.com/MrAstroThomas

Peter Smith, Python Tutorials, Url: https://petercbsmith.github.io/

Brown & Wilson, Ten quick tips for teaching programming, PlosCompBiol, Url: doi.org/10.1371/journal.pcbi.1006023

American Association of Physics Teachers (AAPT), Computational Physics Report, Url: aapt.org/Resources/upload/AAPT_UCTF_CompPhysReport_final_B.pdf

PICUP, Integrating computing into physics, Url: compadre.org/PICUP/webdocs/About.cfm

astronomycenter Resources, Url: compadre.org/astronomy/index.cfm


Data Files


There is a Data directory alongside the activity directories which contains all the data files for all activities. For descriptions of all the data files available go to Resources in the navigation bar then Data.


Activities List

These are just brief summaries of each activity. Visit the activity directory on GitHub for the aim and prediction questions, all the inputs/data, and output images/files.


Click on one of the contents links below to jump to the activity.



AstPy-001 Intro ActivitiesGitHubLogoView on GitHub


A series of 10 intro activities (4 of which are live) to introduce students to Python, NumPy, Pandas, Matplotlib and other useful modules.


AstPy-002 Intermediate Intro ActivitiesGitHubLogoView on GitHub


COMING SOON - A series of 10 activities to introduce students to intermediate topics in Python.

bouncing balls

AstPy-003 Stellar FusionGitHubLogoView on GitHub


Introduces the atomic mass unit. Students calculate nuclear binding energies, mass defects, and mass excesses. Contains nuclear data (masses and binding energies) from the Atomic Mass Data Center.

binding energy

AstPy-004 Solar ImagesGitHubLogoView on GitHub


Students use the SunPy module to explore the sun in different wavelengths and can download an image of the sun taken on today's date. Both SDO and SOHO images are explored as well as the sunspot cycle and flares. Some SDO HMI and AIA FITS files are provided.

sun AIA images

AstPy-005 Solar RadiationGitHubLogoView on GitHub


Students are introduced to the blackbody curve, Wien's law, and the effective temperature of planets.

blackbody dists

AstPy-006 SunspotsGitHubLogoView on GitHub


Students track sunspots across the face of the sun and use that information to calculate the sidereal and synodic rotation rate of the sun. There is also code here that attempts to automatically detect and track sunspots.

sunspots

AstPy-007 Lunar SurfaceGitHubLogoView on GitHub


Students upload an image of the moon they took and then annotate it. From the image they calculate sizes and depths of craters using the SkyField package. Requires students to calcualte the resolution of their telescope (or camera). They can then compare their image to known data and the included Lunar Reconnaissance Orbiter (LRO) and Lunar Orbiter Laser Altimeter (LOLA) data.

annotated moon

AstPy-008 PlanetsGitHubLogoView on GitHub


Students compare data from the NASA planetary factsheet such as mass and radius and try and identify trends/groupings. The end of the assignment introduces students to exoplanet detection and observational biases.

density vs radius for planets

AstPy-009 Planetary InteriorsGitHubLogoView on GitHub


Students compare data on the interior compositions of the planets. They learn about compositional and mechanical layers and visualise the chemical composition of the Earth's crust.

planetary interiors

AstPy-010 Planetary AtmospheresGitHubLogoView on GitHub


Students compare data on the chemical composition of planetary atmospheres. They can also calculate the escape velocity of some gases and work out whether those gases can escape from the planets atmosphere.

atmospheric retention

AstPy-011 Earth's HeatGitHubLogoView on GitHub


Students model the geothermal gradient of the lithospehre and then plot the geotherm for the whole Earth. Students also calculate the energy transfer via conduction and latent heat.

Earth's geotherm

AstPy-012 Earth's AtmosphereGitHubLogoView on GitHub


Students visualise how the temperature, pressure, density, and speed of sound vary with geopotential altitude using the International Standard Atmosphere model. Temperatures are constructed from data but all other properties are calculated using the ideal gas law etc.

atmospheric retention

AstPy-014 Planetary RingsGitHubLogoView on GitHub


Students visualise the rings of Saturn and then the other gas giants using data from the Ring-Moon Systems Node of the Planetary Data System. They plot the inner satellites on their figures along with their Roche limits (rigid and fluid) to see which moons are about to break up!

saturn's rings

AstPy-015 Ring DynamicsGitHubLogoView on GitHub


Students visualise the Roche limit using the N-body simulation package rebound. They calculate the location of resonances between moons and between moons and ring particles. Then they identify ring features associated with these resonances. Finally they look briefly at shepherd moons.

shepherd moon sim

S001 Mars 2020 Launch WindowsGitHubLogoView on GitHub


To celebrate the landing of the Mars 2020 rover Perseverance students use basic algebra to calculate when the launch windows are for a Hohmann transfer orbit to Mars.

Hohmann orbit gif

S002 Team Seas - River PollutionGitHubLogoView on GitHub


Analyse plastic discharge by global and local rivers using data from the Ocean Cleanup Project.

River Plastics Map