Skip to content

hvwaldow/pyws-BE-15-2-26

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c2sm logo

Scientific Programming in Python for Atmospheric Sciences and Climatology

Harald von Waldow <[email protected]> | Bas Crezee | Nicolas Piaget

How to use it - Instructors
How to use it - Learners
Format | Audience | Duration | Bonus Material | Feedback | License


Format

The lectures mostly consist of IPython Notebooks. There is an "Intro" slide-deck and one related to Exercise 3 in the folder "slides".

Audience

Python novices who should have programming experience in other languages. A number of examples and problems are drawn from the field of Atmospheric Dynamics and Climate Impact Research.

Duration

An eight hour day. This is enough time to cover Exercises 1 through 4.

Bonus Material

Exercise 5 is not really an exercise but rather a very explicit walk through the solution of a real world problem that combines several powerful packages. This Notebook uses PIL, Cartopy, matplotlib, CDO.py, requests, Pandas to solve a GIS-like problem. This Notebook could form the basis of a final exercise in an advanced workshop that deals with the visualization of geocoded data.

Exercise 6 are some basic (and rather simple) Python coding exercises. In previous workshops they got not so stellar marks in the evaluation. They are left so that interested participants can use them on their own.

How to use it

Instructors

In case you have a computer lab at your hands that fulfills some basic requirements, we recommend that you have a look at the ready-made, robust, and well tested setup procedure here.

In case you have not, you want to set up the participant's computers individually (or have them do the setup) as explained in the section below.

We found that the material provided by Software Carpentry is an extremely useful resource, in particular when it comes to workshop organization and teaching skills.

Learners

1. Download

Either

git clone https://github.com/C2SM/pyws-BE-15-2-26.git <pyws-directory>

in case you are familiar with the command line and have git installed.

Otherwise download the zip-archive and unpack. This will yield a directory pyws-15-2-26-master, that contains everything. Feel free to rename that directory to anything you want (<pyws-directory>) in the following.

2. Installation of Python modules and start IPython Notebook

These recommendations were changed (2015-04-13).

Realizing the difficulties that might arise due to interactions of system - Python and workshop - Python -- even if using a virtualenvironment, we now recommend for all OS (Windows, OS X, Linux) the Anaconda Python distribution. Next to a quick setup to work with the tutorial material, this also provides you with a very comprehensive environment of the latest Python packages, suited for almost all tasks. (h/t Chris Barker).

a) Installation with Anaconda
  1. Download Anaconda: http://continuum.io/downloads Use Python 2.7 (as opposed to 3.4)

  2. Open the "Anaconda Command Prompt" (Windows) or or just a terminal window (OS X, Linux).

  3. Update conda and anaconda with the latest packages:

    conda update conda
    conda update anaconda
  4. Install some additional packages:

    conda install basemap
    conda install netCDF4
    pip install urllib3
    pip install python-magic
    conda install shapely
    pip install pyshp
    pip install cartopy
    pip install cdo

    In case one of the pip install commands above fails (because your machine is not set up to do the necessary build), look for a binary distribution using binstar, e.g.

    binstar search cartopy
  5. Launch the "Anaconda Ipython Notebook" (Windows), or simpy type

    ipython notebook --pylab=inline

    at the command prompt (OS X, Linux) and navigate to the exercises.

The binstar channel https://conda.binstar.org/ioos is worth a closer look. It contains around 100 packages contributed by the U.S. IOOS Integrated Ocean Observing System community. Not just for this tutorial, but also to see what other geoscientists are using.

Have fun!

b) Installation for real programmers™, using a UNIXy system such as Linux or OS X

execute the setup script:

cd <pyws-directory>
chmod u+x setup.sh
./setup.sh

This will create (download, compile, install) a "virtual environment", that is a python-interpreter and all necessary library packages into the directory <pyws-directory>/venv. It is a neat way to organize Python projects and makes you independent of the system - Python installation. The virtual environment will take up about 350 MB. The only requirement for this to work is that you already have any (well, >=2.6) version of Python installed system-wide that includes the virtualenv package. Also building the necessary modules requires your system to have the build-tool-chain (compilers, etc.) installed. This should be no issue for all stock Linux distributions.

Activate the virtual environment:

source venv/bin/activate

Start the notebook:

ipython notebook --pylab=inline

Enjoy!

Feedback

I would be very happy to hear from you (mail to [email protected]) in case you give this course a chance, be it as an instructor (who maybe mixes parts of this workshop with her own material), as a learner who attended one of our workshops, or as independent learner who uses this material for self-study.

Particularly welcome are problem reports, errors, criticism.

License

Creative Commons License
The material in this repository is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

About

Scientific Programming in Python for Atmospheric Sciences and Climatology

Resources

License

Stars

Watchers

Forks

Packages

No packages published