Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3e9a3c5
Commit install-run.md; neglected to commit it earlier
emiliom Jul 1, 2025
387a48d
Remove local copy of Project Pythia Python overview notebook
emiliom Jul 1, 2025
1081cc4
Massive overhaul for 2025. First stab at incorporating Ethan's lesson…
emiliom Jul 2, 2025
63aa625
Merging from origin; README conflict
emiliom Jul 2, 2025
6013b95
Overhaul the front page
emiliom Jul 2, 2025
3e99141
Update the Running Python page to reflect the use of Colab for lessons
emiliom Jul 2, 2025
1d441d1
Update Quick Python overview page
emiliom Jul 3, 2025
e23afac
Add week 1 notebook
ethan-campbell Jul 3, 2025
f017317
Update index.md
ethan-campbell Jul 3, 2025
d0649da
Merge pull request #1 from UW-APL-SURP/ethan-campbell-patch-1
ethan-campbell Jul 3, 2025
071b2a1
Merge pull request #2 from UW-APL-SURP/ethan-campbell-patch-1-1
ethan-campbell Jul 3, 2025
f0e4931
Update index.md
ethan-campbell Jul 3, 2025
8fb2594
Merge pull request #3 from UW-APL-SURP/ethan-campbell-patch-1
ethan-campbell Jul 3, 2025
75db8b3
Delete site/lessons/Python lesson (Day 4) - blank copy.ipynb
ethan-campbell Jul 3, 2025
2b88b03
Merge pull request #4 from UW-APL-SURP/ethan-campbell-patch-2
ethan-campbell Jul 3, 2025
7ef8249
Delete site/lessons/Python lesson (Day 3) - blank copy.ipynb
ethan-campbell Jul 3, 2025
cb7514b
Merge pull request #5 from UW-APL-SURP/ethan-campbell-patch-2
ethan-campbell Jul 3, 2025
d120e07
Delete site/lessons/Python lesson (Day 2) - blank copy.ipynb
ethan-campbell Jul 3, 2025
1b81144
Merge pull request #6 from UW-APL-SURP/ethan-campbell-patch-2
ethan-campbell Jul 3, 2025
c766dc0
Update _toc.yml
ethan-campbell Jul 3, 2025
dedd82a
Merge pull request #7 from UW-APL-SURP/ethan-campbell-patch-2
ethan-campbell Jul 3, 2025
ecec9e3
Update index.md with Open in Colab button
ethan-campbell Jul 3, 2025
39660ce
Merge pull request #8 from UW-APL-SURP/ethan-campbell-patch-2
ethan-campbell Jul 3, 2025
38c68bb
Update _config.yml
ethan-campbell Jul 3, 2025
9779885
Merge pull request #9 from UW-APL-SURP/ethan-campbell-patch-1-1
ethan-campbell Jul 3, 2025
e74cbd2
Update index.md
ethan-campbell Jul 3, 2025
eb83565
Merge pull request #10 from UW-APL-SURP/ethan-campbell-patch-2
ethan-campbell Jul 3, 2025
d8f3a51
Update index.md
ethan-campbell Jul 3, 2025
0b8cd23
Delete site/lessons/APL_SURP_Python_course_Notebook_1.ipynb
ethan-campbell Jul 3, 2025
33f3541
Add files via upload
ethan-campbell Jul 3, 2025
19bedd8
Update GH Action deploy.yml
emiliom Jul 7, 2025
04cf169
Merge pull request #11 from UW-APL-SURP/emiliom-patch-1
emiliom Jul 7, 2025
a2ea30d
Test the deploy GH Action, update install-run.md
emiliom Jul 7, 2025
8ce6d52
Merge pull request #12 from UW-APL-SURP/emiliom-patch-1
emiliom Jul 7, 2025
fb6ab4f
Test deploy GH action again, Update cheatsheets.md
emiliom Jul 7, 2025
113608c
Merge pull request #13 from UW-APL-SURP/emiliom-patch-1
emiliom Jul 7, 2025
3977ebc
Tweaks to overview page
emiliom Jul 8, 2025
c9d43c6
Minor change to test authentication
ethan-campbell Jul 9, 2025
9dfee00
Added week 2 notebook; updated TOC and index page
ethan-campbell Jul 10, 2025
9b711c5
Updated Day 2 notebooks, including instructor version and blank copy;…
ethan-campbell Jul 10, 2025
0de4a70
Add notebook 3, update toc and related pages
emiliom Jul 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.8]
python-version: [3.12]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Install dependencies
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install -r requirements.txt
Expand All @@ -46,19 +47,21 @@ jobs:
run: |
jupyter-book build site

- name: Create deployment artifact
uses: actions/upload-pages-artifact@v1
# Upload the book's HTML as an artifact
- name: Upload deployment artifact
uses: actions/upload-pages-artifact@v3
with:
path: sitio/_build/html
path: site/_build/html

# Deploy the book's HTML to GitHub Pages
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build-book
if: github.ref == 'refs/heads/main' && github.repository == 'emiliom/dinosip-python'
if: github.ref == 'refs/heads/main' && github.repository == 'UW-APL-SURP/aplsurp-python'
steps:
- name: Deploy to Github Pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v4
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
# README

Stub.
**(NONE OF THIS IS ON THE PUBLIC-REPO README. DELETE, ADAPT)**

- ~~Rename the base folder to aplsurp-python~~
- ~~Conda env (previously `dinosip-python-web`, now renamed to `aplsurp-python-web`)~~
- Conda env: I currently just use `environment.yml`. But maybe `requirements.txt` will be needed later for CI-based builds on GH
- To build the site: `jb build site` (or `jb clean site` first)
- To preview it: open the file `site/_build/html/index.html`
- To publish: `ghp-import -n -p -f --remote origin site/_build/html`
- Integrating Ethan's notebooks:
- See my local clone of Ethan's repo: `/home/mayorga/Desktop/DEI/APL/2021_DON_APL-DID-NOW/Python-crashcourse/NCAT_MATE_floats_teaching/`
- Use [url encoding](https://meyerweb.com/eric/tools/dencoder/) to transform the names of the notebook files if they have spaces and other unsafe characters
- Say something about notebooks: Jupyter notebooks vs notebooks in Colab
- Weave the individual lessons (from Carpentry & Pythia) into the notebooks, or as additional notes here next to each notebook


## Stuff in Spanish about Jupyter Book that I'm going to cull and translate

## From Hackaton OHW en español

Con el [Jupyter Book](https://jupyterbook.org) (y muchos sistemas parecidos), uno modifica los archivos "fuente", típicamente en markdown, y luego "genera" los archivos del sitio en sí. Pueden leer sobre esto [aquí](https://jupyterbook.org/en/stable/basics/building/index.html).

Los archivos fuente (el contenido) se almacenan en el branch principal, `main`, bajo la carpeta [`sitio`](sitio). Los archivos generados del sitio son colocados en el branch `gh-pages`. En la gran mayoría de los casos no es recomendable editar los archivos en `gh-pages` manualmente, directamente. Entonces, hay dos workflows recomendados:
- Se corre (`build`) jupyter book localmente, para confirmar que todo se vea bien. Una vez que esté listo, se empujan los archivos del build al repositorio usando el programa ghp-import, corrido con algo parecido a esto: `ghp-import -n -p -f --remote upstream sitio/_build/html`. Los archivos fuente en el repositorio son actualizados usando idealmente un pull request. Esto es lo que he estado haciendo hasta ahora.
- Activando un sistema en GitHub que genera (build) el sitio automáticamente cada vez que se envía un pull request. Este sistema también incluye un preview de los cambios propuestos, que es muy útil. Este automatización hace futuras modificaciones mucho más sencillas, especialmente cuando se trata de modificaciones de páginas existentes.

Este mecanismo automático ya está activo. Ahora, al crear un pull request (PR), después de un minuto (mas o menos) verán un enlace como este bajo "Deploy Preview for sage-puppy-e64764 ready!":
![image](https://user-images.githubusercontent.com/742403/220565139-f8aea2b4-9801-4ef0-81e8-9a5e318d3a4d.png)

Este enlace los llevará a una versión temporal del sitio donde pueden confirmar los cambios propuestos en el PR. Una vez que le hagan "merge" al PR, el sitio será reconstruido automáticamente en `gh-pages` con los cambios en el PR. Esto toma un par de minutos.

Pueden ver un ejemplo de esto en un PR reciente, como este: #3

Es sencillo editar una página directamente desde el sitio web: en los íconos arriba a la derecha de cada página, presionen el ícono de gihub y luego seleccionen "suggest edit". Esto los lleva a github, con el interfaz de modificación del markdown.
![image](https://user-images.githubusercontent.com/742403/220717342-8afb20b4-5ee4-4547-9c92-c5011633431b.png)

Cuando estén listos a enviar los cambios, por favor seleccionen "Create a new branch for this commit and start a pull request" antes de presionar "Commit changes". Esto nos permitir a otros revisar los cambios antes de aprobarlos.

![image](https://user-images.githubusercontent.com/742403/220717826-e1062654-4757-4bcb-9d85-aa8300dcf432.png)


Hay dos archivos importantes de configuración del sitio:
- [`_config.yml`](sitio/_config.yml). [Configuraciones básicas del sitio](https://jupyterbook.org/en/stable/customize/config.html). Raremente tendremos que modificar esto.
- [`_toc.yml`](sitio/_toc.yml). "Table of Content". [Organización de las páginas en el sitio.](https://jupyterbook.org/en/stable/basics/organize.html)
6 changes: 3 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: dinosip-python-web
name: aplsurp-python-web
channels:
- conda-forge
- nodefaults
dependencies:
- python=3.9
- python=3.12
- pip
- jupyter-book
- ipykernel
- ghp-import
- folium
- matplotlib
- numpy
- pandas
- seabird
# - geopandas
# - xarray
# - seaborn
# - folium
# - cartopy

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
jupyter-book
attrs<22
nbclient<0.6
attrs
nbclient
matplotlib
numpy
22 changes: 13 additions & 9 deletions site/_config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Book settings
# Learn more at https://jupyterbook.org/customize/config.html

title: DINOSIP Python workshop
author: Emilio Mayorga
logo: img/dinosip-logo.png
title: APL SURP Python Course
author: Emilio Mayorga, Ethan Campbell
copyright: "2025"
logo: img/surp_logo_115x168.png
# HMM, where do these show up?
announcement: Python tour workshop for DINO SIP
announcement: Python course for APL SURP program
description: >-
Python tour workshop for DINO SIP
Python course for APL SURP program

# Force re-execution of notebooks on each build.
# See https://jupyterbook.org/content/execute.html
Expand All @@ -25,21 +26,24 @@ parse:

# Information about where the book exists on the web
repository:
url: https://github.com/emiliom/dinosip-python # Online location of your book
url: https://github.com/UW-APL-SURP/aplsurp-python # Online location of your book
path_to_book: site # Optional path to your book, relative to the repository root
branch: main # Which branch of the repository should be used when creating links (optional)

# Add GitHub buttons to your book
# See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository
html:
#baseurl: https://emiliom.github.io/nica-ecocomputacion/
#favicon: imagenes/favicon1.ico
home_page_in_navbar: false
#baseurl: https://UW-APL-SURP.github.io/aplsurp-python/
#favicon: img/favicon1.ico
home_page_in_navbar: true
#extra_navbar: ""
use_issues_button: true
use_repository_button: true
use_edit_page_button: true

launch_buttons:
colab_url: "https://colab.research.google.com"

sphinx:
config:
language: en
Expand Down
37 changes: 25 additions & 12 deletions site/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@
# Learn more at https://jupyterbook.org/customize/toc.html

format: jb-book
root: index

chapters:
- file: install-run
title: Installation, execution
- file: overview
title: Quick overview
- file: lessons
title: Detailed lessons
- file: advancedexamples
title: Advanced examples
- file: cheatsheets
root: index
parts:
- caption:
chapters:
- file: python
- file: overview
- caption: Main lessons
chapters:
- file: lessons/index
title: Overview
- file: "lessons/APL_SURP_Python_course_Notebook_1.ipynb"
title: Day 1
- file: "lessons/APL_SURP_Python_course_Notebook_2.ipynb"
title: Day 2
- file: "lessons/APL_SURP_Python_course_Notebook_3_blank_copy.ipynb"
title: Day 3
- caption: Other resources
chapters:
- file: install-run
title: Running Python
- file: complementary_lessons
title: Complementary lessons
- file: cheatsheets
- file: advancedexamples
title: Advanced examples
9 changes: 1 addition & 8 deletions site/advancedexamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[SeaBird](https://www.seabird.com/) CTD instruments are widely used in Oceanography. Reading SeaBird CTD `.cnv` data files is therefore a common task. The files are text based and one could write code from scratch to read and parse them, but then lots of people would be reinventing the wheel, imperfectly.

We will use the existing `ctd` open-source Python package, https://pyoceans.github.io/python-ctd/. We'll go through a notebook that demonstrates its use. I copied the notebook to [notebooks/ctd-quick_intro.ipynb](./notebooks/ctd-quick_intro.ipynb). It can be run by installing the `ctd` package in your conda environment. If at the terminal, you'd do this, where `my_conda_env` is the name of your conda environment:
We will use the existing `ctd` open-source Python package, https://pyoceans.github.io/python-ctd/. We'll go through a [notebook found on that site](https://pyoceans.github.io/python-ctd/quick_intro-output.html#Reading-and-plotting) that demonstrates its use; I copied the notebook to [notebooks/ctd-quick_intro.ipynb](./notebooks/ctd-quick_intro.ipynb). It can be run by installing the `ctd` package in your conda environment. If at the terminal, you'd do this, where `my_conda_env` is the name of your conda environment:
```bash
conda activate my_conda_env
conda install -c conda-forge ctd
Expand All @@ -18,10 +18,3 @@ Here's a depth profile image created by the `ctd` example notebook:
```{note}
It's not uncommon for different people or groups to create open-source packages with overlapping capabilities. There is at least one other package that reads SeaBird `cnv` files: the `seabird` package, https://seabird.readthedocs.io. Often in these cases, each package may have some features that the other one doesn't.
```

## microSWIFT data file

Prospects for reading [microSWIFT](https://apl.uw.edu/project/project.php?id=swift) data files in Python:

- https://github.com/jacobrdavis
- https://github.com/edwinrainville/microSWIFT-io
5 changes: 2 additions & 3 deletions site/cheatsheets.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
It's hard to remember the details of syntax and function calls without using it actively and regularly. Compact "cheat sheets" can be a convenient resource for looking up specific details and capabilities. Here are a set of Python cheat sheets that should be useful.

- General: https://www.pythoncheatsheet.org/
- General and Matplotlib: https://ehmatthes.github.io/pcc_2e/cheat_sheets/cheat_sheets/
- Numpy: https://www.datacamp.com/cheat-sheet/numpy-cheat-sheet-data-analysis-in-python
- Matplotlib and Pandas: https://python-graph-gallery.com/cheat-sheets/
- Pandas: https://www.datacamp.com/cheat-sheet/pandas-cheat-sheet-for-data-science-in-python
- Matplotlib: https://matplotlib.org/cheatsheets/
- Pandas: https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf
15 changes: 6 additions & 9 deletions site/lessons.md → site/complementary_lessons.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Detailed lessons
# Complementary, in-depth lessons from other groups

There are **many** free Python tutorials online; a quick search will produce a very long list. For example, [Python Basics: Introduction to Python](https://realpython.com/learning-paths/python-basics/) features many detailed lessons from [https://realpython.com](https://realpython.com), which I find to be a great source for Python in-depth learning. [Project Pythia Foundations](https://foundations.projectpythia.org/landing-page.html) has a great collection of more advanced tutorials especially geared for the earth sciences, including Oceanography.
There are **many** free Python tutorials online; a quick search will produce a very long list. For example, [Python Basics: Introduction to Python](https://realpython.com/learning-paths/python-basics/) features many detailed lessons from [https://realpython.com](https://realpython.com), which are a great source for Python in-depth learning. [Project Pythia Foundations](https://foundations.projectpythia.org/landing-page.html) has a great collection of more advanced tutorials especially geared for the earth sciences, including Oceanography.

Instead of creating learning materials from scratch, we'll take advantage of [The Carpentries, https://carpentries.org](https://carpentries.org), "a global community teaching foundational computational and data science skills to researchers in academia, industry and government." Carpentries tutorials and lessons are openly accessible.
The [lessons we created for the APL SURP course](lessons/index) cover each topic relatively briefly. Rather than creating new, in-depth learning materials from scratch, we'll take advantage of [The Carpentries](https://carpentries.org), "a global community teaching foundational computational and data science skills to researchers in academia, industry and government." Carpentries tutorials and lessons are openly accessible.

Specifically, **we'll use the [Plotting and Programming in Python](https://swcarpentry.github.io/python-novice-gapminder/) lesson from The Carpentries**: "This lesson is an introduction to programming in Python 3 for people with little or no previous programming experience." It's also referred to as the "gapminder" lesson, based on the dataset it uses.
Specifically, **we'll focus on the [Plotting and Programming in Python](https://swcarpentry.github.io/python-novice-gapminder/) lesson from The Carpentries**: "This lesson is an introduction to programming in Python 3 for people with little or no previous programming experience." It's also referred to as the "gapminder" lesson, based on the dataset it uses.

```{note}
Another, similar Carpentries lesson that you may find helpful is [Programming with Python](https://swcarpentry.github.io/python-novice-inflammation/): "The best way to learn how to program is to do something useful, so this introduction to Python is built around a common scientific task: data analysis."
```

## Getting the Data

The data we will use is taken from the [gapminder](https://en.wikipedia.org/wiki/Gapminder_Foundation) dataset. To obtain it, download and unzip the file [python-novice-gapminder-data.zip](https://swcarpentry.github.io/python-novice-gapminder/files/python-novice-gapminder-data.zip). In order to follow the presented material, you should launch JupyterLab in the folder that contains the unzipped ddadta file. (see [Starting JupyterLab](https://swcarpentry.github.io/python-novice-gapminder/01-run-quit.html#starting-jupyterlab)).
The data used in this subset of Software Carpentry lessons is taken from the [gapminder](https://en.wikipedia.org/wiki/Gapminder_Foundation) dataset. To obtain it, download and unzip the file [python-novice-gapminder-data.zip](https://swcarpentry.github.io/python-novice-gapminder/files/python-novice-gapminder-data.zip). To execute the lesson materials, launch JupyterLab in the folder that contains the unzipped data file. (see [Starting JupyterLab](https://swcarpentry.github.io/python-novice-gapminder/01-run-quit.html#starting-jupyterlab)).

## Lesson episodes

The Plotting and Programming in Python lesson is intended as a workshop that takes a full day. We will go through a *subset* of the materials (referred to as "episodes") and will only highlight some specific points within each episode. The goal is to examine in more detail most of the Python and programming elements we saw in the previous "Quick overview".
The *Plotting and Programming in Python* lesson is intended as a workshop that takes a full day. The *subset* of materials (referred to as "episodes") presented here expands on the lessons presented directly in the APL SURP course.

### The basics

Expand All @@ -29,7 +29,6 @@ The Plotting and Programming in Python lesson is intended as a workshop that tak
- [12. For Loops](https://swcarpentry.github.io/python-novice-gapminder/12-for-loops.html)
- [13. Conditionals](https://swcarpentry.github.io/python-novice-gapminder/13-conditionals.html)

### -- Break and Q/A
### More advanced topics

- [Numpy -- from Project Pythia](https://foundations.projectpythia.org/core/numpy/numpy-basics.html)
Expand All @@ -40,5 +39,3 @@ The Plotting and Programming in Python lesson is intended as a workshop that tak
- [16. Writing Functions](https://swcarpentry.github.io/python-novice-gapminder/16-writing-functions.html)

The key points from each episode are [summarized here](https://swcarpentry.github.io/python-novice-gapminder/instructor/key-points.html)

### -- Break and Q/A
Binary file added site/img/Pythia-launch-kernel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added site/img/surp_logo_115x168.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading