Introduction to Python workshop in the Department of Geology and Geophysics at the University of Hawaii at Manoa
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data
figures
notebooks
notes
.gitignore
README.md
countries-selected.txt
countries.txt
demographics-analysis.ipynb
demographics.csv
download_data.py
environment.yml
feedback.md
sample-data.txt

README.md

Introduction to Python Workshop at UH Manoa

Instructor: Leonardo Uieda

When: April 17, 19, and 20. 4:30pm - 6:30pm

Where: Room 703 in the POST building. Department of Geology and Geophysics.

What: We will teach a hands-on introduction to the Python programming language. You will not fall asleep with PowerPoint slides full of code, calculate Fibonacci numbers, organize lists of names, print all odd numbers between 0 and 30, or any of that programmer nonsense. You will write code from the start, work in pairs/groups, download data from the internet, load data, perform linear regressions, make figures and maps, and other things that you will actually need to do on a daily basis.

Bring: Participants must bring their own computers (Mac, Windows, or Linux) with the required software already installed (see What to install below). Contact me if you need any help before the workshop.

Goals

This is going to be a hands-on workshop of the basic concepts you'll need to use Python for your research and studies. Participants who complete the workshop should be able to use Python to gather data from one or more files, process the data, run an analysis, make publication quality figures, and save the output.

Schedule

Topics
Day 1
Introductions
First steps: Opening Python and running code
The Jupyter notebook
Documentation using Markdown
Using variables to store data
Day 2
Recap
Built-in functions and getting help
The power of libraries
Loading data with numpy
Computing with numpy arrays
Making plots with matplotlib
Day 3
Recap
Repeating actions with for loops
Specifying conditions with if statements
Making your own functions
Bonus: Artisanal data input
Bonus: Analysing our data with numpy and scipy

Shared class notes

We'll use Google Docs to edit shared class notes. Please keep the document open during class. You can post questions/comments/whatever on the notes or on the group chat.

  1. Notes for day 1
  2. Notes for day 2
  3. Notes for day 3

Data

Throughout the workshop, we will work with temperature data from Berkeley Earth.

We'll start working with the time series of average temperature in Hawaii and try to reproduce the figure from the website using Python tools.

Next, we will automatically download the temperature time series for a list of countries, make plots, and run some analysis on the data.

The data files are available in the data folder just in case we have network problems. The files were downloaded using the script download-data.py which is what we would write on day 2.

What to install

There are many ways to get Python on your system and it can be very confusing when you're first starting out. I don't recommend downloading it from python.org or using the Python that came with your system (common on Linux). Instead, use the Anaconda distribution. It will come with all the libraries you'll need and doesn't require administrative access to install.

Go to https://www.continuum.io/downloads and select the Python 3.6 version of the installer for your system. It's safe to use all the default configuration options when installing.

Even if you already have Python (say from your system package manager or ArcGIS, etc), I recommend that you install Anaconda to avoid problems with versioning.

You'll also need a text editor. If you don't already have one of your choice, I recommend installing Sublime Text (it's available for Linux, Windows, and Mac).

Please install all software BEFORE comming to the workshop. If you have any problems installing or don't know which version you need to download, come talk to me.

Recommended Literature

We will loosely follow the Python lessons from Software Carpentry. I highly recommend taking a look at all of their material. Everything there is worth learning.

See this blog post for more resources for getting started in Python: http://www.leouieda.com/blog/getting-started-with-python-for-science.html

To perfect your Python-fu, I highly recommend trying to solve the Python Challenge. It's a fun way to learn general Python skills, like parsing text, downloading web content, regular expressions, and much more. The challenges are usually very difficult but also very rewarding when you can complete them.

License

Creative Commons License
This content is licensed under a Creative Commons Attribution 4.0 International License.