Practical Python Programming for Astronomers
Description of the course
- Informal course on practical Python programming for master students
- Offered from mid-Sep to mid-November 2019
- Schedule
- 16:00-18:00 on 17/Sep/2019
- 16:00-18:00 on 24/Sep/2019
- 16:00-18:00 on 01/Oct/2019
- 16:00-18:00 on 08/Oct/2019
- 16:00-18:00 on 15/Oct/2019
- 16:00-18:00 on 22/Oct/2019
- 16:00-18:00 on 29/Oct/2019
- 16:00-18:00 on 05/Nov/2019
- Venue
- Participants need to bring a computer.
- Recommended computer system for this course:
- operating system: BSD or Linux
- recommended BSD systems: NetBSD, FreeBSD
- recommended Linux system: Debian GNU/Linux
- BSD or Linux system can be installed as a guest system using virtualization software (e.g. Xen hypervisor) if you prefer to do so.
- If you use other operating systems, you need to set up an environment to execute Python scripts by yourself.
- text editor: Emacs
- Emacs has powerful support functions for writing source codes of various programming languages, including Python.
- terminal emulator: Xterm
- We will use command-line arguments to change the behaviour of programs.
- Python used for this course: Python 3
- Suggested readings:
- External programs used for this course:
- External Python modules used for this course:
- Numpy
- Matplotlib
- SciPy
- sqlite3
- Catalogues used for this course:
- Office hours: 14:00-15:00 on Mon, 15:00-16:00 on Wed
Hands-on sessions
- Session #1 (17/Sep/2019)
- making a simple Python script
- executing a Python script
- doing simple calculations using Python
- using math module of Python
- making and using your own function
- using command-line arguments
- using argparse module to analyse command-line arguments
- Session #2 (24/Sep/2019)
- using control flow statements “if”, “elif”, and “else”
- using control flow statement “for”
- using control flow statement “while”
- using control flow statement “continue”
- using control flow statement “break”
- using lists
- using dictionaries
- reading a file
- writing a file
- playing with Hipparcos catalogue
- playing with exoplanet catalogue
- playing with near-Earth asteroid catalogue
- Session #3 (01/Oct/2019)
- string manipulation
- making and using your own module
- playing with Hipparcos catalogue
- reading Hipparcos catalogue
- calculating absolute magnitudes
- calculating mean value
- calculating standard deviation
- average absolute magnitudes of O, B, A, F, G, K, and M dwarfs
- playing with NASA Exoplanet Archive
- playing with the data file on Minor Planet Center
- Session #4 (08/Oct/2019)
- Numpy
- installation
- suggested documents
- playing with Numpy array
- mathematical functions of Numpy
- sorting of Numpy arrays
- calculating statistical values (mean, median, variance, standard deviation)
- playing with Hipparcos catalogue using Numpy
- playing with NEA catalogue using Numpy
- playing with Exoplanet catalogue using Numpy
- Session #5 (15/Oct/2019)
- Matplotlib
- plotting a sine curve
- plotting data points
- plotting data points with error bars
- making a histogram
- Kepler's 3rd law
- Making a HR diagram of 30 bright stars
- Making a HR diagram using Hipparcos catalogue
- Orbital distribution of near-Earth asteroids
- Session #6 (22/Oct/2019)
- random numbers
- random numbers of uniform distribution
- random numbers of Gaussian distribution
- numerical integration
- trapezoidal rule of integration
- integrating sin(x)
- integrating Gaussian function
- Session #7 (29/Oct/2019)
- least-squares fitting
- errors of fitted coefficients
- degree of freedom, reduced chi-square, covariance matrix
- setting initial values for fitting coefficients
- weighted least-squares fitting
- ODR (Orthogonal Distance Regression)
- OLS (Ordinary Least-Squares) bisector
- Age of the solar system
- Session #8 (05/Nov/2019)
- relational database management system SQLite
- designing a table
- adding data to a table
- trying SQL queries
- using SQLite from a Python script
- playing with MPCORB asteroid orbit database
- playing with Hipparcos catalogue
- playing with NASA Exoplanet Archive
Kinoshita Daisuke