When writing a science research paper, usually there will be some code that was used to do the science being discussed. It is becoming customary to share this code so that others can see what you did and perhaps expand upon it or check the work. Since this code might be long and involve many parts, it is generally the case that it doesn't appear in the paper itself, but is referenced using an online link.
Let's take a look at how to do that.
If you've written some plotting routines with Google Colab (and I hope you do), you can make them into a sharable notebook very easily. Just the share button, then set the sharing access Anyone with the link. The default is restricted, but that's won't work unless you have specifically invited someone to view it. This is very much the preferred way to share things for this course.
Click the share button and then make sure it is set to Anyone with the link.
Github is a place where anyone can share code. It's deeper and original function is to be a Version Control system, which let's people and groups keep track of changes made to code (like a history). But, we can use it for simpler things, like just sharing a csv file.
Make a repository.
You can make a free account here: Github account (and there are plenty of student perks if you want them as well: Education pack
Once you make an account, you can start by creating a repository.
The initial commit.
After you have a repo set up, it should show up like this. There's nothing in it, except the README.md
file which can be edited to explain what the repo is about.
There are many ways to start changing things in your repo. The easiest and most middle-of-road in terms of complexity and features is to use the GitHub desktop application.
Select the Open with Desktop option.
Once you open it with GH desktop, you'll have to put a local
version somewhere on your computer. (This is what you edit, then push to the online version once you are happy with your edits.)
Pick a good local path for your local version of the repo.
Now, you can make a change to a file in your repo. You'll need a code editor (i.e. NOT ms word). This page has some recommendations. Here, we've added a line to the README.md
file.
Editing the README.md
file
Now, go back to Github Desktop. You should see that it has automatically detected the change you made.
We've got a change!
Send it through the pipes.
Now, when you return to your repo on the github page, you should see the modifications to the README.md
file.
Now the README has changed.
This is just the beginning. You can do all sorts of things now. In this repo, we've added a folder called in-class-measurements
. In there, we've put a csv
file that contains the data we recorded during class. By following the same process of commit → push to origin, now that data set is hosted in our repo online, and anyone can access it.
Send it through the pipes.
If you press the Raw button, it will take you the file itself via a URL:
https://raw.githubusercontent.com/hedbergj/PHYS-37100-data/main/in-class-measurements/change-resistance-with-decade-box-9-12-2022.csv
Now, you can use that URL to load the data into a Colab Notebook or other analysis application.
Plotting our csv file.
Here is the link to the repository we just made.
https://github.com/hedbergj/PHYS-37100-data
This is a great way to host your work online.
Please do not use services such as Pastebin, Dropbox, or other random web services to share code for this class. The two options explored above are trustworthy and professional and are widely used by the scientific community for these purposes.
Always check that your links actually work, before submitting them. You can use a private browsing tab to make sure that someone who is not you can see them.