Software Carpentry at UCL: Bash, Git, and Python Workshop

:tada: Welcome!

:calendar: Tuesday 30th May - Wednesday 31st May

:ballot_box_with_check: Sign-in

Exercises

Lesson Material


Staff

Tuesday 30th:

Instructors: Samantha Ahern (AM), Ed Lowther (PM)
Helpers: David Wong, Will Graham, Cristian Dinu

Wednesday 31st:

Instructors: Paddy Roddy (AM), Will Graham (PM)
Helpers: Harvey Mannering, Paddy Roddy, Will Graham

Sign In

Add your name to the lists below to sign-in for each day.
Tip: You can add an extra bullet-point by creating a new line that starts with a dash - followed by a space.

Tuesday 30th (Bash and Git)

Add your name to the list below to check-in for Tue 30th May:

Wednesday 31st May (Python)

Feedback and Surveys

We are constantly looking to improve our delivery of these workshops and welcome your feedback on any aspect of the day; the teaching, schedule, location, you name it!

Please feel free to add feedback here during the day. Additionally, there are also the

that we would ask you to fill in, if you have the time.

Notes

If you missed any commands that Ed ran, you can find them here:
https://swcarpentry.github.io/git-novice/07-github.html#ssh-background-and-setup

https://swcarpentry.github.io/git-novice/02-setup.html

Paddy’s plotting code:

fig = plt.figure(figsize=(10, 3))
ax1 = fig.add_subplot(1, 3, 1)
ax2 = fig.add_subplot(1, 3, 2)
ax3 = fig.add_subplot(1, 3, 3)

ax1.set_ylabel("average")
ax1.plot(data.mean(axis=0));
ax1.set_ylim(0, 20)

ax2.set_ylabel("maximum")
ax2.plot(data.max(axis=0));
ax2.set_ylim(0, 20)

ax3.set_ylabel("minimum")
ax3.plot(data.min(axis=0));
ax3.set_ylim(0, 20)

fig.tight_layout()

ax1.set_xlabel("days")

plt.savefig("inflammation.png")

Plotting with a loop over files:

import numpy as np
import matplotlib.pyplot as plt
import glob

# Fetch all the inflammation csv files in this folder
list_of_files = glob.glob("inflammation-*.csv")


# Let's get Python to make a whole bunch of plots - one for each dataset!
for data_file in list_of_files:
    fig = plt.figure(figsize=(10,3)) # Forgot to import libraries!
    
    ax1 = fig.add_subplot(1, 3, 1)
    ax2 = fig.add_subplot(1, 3, 2)
    ax3 = fig.add_subplot(1, 3, 3)
    
    # Read in the data from the data_file
    data = np.loadtxt(data_file, delimiter=",")
    
    # Plot the max, min, and mean
    ax1.set_ylabel("Average")
    ax1.plot(data.mean(axis=0))
    
    ax2.set_ylabel("maximum")
    ax2.plot(data.max(axis=0));

    ax3.set_ylabel("minimum")
    ax3.plot(data.min(axis=0));
    
    fig.tight_layout()
    plt.show()

Plotting the cumilative total across all the files:

import numpy as np
import matplotlib.pyplot as plt
import glob

# Fetch all the inflammation csv files in this folder
list_of_files = glob.glob("inflammation-*.csv")

# Setup a variable to track the cumilative total across the datasets!
total_data = np.zeros((60,40)) # total_data = 0 will also work! 
# This just creates a numpy array of the same size as our data to speed things up a bit

# Let's get Python to make a whole bunch of plots - one for each dataset!
for data_file in list_of_files:
    # Load in the data
    data_from_this_file = np.loadtxt(data_file, delimiter=",")
    # Add the data from this file to our total data for each day
    total_data = total_data + data_from_this_file
    
# total_data contains the sum of all the inflammation records for each day, and each patient
fig = plt.figure()

plt.plot(total_data.std(axis=0))
plt.ylabel("Standard deviation across all files")
plt.xlabel("Day")
plt.title("Culmilative data")
plt.show()