reV.supply_curve.tech_mapping.TechMapping
- class TechMapping(excl_fpath, sc_resolution=1200)[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
sc_resolution (int | None, optional) – Defines how many exclusion pixels are mapped at a time. Units indicate the length of one dimension, in pixels, of each square chunk to be mapped. By default, this value is 1200, which will map the exclusion pixels in 1200x1200 pixel chunks.
Note
This parameter does not affect the exclusion to resource (tech) mapping, which deviates from how the effect of the
sc_resolution
parameter works in other functionality withinreV
.
Methods
initialize_dataset
(dset[, chunks])Initialize output dataset in exclusions h5 file.
map_resource
(dset, res_fpath[, dist_margin, ...])Map all resource gids to exclusion gids.
map_resource_gids
(excl_coords, tree, dist_thresh)Map exclusion pixels to the resource meta.
run
(excl_fpath, res_fpath, dset[, ...])Run parallel mapping and save to h5 file.
- classmethod map_resource_gids(excl_coords, tree, dist_thresh)[source]
Map exclusion pixels to the resource meta.
- Parameters:
excl_coords (ndarray) – 2D Array of the un-projected latitude, longitude array of tech exclusion pixels. Rows correspond to exclusion pixels, columns correspond to latitude and longitude, respectively.
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 (ndarray) – 1D arrays of index values from the NN. Entries correspond to input exclusion pixels.
- initialize_dataset(dset, chunks=(128, 128))[source]
Initialize output dataset in exclusions h5 file. If dataset already exists, a warning will be issued.
- Parameters:
dset (str) – Name of the dataset in the exclusions H5 file to create.
chunks (tuple, optional) – Chunk size for the dataset, by default (128, 128).
- map_resource(dset, res_fpath, dist_margin=1.05, max_workers=None, batch_size=100)[source]
Map all resource gids to exclusion gids. Save results to dset in exclusions h5 file.
- Parameters:
dset (str, optional) – Name of the output dataset in the exclusions H5 file to which the tech map will be saved.
res_fpath (str) – Filepath to .h5 resource file that we’re mapping to.
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
batch_size (int, optional) – Number of tasks to be submitted to parallel worker pool at one time, by default 1000. As a rule of thumb, this number should be set to ~10x the number of max_workers. Higher values are not necessarily better, and may slow down processing and/or result in out-of-memory errors. Values less than the number of workers can also lead to slower processing, due to poor load balancing.
- classmethod run(excl_fpath, res_fpath, dset, sc_resolution=1200, dist_margin=1.05, max_workers=None, batch_size=1000)[source]
Run parallel mapping and save to h5 file.
- Parameters:
excl_fpath (str) – Filepath to exclusions data HDF5 file. This file must must contain latitude and longitude datasets.
res_fpath (str) – Filepath to HDF5 resource file (e.g. WTK or NSRDB) to which the exclusions will be mapped. Can refer to a single file (e.g., “/path/to/nsrdb_2024.h5” or a wild-card e.g., “/path/to/nsrdb_{}.h5”)
dset (str) – Dataset name in the excl_fpath file to which the the techmap (exclusions-to-resource mapping data) will be saved.
Important
If this dataset already exists in the h5 file, it will be overwritten.
sc_resolution (int | None, optional) – Defines how many exclusion pixels are mapped at a time. Units indicate the length of one dimension, in pixels, of each square chunk to be mapped. By default, this value is 1200, which will map the exclusion pixels in 1200x1200 pixel chunks.
Note
This parameter does not affect the exclusion to resource (tech) mapping, which deviates from how the effect of the
sc_resolution
parameter works in other functionality withinreV
.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
batch_size (int, optional) – Number of tasks to be submitted to parallel worker pool at one time, by default 1000. As a rule of thumb, this number should be set to ~10x the number of max_workers. Higher values are not necessarily better, and may slow down processing and/or result in out-of-memory errors. Values less than the number of workers can also lead to slower processing, due to poor load balancing.