Skip to content

Commit b895802

Browse files
committed
added example for plotting MODIS landuse from HRRR model
1 parent 48ab41d commit b895802

3 files changed

Lines changed: 144 additions & 12 deletions

File tree

216 KB
Loading

docs/user_guide/tutorial/paint.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,47 @@ Here are other examples:
127127
| `water` | Water | m |
128128
| | | |
129129

130+
## MODIS Landuse Categories
131+
132+
```python
133+
import matplotlib.patches as mpatches
134+
import matplotlib.pyplot as plt
135+
136+
from herbie import Herbie, paint
137+
from herbie.toolbox import EasyMap, pc
138+
139+
H = Herbie("2026-03-01", model="hrrr")
140+
ds = H.xarray("VGTYP")
141+
142+
ax = EasyMap("50m", figsize=(10, 8), crs=ds.herbie.crs).BORDERS().STATES().ax
143+
art = ax.pcolormesh(
144+
ds.longitude, ds.latitude, ds.vgtyp, transform=pc, **paint.MODIS21.kwargs
145+
)
146+
147+
# Create legend with patches instead of colorbar
148+
present = np.unique(ds.vgtyp).astype(int)
149+
n_cats = len(paint.MODIS21.labels)
150+
colors = ["#ffffff"] + [str(i) for i in paint.MODIS21.colors]
151+
labels = [""] + [str(i) for i in paint.MODIS21.labels]
152+
patches = [
153+
mpatches.Patch(
154+
color=colors[i],
155+
label=labels[i],
156+
)
157+
for i in present
158+
if 1 <= i <= n_cats
159+
]
160+
161+
ax.legend(handles=patches, bbox_to_anchor=(1.01, 1), loc="upper left", fontsize=7)
162+
ax.set_title("HRRR Landuse (MODIS)", loc="left", fontweight="bold")
163+
ax.set_title(f"{H.date:%Hz %d %b %Y}", loc="right")
164+
165+
plt.tight_layout()
166+
plt.savefig("../../_static/paint/herbie_paint_modis21", bbox_inches="tight")
167+
```
168+
169+
![](../../_static/paint/herbie_paint_modis21.png)
170+
130171
## Lightness
131172

132173
![](../../_static/paint/NWS_Sequential_lightness.png)

docs/user_guide/tutorial/paint_figures.ipynb

Lines changed: 103 additions & 12 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)