This lesson is in the early stages of development (Alpha version)

Python for Atmosphere and Ocean Scientists: Setup

Data

In preparation for these lessons, you will need to download the following two Python scripts and four netCDF files and place them in a new folder/directory:

  1. Make a new folder in your Desktop called data-carpentry.
  2. Download script_template.py and plot_precipitation_climatology.py and move them into that folder.
  3. Make a new folder in your data_carpentry folder called data. Download the following files and place them in that folder:

Software installation

In order to complete the lessons, you will need access to the following:

If you don’t already have these installed, please follow The Carpentries software installation instructions. You do not need to install R, SQL or any of the additional software listed at that site.

Troubeshooting

If you have any trouble with software installation, The Carpentries maintain a list of common issues on their Configuration Problems and Solutions wiki page.

Depending on time and wifi constraints, your workshop instructor may also ask that you install the python packages introduced in the first lesson ahead of time. They will specify whether to do this following the “default” or “conda environments” approach (see below for instructions).

Installation of python packages: Linux & Mac (default)

The required python packages can be installed at the bash shell as follows:

$ conda config --add channels conda-forge
$ conda install jupyter xarray netCDF4 cartopy cmocean

Installation of python packages: Windows (default)

Python packages can be added to your base environment via the Anaconda Navigator (which can be found at the Windows start menu):

Step 1: Add the conda-forge channel. Anaconda Navigator add conda-forge

Step 2: Install the jupyter, xarray, netCDF4, cartopy and cmocean packages one-by-one (click “apply” to install once selected) Anaconda Navigator install xarray

Installation of python packages: Linux & Mac (using conda environments)

The required python packages can be installed in a new conda environment called pyaos-lesson by executing the following commands at the bash shell:

$ conda config --add channels conda-forge
$ conda create -n pyaos-lesson jupyter xarray netCDF4 cartopy cmocean

You can activate this new environment as follows:

$ conda activate pyaos-lesson

(Or source activate pyaos-lesson if that doesn’t work.)

Type conda deactivate to exit that environment.

Installation of python packages: Windows (using conda environments and bash shell)

The conda command is not automatically available using Git Bash. This means that Windows users cannot create and activate a conda environment from the bash shell, which is an option in the first lesson. While this is not a big issue (the first lesson can be completed without creating a new environment), Windows users who would like to be able create and activate conda environments from the bash shell can do so by following one of these two options:

Option 1: Access the bash shell from the Anaconda Prompt using the posix package

  • Open the Anaconda Prompt program (via the Windows start menu)
  • Type conda install posix (this only needs to be done once)
  • Type bash to run the Bash Shell

Option 2: Update your Anaconda path so that conda is available using Git Bash

  • Open the Anaconda Prompt program (via the Windows start menu) and enter where python to find the path of the Anaconda3 directory (the output should show a path similar to C:\Users\Username\Anaconda3\python.exe)
  • Convert that path for use in the next step by doing the following:
    • Replace all instances of \ with /
    • Replace C: with /c
    • Replace python.exe with Scripts/activate
    • e.g. if you got C:\Users\Username\Anaconda3\python.exe from the previous step, you will use /c/Users/Username/Anaconda3/Scripts/activate for the next step
  • Go back to the terminal and run echo "source [Anaconda path]" >> ~/.profile && source ~/.profile, replacing [Anaconda path] with the path you generated in the previous step

Once conda is available at the bash shell, the required python packages can be installed in a new conda environment called pyaos-lesson by executing the following commands:

$ conda config --add channels conda-forge
$ conda create -n pyaos-lesson jupyter xarray netCDF4 cartopy cmocean

You can activate this new environment as follows:

$ conda activate pyaos-lesson

(Or source activate pyaos-lesson if that doesn’t work.)

Type conda deactivate to exit that environment.

Software check

To check that everything is installed correctly, follow the instructions below.

Bash Shell

Git

Anaconda