Course introduction

A. Overview

Am I ready to take this course?

Some programming experience will help, but is not required. If you have no programming experience, I strongly encourage you to go through the first handful of modules on the Codecademy Python course as soon as possible. During the semester, you may want to take more of the modules, and you should plan to spend extra time on this class.

There are lots of online resource that you can use to supplement things we learn in class. Some examples are:

What computational resources do I need for class?

I assume you have a laptop that you will bring to class and use to follow along. If you don't have access to some sort of portable device that you can use in class, please let me know as soon as possible.

How is this for geosciences specifically?

The goal of this class is to provide information for all fields in geoscience. To that end, I will try to cover topics from geology, geography, atmospheric sciences, and oceanography. Specifically, I will focus on 1D timeseries, and 2D geospatial (i.e., on a map) analysis. If you have any topics you would like to cover, please let me know, and I will do our best to accommodate.

Class setup

Class format

We will go through course materials during class time. You should bring a laptop to class so that you can follow along and participate in exercises. Also, course materials are interactive, so you can learn by running code snippets as we go and asking questions.

Course materials

The course materials are available in the class repository, which are provided in your account on redfish. They are in the form of Jupyter notebooks. More information on notebooks in the next section. You should start each class by clicking on the appropriate materials in the weekly schedule.

You'll do your work in your account on a local workstation. You can access this using a web browser pointed to:

https://redfish.geos.tamu.edu:8000

and you log in with your netid and a password that I have emailed to you.

IMPORTANT: To work on redfish when off campus, you need to first set up a VPN connection. Set this up for your laptop by visiting https://connect.tamu.edu and follow instructions there. You'll need to sign in with your netid, and click on the little blue link that says "AnyConnect VPN" if and when you find that "Web-based installation was unsuccessful" to install Cisco AnyConnect (you will no longer use the web-based installer after this). When you open the Cisco application on your computer, you will need to fill in "connect.tamu.edu" in the little box, then use your netid and university password to connect. Then you can run this application to use your computer as if you are on campus.

Course textbook

There is no textbook for the course. But if you'd like an outside resource, here are two recommendations:

  1. From O'Reilly, Learning Python: http://www.amazon.com/Learning-Python-Edition-Mark-Lutz/dp/1449355730 (you can find both print and e versions)
  2. Allen Downey has written a number of books on Python and related scientific subjects. And as a bonus, they are free (digital versions): http://greenteapress.com/wp/. In particular you would want to check out Think Python (2nd edition).

B. Jupyter notebooks

This file format makes it easy to seamlessly combine text and code. The text can be plain or formatted with Markdown. The code can be written in over 40 languages including Python, R, and Scala. Most importantly, the code can be interacted with when the notebook is opened in a local (that is, on your computer) iPython server. Alternatively, it can simply be viewed through a github repository (like this very notebook) or through nbviewer.

JupyterHub

You all have a username and password on a local machine that is running a server for us to use in class. By using this, we will be able to avoid a lot of installation issues that occur from using different operating systems, etc. You'll be able to run class materials (in the form of Jupyter notebooks) through this server via your web browser as well as create and work on homework assignments. If you prefer, you are welcome to run Python on your own computer, but you will need to do that mostly on your own. If you go that route, I recommend using Python 3 (which we will be using in class) and a distribution from Anaconda. We'll talk about it as a class later in the semester, too. I recommend you all use this system I have set up for you. It will integrate nicely for our homeworks, too.

To access the server, open your web browser and navigate to https://redfish.geos.tamu.edu:8000 and sign in with the username and password that I have emailed you. I've already set it up so that you can access materials and create notebooks within this system.

Create a new notebook

Start up your local notebook server in your new repo and create a new Jupyter notebook from the local server page.

Choose syntax for a cell

Notebooks are built of cells. Cells can have multiple built-in formats including code and Markdown for text. You can select the desired format from a dropdown menu at the top.

If you want to type words, use "Markdown"; if you want to write code, choose "code".

Move between cells

To run a given cell, type [shift-enter] which active in that cell. You can run all of the cells with Cell > Run all; other variations are available in that drop down menu.

Homework

We'll discuss homework soon and go through details. It will be in the form of Jupyter notebooks and will probably be submitted through JupyterHub.

On-campus access

If you want to connect to redfish from off-campus (including all Galveston students always), you'll need to use VPN. You can do so by following directions at https://connect.tamu.edu.


The material below is bonus for any students that are interested in using a terminal window on their own computer for running Python. We won't go through it in class.

Command-line interface

A command-line interface is a way to interact with your computer using text instead of a Graphical User Interface (GUI), a GUI being visually based with icons etc. We will use these in this class. On a Macintosh or Linux machine, this is a terminal window. On a PC this is often called a command prompt.

Here are some commonly-used commands:

  • cd [path]: change directory from current location to [path]. cd .. can be used to move up a single directory, and cd ../.. moves up two directories, etc.
  • pwd: print working directory, as in write out the current location in the terminal window.
  • ls: list files in current directory. ls -l list files in long format to include more information, ls -a to list all files even those that are usually not shown because the have a . in front, ls -h to show file sizes in human readable format. Flags can always be combined to use multiple options at once, as in ls -ah to show all files in human readable format.
  • [tab]: Tab completion. You can always push tab in the terminal window to see available options. As you have some letters entered and push tab, the options will be limited to those that fit the pattern you have started.
  • mkdir [dirname]: make directory called dirname.
  • rm [filename]: remove a file called filename. To remove a directory called dirname, use rm -r [dirname].