Starter Kit

Welcome to the UChicago Physics Coding Club Starter Kit!

This Starter Kit provides some tools that will help get you started with coding with python, plotting and visualization, and data analysis.

Click here to go back to the main page.


Table of Contents

  1. Programming languages, software, and platforms
    1. python
    2. Installation
      1. macOS
      2. Windows
      3. Linux
      4. Chrome OS
      5. Browser
    3. python Software packages
    4. Jupyter notebooks
  2. Version control
    1. Git, GitHub
    2. Example
  3. Other useful information
    1. Slack channels
    2. Text editors
  4. Starter Kit Tutorials

Programming languages, software, and platforms

python

The Starter Kit and Tutorials will primarily use python, although any programming language will do.

python is a powerful, and high-level language that is used across much of academia and industry in one form or another, and so is a very sensible language to use here.

Installation

We have a full Jupyter lab environment available to use without any local installation here, which will give you access through your UChicago credentials to all the software you need for basic data analysis.

If you want to work locally, then the easiest way to get and manage all of these packages is through a package manager such as conda; we recommend using Anaconda for this.

This is easy to use on almost any operating system. Note: conda is available through both Anaconda and Miniconda; while both work, we will assume Anaconda throughout as that comes with all of the packages we will use and doesn’t require the use of the command line interface (CLI).

macOS

More detailed installation information here.

Apple provides most tools you would want through terminal.app, found in the ~/Applications/Utilities/ folder. While you don’t need to do use the CLI for most tasks, it offers a significant amount of power and flexibility and so can be valuable to learn.

Once you’ve installed Anaconda, you should be able to open up a terminal and type: conda --version to verify that conda has been successfully installed and is usable on your machine.

Windows

More detailed installation information here.

Microsoft’s prebundled CLI, Cmd.exe, lacks some important features that we will want for programming, so we recommend installing another terminal emulator. We have found that doing a full download of Cmder works well; there is also Microsoft’s Windows Subsystem for Linux for those more familiar with Linux.

During installation of Anaconda, you will be prompted on whether or not you want to add Anaconda to your PATH environment variable. While Anaconda does not recommend this, if you have not used python before then you should not run into any problems, and you may later wish that you had put Anaconda in your PATH (this can be done manually whenever you wish as well). Hence, provided you don’t have another installation of python on your machine, it will not hurt to add Anaconda to your path now, but you do not need to do so unless you are interested in working with the CLI.

Once Anaconda has been installed, you should be able to run it from the Start menu by opening the Anaconda prompt.

Linux

More detailed installation information here.

As with macOS, most (if not all) Linux distributions come prepackaged with fully usable terminal emulators and should be usable out of the box.

Once you’ve installed Anaconda, you should be able to open up a terminal and type: conda --version to verify that conda has been successfully installed and is usable on your machine.

Chrome OS

Google’s Chromebook operating system now (for versions 53 or newer) supports Android apps, which give more flexibility in terms of programming and development.

In particular, Termux gives you access to a fantastic termunal emulator similar to what you would find in a more traditional Unix (Linux, macOS, etc…) desktop environment. While Termux can get most, if not all, of the work we want done, the lack of a graphical user interface (GUI) means that Jupyter notebooks aren’t an option here. Furthermore, there is no easy installation of conda here either, so you will need to install most packages manually. Consequently, unless you are already familiar and comfortable with the CLI, you may want to look to the following section.

Browser

Depending on your operating system and hardware, the above options might not be viable for you, so there are some browser-based alternatives that should get you up-and-running quickly and easily. If you don’t want to install more software on your computer then this is also a good option; note that this method will not require the Anaconda installation.

Google’s Colaboratory is a fantastic option and well-suited for our purposes here as it comes with Jupyter and all of the packages we’re interested in using.

python Software packages

One of the primary sets of packages that we will be using is referred to as the scipy stack.

The reason for this is that it includes these incredibly powerful, ubiquitous, and useful packages:

All of these packages are installed by default with Anaconda, so you shouldn’t need to worry about getting these individually. If you find that you need some package that is not included with Anaconda, then the conda package manager provides an easy interface for installation. For instance, let’s say we needed to install numpy; then, simply run

conda install numpy

Some packages can’t be found in the conda repository but may be installable with pip, which is a python package manager. The syntax for pip is often similar:

pip install numpy

However, we don’t recommend using pip if you can use conda instead as conda has support for environments, which we won’t cover here but can be very useful when you have multiple projects simultaneously.

Jupyter notebooks

One of the easiest to use applications for python-based computational physics is Jupyter Notebooks.

These are interactive, easy-to-use interfaces that make writing simple and moderately complex software programs enjoyable and straightforward. The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text.

To run a Jupyter notebook, one simply needs to open a terminal and execute the following command: jupyter notebook which should begin a Jupyter notebook session in your default browser. If you are running Windows, you should also be able to click the Jupyter Notebook icon installed by Anaconda in the start menu.

Version control

Git, GitHub

git is a version-control system that allows you to track changes in your code and facilitate collaboration with others. git is used throughout the science and programming communities and can be an invaluable tool when working on coding projects.

Most people interact with git using GitHub (that’s this thing you’re using now on the web):

Graphical user interface (GUI) applications are also available for git:

For those familiar and comfortable with the command line, git can also be used directly from a terminal. Any method of using git should be fine, and you should familiarize yourself with using it as a regular part of your workflow.

Example

You are not only welcome, but encouraged to “fork” this repository directly to your own respository and develop it further

To do this:

  1. Fork this repository by clicking on the “Fork” button above
  2. Clone your fork of the repository to your computer (find repository in your GitHub user profile, and clone it from there)

If there are updates to this repository that you want to get:

  1. Check if your repository is in a clean state with git status
  2. If it is not, you will need to clean it up (more info below)
  3. If it is, then make sure you are on your master branch with git branch

If you aren’t in a clean state, you need to check it out with git checkout master Now you are ready to update:

git fetch
git merge

Now you should have the up-to-date repository.

  1. On your computer you should make a new branch if you want to play aroud
    git branch play
    git checkout play
    

    now you can make changes without conflicting with the master branch.

  2. To save your changes, you must add, commit, and push your updated files
    git add *
    git commit -m "Commit message"
    git push
    

    where * is shorthand for all of the files in your directory. Usually you’ll want to say a general idea of what your changes are in the commit message as other people may look at these to see when certain files were added or gained new features. You also don’t need to push right away.

There are a huge number of git and GitHub tutorials out there, but here are a few good ones:

Other useful information

Slack channels

A dedicated Slack discussion channel is available for real-time discussions, sharing of code and results, and other communications.

Sign-up at uchicagocodingclub.slack.com.

Once you’ve registered on the Slack workspace, feel free to ask questions in any of the channels or to send direct messages. Remember, don’t hesitate to ask for help!

Text editors

A common way to program is through text editors or integraded development environments (IDEs).

There are many good text editors that work on most systems:

These text editors can edit and run python source code (.py) files, but won’t be able to work with Jupyter Notebooks, so we recommend that you only use them if you feel more comfortable with programming outside of the notebook interface.

Starter Kit Tutorials

This Starter Kit includes a few basic tutorials to get you started with programming in python:

  1. Overview
  2. Jupyter
  3. Python
  4. NumPy
  5. Matplotlib

Once you’ve familiarized yourself with the content in these, you should be able to tackle some of the more in-depth tutorials.

Click here to go back to the main page.