Skip to content

Notebook: Wave Height from Buoy #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 43 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3001ecc
update descriptions
cyschneck Dec 5, 2024
0d6a586
notebook edits
cyschneck Dec 18, 2024
0a0cb31
Apply automatic changes
cyschneck Dec 18, 2024
162cfac
edits
cyschneck Dec 18, 2024
6d6adf3
Merge branch 'main' of https://github.com/cyschneck/wavelet-cookbook
cyschneck Dec 18, 2024
761854d
Merge branch 'main' into main
cyschneck Dec 18, 2024
3cf7f8a
choosing which wavelet
cyschneck Dec 18, 2024
c4280f9
ignore mathworks links
cyschneck Dec 19, 2024
8ca2add
update contributors, thumbnail
cyschneck Dec 19, 2024
a55a70a
updated edits
cyschneck Dec 23, 2024
bd42650
spelling edits
cyschneck Dec 23, 2024
563b584
Merge branch 'ProjectPythia:main' into main
cyschneck Dec 27, 2024
3e70b12
fix spelling, reorganize workflows
cyschneck Jan 10, 2025
5939309
Merge branch 'main' of https://github.com/cyschneck/wavelet-cookbook
cyschneck Jan 10, 2025
f60b490
Merge branch 'main' of https://github.com/cyschneck/wavelet-cookbook
cyschneck Jan 10, 2025
bfd39b0
update README.md
cyschneck Jan 10, 2025
b02d02f
update README.md
cyschneck Jan 10, 2025
558a41f
setup buoy wave height notebook
cyschneck Mar 14, 2025
a442365
add buoy to toc
cyschneck Mar 14, 2025
0b03c83
retrieve data via requests
cyschneck Mar 14, 2025
4f5e992
setup power spectrum
cyschneck Mar 18, 2025
0ef7b81
update to station 41001
cyschneck Mar 18, 2025
2063a80
two years of data
cyschneck Mar 18, 2025
aeecc24
array size fix
cyschneck Mar 18, 2025
5fcb7ff
update date range
cyschneck Mar 21, 2025
b6c8a9b
add dates to x axis imshow
cyschneck Mar 21, 2025
8f9b675
remove hours from x-axis
cyschneck Mar 21, 2025
59bfc5f
expand background
cyschneck Mar 24, 2025
6b30891
upload map images
cyschneck Mar 24, 2025
56f374c
update headers
cyschneck Mar 24, 2025
49924e0
spelling edits
cyschneck Mar 25, 2025
4cc9f97
add static images
cyschneck Apr 7, 2025
34201bb
remove contourf
cyschneck Apr 8, 2025
9e51464
remove contourf
cyschneck Apr 8, 2025
726af38
reset x-axis
cyschneck Apr 9, 2025
b342b72
update workflow folder
cyschneck Apr 25, 2025
23e3fee
reset paths
cyschneck Apr 25, 2025
1164951
edit descriptions
cyschneck Apr 25, 2025
f25e2d8
add descriptions
cyschneck Apr 25, 2025
3be1cc9
edit spelling
cyschneck Apr 25, 2025
92b4cb5
edit descriptions
cyschneck Apr 30, 2025
294ba3e
update descriptions
cyschneck May 2, 2025
374371d
update description
cyschneck May 9, 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
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ Wavelets are a powerful tool to analyze time-series data. When data frequencies

This cookbook is broken into two main sections:

- Foundations
- Example Workflows
- Introduction
- Example Geoscience Workflows

### Foundations

_"Wavelet Basics"_ covers the motivation and background for wavelet analysis by reviewing time-series data and the strengths and weaknesses of other signal analysis tools like Fourier Transform

### Example Workflows
### Introduction

