Skip to content

Commit 3a492b5

Browse files
committed
updated headers. Only one H1 header in notebook
1 parent e570748 commit 3a492b5

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

examples/case_studies/ssm_hurricane_tracking.ipynb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"cell_type": "markdown",
1919
"metadata": {},
2020
"source": [
21-
"# Introduction\n",
21+
"## Introduction\n",
2222
"In this case study we are going to forecast the paths of hurricanes by applying several State Space Models (SSM). We will begin with a simple two-dimensional constant acceleration tracking model, where we only have one parameter to estimate. Subsequently, we will progressively add complexity and parameters as we develop up our model. \n",
2323
"\n",
2424
"As a brief introduction to SSMs, the general idea is that we define our system using two equations.<br> \n",
@@ -79,7 +79,7 @@
7979
"cell_type": "markdown",
8080
"metadata": {},
8181
"source": [
82-
"# Imports"
82+
"## Imports"
8383
]
8484
},
8585
{
@@ -137,7 +137,7 @@
137137
"cell_type": "markdown",
138138
"metadata": {},
139139
"source": [
140-
"# Helper Functions"
140+
"## Helper Functions"
141141
]
142142
},
143143
{
@@ -484,7 +484,7 @@
484484
"cell_type": "markdown",
485485
"metadata": {},
486486
"source": [
487-
"# Load and Process the Dataset\n",
487+
"## Load and Process the Dataset\n",
488488
"The data comes from the National Oceanic and Atmospheric Administration (NOAA) and is stored in an odd format (likely to save space). We need to wrangle it before we can proceed."
489489
]
490490
},
@@ -700,14 +700,14 @@
700700
"cell_type": "markdown",
701701
"metadata": {},
702702
"source": [
703-
"# Generate visualizations"
703+
"## Generate visualizations"
704704
]
705705
},
706706
{
707707
"cell_type": "markdown",
708708
"metadata": {},
709709
"source": [
710-
"## Hurricane Originations\n",
710+
"### Hurricane Originations\n",
711711
"Let's plot the origination points of the hurricanes in our dataset. There are a few different origination definitions when looking at the tropical cyclones within the HURDAT dataset:\n",
712712
"- A tropical depression when the maximum sustained surface wind is $\\le$ 33.89 knots\n",
713713
"- A tropical cyclone when the maximum sustained surface wind is $\\gt$ 33.89 knots\n",
@@ -8573,7 +8573,7 @@
85738573
"cell_type": "markdown",
85748574
"metadata": {},
85758575
"source": [
8576-
"## Hurricane Fiona's Path\n",
8576+
"### Hurricane Fiona's Path\n",
85778577
"From here on out our task is to forecast the trajectory of Hurricane Fiona. Let's plot the path it took. We mark the origination point in blue and the last observed location of Fiona in red. We see that Fiona initially travels westward and curves to the right making its way northward. This trajectory is typical for Hurricanes that originate in the Northern Hemisphere of the Atlantic Ocean."
85788578
]
85798579
},
@@ -12632,7 +12632,7 @@
1263212632
"\n",
1263312633
"Where in this case we assume the same stochastic innovations on the acceleration term in both dimensions. You can derive the rest of the entries in $Q$ by taking the variance or covariance of the Newtonian equations.\n",
1263412634
"\n",
12635-
"# Optional Material\n",
12635+
"### Optional Material\n",
1263612636
"We can also derive the Newtonian equations of motion from a system of ordinary differntial equations (ODE)s. Here we have a system that consists of:\n",
1263712637
"\n",
1263812638
"1. $\\dot{p}(t) = v(t)$\n",
@@ -17150,7 +17150,7 @@
1715017150
"cell_type": "markdown",
1715117151
"metadata": {},
1715217152
"source": [
17153-
"# Generate 24-hour forecasts with our Newtonian model"
17153+
"### Generate 24-hour forecasts with our Newtonian model"
1715417154
]
1715517155
},
1715617156
{
@@ -21215,7 +21215,7 @@
2121521215
"cell_type": "markdown",
2121621216
"metadata": {},
2121721217
"source": [
21218-
"# Adding Deterministic Covariates/Exogenous Variables\n",
21218+
"## Adding Deterministic Covariates/Exogenous Variables\n",
2121921219
"In our dataset we have variables that aren't a part of the Newtonian system process, but may carry information that we can leverage to better track the path of the hurricane. We have two options when introducing these exogenous variables into our model. We can add them in as time invariant or time-varying variables. In our case, we are going to add exogenous variables as time invariant. Our aim then is to model our observations as:\n",
2122021220
"\n",
2122121221
"$$\n",
@@ -21856,7 +21856,7 @@
2185621856
"cell_type": "markdown",
2185721857
"metadata": {},
2185821858
"source": [
21859-
"# Make in-sample forecasts with new exogenous model"
21859+
"## Make in-sample forecasts with new exogenous model"
2186021860
]
2186121861
},
2186221862
{
@@ -25830,7 +25830,7 @@
2583025830
"cell_type": "markdown",
2583125831
"metadata": {},
2583225832
"source": [
25833-
"# Generate 24-hour forecasts with our Exogenous SSM"
25833+
"### Generate 24-hour forecasts with our Exogenous SSM"
2583425834
]
2583525835
},
2583625836
{
@@ -29927,7 +29927,7 @@
2992729927
"cell_type": "markdown",
2992829928
"metadata": {},
2992929929
"source": [
29930-
"# Add B-Splines\n",
29930+
"## Add B-Splines\n",
2993129931
"In the previous section, we tried adding an interaction term between the maximum sustained surface wind speed and the minumum central pressure. However, our estimated parameters were not too far off from zero. In this section we are going to attempt to model the non-linear complexities of the path, particularly in the mid-section, using cubic B-splines.\n",
2993229932
"\n",
2993329933
"We first need to define what variables we are going to model as a smooth function. In our case, we are going to model the longitude values as a smooth function of the latitude values and vice versa. \n",
@@ -30652,7 +30652,7 @@
3065230652
"cell_type": "markdown",
3065330653
"metadata": {},
3065430654
"source": [
30655-
"# Make in-sample forecasts with new spline model"
30655+
"### Make in-sample forecasts with new spline model"
3065630656
]
3065730657
},
3065830658
{
@@ -38701,7 +38701,7 @@
3870138701
"cell_type": "markdown",
3870238702
"metadata": {},
3870338703
"source": [
38704-
"# Closing Remarks\n",
38704+
"## Closing Remarks\n",
3870538705
"In this case study we looked at how we can track a hurricane in two-dimensional space using a state space representation of Newtonian kinematics. We proceeded to expand on the pure Newtonian model and added exogenous variables that may hold information pertintent to the Hurricane's track. We then expanded our model by modeling our variables as smooth functions using cubic B-splines. \n",
3870638706
"\n",
3870738707
"Throughout, the case study we have been evaluating our 24-hour forecasts and our overall mean error is smallest with our first Newtonian model. Below you will find the errors from all three models plotting against one another. It seems that (as expected) the exogenous information we included in the exogenous model was not informative with respect to the hurricances' trajectory. However, it is worth noting that in the period (around 40 through 56) where the hurricane manuevers we obtain less spikes in error in that section with our cubic B-spline model. This implies that the model could benefit from some non-linear specification to handle the angular acceleration. Hopefully, someday the `StateSpace` module in `pymc-extras` may support non-linear state space specifications with either the Extended Kalman Filter or with the Unscented Kalman Filter. Until then you can learn more about how to build your own custom state space models with the `StateSpace` module on the `pymc-extras` official GitHub repository."
@@ -38762,15 +38762,15 @@
3876238762
"cell_type": "markdown",
3876338763
"metadata": {},
3876438764
"source": [
38765-
"# Authors\n",
38765+
"## Authors\n",
3876638766
"* Authored by Jonathan Dekermanjian in April, 2025 "
3876738767
]
3876838768
},
3876938769
{
3877038770
"cell_type": "markdown",
3877138771
"metadata": {},
3877238772
"source": [
38773-
"# Acknowledgements\n",
38773+
"## Acknowledgements\n",
3877438774
"* Chris Fonnesbeck who reviewed and provided valueable feedback that improved the text\n",
3877538775
"* Jesse Grabowski reviewed and provided valueable feedback that improved the text and content, and suggested additional content that improve the overall quality of the work."
3877638776
]
@@ -38779,7 +38779,7 @@
3877938779
"cell_type": "markdown",
3878038780
"metadata": {},
3878138781
"source": [
38782-
"# References \n",
38782+
"## References \n",
3878338783
"\n",
3878438784
":::{bibliography}\n",
3878538785
":filter: docname in docnames \n",
@@ -38792,7 +38792,7 @@
3879238792
"cell_type": "markdown",
3879338793
"metadata": {},
3879438794
"source": [
38795-
"# Watermark"
38795+
"## Watermark"
3879638796
]
3879738797
},
3879838798
{

examples/case_studies/ssm_hurricane_tracking.myst.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ myst:
2424

2525
+++
2626

27-
# Introduction
27+
## Introduction
2828
In this case study we are going to forecast the paths of hurricanes by applying several State Space Models (SSM). We will begin with a simple two-dimensional constant acceleration tracking model, where we only have one parameter to estimate. Subsequently, we will progressively add complexity and parameters as we develop up our model.
2929

3030
As a brief introduction to SSMs, the general idea is that we define our system using two equations.<br>
@@ -82,7 +82,7 @@ We wrote the equation for $P_{t\|t}$ above using Joseph form, which is more nume
8282

8383
+++
8484

85-
# Imports
85+
## Imports
8686

8787
```{code-cell} ipython3
8888
# Import libraries
@@ -120,7 +120,7 @@ from pymc_extras.statespace.utils.constants import (
120120
pio.renderers.default = "notebook"
121121
```
122122

123-
# Helper Functions
123+
## Helper Functions
124124

125125
```{code-cell} ipython3
126126
def ellipse_covariance(covariance: np.ndarray) -> np.ndarray:
@@ -437,7 +437,7 @@ def plot_model_evaluations(
437437
return fig
438438
```
439439

440-
# Load and Process the Dataset
440+
## Load and Process the Dataset
441441
The data comes from the National Oceanic and Atmospheric Administration (NOAA) and is stored in an odd format (likely to save space). We need to wrangle it before we can proceed.
442442

443443
```{code-cell} ipython3
@@ -580,11 +580,11 @@ df_clean = (
580580
df_clean.head()
581581
```
582582

583-
# Generate visualizations
583+
## Generate visualizations
584584

585585
+++
586586

587-
## Hurricane Originations
587+
### Hurricane Originations
588588
Let's plot the origination points of the hurricanes in our dataset. There are a few different origination definitions when looking at the tropical cyclones within the HURDAT dataset:
589589
- A tropical depression when the maximum sustained surface wind is $\le$ 33.89 knots
590590
- A tropical cyclone when the maximum sustained surface wind is $\gt$ 33.89 knots
@@ -630,7 +630,7 @@ fig.update_layout(
630630
fig
631631
```
632632

633-
## Hurricane Fiona's Path
633+
### Hurricane Fiona's Path
634634
From here on out our task is to forecast the trajectory of Hurricane Fiona. Let's plot the path it took. We mark the origination point in blue and the last observed location of Fiona in red. We see that Fiona initially travels westward and curves to the right making its way northward. This trajectory is typical for Hurricanes that originate in the Northern Hemisphere of the Atlantic Ocean.
635635

636636
```{code-cell} ipython3
@@ -761,7 +761,7 @@ $$
761761

762762
Where in this case we assume the same stochastic innovations on the acceleration term in both dimensions. You can derive the rest of the entries in $Q$ by taking the variance or covariance of the Newtonian equations.
763763

764-
# Optional Material
764+
### Optional Material
765765
We can also derive the Newtonian equations of motion from a system of ordinary differntial equations (ODE)s. Here we have a system that consists of:
766766

767767
1. $\dot{p}(t) = v(t)$
@@ -1007,7 +1007,7 @@ plot_model_evaluations(
10071007
).show(width=1000, renderer="svg")
10081008
```
10091009

1010-
# Generate 24-hour forecasts with our Newtonian model
1010+
### Generate 24-hour forecasts with our Newtonian model
10111011

10121012
```{code-cell} ipython3
10131013
:tags: [hide-output]
@@ -1035,7 +1035,7 @@ plot_model_evaluations(
10351035
).show(width=1000, renderer="svg")
10361036
```
10371037

1038-
# Adding Deterministic Covariates/Exogenous Variables
1038+
## Adding Deterministic Covariates/Exogenous Variables
10391039
In our dataset we have variables that aren't a part of the Newtonian system process, but may carry information that we can leverage to better track the path of the hurricane. We have two options when introducing these exogenous variables into our model. We can add them in as time invariant or time-varying variables. In our case, we are going to add exogenous variables as time invariant. Our aim then is to model our observations as:
10401040

10411041
$$
@@ -1363,7 +1363,7 @@ az.plot_forest(
13631363
);
13641364
```
13651365

1366-
# Make in-sample forecasts with new exogenous model
1366+
## Make in-sample forecasts with new exogenous model
13671367

13681368
```{code-cell} ipython3
13691369
predicted_covs = exogenous_idata.posterior["predicted_covariance"].mean(("chain", "draw"))
@@ -1389,7 +1389,7 @@ plot_model_evaluations(
13891389
).show(width=1000, renderer="svg")
13901390
```
13911391

1392-
# Generate 24-hour forecasts with our Exogenous SSM
1392+
### Generate 24-hour forecasts with our Exogenous SSM
13931393

13941394
+++
13951395

@@ -1441,7 +1441,7 @@ plot_model_evaluations(
14411441
).show(width=1000, renderer="svg")
14421442
```
14431443

1444-
# Add B-Splines
1444+
## Add B-Splines
14451445
In the previous section, we tried adding an interaction term between the maximum sustained surface wind speed and the minumum central pressure. However, our estimated parameters were not too far off from zero. In this section we are going to attempt to model the non-linear complexities of the path, particularly in the mid-section, using cubic B-splines.
14461446

14471447
We first need to define what variables we are going to model as a smooth function. In our case, we are going to model the longitude values as a smooth function of the latitude values and vice versa.
@@ -1823,7 +1823,7 @@ az.plot_trace(spline_idata, var_names="acceleration_innovations");
18231823
az.plot_trace(spline_idata, var_names=["beta_exog"], compact=True, figsize=(20, 8));
18241824
```
18251825

1826-
# Make in-sample forecasts with new spline model
1826+
### Make in-sample forecasts with new spline model
18271827

18281828
+++
18291829

@@ -1889,7 +1889,7 @@ plot_model_evaluations(
18891889
).show(width=1000, renderer="svg")
18901890
```
18911891

1892-
# Closing Remarks
1892+
## Closing Remarks
18931893
In this case study we looked at how we can track a hurricane in two-dimensional space using a state space representation of Newtonian kinematics. We proceeded to expand on the pure Newtonian model and added exogenous variables that may hold information pertintent to the Hurricane's track. We then expanded our model by modeling our variables as smooth functions using cubic B-splines.
18941894

18951895
Throughout, the case study we have been evaluating our 24-hour forecasts and our overall mean error is smallest with our first Newtonian model. Below you will find the errors from all three models plotting against one another. It seems that (as expected) the exogenous information we included in the exogenous model was not informative with respect to the hurricances' trajectory. However, it is worth noting that in the period (around 40 through 56) where the hurricane manuevers we obtain less spikes in error in that section with our cubic B-spline model. This implies that the model could benefit from some non-linear specification to handle the angular acceleration. Hopefully, someday the `StateSpace` module in `pymc-extras` may support non-linear state space specifications with either the Extended Kalman Filter or with the Unscented Kalman Filter. Until then you can learn more about how to build your own custom state space models with the `StateSpace` module on the `pymc-extras` official GitHub repository.
@@ -1930,18 +1930,18 @@ fig.update_layout(
19301930
fig.show(renderer="svg")
19311931
```
19321932

1933-
# Authors
1933+
## Authors
19341934
* Authored by Jonathan Dekermanjian in April, 2025
19351935

19361936
+++
19371937

1938-
# Acknowledgements
1938+
## Acknowledgements
19391939
* Chris Fonnesbeck who reviewed and provided valueable feedback that improved the text
19401940
* Jesse Grabowski reviewed and provided valueable feedback that improved the text and content, and suggested additional content that improve the overall quality of the work.
19411941

19421942
+++
19431943

1944-
# References
1944+
## References
19451945

19461946
:::{bibliography}
19471947
:filter: docname in docnames
@@ -1951,7 +1951,7 @@ becker2023kalman
19511951

19521952
+++
19531953

1954-
# Watermark
1954+
## Watermark
19551955

19561956
```{code-cell} ipython3
19571957
%load_ext watermark

0 commit comments

Comments
 (0)