Materials for Scientific Python Course for astronomers of Moscow University
How to use this repository
Read files from
scientific_python folder in alphabetical order and try to understand how all prints
and asserts work.
This repository has a structure of a Python package with some additional files:
scientific_pythonfolder represents top level package of the same name. This package contains several sub-packages and modules. You can start with
a_introsub-package and read its modules one by one in alphabetical order. All modules can be used as separate modules and scripts without package installation
binfolder contains scripts that can be used after package installation. Now they are used for testing
docfolder is used for documentation. Now it contains only MS Word file with course annotation (in Russian)
misccontains two sub-folders related to
Juyternotebooks used in class:
setup.pyis used to install this package
requirements.txtfile contains Python dependencies of the project.
virtualenv_activation.shis a sample shell script (for *nix systems only) that can be used to activate
virtualenvand install the package. Use it by typing
source virtualenv_activation.sh. For exit virtualenv type
docker-compose.ymlfiles can be used to run the project inside
.dockerignoreis just a link to
.gitignore, it used to prevent load garbage into Docker container
Travisis a continuous integration (CI) system used to test this project with various Python versions, 2.7 and 3.5+ are supported
Remember to use Python 3, 3.6 and later is good enough in 2018. You can check python version typing in console
python3 --version or
import sys; print(sys.version) in Python itself
- Anaconda Python distribution is a good choice for scientific Python programming on every platform. It includes a lot of pre-compiled numerical and scientific packages and
condapackage manager where you can find even more packages, like
- Official Python distribution: good on Windows or macOS, when you like to build your environment from scratch.
Instead of official Python distribution I recommend to use Homebrew package manager, type
brew install python
Probably you already have Python 3, check its version before start. If you haven't use your Linus package manager to install
iOS doesn't have any application to use for scientific programming. The best choice is Pythonista paid application that can run and edit Python 3.5 code and supports
numpy package, but doesn't support
scipy and other useful packages.
PyDroid 3 looks good
Source code editors for Python
- IDLE: a simple Python source code editor. It is a part of Python standard library, so if you have Python, you probably have IDLE
- Visual Studio Code (do not be confused with Visual Studio, they are two different products): a powerful source code editor
- Spyder: the scientific Python development environment
- PyCharm: a powerful Python IDE (integrated development environment). PyCharm is closed source product, but Community edition is free to use and every student and professor can ask for a free professional version
Dive into Python
- Learn Python in Y minutes: short and deep language tutorial. This tutorial has Russian version
- Official Python tutorial
- Python for astronomers
- Python 3 in one picture: print it and enjoy
- Use of Python programming language in astronomy and science
- WTF Python
Classes materials (2018)
Classes have place in classroom 48 of Sternberg Astronomical Institute MSU at 9:00 on Wednesdays from September to December 2018. Development of the course in 2018 is supported by BASIS foundation.
|Date||Description||Materials||Links||Video (in Russian)|
|2018.09.05||Introduction, coursework requirements. About Python. Numbers, lists, if-else, while, Boolean variables||
||Python documentation, see section "Dive into Python" above||link|
|2018.09.12||Built-in collections: tuples, dictionaries, sets. for-in, in.||
||Iteration, "Hash table" Wikipedia article, CPython implementation of lists and tuples||link|
|2018.09.19||Strings: unicode and formating. Functions: functions as objects, lambdas, argument packing and unpacking||
||String formating (use "new" syntax), keyword arguments||link|
|2018.09.26||Some more details about strings: methods and
||Regular expressions (in Russian), iteration and generators, scope and namespaces, modules||link|
|2018.10.03||Jupyter notebook: a good way to use Python and another languages. Introduction in
||Jupyter website, Jupyter guide,
|2018.10.10||Multidimensional arrays in
|2018.10.17||Read of files and cats.
||Jupiter notebook and data files||
||Jupyter notebooks||"Scientific graphics in Python" (In Russian), Python matplotlib guide, "An introduction to Numpy and Scipy"||link|
|2018.10.31||Python packages and how to prepare them. Testing,
||Sample Python project, unit test example, Jupyter notebook with
||"Python modules and packages",
|2018.11.07||Introduction to Astropy. Constants, units, quantities. Coordinates: sky coordinates, Earth coordinates, rtansformations beetween frames. Breif introduction to
|2018.11.14||Least squares method usage with
|2018.11.21||Sky coordinate match:
|2018.11.28||Seminar on listeners' requests. Student Alexey Nikonov tells about annotation and animation in
|2018.12.05||Speed up Python code. Why Python functions and loops are slow and how to overcome it. Use the power of
||Jupyter notebooks, C++ and Python codes,
||"High Performance Python".
Classes materials (2017)
Seminars had place in classroom 17 of Sternberg Astronomical Institute MSU at 13:30 on Fridays from September to December 2017. Records of on-line translations of the seminars are hosted on YouTube.
|Date||Description||Materials||Video (in Russian)|
|2017.09.15||Introduction, coursework requirements. Why Python 3? Numbers, lists, if-else, loops.||
|2017.09.22||Boolean variables, lists, tuples, dictionaries, sets. Strings and their formatting. Functions, arguments packing and unpacking.||
|2017.09.29||Functions: default values of keyword arguments, docstrings. Iterators and generators. Modules: file.py as a module.||
|2017.10.06||Jupyter notebooks. Read and write files and cats. Introduction to
|2017.10.20||Read tabular data files with
|2017.11.10||Packaging of Python project. Classes: example and magic methods. Unit testing.||Notebook and script,
|2017.11.17||Two examples of
|2017.11.24||Dr. Ivan Zolotukhin tells about
|2017.12.01||Student Nikita Utkin tells about
||Scripts and notebook,
|2017.12.08||Parallel execution of Python code.
|2017.12.15||Cython language and C-code usage with Python.||Python, Cython and C code,
Copyright (c) 2017, Konstantin L. Malanchev.
All program code in this repository is distributed under the terms of the MIT license. All data files are properties of their authors, see
COPYRIGHT_NOTE files in folders with foreign data.