-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_rainfall.py
More file actions
33 lines (25 loc) · 761 Bytes
/
plot_rainfall.py
File metadata and controls
33 lines (25 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import numpy as np
import xarray as xr
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
ds = xr.open_dataset("RF25_ind2025_rfp25.nc")
rain = ds["RAINFALL"]
rain = rain.where(rain < 9e20)
day = rain.isel(TIME=0)
fig, ax = plt.subplots(
figsize=(8, 7),
subplot_kw={"projection": ccrs.PlateCarree()}
)
mesh = ax.pcolormesh(
rain.LONGITUDE, rain.LATITUDE, day,
cmap="YlGnBu",
vmin=0, vmax=50,
transform=ccrs.PlateCarree(),
shading="auto"
)
ax.coastlines(resolution="50m", linewidth=0.8)
ax.set_extent([66.5, 100.0, 6.5, 38.5], crs=ccrs.PlateCarree())
plt.colorbar(mesh, ax=ax, label="Rainfall (mm)", shrink=0.8)
ax.set_title("Rainfall — Day 1")
plt.savefig("rainfall_map.png", dpi=150, bbox_inches="tight")
plt.show()