Skip to content

Astrojigs/PythonAstronomyWorkshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Astropy License Jupyter

Python Astronomy Workshop

A hands-on workshop for learning astronomy with Python
From Python basics to real astronomical data analysis

Organized by Wilson College in collaboration with IAPT


About

This repository is a complete learning resource for undergraduate and postgraduate students who want to explore astronomy through Python programming. Whether you're writing your first line of code or already comfortable with Python, this workshop takes you from the fundamentals all the way to analyzing real astronomical data.

What you'll learn:

  • Python fundamentals and scientific computing with NumPy
  • Astronomical calculations using Astropy (units, coordinates, time, constants)
  • Curve fitting and numerical methods with SciPy
  • Working with real astronomical data formats (CSV, FITS)
  • Data analysis and visualization with Pandas and Matplotlib

Learning Path

The materials are structured as a progressive learning journey:

 START HERE
     |
     v
 [1] Getting Started .............. Jupyter setup & environment
     |
     v
 [2] Session 1 .................... Python basics, NumPy arrays
     |
     v
 [3] Session 2 .................... Astropy: units, coordinates, time
     |
     v
 [4] Lecture - 27 Dec ............. Functions, curve fitting, SciPy
     |
     v
 [5] Lecture - 28 Dec ............. Pandas, CSV & FITS data import
     |
     v
 [6] Assignments .................. Test your understanding
     |
     v
 [7] Additional Questions ........ Challenge problems
     |
     v
  DONE! You're ready for research-level data analysis

Repository Structure

PythonAstronomyWorkshop/
|
|-- lectures/                        # Core workshop materials
|   |-- Getting started.ipynb             # Setup & Jupyter intro
|   |-- Session 1 - Basics & Numpy.ipynb  # Python fundamentals + NumPy
|   |-- Session 2 - Astropy.ipynb         # Astropy deep dive
|   |-- Lecture Notes for 27th Dec 2024.ipynb  # Functions & curve fitting
|   |-- Lecture Notes for 28th Dec 2024.ipynb  # Data import & analysis
|   |-- additional_questions.md           # Challenge problems with solutions
|   +-- data/                             # FITS files for exercises
|
|-- assignments/                     # Practice & assessment
|   |-- Assignments.ipynb                 # Problem sets
|   +-- Assignment Solutions.ipynb        # Detailed solutions
|
|-- Referring Docs/                  # Quick-reference guides
|   |-- Python Quick Guide.ipynb
|   |-- Curve Fitting and Numerical Computation Reference.ipynb
|   |-- Astronomical Coordinate Conversion Reference.ipynb
|   |-- Working with FITS Files.ipynb
|   +-- Sample Data Sets for Python Astronomy Workshop.ipynb
|
|-- data/                            # Datasets
|   +-- Cepheids.csv                      # Cepheid variable star data
|
|-- requirements.txt
+-- LICENSE

Getting Started

Prerequisites

  • Python 3.9+ installed (Anaconda recommended)
  • Basic familiarity with using a terminal/command line
  • No prior astronomy knowledge required!

Installation

1. Clone the repository

git clone https://github.com/Astrojigs/PythonAstronomyWorkshop.git
cd PythonAstronomyWorkshop

2. Create a virtual environment (recommended)

python -m venv venv
source venv/bin/activate        # macOS/Linux
venv\Scripts\activate           # Windows

3. Install dependencies

pip install -r requirements.txt

4. Launch Jupyter

jupyter lab

Then open lectures/Getting started.ipynb to begin!

Using Google Colab

If you prefer not to install anything locally, you can open any notebook directly in Google Colab by uploading the .ipynb files.


Workshop Schedule

Date Topic Notebook
Day 1 Python basics, NumPy, functions Session 1 - Basics & Numpy.ipynb
Day 2 Astropy: units, coordinates, constants, time Session 2 - Astropy.ipynb
27 Dec Functions, curve fitting, SciPy Lecture Notes for 27th Dec 2024.ipynb
28 Dec Pandas, CSV, FITS file handling Lecture Notes for 28th Dec 2024.ipynb
30 Dec Exoplanet data analysis Coming soon
31 Dec Cosmology & solar flare analysis Coming soon
1 Jan X-ray binary data analysis Coming soon

Topics Covered

Python Fundamentals
  • Variables, data types, and operators
  • Lists, tuples, dictionaries, and sets
  • Control flow (if/else, loops)
  • Functions and list comprehensions
  • String formatting and operations
Scientific Computing with NumPy
  • Array creation and manipulation
  • Indexing, slicing, and reshaping
  • Mathematical and statistical operations
  • Trigonometric functions
  • Random number generation
Astronomy with Astropy
  • Unit handling and conversions
  • Physical constants (G, M_sun, c, etc.)
  • Celestial coordinate systems (ICRS, Galactic, AltAz)
  • Time handling and Julian dates
  • Equivalencies (mass-energy, parallax, Doppler)
Curve Fitting & Numerical Methods
  • Linear and nonlinear curve fitting with scipy.optimize.curve_fit
  • Numerical integration with scipy.integrate.quad
  • Root finding with scipy.optimize.root
  • Fitting real astronomical data (Cepheid light curves)
Data Analysis
  • Reading CSV and FITS files
  • Pandas DataFrames: filtering, grouping, aggregation
  • FITS header inspection and data extraction
  • Coordinate transformations on datasets
  • Data visualization with Matplotlib

Reference Guides

The Referring Docs/ folder contains standalone reference notebooks you can use anytime:

Guide Description
Python Quick Guide Python syntax and essential libraries cheat sheet
Curve Fitting Reference Detailed curve fitting and numerical computation examples
Coordinate Conversion Reference Astronomical coordinate systems and transformations
Working with FITS Files Complete guide to FITS file operations
Sample Data Sets Overview of available datasets for practice

Assignments

The workshop includes hands-on assignments to reinforce each topic:

  • Assignment 1 — Functions, curve fitting, and numerical integration

    • Calculate celestial distances from equatorial coordinates
    • Fit sinusoidal curves to Cepheid variable star data
    • Integrate blackbody radiation curves
  • Assignment 2 — Data importing and analysis

    • Filter and group star catalog data
    • Read and visualize FITS image data
    • Convert between coordinate systems
  • Challenge Problems — See additional_questions.md for advanced problems including galactic time calculations, Kepler's law fitting, supernova luminosity decay, and more.


Dependencies

Package Version Purpose
astropy >= 5.3 Astronomical computations
numpy >= 1.23 Numerical computing
scipy >= 1.10 Scientific computing & curve fitting
matplotlib >= 3.7 Data visualization
pandas >= 2.0 Data analysis
jupyterlab >= 4.0 Interactive notebooks

Contributing

Contributions are welcome! If you'd like to add new lecture materials, fix errors, or improve explanations:

  1. Fork the repository
  2. Create a feature branch (git checkout -b add-new-lecture)
  3. Commit your changes
  4. Open a Pull Request

License

This project is licensed under the MIT License — see the LICENSE file for details.


Made with curiosity about the cosmos
Workshop by Jigar Patel | Wilson College & IAPT

About

Materials and exercises for a hands-on introductory workshop on using Python and Astropy for astronomical calculations, data analysis, and visualization. Ideal for undergrad/grad students and astronomy enthusiasts eager to learn Python-based techniques for exploring and interpreting astronomical data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors