Lecture 1
ORIGINS BASEMENT
MPP [ALPS]
Will be made available on our GitHub before each lecture
For TUM students: 6 Credits
For LMU students:
Lectures:
Jarred Green
Tutorials:
Nadine Bourriche
Advisor:
Lukas Heinrich
Hypothesis / Theory
Data / Experiment
Predict outcomes of experiments
Create new hypotheses
based on observations
Theory of Newtonian Gravity
Cavendish Experiment
Example
Theory of Newtonian Gravity
Cavendish Experiment
Example
Mercury Perihelion Precession
Theory of Newtonian Gravity
Cavendish Experiment
Example
Mercury Perihelion Precession
Theory of General Relativity
Theory of Newtonian Gravity
Cavendish Experiment
Example
Mercury Perihelion Precession
Theory of General Relativity
1919 Solar Eclipse
16th Century Astronomer
16th Century Astronomer
The experiment
and the theory
O(10) Parameters
100 Million Sensors
To probe fundamental physics, we measure more and more indirectly
To probe fundamental physics, we measure more and more indirectly
To probe fundamental physics, we measure more and more indirectly
There are often no longer simple formulas we can write by hand
Are we ready to define data science?
Domain Expertise
Math and Statistics
Programming
Communication
Meaningful Insights
Experimental Data
A skill-based view
Communication
Experimental Data
Input
Output
Domain Expertise
Math and Statistics
Programming
Data
Science
Machine Learning
Traditional Research
Danger
Zone!
Communication
Experimental Data
Input
Output
Domain Expertise
Math and Statistics
Programming
Data
Science
Machine Learning
Traditional Research
Danger
Zone!
VS Code
Programming Languages
Core Tools
Software
Specialized Tools
VS Code
Programming Languages
Core Tools
Specialized Tools
All code here is "Open Source"
Software
Week 1
Programming Languages
Core Tools
Software
Week 2
Specialized Tools
Core Tools
Software
Programming Languages
Core Tools
VS Code
Programming Languages
Core Tools
Software
Specialized Tools
VS Code
Core Tools
Software
Specialized Tools
Programming Languages
VS Code
Core Tools
Software
Specialized Tools
Programming Languages
VS Code
Core Tools
Software
Specialized Tools
Programming Languages
VS Code
Core Tools
Software
Specialized Tools
Programming Languages
VS Code
Software
Programming Languages
Core Tools
Specialized Tools
VS Code
Core Tools
Software
Specialized Tools
Programming Languages
Your IDE of choice?
Integrated Development Environment
Integrated Development Environment
Our IDE of choice
You have two options:
Download and
run locally
Run in the browser
Recommended for now!
We'll learn how to do that later!
Do it!
file browser
file editor
multiple tabs
terminal
Markdown
# Example markdown file
Here is an example of a *really cool* markdown file.
There are some nice things about markdown:
1. One
2. Two
3. Three
## Things to try
In addition, you may try:
- this
- that
- these
- **especially this**What is Markdown?
Markdown
# Example markdown file
Here is an example of a *really cool* markdown file.
There are some nice things about markdown:
1. One
2. Two
3. Three
## Things to try
In addition, you may try:
- this
- that
- these
- **especially this**Shell:
Generic term for a computer program that interprets text commands
Bash:
The most popular shell program that is also a scripting language
+
find . -name '*.py' -printf '%k\n' \
| sort -nr \
| head -n5 \
| paste -sd+ - \
| bc \
| xargs -I{} echo Total: {} kB
# Total: 176 kB"Find the 5 longest python files in this folder and give me the total size in MB"
Why?
Remote Servers
Your first command:
echoecho "Hello, Garching!"Do it!
The filesystem
A big tree starting from /
Everything is a file
Navigating your filesystem
cdlspwdSpecial Directory Nicknames
.~/..Do it!
Paths
# Absolute Path
pwd
/home/jgreen/Documents/my_file.txt
# Relative path generally replaces the current directory with "."
./my_file.txtMost commands have extra options e.g. ls
# 1. no extra options
ls
file.txt subfolder/
# 2. show hidden files as well
ls -a
./ ../ .hidden-file.txt file.txt subfolder/
# 3. show extra details
ls -l
total 0
-rw-r--r-- 1 jarred staff 0 Aug 27 16:17 file.txt
drwxr-xr-x 2 jarred staff 64 Aug 27 16:17 subfolder/
# 4. show file sizes in human-readable way
ls -alh
total 0
drwxr-xr-x 5 jarred staff 160B Aug 27 16:18 ./
drwxr-xr-x 17 jarred staff 544B Aug 27 16:17 ../
-rw-r--r-- 1 jarred staff 0B Aug 27 16:18 .hidden-file.txt
-rw-r--r-- 1 jarred staff 0B Aug 27 16:17 file.txt
drwxr-xr-x 2 jarred staff 64B Aug 27 16:17 subfolder/Can usually list all options with the `man` command
man lsNOTES
Review: moving around quickly
pwdls -alhcd xcd ~cd -Making things
mkdir folder_nametouch file_nameMoving things
cp file1 file2mv file1 file2mv ./folder/file1.txt ./other-folder/file1.txt⚠️ Deleting things!
rm file1.txtrm -r directory_name🚨
There is no trash bin in bash
rm is forever
Editing files
nano file.txtQuickly reading files
cat file.txthead -n 5 file.txttail -n 5 file.txtPro tips for speed
Wildcards
* represents any number of characters
ls -alh ./data*.txtLists all text files in the current folder which start with "data" and end with ".txt"
Wildcards
? represents a single character
ls -alh ./data-v?.txtLists all text files in the current folder which match "data-vX.txt"
Wildcards
[123] matches those exact characters
ls -alh ./data-v[123].txtLists exactly data-v1.txt, data-v2.txt, and data-v3.txt, if they exist
Advanced Bash: Pipes
Pipes send output of one command as input to the next command
ls -alh data*.txt | head -n 5Shows only the first 5 files that match the given patten
Advanced Bash: Variables
Store a value to reuse
FOLDER="/home/jgreen/files"
ls -alh $FOLDERYou must use the $ to recall the value of the variable and not just normal text
Advanced Bash: Output Redirection
Write the output of a command to a file
cat log.txt > newfile.txt
cat log.txt >> otherfile.txt> overwrites existing files >> adds lines to the end of file
The last thing: scripts
You can save a list of commands to a file to reuse over and over!
#!/bin/bash
NAME="world"
echo "Hello $NAME!"The first line, called Shebang tells the script which program to use to run itself
#!/bin/bash
NAME="world"
echo "Hello $NAME!"Do it!
chmod +x helloworld.sh
./helloworld.shpwd
ls
cd
man
mkdir
touch
mv
cp
rm
nano
cat
head
tailA recap
Commands
Skills
. current directory
.. parent directory
~ home directory
/ filesystem root
- command options
# comments
$ variables
| pipes
* wildcards
? wildcards
>> output redirection
#! shebangs
.sh scriptsTime travel and collaboration for code
By far the most widely-used version control tool
The Mental Model
main
💡 a new idea
Create a new branch of the code
idea1
The Mental Model
main
💡 a new idea
idea1
Edit your code
⚠️ Now the two branches are different
The Mental Model
main
💡 a new idea
idea1
Commit your code
💾This is the equivalent of saving your changes
The Mental Model
main
💡 a new idea
idea1
🤝 Now everyone can see your updates!
main
Merge your code into the main branch
The Mental Model
main
💡 a new idea
idea1
main
🤝 Merge your code into the main branch
🌳 Create a new branch of the code
💻 Edit your code
💾 Commit your code
Of course there are commands to do this
🤝 Merge your code into the main branch
💾 Commit your code
🌳 Create a new branch of the code
💻 Edit your code
git branch idea1
git checkout idea1
💻 Edit your code
git commit -m 'describe changes'
git add edited.md
git checkout main
git merge idea1
git branch -d idea1
The standard formula for making changes
git branch idea1
git checkout idea1
💻 Edit your code
git add edited.md
git commit -m 'describe changes'
git checkout main
git merge idea1
git branch -d idea1
Create a new branch named 'idea1'
Switch your code to that branch
Go ahead and change your code
Tell git which files you want to 'save' by adding them to the 'staging area'
'save' the changes to your history by committing them with a clear message
switch back to the original branch
merge the commits from 'idea1' branch into the (current) main branch
clean up-- delete the idea1 branch
Tips for committing
🌳 Create a new branch of the code
💻 Edit your code
git branch idea1
git checkout idea1
💻 Edit your code
💾 Commit your code
git commit -m 'describe changes'
git add edited.md
⚠️ by default, git just backs up history locally
hello
% developers using these code documentation and collaboration tools
❗️4/5 developers use GitHub
Downloading a entire repository
git clone https://github.com/user/project
How do we collaborate on it?
☁️ Download and sync new changes
git clone
Fork on GitHub site
⬆️ Upload your changes
git push
💾 Commit your code
git commit -m 'describe changes'
git add edited.md
💾 Commit your code
git commit -m 'describe changes'
git add edited.md
🌳 Create a new branch of the code
💻 Edit your code
git branch idea1
git checkout idea1
💻 Edit your code
🌳 Create a new branch of the code
💻 Edit your code
git branch idea1
git checkout idea1
💻 Edit your code
Let's update our standard formula
👀 Review your changes
Submit pull request (PR) on GitHub site
The End