Software Carpentry at UCL: Bash, Git, and Python Workshop
Welcome!
Tuesday 30th May - Wednesday 31st May
Links
Exercises
- Go to gosocrative.com and enter room code
UCLSWC
to follow along and submit answers to the 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:
- Anna Sadnicka
- Farzan Ramzan
- Jeremy Saxe
- Anne Gaule
- Cristian Dinu (in the small TESA room, Royal Free)
- David Wong
- Daniel Delargy
- Mahmoud Abdelrazek
- Shipra Suman
- Michelle Harricharan
- Yining Sun
- Jingyi Xuan
- Sruthi George
- Katie Buntic
- Sofia Kuznetsova
- Lizzy Iroajanma
- Konstantninos Tzoumkas
- Chrysoula Vasileiadou
- Darja Demeneva
- Stathis Varzakis
- John Omotoye
Wednesday 31st May (Python)
- Anna Sadnicka
- Daniel Delargy
- John Omotoye
- Stathis Varzakis
- Anne Gaule
- Katie Buntic
- Farzan Ramzan
- Jeremy Saxe
- Michelle Harricharan
- Lizzy Iroajanma
- Jess Constable
- Shipra Suman
- Konstantinos Tzoumkas
- Mahmoud Abdelrazek
- David Wong
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
list_of_files = glob.glob("inflammation-*.csv")
for data_file in list_of_files:
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)
data = np.loadtxt(data_file, delimiter=",")
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
list_of_files = glob.glob("inflammation-*.csv")
total_data = np.zeros((60,40))
for data_file in list_of_files:
data_from_this_file = np.loadtxt(data_file, delimiter=",")
total_data = total_data + data_from_this_file
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()
Software Carpentry at UCL: Bash, Git, and Python Workshop
Exercises
UCLSWC
to follow along and submit answers to the exercises.Lesson Material
shell-lesson-data.zip
file and Unzip/extract it, save to your Desktop.python-novice-inflammation-data.zip
file and (optionally) thecode.zip
file too.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()