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.
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.
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.
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.
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 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:
Two monitors: If you have two monitors,
plan to have the tool you are learning up on one monitor and
the video conferencing software on the other.
Two devices: If you don't have two monitors,
do you have another device (tablet, smartphone) with a medium to large
sized screen? If so, try using the smaller device as your video
conference connection and your larger device (laptop or desktop)
to follow along with the tool you will be learning about.
Divide your screen: If you only have one device
and one screen, practice having two windows
(the video conference program and one of the tools you will be using
at the workshop) open together.
How can you best fit both on your screen?
Will it work better for you to toggle between them
using a keyboard shortcut?
Try it out in advance to decide what will work best for you.
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.
Search for `Software Center` in your Windows search bar and click on it once it is found
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.)
Double click on `Git 2.45.2` and then click `Install`
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).
Search for `Software Center` in your Windows search bar and click on it once it is found
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.)
Click the green `Install` button
Python Package Installation
Search for `Miniforge` in the Windows search and click on `Miniforge Prompt`
Enter the following into the Miniforge Prompt:
conda install pandas matplotlib jupyter m2-base
Miniforge will collect package metadata, solve the environment, and display packages to be downloaded and installed
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.
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.
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.
Install Python 3 by running the Miniforge3 shell installer using all of the defaults for installation.
Your web browser might need you to click the Allow Downloads prompt
After the download completes, open the Terminal app, cd ~/Downloads, run file, Space bar, yes, ENTER
cd ~/Downloads
Run the sh file by typing the filename and hitting the ENTER key and continue to follow the prompts
Type "yes" at the end so that it installs conda to the prompt
If you need to edit this use this command: conda config --set auto_activate_base false
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
Open the Miniforge Prompt
Enter the following into the Miniforge Prompt:
conda install pandas matplotlib jupyter m2-base
Miniforge will collect package metadata, solve the environment, and display packages to be downloaded and installed
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.
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.
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.