Update src/seismic_hazard_forecasting.py
use dataframe total_bounds as the bounding box of SVG file
This commit is contained in:
@@ -724,13 +724,11 @@ verbose: {verbose}")
|
|||||||
(centroids_latlon.x >= AOI_lon[0]) & (centroids_latlon.x <= AOI_lon[1]) &
|
(centroids_latlon.x >= AOI_lon[0]) & (centroids_latlon.x <= AOI_lon[1]) &
|
||||||
(centroids_latlon.y >= AOI_lat[0]) & (centroids_latlon.y <= AOI_lat[1])
|
(centroids_latlon.y >= AOI_lat[0]) & (centroids_latlon.y <= AOI_lat[1])
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
grid_gdf_latlon['AOI']=True #set entire grid to be the area of interest
|
||||||
|
|
||||||
distances_sel = grid_gdf_latlon.loc[grid_gdf_latlon['AOI']]['distance_matrix'].to_numpy()
|
distances_sel = grid_gdf_latlon.loc[grid_gdf_latlon['AOI']]['distance_matrix'].to_numpy()
|
||||||
centroids_sel = grid_gdf_latlon.loc[grid_gdf_latlon['AOI']].centroid
|
centroids_sel = grid_gdf_latlon.loc[grid_gdf_latlon['AOI']].centroid
|
||||||
else:
|
|
||||||
grid_gdf_latlon['AOI']=True #set entire grid to be the area of interest
|
|
||||||
distances_sel = grid_gdf_latlon['distance_matrix'].to_numpy()
|
|
||||||
centroids_sel = grid_gdf_latlon.centroid
|
|
||||||
|
|
||||||
loc_pdf = grid_gdf_latlon['location_PDF'].to_numpy() # extract the previously created location PDF from the GDF
|
loc_pdf = grid_gdf_latlon['location_PDF'].to_numpy() # extract the previously created location PDF from the GDF
|
||||||
|
|
||||||
@@ -821,16 +819,10 @@ verbose: {verbose}")
|
|||||||
plt.close(fig)
|
plt.close(fig)
|
||||||
|
|
||||||
# set image map extent in geographic coordinates
|
# set image map extent in geographic coordinates
|
||||||
if use_AOI:
|
north = grid_gdf_latlon[grid_gdf_latlon['AOI']].total_bounds[3]
|
||||||
north = AOI_lat[1]
|
south = grid_gdf_latlon[grid_gdf_latlon['AOI']].total_bounds[1]
|
||||||
south = AOI_lat[0]
|
east = grid_gdf_latlon[grid_gdf_latlon['AOI']].total_bounds[2]
|
||||||
east = AOI_lon[1]
|
west = grid_gdf_latlon[grid_gdf_latlon['AOI']].total_bounds[0]
|
||||||
west = AOI_lon[0]
|
|
||||||
else:
|
|
||||||
north = grid_gdf_latlon.total_bounds[3]
|
|
||||||
south = grid_gdf_latlon.total_bounds[1]
|
|
||||||
east = grid_gdf_latlon.total_bounds[2]
|
|
||||||
west = grid_gdf_latlon.total_bounds[0]
|
|
||||||
|
|
||||||
# Embed geographic bounding box into the SVG
|
# Embed geographic bounding box into the SVG
|
||||||
map_bounds = dict(zip(("south", "west", "north", "east"),
|
map_bounds = dict(zip(("south", "west", "north", "east"),
|
||||||
@@ -858,7 +850,7 @@ verbose: {verbose}")
|
|||||||
extent=[0, 1, vmin, vmax]) # Note: extent order is different for vertical
|
extent=[0, 1, vmin, vmax]) # Note: extent order is different for vertical
|
||||||
ax.set_xticks([]) # Remove x-ticks for vertical colorbar
|
ax.set_xticks([]) # Remove x-ticks for vertical colorbar
|
||||||
num_ticks = 11 # Show more ticks
|
num_ticks = 11 # Show more ticks
|
||||||
tick_positions = np.linspace(vmin, vmax_hd, num_ticks)
|
tick_positions = np.linspace(vmin, vmax, num_ticks)
|
||||||
ax.set_yticks(tick_positions)
|
ax.set_yticks(tick_positions)
|
||||||
ax.set_yticklabels([f"{tick:.2f}" for tick in tick_positions]) # format tick labels
|
ax.set_yticklabels([f"{tick:.2f}" for tick in tick_positions]) # format tick labels
|
||||||
ax.set_title(colorbar_title, loc='right', pad=15)
|
ax.set_title(colorbar_title, loc='right', pad=15)
|
||||||
|
|||||||
Reference in New Issue
Block a user