easy_vic_build.tools.plot_func.plot_map
Module easy_vic_build.tools.plot_func.plot_map.
Functions
|
|
|
Plot the background for a given basin and grid shape. |
|
Plot basin shapes on a given axis. |
|
Plot grid shapes and point geometries on a given axis. |
|
Plot soil data from HWSD, USDA texture classes, and basin information on multiple maps. |
|
Plot land cover data along with basin, grid, and intersection information on a map. |
|
Plot shapefiles of basins, grids, and intersecting grids on a map with specified boundaries. |
|
Plot the basin map including elevation, basin boundary, river network, and gauge location. |
|
Plot a basemap of the United States with customizable tick settings. |
|
|
|
|
|
|
|
Plot selected basins on a map and optionally annotate and plot basins individually. |
|
Set the boundary limits for the x and y axes. |
|
- easy_vic_build.tools.plot_func.plot_map.plotBackground(basin_shp, grid_shp, fig=None, ax=None)[source]
Plot the background for a given basin and grid shape.
This function plots the background for a given basin and grid shape on a figure and axis. If no axis object is provided, a new figure and axis are created.
- Parameters:
basin_shp (shapefile) – The shapefile object containing basin boundaries.
grid_shp (shapefile) – The shapefile object containing grid boundaries.
fig (matplotlib.figure.Figure, optional) – The figure object to plot on (default is None, a new figure is created).
ax (matplotlib.axes.Axes, optional) – The axis object to plot on (default is None, a new axis is created).
- Returns:
fig (matplotlib.figure.Figure) – The figure object with the background plot.
ax (matplotlib.axes.Axes) – The axis object with the background plot.
- easy_vic_build.tools.plot_func.plot_map.plotGrids(grid_shp, column=None, fig=None, ax=None, plot_kwgs1=None, plot_kwgs2=None)[source]
Plot grid shapes and point geometries on a given axis.
This function plots the grid shapes from the grid_shp object on the given ax (or creates a new figure and axis if ax is not provided). Two sets of keyword arguments can be used to customize the appearance of the grid shapes and the point geometries.
- Parameters:
grid_shp (geopandas.GeoDataFrame) – A GeoDataFrame containing the grid shapes and point geometries to be plotted.
column (str, optional) – The column in grid_shp to use for coloring the grid shapes. If not provided, no coloring is applied.
fig (matplotlib.figure.Figure, optional) – The figure to plot on. If not provided, a new figure is created.
ax (matplotlib.axes.Axes, optional) – The axis to plot on. If not provided, a new axis is created.
plot_kwgs1 (dict, optional) – A dictionary of keyword arguments for customizing the grid shape plot. Defaults to an empty dictionary.
plot_kwgs2 (dict, optional) – A dictionary of keyword arguments for customizing the point geometry plot. Defaults to an empty dictionary.
- Returns:
fig (matplotlib.figure.Figure) – The figure object with the grid shapes and point geometries plotted.
ax (matplotlib.axes.Axes) – The axis object with the grid shapes and point geometries plotted.
- easy_vic_build.tools.plot_func.plot_map.plotBasins(basin_shp, column=None, fig=None, ax=None, plot_kwgs=None)[source]
Plot basin shapes on a given axis.
This function plots the basin shapes from the basin_shp object on the given ax (or creates a new figure and axis if ax is not provided). Additional customization can be done using the plot_kwgs dictionary.
- Parameters:
basin_shp (geopandas.GeoDataFrame) – A GeoDataFrame containing the basin shapes to be plotted.
column (str, optional) – The column in basin_shp to use for coloring the basin shapes. If not provided, no coloring is applied.
fig (matplotlib.figure.Figure, optional) – The figure to plot on. If not provided, a new figure is created.
ax (matplotlib.axes.Axes, optional) – The axis to plot on. If not provided, a new axis is created.
plot_kwgs (dict, optional) – A dictionary of keyword arguments for customizing the basin plot. Defaults to an empty dictionary.
- Returns:
fig (matplotlib.figure.Figure) – The figure object with the basin shapes plotted.
ax (matplotlib.axes.Axes) – The axis object with the basin shapes plotted.
- easy_vic_build.tools.plot_func.plot_map.setBoundary(ax, boundary_x_min, boundary_x_max, boundary_y_min, boundary_y_max)[source]
Set the boundary limits for the x and y axes.
This function adjusts the x and y axis limits of the provided axis object (ax) based on the given boundary values.
- Parameters:
ax (matplotlib.axes.Axes) – The axis object to set the boundaries on.
boundary_x_min (float) – The minimum value for the x-axis.
boundary_x_max (float) – The maximum value for the x-axis.
boundary_y_min (float) – The minimum value for the y-axis.
boundary_y_max (float) – The maximum value for the y-axis.
- Returns:
ax – The axis object with the updated boundaries.
- Return type:
matplotlib.axes.Axes
- easy_vic_build.tools.plot_func.plot_map.plot_basemap(fig=None, ax=None, set_xyticks_bool=True, extent=None, x_locator_interval=15, y_locator_interval=10, yticks_rotation=0)[source]
Plot a basemap of the United States with customizable tick settings.
This function creates a map of the United States, including coastlines, rivers, lakes, and state boundaries, and allows for customization of x and y axis ticks, including their interval and rotation.
- Parameters:
fig (matplotlib.figure.Figure, optional) – The figure to plot on. If not provided, a new figure is created.
ax (matplotlib.axes.Axes, optional) – The axis to plot on. If not provided, a new axis is created.
set_xyticks_bool (bool, optional) – If True, sets the x and y axis ticks to a specified interval (default is True).
x_locator_interval (int, optional) – The interval for the x-axis ticks (default is 15).
y_locator_interval (int, optional) – The interval for the y-axis ticks (default is 10).
yticks_rotation (int, optional) – The rotation angle for the y-axis ticks (default is 0).
- Returns:
fig (matplotlib.figure.Figure) – The figure object with the US basemap plotted.
ax (matplotlib.axes.Axes) – The axis object with the US basemap plotted.
- easy_vic_build.tools.plot_func.plot_map.plot_selected_map(basin_index, dpc, text_name='basin_index', plot_solely=True, column=None, plot_kwgs_set={}, fig=None, ax=None)[source]
Plot selected basins on a map and optionally annotate and plot basins individually.
- Parameters:
basin_index (list) – List of basin indices to be plotted.
dpc (object) – Data processing class instance containing the basin shapefile and related data.
text_name (str, optional) – The type of text annotation to plot. Defaults to “basin_index”.
plot_solely (bool, optional) – Whether to plot each selected basin separately. Defaults to True.
column (str, optional) – The column name from the shapefile to be used for coloring. Defaults to None.
plot_kwgs_set (dict, optional) – Additional keyword arguments to customize the plot (e.g., color map). Defaults to an empty dictionary.
fig (matplotlib.figure.Figure, optional) – The figure object to use for the plot. If None, a new figure will be created. Defaults to None.
ax (matplotlib.axes.Axes, optional) – The axis object to use for the plot. If None, a new axis will be created. Defaults to None.
- Returns:
fig (matplotlib.figure.Figure) – The figure object containing the plot.
ax (matplotlib.axes.Axes) – The axis object containing the plot.
fig_solely (dict or None) – A dictionary of figures and axes for each basin if plot_solely is True, otherwise None.
Notes
The function uses a PlateCarree projection for the map.
The function can annotate each basin with its basin_index or other attributes (e.g., hru_id or gauge_id).
The basins are plotted using the plotBasins function.
Usages:
- fig, ax, fig_solely = plot_selected_map(basin_shp_area_excluding.index.to_list(), # [0, 1, 2]
dpc, text_name=”basin_index”, # “basin_index”, None, plot_solely=False, column=None, # “camels_clim:aridity”, # None plot_kwgs_set=dict()) # {“cmap”: plt.cm.hot}) # dict()
- easy_vic_build.tools.plot_func.plot_map.plotShp(basinShp_original, basinShp, grid_shp, intersects_grids, boundary_x_min, boundary_x_max, boundary_y_min, boundary_y_max, fig=None, ax=None)[source]
Plot shapefiles of basins, grids, and intersecting grids on a map with specified boundaries.
- Parameters:
basinShp_original (geopandas.GeoDataFrame) – Original basin shapefile to be plotted with an outline.
basinShp (geopandas.GeoDataFrame) – Basin shapefile to be plotted on top of the original basin shapefile.
grid_shp (geopandas.GeoDataFrame) – Grid shapefile containing the geometry and point geometry to be plotted.
intersects_grids (geopandas.GeoDataFrame) – Shapefile representing the intersection of grids to be plotted.
boundary_x_min (float) – Minimum x-coordinate (longitude) for the plot boundary.
boundary_x_max (float) – Maximum x-coordinate (longitude) for the plot boundary.
boundary_y_min (float) – Minimum y-coordinate (latitude) for the plot boundary.
boundary_y_max (float) – Maximum y-coordinate (latitude) for the plot boundary.
fig (matplotlib.figure.Figure, optional) – The figure object to use for the plot. If None, a new figure will be created. Defaults to None.
ax (matplotlib.axes.Axes, optional) – The axis object to use for the plot. If None, a new axis will be created. Defaults to None.
- Returns:
fig (matplotlib.figure.Figure) – The figure object containing the plot.
ax (matplotlib.axes.Axes) – The axis object containing the plot.
Notes
The plot includes multiple layers: original basin, basin, grid geometry, grid points, and intersecting grids.
The boundaries of the plot are set using the provided min and max x and y coordinates.
- easy_vic_build.tools.plot_func.plot_map.plotLandCover(basinShp_original, basinShp, grid_shp, intersects_grids, boundary_x_min, boundary_x_max, boundary_y_min, boundary_y_max, fig=None, ax=None)[source]
Plot land cover data along with basin, grid, and intersection information on a map.
- Parameters:
basinShp_original (geopandas.GeoDataFrame) – Original basin shapefile to be plotted with an outline.
basinShp (geopandas.GeoDataFrame) – Basin shapefile to be plotted on top of the original basin shapefile.
grid_shp (geopandas.GeoDataFrame) – Grid shapefile containing land cover classification data.
intersects_grids (geopandas.GeoDataFrame) – Shapefile representing the intersection of grids to be plotted.
boundary_x_min (float) – Minimum x-coordinate (longitude) for the plot boundary.
boundary_x_max (float) – Maximum x-coordinate (longitude) for the plot boundary.
boundary_y_min (float) – Minimum y-coordinate (latitude) for the plot boundary.
boundary_y_max (float) – Maximum y-coordinate (latitude) for the plot boundary.
fig (matplotlib.figure.Figure, optional) – The figure object to use for the plot. If None, a new figure will be created. Defaults to None.
ax (matplotlib.axes.Axes, optional) – The axis object to use for the plot. If None, a new axis will be created. Defaults to None.
- Returns:
fig (matplotlib.figure.Figure) – The figure object containing the plot.
ax (matplotlib.axes.Axes) – The axis object containing the plot.
Notes
The plot includes multiple layers: original basin, basin, grid land cover classification, and intersecting grids.
A color map is applied to the land cover classification with corresponding ticks in the legend.
The boundaries of the plot are set using the provided min and max x and y coordinates.
- easy_vic_build.tools.plot_func.plot_map.plotHWSDSoilData(basinShp_original, basinShp, grid_shp, intersects_grids, boundary_x_min, boundary_x_max, boundary_y_min, boundary_y_max, fig=None, ax=None, fig_T=None, ax_T=None, fig_S=None, ax_S=None)[source]
Plot soil data from HWSD, USDA texture classes, and basin information on multiple maps.
- Parameters:
basinShp_original (geopandas.GeoDataFrame) – Original basin shapefile to be plotted with an outline.
basinShp (geopandas.GeoDataFrame) – Basin shapefile to be plotted on top of the original basin shapefile.
grid_shp (geopandas.GeoDataFrame) – Grid shapefile containing soil data including HWSD and USDA texture classes.
intersects_grids (geopandas.GeoDataFrame) – Shapefile representing the intersection of grids to be plotted.
boundary_x_min (float) – Minimum x-coordinate (longitude) for the plot boundary.
boundary_x_max (float) – Maximum x-coordinate (longitude) for the plot boundary.
boundary_y_min (float) – Minimum y-coordinate (latitude) for the plot boundary.
boundary_y_max (float) – Maximum y-coordinate (latitude) for the plot boundary.
fig (matplotlib.figure.Figure, optional) – The figure object to use for the plot. If None, a new figure will be created. Defaults to None.
ax (matplotlib.axes.Axes, optional) – The axis object to use for the plot. If None, a new axis will be created. Defaults to None.
fig_T (matplotlib.figure.Figure, optional) – The figure object for T_USDA_TEX_CLASS plot. If None, a new figure will be created. Defaults to None.
ax_T (matplotlib.axes.Axes, optional) – The axis object for T_USDA_TEX_CLASS plot. If None, a new axis will be created. Defaults to None.
fig_S (matplotlib.figure.Figure, optional) – The figure object for S_USDA_TEX_CLASS plot. If None, a new figure will be created. Defaults to None.
ax_S (matplotlib.axes.Axes, optional) – The axis object for S_USDA_TEX_CLASS plot. If None, a new axis will be created. Defaults to None.
- Returns:
fig (matplotlib.figure.Figure) – The figure object containing the main plot.
ax (matplotlib.axes.Axes) – The axis object containing the main plot.
fig_S (matplotlib.figure.Figure) – The figure object containing the S_USDA_TEX_CLASS plot.
ax_S (matplotlib.axes.Axes) – The axis object containing the S_USDA_TEX_CLASS plot.
fig_T (matplotlib.figure.Figure) – The figure object containing the T_USDA_TEX_CLASS plot.
ax_T (matplotlib.axes.Axes) – The axis object containing the T_USDA_TEX_CLASS plot.
Notes
Three different maps are created for HWSD soil data, T_USDA_TEX_CLASS, and S_USDA_TEX_CLASS.
Each map is plotted with the corresponding soil classification data overlaid on the basin and grid shapefiles.
The boundaries of the plots are set using the provided min and max x and y coordinates.
Legends for each map are created with the respective soil classification.
- easy_vic_build.tools.plot_func.plot_map.plot_Basin_map(dpc_VIC_level0, dpc_VIC_level1, dpc_VIC_level2, stream_gdf, gauge_coord, x_locator_interval=0.3, y_locator_interval=0.2, fig=None, ax=None, dem_column='SrtmDEM_mean_Value', **kwargs)[source]
Plot the basin map including elevation, basin boundary, river network, and gauge location.
- Parameters:
dpc_VIC_level0 (object) – A VIC model object at level 0 containing grid and basin shapefiles.
dpc_VIC_level1 (object) – A VIC model object at level 1 containing grid and basin shapefiles.
dpc_VIC_level2 (object) – A VIC model object at level 2 containing grid and basin shapefiles.
stream_gdf (geopandas.GeoDataFrame) – A GeoDataFrame containing the river network to be plotted.
gauge_coord ([lon, lat])
x_locator_interval (float, optional) – The interval for x-axis ticks. Defaults to 0.3.
y_locator_interval (float, optional) – The interval for y-axis ticks. Defaults to 0.2.
fig (matplotlib.figure.Figure, optional) – The figure object to use for the plot. If None, a new figure will be created. Defaults to None.
ax (matplotlib.axes.Axes, optional) – The axis object to use for the plot. If None, a new axis will be created. Defaults to None.
- Returns:
fig_dict (dict) – A dictionary containing the figure objects for the basin map and grid basins.
ax_dict (dict) – A dictionary containing the axis objects for the basin map and grid basins.
Notes
The function plots the basin map with layers including the DEM (elevation), basin boundary, river network, and gauge location.
It also generates plots for different grid levels (level 0, 1, and 2) of the VIC model.
- easy_vic_build.tools.plot_func.plot_map.plot_basin_map_combine(evb_dir, evb_dir_hydroanalysis, dpc_VIC_level0, dpc_VIC_level1, dpc_VIC_level3, figsize=(12, 8), grid_kwarg={'bottom': 0.05, 'hspace': 0.1, 'left': 0.06, 'right': 0.99, 'top': 0.98, 'wspace': 0.15}, ax1_box_aspect_factor=1.5, x_locator_interval_landsurface=0.47, y_locator_interval_landsurface=0.5, x_locator_interval_grid=0.24, y_locator_interval_grid=0.3)[source]
- easy_vic_build.tools.plot_func.plot_map.plot_river_network(G, river_paths=None, figsize=(12, 8), mask_by=None, threshold_label=None, labeled_nodes=None)[source]