Datasets:
File size: 1,023 Bytes
563203c |
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 34 |
import matplotlib.pyplot as plt
import numpy as np
from plots import plot_map_rain, project_to_latlon
# Load the file
data = np.load("2020/202004201700.npz") # Adjust path as needed
rain = data["arr_0"] # The array is stored under 'arr_0'
print("Array shape:", rain.shape) # Shape = (1536, 1536)
# Negative values indicate no data, replace them with NaN:
rain = np.where(rain < 0, np.nan, rain)
# Visualize
print("Making basic plot...")
plt.imshow(rain, cmap="Blues")
plt.colorbar(label="Rainfall (x0.01 mm / 5min)")
plt.title("Rainfall Accumulation – 2020-04-20 17:00 UTC")
plt.savefig("rainfall_20200420_1700_basic.png")
plt.close()
print("Converting and projecting rainfall data...")
rain = rain / 100 # Convert from mm10-2 to mm
rain = rain * 60 / 5 # Convert from mm to mm/h
da_reproj = project_to_latlon(rain)
print(da_reproj)
print("Plotting projected rainfall data...")
plot_map_rain(
data=da_reproj,
title="Rainfall Rate – 2020-04-20 17:00 UTC",
path="rainfall_20200420_1700_map.png",
)
|