- _"Wavelet Basics"_: Understand the motivation and background for wavelet analysis by reviewing time-series data and the strengths and weaknesses of other signal analysis tools like Fourier Transform
- _"PyWavelets and Jingle Bells"_: Learn how to use `PyWavelets`, a Python implementation of wavelet analysis, to determine the order of notes in a simple musical piece
- _"Spy Keypad"_: Learn how to use wavelets to undercover the frequency and order of notes in an unknown piece of audio data
- _"Atmospheric Data: Nino 3 SST Index"_: Learn how to apply wavelets to real atmospheric and oceanic data to generate a power wavelet scalogram, similiar to the 1999 paper ["A Practical Guide to Wavelet Analysis"](https://psl.noaa.gov/people/gilbert.p.compo/Torrence_compo1998.pdf) by Torrence and Compo in Python

### Geoscience Workflows

- _"Atmospheric Data: Nino 3 SST Index"_: Learn how to apply wavelets to real atmospheric and oceanic data to generate a power wavelet scalogram, similar to the 1999 paper ["A Practical Guide to Wavelet Analysis"](https://psl.noaa.gov/people/gilbert.p.compo/Torrence_compo1998.pdf) by Torrence and Compo in Python

## Running the Notebooks

Expand All @@ -63,17 +63,15 @@ Jupyter](https://foundations.projectpythia.org/foundations/getting-started-jupyt

If you are interested in running this material locally on your computer, you will need to follow this workflow:

(Replace "cookbook-example" with the title of your cookbooks)

1. Clone the `https://github.com/ProjectPythia/cookbook-example` repository:
1. Clone the `https://github.com/ProjectPythia/wavelet-cookbook` repository:

```bash
git clone https://github.com/ProjectPythia/cookbook-example.git
git clone https://github.com/ProjectPythia/wavelet-cookbook.git
```

1. Move into the `cookbook-example` directory
1. Move into the `wavelet-cookbook` directory
```bash
cd cookbook-example
cd wavelet-cookbook
```
1. Create and activate your conda environment from the `environment.yml` file
```bash
Expand Down
7 changes: 4 additions & 3 deletions _toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ parts:
- caption: Introduction
chapters:
- file: notebooks/wavelet-introduction/wavelet-basics
- caption: Example Workflows
- file: notebooks/wavelet-introduction/jingle-bells
- file: notebooks/wavelet-introduction/spy-keypad
- caption: Geoscience Workflows
chapters:
- file: notebooks/example-workflows/jingle-bells
- file: notebooks/example-workflows/spy-keypad
- file: notebooks/example-workflows/nino3
- file: notebooks/example-workflows/buoy-wave-height
611 changes: 611 additions & 0 deletions notebooks/example-workflows/buoy-wave-height.ipynb

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions notebooks/example-workflows/nino3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wavelets = [f\"cmor{x:.1f}-{y:.1f}\" for x in [0.5, 1.5, 2.5] for y in [0.5, 1.0, 1.5]]\n",
"fig, axs = plt.subplots(3, 3, figsize=(10, 10), sharex=True, sharey=True)\n",
Expand Down Expand Up @@ -349,7 +351,7 @@
"metadata": {},
"source": [
"## Power Spectrum\n",
"The power spectrum is the real component of the wavelet coefficents. We can find this value by squaring the absolute value of the `wavelet_coeffs` to return the magnitude of the real component to make a better graph."
"The power spectrum is the real component of the wavelet coefficients. We can find this value by squaring the absolute value of the `wavelet_coeffs` to return the magnitude of the real component to make a better graph."
]
},
{
Expand Down Expand Up @@ -460,11 +462,11 @@
"metadata": {},
"source": [
"## Summary\n",
"Frequency signals appear in more than just audio! A frequency analysis of weather data can inform us about how weather trends change through a year and over a decades worth of data\n",
"Frequency signals appear in more than just audio! A frequency analysis of weather data can inform us about how weather trends change through a year and over a decades worth of data.\n",
"\n",
"### What's next?\n",
"\n",
"- [Learn how more about PyWavelets](https://pywavelets.readthedocs.io/en/latest/regression/index.html)\n"
"- Buoys and Wave(lets)\n"
]
},
{
Expand Down Expand Up @@ -493,7 +495,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.1"
"version": "3.13.2"
},
"nbdime-conflicts": {
"local_diff": [
Expand Down
Binary file added notebooks/images/Z03A_2025_04_07_1910.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 notebooks/images/buoy-station.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 notebooks/images/buoy-world-map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"source": [
"## PyWavelets Overview\n",
"\n",
"PyWavelets returns both the coefficents and frequency information for wavelets from the input data\n",
"PyWavelets returns both the coefficients and frequency information for wavelets from the input data\n",
"\n",
"```\n",
"coeffs, frequencies = pywt.cwt(data, scales, wavelet, sampling_period)\n",
Expand All @@ -124,10 +124,10 @@
"Required:\n",
"- data: input data (as an array)\n",
"- wavelet: name of the Mother wavelet\n",
"- scales: collection of the scales to use will determine the range which the wavelet will be streched or squished\n",
"- scales: collection of the scales to use will determine the range which the wavelet will be stretched or squished\n",
"\n",
"Optional:\n",
"- sampling_period: sampling period for frequencies output. Scales are not scaled by the period (and coefficents are independent of the sampling_period)"
"- sampling_period: sampling period for frequencies output. Scales are not scaled by the period (and coefficients are independent of the sampling_period)"
]
},
{
Expand All @@ -137,7 +137,7 @@
"### Return Values\n",
"The continuous wavelet transforms in PyWavelets returns two values:\n",
"\n",
"- coefficents: collection of complex number outputs for wavelet coefficients\n",
"- coefficients: collection of complex number outputs for wavelet coefficients\n",
"- frequencies: collection of frequencies (if the sampling period are in seconds then frequencies are in hertz otherwise a sampling period of 1 is assumed)\n",
"\n",
"The final size of coefficients depends on the length of the input data and the length of the given scales."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"source": [
"## Wavelet Analysis: Power Spectrum\n",
"\n",
"The power spectrum plots the real component of the complex number returns from wavelet coefficents. This will return information about the frequency and time that we need to use to determine which notes are used in what order for the keypad.\n",
"The power spectrum plots the real component of the complex number returns from wavelet coefficients. This will return information about the frequency and time that we need to use to determine which notes are used in what order for the keypad.\n",
"\n",
"For the purpose of this example, we will use the Morlet mother wavelet. Morlet is one type of mother wavelet useful for working with audio signals and is a good general wavelet to start with when analyzing frequencies of a signal.\n",
"\n",
Expand Down
Loading