Hi all,
as I am trying to compare my ICON simulations with radar observation, I want to keep the underlying grid structure in mind. Therefore, I am trying to plot the grid structure of each.
I am reading the data with rasterio, but I am not sure how I could plot the underlying radar grid structure. Could someone help me how I could do this?
The code for plotting my radar data is the following:
# Erstellen der Figuren und Achsen
fig = plt.figure(figsize=(20, 6))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.Mercator())
ax.set_extent([10.3, 38.3, 55.83, 67.83], crs=ccrs.PlateCarree())
ax.coastlines(linewidth=.5)
ax.add_feature(cf.LAND, color='white', alpha=.15)
ax.add_feature(cf.BORDERS, linestyle='-', linewidth=.6)
gl = ax.gridlines(draw_labels=True, linewidth=1, color='gray', alpha=0.5, linestyle='--')
gl.top_labels = False
gl.right_labels = False
gl.left_labels = False
# Load data
dataset = rasterio.open(flist_rasterio[3])
# read the data
data = dataset.read()
# mask all NoData-values with True, convert the data with the meta-data values and replace all as true-marked nodata-values with a nan
nodata_mask = data == nodata
data = gain * data + offset
data[nodata_mask] = np.nan
# Reshaped the data
data_reshaped = np.reshape(data, (dataset.height, dataset.width))
# Plotting GeoTIFF-Data
extent = (dataset.bounds.left, dataset.bounds.right, dataset.bounds.bottom, dataset.bounds.top)
boundaries = [0, 0.01, 0.1, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 2.5, 3, 5, 10, 20]
colors = ('#FF000000', '#c4c4e4','#8989c9','#4e4eaf','#141494','#272776','#626256','#9d9d35','#d8d815','#f6eb00','#dbb100','#c17600','#a63b00','#8b0000')
cmap = mcolors.ListedColormap(colors)
norm = mcolors.BoundaryNorm(boundaries, cmap.N)
im = ax.imshow(data_reshaped, extent=extent, cmap=cmap, norm=norm, transform=get_crs_of_data(dataset))
# Add colorbar to figure
divider = make_axes_locatable(ax)
cax = divider.new_horizontal(size="2%", pad=0.05, axes_class=plt.Axes)
fig.add_axes(cax)
cbar = fig.colorbar(im, cax=cax, orientation='vertical', ticks=boundaries, label='Precipitation rate [kg/(m$^2$h)]')
#Adjust the colour bar limits to remove the masked values
cbar.ax.set_ylim(0.01, cbar.ax.get_ylim()[1])
fig.tight_layout()
# Zeige das gesamte Bild an
plt.show()
while my output looks like this: