USGS CDI Software Carpentry Intro to Python Workshop Series

U.S. Geological Survey

Online

August 7th, 14th & 21st, 2024

9:00 am - 1:00 pm MT

Instructors: Madison Langseth, Chris Sherwood, Marc Hunter, Brandon Serna, Labeeb Ahmed

Helpers: Josh von Nonn, C. Justin Mayers, Bojan Milinic, Joshua May, Jordan Lubbers

General Information

Software Carpentry aims to help researchers get their work done in less time and with less pain by teaching them basic research computing skills. This hands-on workshop will cover basic concepts and tools, including program design, version control, data management, and task automation. Participants will be encouraged to help one another and to apply what they have learned to their own research problems.

For more information on what we teach and why, please see our paper "Best Practices for Scientific Computing".

Who: The course is aimed at graduate students and other researchers. You don't need to have any previous knowledge of the tools that will be presented at the workshop.

Where: This training will take place online. The instructors will provide you with the information you will need to connect to this meeting.

When: August 7th, 14th & 21st, 2024. Add to your Google Calendar.

Requirements: Participants must have access to a computer with a Mac, Linux, or Windows operating system (not a tablet, Chromebook, etc.) that they have administrative privileges on. They should have a few specific software packages installed (listed below).

Accessibility: We are dedicated to providing a positive and accessible learning environment for all. Please notify the instructors in advance of the workshop if you require any accommodations or if there is anything we can do to make this workshop more accessible to you.

Contact: Please email mlangseth@usgs.gov , gdonovan@usgs.gov or lhsu@usgs.gov for more information.

Roles: To learn more about the roles at the workshop (who will be doing what), refer to our Workshop FAQ.


Code of Conduct

Everyone who participates in Carpentries activities is required to conform to the Code of Conduct. This document also outlines how to report an incident if needed.


Collaborative Notes

We will use this collaborative document for chatting, taking notes, and sharing URLs and bits of code.


Surveys

Please be sure to complete these surveys before and after the workshop.

Pre-workshop Survey

Post-workshop Survey


Schedule


Setup

To participate in a Software Carpentry workshop, you will need access to software as described below. In addition, you will need an up-to-date web browser.

We maintain a list of common issues that occur during installation as a reference for instructors that may be useful on the Configuration Problems and Solutions wiki page.

Microsoft Teams

We will be using Microsoft Teams as the videoconferencing client.

Set up your workspace

Like other Carpentries workshops, you will be learning by "coding along" with the Instructors. To do this, you will need to have both the window for the tool you will be learning about (a terminal, RStudio, your web browser, etc..) and the window for the Teams video conference client open. In order to see both at once, we recommend using one of the following set up options:

This blog post includes detailed information on how to set up your screen to follow along during the workshop.

The Bash Shell

Bash is a commonly-used shell that gives you the power to do tasks more quickly.

  1. Search for `Software Center` in your Windows search bar and click on it once it is found
  2. Select `Applications` on the left menu and search for `Git`. (Git should have been added to your Software Center when you signed up for the Workshop. If you do not see it, please contact the service desk.)
    Screenshot of Software Center Applications
  3. Double click on `Git 2.45.2` and then click `Install`
    Screenshot of Software Center Git Install Button

This will provide you with both Git and Bash in the Git Bash program.

The default shell in Mac OS X Ventura and newer versions is Zsh, but Bash is available in all versions, so no need to install anything. You access Bash from the Terminal (found in /Applications/Utilities). See the Git installation video tutorial for an example on how to open the Terminal. You may want to keep Terminal in your dock for this workshop.

To see if your default shell is Bash type echo $SHELL in Terminal and press the Return key. If the message printed does not end with '/bash' then your default is something else, you can change your current shell to Bash by typing bash and then pressing Return. To check your current shell type echo $0 and press Return.

To change your default shell to Bash type chsh -s /bin/bash and press the Return key, then reboot for the change to take effect. To change your default back to Zsh, type chsh -s /bin/zsh, press the Return key and reboot. To check available shells, type cat /etc/shells.

Video Tutorial

Python

Python is a popular language for research computing, and great for general-purpose programming as well. Installing all of its research packages individually can be a bit difficult, so USGS recommends Miniforge, an all-in-one installer.

We will teach Python using the JupyterLab, a programming environment that runs in a web browser (JupyterLab will need to be installed along with a couple of other packages). For JupyterLab 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).

  1. Search for `Software Center` in your Windows search bar and click on it once it is found
  2. Select `Applications` on the left menu and search for `Miniforge`. (Miniforge should have been added to your Software Center when you signed up for the Workshop. If you do not see it, please contact the service desk.)
  3. Screenshot of Software Center Applications
  4. Click the green `Install` button
  5. Screenshot of Software Center Miniforge Install Button

Python Package Installation

  1. Search for `Miniforge` in the Windows search and click on `Miniforge Prompt`
  2. Enter the following into the Miniforge Prompt:
    1. conda install pandas matplotlib jupyter m2-base
    2. Miniforge will collect package metadata, solve the environment, and display packages to be downloaded and installed
    3. Miniforge will ask if it is okay to proceed. Enter
      y
      to continue your installation

Get the Data

You need to download some files to follow this lesson.

  1. Download shell-lesson-data.zip and move the file to your Desktop.
  2. Unzip/extract the file. Let your instructor know if you need help with this step. You should end up with a new folder called shell-lesson-data on your Desktop.
  3. Download python-novice-gapminder-data.zip. and move the file to your Desktop. Thees data are taken from the gapminder dataset.
  4. Unzip/extract the file. Let your instructor know if you need help with this step. You should end up with a new folder called python-novice-gapminder-data on your Desktop.

  1. Open https://conda-forge.org/miniforge/ with your web browser.
  2. Download Miniforge3 for MacOSX
  3. Screenshot of Miniforge MacOSX Download
  4. Install Python 3 by running the Miniforge3 shell installer using all of the defaults for installation.
  5. Your web browser might need you to click the Allow Downloads prompt
  6. After the download completes, open the Terminal app, cd ~/Downloads, run file, Space bar, yes, ENTER
  7. cd ~/Downloads
  8. Run the sh file by typing the filename and hitting the ENTER key and continue to follow the prompts
  9. Type "yes" at the end so that it installs conda to the prompt
  10. If you need to edit this use this command: conda config --set auto_activate_base false
  11. Screenshot of Miniforge MacOSX Download
    • If the Mac user requires admin privilege to install the program, they can try to elevate temporarily by using the "Make Me an Admin" tool in the USGS Self Service Mac app.
    • If that does not work, then a ticket can be sent to Tier 2 to perform the installation.
    </ol>

    Python Package Installation

    1. Open the Miniforge Prompt
    2. Enter the following into the Miniforge Prompt:
      1. conda install pandas matplotlib jupyter m2-base
      2. Miniforge will collect package metadata, solve the environment, and display packages to be downloaded and installed
      3. Miniforge will ask if it is okay to proceed. Enter
        y
        to continue your installation

      Get the Data

      You need to download some files to follow this lesson.

      1. Download shell-lesson-data.zip and move the file to your Desktop.
      2. Unzip/extract the file. Let your instructor know if you need help with this step. You should end up with a new folder called shell-lesson-data on your Desktop.
      3. Download python-novice-gapminder-data.zip. and move the file to your Desktop. Thees data are taken from the gapminder dataset.
      4. Unzip/extract the file. Let your instructor know if you need help with this step. You should end up with a new folder called python-novice-gapminder-data on your Desktop.