reV.supply_curve.tech_mapping.TechMapping
- class TechMapping(excl_fpath, res_fpath, sc_resolution=2560, dist_margin=1.05)[source]
Bases:
object
Framework to create map between tech layer (exclusions), res, and gen
- Parameters:
excl_fpath (str) – Filepath to exclusions h5 file, must contain latitude and longitude arrays to allow for mapping to resource points
res_fpath (str) – Filepath to .h5 resource file that we’re mapping to.
sc_resolution (int | None, optional) – Supply curve resolution, does not affect the exclusion to resource (tech) mapping, but defines how many exclusion pixels are mapped at a time, by default 2560
dist_margin (float, optional) – Extra margin to multiply times the computed distance between neighboring resource points, by default 1.05
Methods
map_resource
([max_workers, points_per_worker])Map all resource gids to exclusion gids
map_resource_gids
(gids, excl_fpath, ...)Map exclusion gids to the resource meta.
run
(excl_fpath, res_fpath[, dset, ...])Run parallel mapping and save to h5 file.
save_tech_map
(excl_fpath, dset, indices[, ...])Save tech mapping indices and coordinates to an h5 output file.
Attributes
Get the upper bound on NN distance between excl and res points.
- property distance_threshold
Get the upper bound on NN distance between excl and res points.
- Returns:
float – Estimate the distance between resource points. Calculated as half of the diagonal between closest resource points, with desired extra margin
- classmethod map_resource_gids(gids, excl_fpath, sc_row_indices, sc_col_indices, excl_row_slices, excl_col_slices, tree, dist_thresh)[source]
Map exclusion gids to the resource meta.
- Parameters:
gids (np.ndarray) – Supply curve gids with tech exclusion points to map to the resource meta points.
excl_fpath (str) – Filepath to exclusions h5 file, must contain latitude and longitude arrays to allow for mapping to resource points
sc_row_indices (list) – List of row indices in exclusion array for for every sc_point gid
sc_col_indices (list) – List of column indices in exclusion array for for every sc_point gid
excl_row_slices (list) – List representing the supply curve points rows. Each list entry contains the exclusion row slice that are included in the sc point.
excl_col_slices (list) – List representing the supply curve points columns. Each list entry contains the exclusion columns slice that are included in the sc point.
tree (cKDTree) – cKDTree built from resource lat, lon coordinates
dist_tresh (float) – Estimate the distance between resource points. Calculated as half of the diagonal between closest resource points, with an extra 5% margin
- Returns:
ind (list) – List of arrays of index values from the NN. List entries correspond to input gids.
- static save_tech_map(excl_fpath, dset, indices, distance_threshold=None, res_fpath=None, chunks=(128, 128))[source]
Save tech mapping indices and coordinates to an h5 output file.
- Parameters:
excl_fpath (str) – Filepath to exclusions h5 file to add techmap to as ‘dset’
dset (str) – Dataset name in fpath_out to save mapping results to.
indices (np.ndarray) – Index values of the NN resource point. -1 if no res point found. 2D integer array with shape equal to the exclusions extent shape.
distance_threshold (float) – Distance upper bound to save as attr.
res_fpath (str, optional) – Filepath to .h5 resource file that we’re mapping to, by default None
chunks (tuple) – Chunk shape of the 2D output datasets.
- map_resource(max_workers=None, points_per_worker=10)[source]
Map all resource gids to exclusion gids
- Parameters:
max_workers (int, optional) – Number of cores to run mapping on. None uses all available cpus, by default None
points_per_worker (int, optional) – Number of supply curve points to map to resource gids on each worker, by default 10
- Returns:
indices (np.ndarray) – Index values of the NN resource point. -1 if no res point found. 2D integer array with shape equal to the exclusions extent shape.
- classmethod run(excl_fpath, res_fpath, dset=None, sc_resolution=2560, dist_margin=1.05, max_workers=None, points_per_worker=10)[source]
Run parallel mapping and save to h5 file.
- Parameters:
excl_fpath (str) – Filepath to exclusions h5 (tech layer). dset will be created in excl_fpath.
res_fpath (str) – Filepath to .h5 resource file that we’re mapping to.
dset (str, optional) – Dataset name in excl_fpath to save mapping results to, if None do not save tech_map to excl_fpath, by default None
sc_resolution (int | None, optional) – Supply curve resolution, does not affect the exclusion to resource (tech) mapping, but defines how many exclusion pixels are mapped at a time, by default 2560
dist_margin (float, optional) – Extra margin to multiply times the computed distance between neighboring resource points, by default 1.05
max_workers (int, optional) – Number of cores to run mapping on. None uses all available cpus, by default None
points_per_worker (int, optional) – Number of supply curve points to map to resource gids on each worker, by default 10
- Returns:
indices (np.ndarray) – Index values of the NN resource point. -1 if no res point found. 2D integer array with shape equal to the exclusions extent shape.