Welcome!
30 Sep - 1 Oct
Links
Workshop website
Notes made during the workshop
Instructors and Helpers
/
Feedback
UCL Research Programming Hub (Slack): A platform to ask programming questions to the UCL research community, you can join using your UCL email. Anything from “How to I get started on X” to “what would people recommend for solving Y”.
More information about what ARC does, and our drop-in sessions.UCLARC to follow along and submit answers to the exercises.
Sample data we’ll be using for Unix Shell - follow the link and download the shell-lesson-data.zip file and Unzip/extract it, save to your Desktop.
Sample data we’ll be using for Python - follow the link and download the python-novice-inflammation-data.zip file and (optionally) the code.zip file too.Instructors: Haroon Chughtai, David Pérez-Suárez (Ruaridh Gollifer, Stephen Thompson)
Helpers: Henry Crosswell, Mary Tziraki
Instructors: Paul Smith, Kimberly Meechan (Will Graham, Tuomas Koskela)
Helpers: Henry Crosswell, Mary Tziraki
Please also include whether you are using Windows/Mac/Linux
If you have a questions during the session and don’t want to ask it publicly, you can write them here!
Sample data we’ll be using for Unix Shell - follow the link and download the shell-lesson-data.zip file and Unzip/extract it, save to your Desktop.pwd : Print Working Directory. Displays the folder (directory) that your terminal is currently “looking at”. Everything you ask your terminal to do will be done from this folder, and any commands you ask give it will be interpreted as being “relative to” that directory.cd: Change Directory. Move your terminal from the current working directory (what pwd prints) to a new directory. You can give the name after the cd command to select the folder to move to. i.e., cd <folder_name>
cd without any arguments take you to the home directoryls : List contents. Displays all the files and folders inside the current working directory. Can take extra options using dashes (-).
ls -F : List contents, and also distinguish between files and folders using a trailing / after the names.ls -a : List all files, even hidden files.ls <folder_name>: List the contents of the given folder, rather than the current working directory.nano <filename>: Open nano, a text editor, to edit the given file (create the file if it does not exist already). When in nano, you can type text using the cursor.
CTRL + O (^O) to save. You will need to then press RETURN to confirm the name of the file to save.CTRL + X (^X) to exit. If you have changed the file and haven’t saved, you’ll be prompted to save your changes before you exit.mv source destination: Move the file source to the destination.
destination file if it already exists!!!destination is a FOLDER, not a FILE, then the source file will be placed inside the destination folder.mv my_file.txt my_folder/new_name.txt: Move my_file.txt into the my_folder directory, and change the file name to new_name.txt.mv my_file.txt new_name.txt: Move my_file.txt into the current folder, and change the file name to new_name.txt. This is effectively “renaming” the file.mv my_folder/my_file.txt .: Move my_file.txt out of my_folder and into the current working directory (. = current working directory). Note that the name is unchanged if the destination is a folder.cp source copy_destination: Copy a file to a new location. Similar to mv, except we get a copy rather than just move the file. It works almost identically to the mv command and the examples above, though some differences are below:
cp -r: The -r flag stands for “recursive”. If source is a folder, cp -r source destination will copy the entire source folder to the destination!rm filename: Delete (REMOVE) the filename.
rmdir folder command will delete the folder, but only if it’s EMPTY.rm has a -r flag, which stands for recursive. This will delete everything inside a folder. AGAIN, BE CAREFUL!!!-i flag helps to prompt you a question to make sure you want to delete that directory.wc word count provides some metrics of text files. They are number of lines, words and characters of a file. With -l, -w, -c gives you the lines, words and characters respectively.cat shows the content of a file.head shows the top lines of a file, using -n X will restrict that to the first X lines.sort does what it does, sort the file alphabetically
-n sorts it numerically, i.e., 1, 2, 3, 10, 21,... rather than 1, 10, 2, 21, 3, ...> redirects the output of a command into a file: e.g., sort filename > new_filename will produce a new file with the same content than the original but with their lines sorted.
>> Using two symbols will append the output of the command to the content that may already exists on the output file.| pipes the output of a command into another command: e.g., sort -n lenghts.txt | head -n 1 will result on the first line of the output from sorting numerically the lengths.txt file.
User A / User B
.
.
If conda failing use jupyter lite
# Bash > Python
# Use glob to discover all our data files
filenames = glob("data/inflammation-*.csv")
filenames = sorted(filenames)
print(filenames)
for file in filenames:
print("Currently at file:", file)
# Load this dataset
data = np.loadtxt(file, delimiter=",")
# Do our analysis (create our plots)
avg_inflam = np.mean(data, axis=0)
min_inflam = np.min(data, axis=0)
max_inflam = np.max(data, axis=0)
# Create our plot for this dataset and save it!
fig = plt.figure(figsize=(10, 3))
avg_axes = fig.add_subplot(1, 3, 1)
max_axes = fig.add_subplot(1, 3, 2)
min_axes = fig.add_subplot(1, 3, 3)
# Actually plot things on our figure
avg_axes.plot(avg_inflam)
avg_axes.set_ylabel("Average")
max_axes.plot(max_inflam)
max_axes.set_ylabel("Max")
min_axes.plot(min_inflam)
min_axes.set_ylabel("Min")
# Tidy things up, save, and display
max_axes.set_title(file)
fig.tight_layout()
# Generate a save file location from the current file name, by substituting
# the .csv extension for .png
png_file_name = file.split(".")[0] + ".png"
png_file_name = "outputs/" + png_file_name.split("/")[1]
fig.savefig(png_file_name)
fig.show()
workshop