You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/earth/forecast.md
+144-1Lines changed: 144 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -7,4 +7,147 @@ kernelspec:
7
7
name: python
8
8
---
9
9
10
-
# Weather Forecasts
10
+
# rolodex: Weather Forecasts
11
+
12
+
One way to model forecast output is a datacube with four dimensions :
13
+
14
+
- 2 spatial dimensions `x` and `y`,
15
+
- a forecast reference time (or initialization time) commonly `time`[datetime64], and
16
+
- a forecast period or "timesteps in to the future" commonly `step`[timedelta64]
17
+
18
+
There is one ancillary variable: 'valid time' which is the time for which the forecast is made: `valid_time = time + step`
19
+
20
+
```{note}
21
+
Note that not all forecast model runs are run for the same length of time! We could model these missing forecasts as NaN values in the output.
22
+
```
23
+
24
+
There are many ways one might index weather forecast output.
25
+
These different ways of constructing views of a forecast data are called "Forecast Model Run Collections" (FMRC).
26
+
For reference, see [this classic image](https://www.unidata.ucar.edu/presentations/caron/FmrcPoster.pdf) where the
27
+
y-axis is the 'valid time', and the x-axis is the 'forecast reference or initialization time':
28
+

29
+
30
+
- "Model Run" : a single model run.
31
+
- "Constant Offset" : all values for a given lead time.
32
+
- "Constant Forecast" : all forecasts for a given time in the future.
33
+
- "Best Estimate" : A best guess stitching together the analysis or initialization fields for past forecasts with the latest forecast.
34
+
35
+
## Highlights
36
+
37
+
All of these patterns are "vectorized indexing", though generating the needed indexers is complicated by missing data.
38
+
39
+
`ForecastIndex` encapsulates this logic and,
40
+
41
+
1. Demonstrates how fairly complex indexing patterns can be abstracted away with a custom Index, and
42
+
1. Again illustrates the value of a custom Index in persisting "state" or extra metadata (here the type of model used).
43
+
44
+
## Example
45
+
46
+
Read an example dataset -- downward short-wave radiation flux from the NOAA's HRRR forecast system ([High Resolution Rapid Refresh](https://rapidrefresh.noaa.gov/hrrr/)).
With the `valid_time` array, we can illustrate the complex structure of this datacube.
71
+
72
+
- green box illustrates the bounding box of valid forecast data, any white cells within this box are NaN --- no forecast was generated for that forecast time with that initialization time.
73
+
- the horizontal black line "2025-01-02 21:00" has 4 valid forecasts, though the underlying data has 23 data points (mostly NaN).
74
+
75
+
```{code-cell}
76
+
---
77
+
tags: [hide-input]
78
+
---
79
+
import numpy as np
80
+
import matplotlib.pyplot as plt
81
+
time = "2025-01-02T21:00"
82
+
83
+
(
84
+
cube.dswrf
85
+
.isel(x=10, y=20)
86
+
.plot(
87
+
x="time",
88
+
y="valid_time",
89
+
cmap="plasma",
90
+
robust=True,
91
+
# edgecolors="#fefefe",
92
+
# linewidths=0.003,
93
+
aspect=2,
94
+
size=5,
95
+
)
96
+
)
97
+
plt.axhline(np.datetime64(time), color="k")
98
+
plt.plot(
99
+
cube.time.data[[0, -1, -1, 0, 0]],
100
+
cube.valid_time.data[
101
+
[0, -1, -1, 0, 0],
102
+
[0, 0, -1, -1, 0],
103
+
],
104
+
color="#32CD32",
105
+
lw=2,
106
+
)
107
+
```
108
+
109
+
We will index out all forecasts for 2025-01-02 21:00, notice that there are 4 valid forecasts.
110
+
111
+
And then assign `rolodex.ForecastIndex` to `time`, `step`, `valid_time`. We pass a custom kwarg `model` to indicate the type of forecast model used, here "HRRR".
0 commit comments