This repository contains the material taught at the OpenAstronomy workshop at Freiburg in February 2017. The first day is an introduction to Python for scientists already familiar with programming concepts, and the second day covers Astropy and SunPy.
The introductory Python lessons and the setup instructions below are adapted from the excellent Software Carpentry material.
If you have any questions about this workshop or its contents, or if you would like to arrange a similar workshop, feel free to contact Stuart Mumford or Drew Leonard.
Day 1 | Day 2 | |
---|---|---|
09:00 | Introduction and software setup | -- |
09:30 | Version Control with Git | Intro to SunPy |
10:50 | Coffee | Coffee |
11:10 | An Introduction to Python | Images in Solar Astronomy |
12:30 | Lunch break | Lunch break |
13:30 | Units and Plotting | Obtaining Solar Data |
14:50 | Coffee | Coffee |
15:10 | Exercise: Approximating Pi (end 16:30) | Exercise: Inspecting Spectral Data (end 16:00) |
To participate in the workshop, you will need access to the software described below. In addition, you will need an up-to-date web browser.
Git is a version control system that lets you track who made changes to what when and has options for easily updating a shared or public version of your code on github.com. You will need a supported web browser (current versions of Chrome, Firefox or Safari, or Internet Explorer version 9 or above).
Download the Git for Windows installer. Run the installer and follow the steps below:
- Click on "Next".
- Click on "Next".
- Click on "Next".
- Click on "Next".
- Click on "Next".
- Select "Use Git from the Windows Command Prompt" and click on "Next". If you forgot to do this programs that you need for the workshop will not work properly. If this happens rerun the installer and select the appropriate option.
- Click on "Next". Keep "Checkout Windows-style, commit Unix-style line endings" selected.
- Select "Use Windows' default console window" and click on "Next".
- Click on "Next".
- Click on "Finish".
This will provide you with both Git and Bash in the Git Bash program.
For OS X 10.9 and higher, install Git for Mac by downloading and running the most recent "mavericks" installer from this list. After installing Git, there will not be anything in your /Applications folder, as Git is a command line program. For older versions of OS X (10.5-10.8) use the most recent available installer labelled "snow-leopard" available here.
If Git is not already available on your machine you can try to install it via your distro's package manager. For Debian/Ubuntu run sudo apt-get install git and for Fedora run sudo yum install git.
Python is a popular language for scientific computing, and great for general-purpose programming as well. Installing all of its scientific packages individually can be a bit difficult, so we recommend Anaconda, an all-in-one installer.
We will teach Python using the Jupyter (IPython) notebook, a programming environment that runs in a web browser. For this to work you will need a reasonably up-to-date browser. The current versions of the Chrome, Safari and Firefox browsers are all supported (some older browsers, including Internet Explorer version 9 and below, are not).
- Open http://continuum.io/downloads with your web browser.
- Download the Python 3.5 installer for Windows.
- Install Python 3.5 using all of the defaults for installation except make sure to check Make Anaconda the default Python.
- Open http://continuum.io/downloads with your web browser.
- Download the Python 3.5 installer for OS X.
- Install Python 3.5 using all of the defaults for installation.
- Open http://continuum.io/downloads with your web browser.
- Download the Python 3.5 installer for Linux.
- Install Python 3.5 using all of the defaults for installation. (Installation requires using the shell. If you aren't comfortable doing the installation yourself stop here and request help at the workshop.)
- Open a terminal window.
- Type
bash Anaconda
and then press tab. The name of the file you just downloaded should appear. - Press enter. You will follow the text-only prompts. When there is a colon at the bottom of the screen press the down arrow to move down through the text. Type yes and press enter to approve the license. Press enter to approve the default location for the files. Type yes and press enter to prepend Anaconda to your PATH (this makes the Anaconda distribution the default Python).
Given that you have installed Python using Anaconda, we can use the Anaconda environment to install SunPy too.
- To install SunPy launch a system command prompt or the 'Anaconda Command Prompt' (under Windows).
- Configure conda for sunpy downloads:
conda config --add channels conda-forge --add channels astropy
Then to install SunPy
conda install sunpy astroquery