# 2023-10 <br> SWD1a: Introduction to Python
**NB**: ask for help! https://bit.ly/arc-help
Welcome to the hack pad for SWD1a course from Research Computing at the University of Leeds!
You can edit this document using [Markdown syntax](https://guides.github.com/features/mastering-markdown/).
## Contents
1. [Links to resource](#Links-to-resources)
2. [Agenda](#Agenda)
3. [What's your name and where do you come from?](#What’s-your-name-and-where-do-you-come-from)
4. [Further reading](#Further-reading)
5. [Extra code snippets](#Misc-code-snippets)
## Links to resources
- **Contact Research Computing** - https://bit.ly/arc-help
- **Workshop Slides** - https://swcarpentry.github.io/python-novice-inflammation/
- **Research Computing website** - https://arc.leeds.ac.uk/
### Course Recordings
- [Day 1, Part 1](https://leeds365.sharepoint.com/:v:/s/TEAM-ResearchSoftwareEngineering/EZysg5ZK1xRDhvOsvXUXHEQBTMQmhssnZkFR6nfw4ayWUg?e=kdPk2E&nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJTdHJlYW1XZWJBcHAiLCJyZWZlcnJhbFZpZXciOiJTaGFyZURpYWxvZyIsInJlZmVycmFsQXBwUGxhdGZvcm0iOiJXZWIiLCJyZWZlcnJhbE1vZGUiOiJ2aWV3In19)
- [Day 1, Part 2](https://leeds365.sharepoint.com/:v:/s/TEAM-ResearchSoftwareEngineering/EQXNwbOwHD1GpGRdWsiyEoUBQW6heNj1iT4ipAL3tzIc3A?e=1eZUBC&nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJTdHJlYW1XZWJBcHAiLCJyZWZlcnJhbFZpZXciOiJTaGFyZURpYWxvZyIsInJlZmVycmFsQXBwUGxhdGZvcm0iOiJXZWIiLCJyZWZlcnJhbE1vZGUiOiJ2aWV3In19)
- [Day 1, Part 3](https://leeds365.sharepoint.com/:v:/s/TEAM-ResearchSoftwareEngineering/EREutXdueEFMoa28OU0RxjQB1zubjT_cAyeZ7oFJEMdhaQ?e=gj9Ecz&nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJTdHJlYW1XZWJBcHAiLCJyZWZlcnJhbFZpZXciOiJTaGFyZURpYWxvZyIsInJlZmVycmFsQXBwUGxhdGZvcm0iOiJXZWIiLCJyZWZlcnJhbE1vZGUiOiJ2aWV3In19)
- [Day 2, Part 1](https://leeds365.sharepoint.com/:v:/s/TEAM-ResearchSoftwareEngineering/EYZxBHZnacZBv-vfYIzQVvMBRKltXcgPHgDRtEbgmxwjkg?e=eL5z3S&nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJTdHJlYW1XZWJBcHAiLCJyZWZlcnJhbFZpZXciOiJTaGFyZURpYWxvZyIsInJlZmVycmFsQXBwUGxhdGZvcm0iOiJXZWIiLCJyZWZlcnJhbE1vZGUiOiJ2aWV3In19)
- [Day 2, Part 2](https://leeds365.sharepoint.com/:v:/s/TEAM-ResearchSoftwareEngineering/EbCGNQrV_SBPv59lN9czM34B19-PjnadNwfU-X1Shu7ZMQ?e=jsbIKE&nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJTdHJlYW1XZWJBcHAiLCJyZWZlcnJhbFZpZXciOiJTaGFyZURpYWxvZyIsInJlZmVycmFsQXBwUGxhdGZvcm0iOiJXZWIiLCJyZWZlcnJhbE1vZGUiOiJ2aWV3In19)
## Agenda
### Agenda Day 1
| Time | Agenda |
| ---- | ------------------------------------------ |
| 1000 | Intro, using Google Colab, What is Python? |
| 1050 | Break |
| 1100 | Python Fundamentals |
| 1130 | Analyzing Patient Data |
| 1230 | Lunch |
| 1330 | Visualizing Tabular Data |
| 1450 | Break |
| 1500 | Storing Multiple Values in Lists |
| 1545 | Questions |
| 1600 | Close |
### Agenda Day 2
| Time | Agenda |
| ---- | ---------------------------------- |
| 1000 | Repeating Actions with Loops |
| 1050 | Break |
| 1100 | Analyzing Data from Multiple Files |
| 1200 | Lunch |
| 1300 | Making Choices |
| 1400 | Creating Functions |
| 1450 | Break |
| 1500 | Errors and Exceptions |
| 1545 | Questions |
| 1600 | Close |
## What's your name and where do you come from?
- Patricia Ternes - RSE - I will be the main instructor of this training.
- [Maeve](https://murphyqm.github.io/) - I'm assisting Patricia today with this training. Also an RSE! Just finished my PhD in the School of Earth and Environment. [Chat with me on Teams.](https://teams.microsoft.com/l/chat/0/0/?users=M.MurphyQuinlan@leeds.ac.uk)
- [Andy Turner](https://arc.leeds.ac.uk/about/team/) Research Computing
- Rossana Escanilla, PhD Student, School of Geography. I am from Chile :) I use python for data analysis in hydrological models.
- Pei Xue, PhD student, School of Geography. Looking for some modelling.
- Saffron Heddell, PhD student , School of Earth and Environment. Looking to use Python for data analysis and modelling the interaction between volcanic aerosols and the ozone hole. Using the UM-UKCA climate model.
- Grace - PhD student from LICAMM, doing a structural biology project. May need to use Python for my project.
- Sheng Chen - PhD student, School of Earth and Environment. Trying to learn how to digitalize some log data from the fieldwork.
- Kevin Douglas - Postdoc in Chemistry. I'm doing this course as it may help with data analysis, presenting data, and python is a useful skill.
- Bianca Hazt - PhD Student, School of Food Science & Nutrition, data analysis. I'm from Brazil as well!!!
- Victor Efren, PhD student, School of Chemical and Process Engineering. I am from Mexico and I want to make perform statistical models and data analysis.
- Dr Suparna Mitra, Lecturer in Microbiomics, FMH---Looking for data analyses and programming. Yess modeling too.. GLM, machine learning[](https://)- Dr Suparna Mitra, Lecturer in Microbiomics, FMH---Looking for data analyses and programming. Yess modeling too.. GLM, machine learning[](https://)
- Harrie Mort - PhD, SRI. From UK. I'm doing a python course because it's a useful skill and I can use it for data analysis and modelling.
- Connie Harpur, PhD student in the School of Geography. I'd like to learn Python for collecting and analysing remote sensing data.
- Nasrollah Hajaliakbari - PhD student - Computing, Fluid Dynmaics Simulation
- Sarah Alshehri, PhD student, school of Physics and Astronomy, data analysis.
- Manon - PhD student, School of Earth and Environment. Data analysis, running model and creating figures - using scripts to plot specific things like stereonets and ternary plots
- Ishfaq Malik - Postdoc, School of Geography. I would like to learn Python to apply it on remote sensing
- I'm Fred. Postdoctoral Researcher at LICAMM doing computer simulations of protein membrane systems.I'm expecting to develop some skills to create scripts to analysis. I'm from Brazil too.
- Meernah Alabdullah, PhD Electronics and Electrical Engineering (Medical Robotics), I am from Saudi Arabia , I am looking for data analysis , and MicroPyhton for micrcocontrollers porgramming, how to use python to build models.
- Chenyi Gao from school of dentistry (PhD student. I would like to learn one more coding language.
- Alex, phd student from LUBS, want to learn python for data analysis
- Chloe Randall, PhD student Medicine from UK, research group works in python scripting for protein modelling
- Xinyue, PhD student from School of Earth and Environment
- Yan Li,PhD student from School of Earth and Environment
- Ebru Kaya, Msc Geogragrphıcal ınformation
- shane from india: MSc Bioscience
- Sufyan Dalal, PhD Student, School of Mechanical Engineering
## Further reading
- Python data types: https://realpython.com/python-data-types/
- Using a code notebook effectively: https://saturncloud.io/blog/productive-use-of-jupyter-notebooks-a-guide-for-data-scientists/
- More advanced Jupyter notebook guidance and best practise: https://carpenter-singh-lab.broadinstitute.org/blog/best-practices-jupyter-notebook
- Full **FREE** datascience with Python textbook with code snippets - https://jakevdp.github.io/PythonDataScienceHandbook/
- Full **FREE** computational numerical Modelling in Python book - https://greenteapress.com/ModSimPy/ModSimPy.pdf
- Data indexing and slicing tutorial: https://realpython.com/lessons/indexing-and-slicing/
- Correlation and statistics in Python: https://realpython.com/numpy-scipy-pandas-correlation-python/
- Starting off with Sci-kit learn (from question during the tutorial): https://machinelearningmastery.com/a-gentle-introduction-to-scikit-learn-a-python-machine-learning-library/
- Then a more intensive in-depth work through: https://scikit-learn.org/stable/tutorial/index.html
- Data visualisation: basic package is matplotlib, if you want to move on to more statistical visualisation, then the seaborn package is useful too: https://jakevdp.github.io/PythonDataScienceHandbook/04.14-visualization-with-seaborn.html, here's another good intro tutorial https://medium.com/geekculture/8-best-seaborn-visualizations-20143a4b3b2f
- A brief/quick talk I gave on data vis with some example code notebooks - https://github.com/murphyqm/planetary-group-figures/
- Plotly graphing library - https://plotly.com/python/
- Animations with Matplotlib: https://towardsdatascience.com/animations-with-matplotlib-d96375c5442c, https://www.geeksforgeeks.org/using-matplotlib-for-animations/
- Some details on File systems with Google Colab: https://neptune.ai/blog/google-colab-dealing-with-files. Remember, when you disconnect, all the folders and files attached to your notebook get deleted - this is why every time we need to load and unzip the example data. So download all the figures you create!
- Alternative plotting libraries for specific tasks: https://www.knowledgehut.com/blog/business-intelligence-and-visualization/python-data-visualization-libraries
- Boolean/logic operators in Python: https://www.geeksforgeeks.org/python-operators/
- Add CNN material
## Textbooks
- Full **FREE** datascience with Python textbook with code snippets - https://jakevdp.github.io/PythonDataScienceHandbook/
- Full **FREE** computational numerical Modelling in Python book - https://greenteapress.com/ModSimPy/ModSimPy.pdf
- High Performance Python - Micha Gorelick and Ian Ozsvald. Potentially available online for free too, if you want to borrow the physical textbook send me a message (Maeve)
- Better Data Vizualisations - Jonathan Schwabish; not specific to Python. Also have a physical copy of this you can borrow (Maeve)
- Programming for Computations - Python
A Gentle Introduction to Numerical Simulations with Python 3.6 [link](https://link.springer.com/book/10.1007/978-3-030-16877-3?source=shoppingads&locale=en-gb&gclid=CjwKCAjw4P6oBhBsEiwAKYVkqwZBOacqY0IM-58Jtx8aIdMXWKRSUOVSOie5j0N6wmLTY5Agkal0fRoCXqIQAvD_BwE); I think it's available in lib, I also have a copy if people need.
## Misc code snippets
### Download data
```python=
# Download 2 files and store in the swc-python folder
!wget -P swc-python https://swcarpentry.github.io/python-novice-inflammation/data/python-novice-inflammation-data.zip
!wget -P swc-python https://swcarpentry.github.io/python-novice-inflammation/files/code/python-novice-inflammation-code.zip
```
### Unzip Files
```python=
# Extract .zip files inside the folder swc-python/
!unzip /content/swc-python/python-novice-inflammation-code.zip -d /content/swc-python/
!unzip /content/swc-python/python-novice-inflammation-data.zip -d /content/swc-python/
```
## Installing packages
- Set up an Anaconda environment with all the packages you need: ``conda install package-name``
- Or use pip install - ``pip install package-name`` from terminal
- Read our documentation on using Anaconda - https://arcdocs.leeds.ac.uk/software/compilers/anaconda.html - while this is aimed at users working on the ARC systems, it is also applicable to your local computer
- Using pip instead: https://packaging.python.org/en/latest/tutorials/installing-packages/