mapgwm.framework module¶
Functions for preprocessing products from the MAP Framework Team
-
mapgwm.framework.
add_discrete_colors_legend
(ax, data, unit_labels=None, cmap='copper', vmin=None, vmax=None, alpha=1, **kwargs)[source]¶ Add a legend with a colored rectangle and label for each discrete value in data.
- Parameters
- axmatplotlib axes object
An axes of the current figure.
- datanp.array or list-like
Discrete data represented by legend.
- unit_labelsdict, optional
Dictionary of unit labels keyed by integer value in data, by default None, in which case all values in data are included with the integer value as the label.
- cmapstr, optional
Matplotlib colormap, by default ‘copper’
- vminfloat, optional
Minimum value of colormap range, by default None
- vmaxfloat, optional
Maximum value of colormap range, , by default None
- **kwargskeyword arguments to
matplotlib.pyplot.legend()
- Return
- lg
matplotlib.pyplot.legend()
handle
-
mapgwm.framework.
get_layer
(botm_array, i, j, elev)[source]¶ Return the botm_array for elevations at i, j locations.
- Parameters
- botm_array3D numpy array
layer bottom elevations
- iscaler or sequence
row index (zero-based)
- jscaler or sequence
column index
- elevscaler or sequence
elevation (in same units as model)
- Returns
- knp.ndarray (1-D) or scalar
zero-based layer index
-
mapgwm.framework.
layers_to_zones
(botm_array, model_cell_z_centers)[source]¶ Map the layers from one grid to zones on another grid. In other words, given a 3D array of model cell bottom elevations (botm_array), and a second 3D array of cell centers at the same i, j locations as botm_array, but with different vertical discretization (model_cell_z_centers), assign each cell in the model_cell_z_centers array a zone value based on its vertical position within botm array. For example, a cell that lies above all of the elevations in botm_array would be assigned a zone number of zero; a cell that lies below the first bottom elevation would be assigned a value of 1.
- Parameters
- botm_array3D numpy array
Layer bottom elevations
- model_cell_z_centers3D numpy array
Cell centers for another grid that is aligned with botm_array along the i and j axis, but has a different vertical discretation.
- Returns
- zones3D numpy array
Zone numbers indicating the layer in botm_array for each cell in model_cell_z_centers.
-
mapgwm.framework.
plot_cross_sections
(layers, out_pdf, property_data=None, voxel_start_layer=0, voxel_zones=None, cmap='copper', voxel_cmap='viridis', unit_labels=None, add_raster_surfaces=None, modelgrid=None)[source]¶ Generate a multi-page PDF of the layer cross sections.
- Parameters
- layers3D numpy array
Array of layer elevations, starting with the model top. (Length equal to the number of botm_array + 1)
- property_data3D numpy array
Array of zone numbers generated by setup_model_layers.
- out_pdfstr (filepath)
Filename of multi-page PDF.
- voxel_start_layerint, optional
First layer with voxel data, by default 0
- voxel_zonessequence, optional
Zone numbers within property_data that are voxel-based, by default None
- cmapstr, optional
Matplotlib colormap for non-voxel zone numbers, by default ‘copper’, to contrast with colormap for voxel-based zone numbers.
- voxel_cmapstr, optional
Matplotlib colormap for voxel-based zone numbers, by default ‘viridis’.
- unit_labelsdict, optional
Dictionary mapping non-voxel zone numbers to hydrogeologic units, by default None
-
mapgwm.framework.
plot_slice
(layer_elevations, property_data=None, row=0, column=slice(None, None, None), voxel_start_layer=0, voxel_zones=None, cmap='copper', voxel_cmap='viridis', unit_labels=None, add_surfaces=None)[source]¶ Plot a single cross section slice
- Parameters
- layer_elevations3D numpy array
Array of layer elevations, starting with the model top. (Length equal to the number of botm_array + 1)
- property_data3D numpy array
Array of zone numbers generated by setup_model_layers.
- rowint or slice instance
If a cross section along a row is desired, row should be a integer, and column should be a slice instance indicating the range of columns to include. by default, 0.
- columnint or slice instance
If a cross section along a column is desired, column should be a integer, and row should be a slice instance indicating the range of rows to include. by default, slice(None), which includes all columns.
- voxel_start_layerint, optional
First layer with voxel data, by default 0
- voxel_zonessequence, optional
Zone numbers within property_data that are voxel-based, by default None
- cmapstr, optional
Matplotlib colormap for non-voxel zone numbers, by default ‘copper’, to contrast with colormap for voxel-based zone numbers.
- voxel_cmapstr, optional
Matplotlib colormap for voxel-based zone numbers, by default ‘viridis’.
- unit_labelsdict, optional
Dictionary mapping non-voxel zone numbers to hydrogeologic units, by default None
- Returns
- axmatplotlib AxesSubplot instance for figure
-
mapgwm.framework.
plot_zone_maps
(layers, out_pdf, zones=None, voxel_cmap='viridis', zones_cmap='copper', voxel_zones=None, unit_labels=None)[source]¶ Generate a multi-page PDF of the zones in each layer in plan view.
- Parameters
- layers3D numpy array
Array of layer elevations, starting with the model top. (Length equal to the number of botm_array + 1)
- zones3D numpy array
Array of zone numbers generated by setup_model_layers.
- out_pdfstr (filepath)
Filename of multi-page PDF.
- voxel_zonessequence, optional
Zone numbers within property_data that are voxel-based, by default None
- unit_labelsstr, optional
Matplotlib colormap for non-voxel zone numbers, by default ‘copper’, to contrast with colormap for voxel-based zone numbers.
- voxel_cmapstr, optional
Matplotlib colormap for voxel-based zone numbers, by default ‘viridis’.
- unit_labelsdict, optional
Dictionary mapping non-voxel zone numbers to hydrogeologic units, by default None
-
mapgwm.framework.
rasters_to_grid
(modelgrid, dem, rasters, dem_elevation_units='meters', raster_elevation_units='meters', dest_elevation_units='meters')[source]¶ Sample a sequence of rasters onto the i, j locations of a modelgrid, returning a 3D numpy array of the sampled elevations. Fill places with nodata using the next valid surface above.
- Parameters
- modelgridModflow-setup
MFsetupGrid
instance Modflow-setup grid instance describing the model grid
- demstr (filepath)
Raster representing the land surface, at the highest resolution being contemplated for the model. Usually this is derived by sampling a higher resolution DEM using zonal statistics, taking the mean DEM value for each model cell.
- rasterslist of strings (filepaths)
Raster surfaces describing hydrogelogic contacts surrounding the voxel data.
- dem_elevation_unitsstr, optional
Elevation units of dem_means_raster, by default ‘meters’
- framework_raster_elevation_unitsstr, optional
Elevation units of the framework_rasters, by default ‘meters’
- model_length_unitsstr, optional
Length units used in the model, by default ‘meters’
- modelgridModflow-setup
References
See the documentation for the
fill_cells_vertically
function in Modflow-setup for an explanation of the filling process.
-
mapgwm.framework.
setup_model_layers
(dem_means_raster, facies_classes_netcdf, framework_rasters, modelgrid, facies_class_variable='fac_a', dem_elevation_units='meters', framework_raster_elevation_units='meters', model_length_units='meters', output_folder='.', framework_unit_names=None)[source]¶ Generate model layering and property zones from voxel-based zone numbers at uniform depths and raster surfaces that represent hydrogeologic contacts. The voxel-based zone numbers may represent hydrogeologically different sediments, as determined from an airborne electromagnetic survey, and are assumed to have priority over the raster surfaces. The model top is set at the land surface (DEM). Subsequent cell bottoms beneath the land surface are set based on the voxel depths subtracted from the DEM elevations, as sampled at the grid cell centers. Voxel cells without valid data are filled with zone numbers based on their position within the raster surfaces of hydrogeologic contacts. For example, a voxel cell that lies above all of the raster surfaces would be assigned a zone number equal to the highest voxel-based zone number + 3 (an arbitrary gap in the zone numbering between the voxel data and the raster surfaces). Similarly, beneath the lowest voxel cell at each location, grid cells are assigned zone values based on their vertical position relative to the raster surfaces. Below the voxel data, botm_array and their bottom elevations correspond to the framework_raster surfaces. The lowermost (last) raster surface forms the model bottom.
- Parameters
- dem_means_rasterstr (filepath)
Raster representing the land surface, at the highest resolution being contemplated for the model. Usually this is derived by sampling a higher resolution DEM using zonal statistics, taking the mean DEM value for each model cell.
- facies_classes_netcdfstr (filepath)
NetCDF file with the voxel zone data, with a facies_class_variable that contains the zone numbers.
- framework_rasterslist of strings (filepaths)
Raster surfaces describing hydrogelogic contacts surrounding the voxel data.
- modelgridmfsetup.MFsetupGrid instance
Modflow-setup grid instance describing the model grid
- facies_class_variablestr, optional
Variable in facies_classes_netcdf containing the zone information, by default ‘fac_a’
- dem_elevation_unitsstr, optional
Elevation units of dem_means_raster, by default ‘meters’
- framework_raster_elevation_unitsstr, optional
Elevation units of the framework_rasters, by default ‘meters’
- model_length_unitsstr, optional
Length units used in the model, by default ‘meters’
- output_folderstr, optional
Location where results will be saved, by default ‘.’
- framework_unit_nameslist, optional
Unit names for the framework_rasters, by default None
- Returns
- botm_array3D numpy array
Array of layer elevations, starting with the model top. (Length equal to the number of botm_array + 1)
- zone_array3D numpy array
Array of zone numbers, including the values from facies_classes_netcdf, followed by a gap of 3 and then the numbers for the framework_rasters. For example, if there are 5 zones in facies_classes_netcdf, and 3 raster surfaces that intersect cells outside of the voxel data, zones 1-5 would correspond to the voxel zones, and zones 8-10 would correspond to hydrogeologic units bounded by the framework_rasters.
Notes
In addition to the variables returned, the results are written to text-array and GeoTiff files within the output_folder.
Two PDFs of figures are also generated- one showing the layering in cross sections at regular intervals throughout the model grid, and one showing the zones within each layer in plan view.