Skip to content

Commit

Permalink
adding functionality to load zones array for a specified gid
Browse files Browse the repository at this point in the history
  • Loading branch information
mjgleason committed Jan 16, 2025
1 parent fd7e488 commit 063ab4f
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions reV/supply_curve/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,53 @@ def _get_gid_inclusion_mask(

return gid_inclusions

@staticmethod
def _get_gid_zones(zones_fpath, zones_dset, gid, slice_lookup):
"""
Get zones 2D array for desired gid.
Parameters
----------
zones_fpath : str | None, optional
Filepath to HDF5 file containing `zones_dset`. If not specified,
output of function will be an array containing all values equal to
1.
zones_dset : str | None, optional
Dataset name in the `zones_fpath` file containing the zones to be
loaded. If not specified, output of function will be an array
containing all values equal to 1.
gid : int
sc_point_gid value, used to extract the applicable subset of zones.
slice_lookup : dict
Mapping of sc_point_gids to exclusion/inclusion row and column
slices
Returns
-------
zones : ndarray | None
2D array of zones for desired gid.
"""

row_slice, col_slice = slice_lookup[gid]
if zones_fpath is not None and zones_dset is not None:
with ExclusionLayers(zones_fpath) as fh:
if zones_dset not in fh:
msg = (
f"Could not find zones_dset {zones_dset} in "
f"zones_fpath {zones_fpath}."
)
logger.error(msg)
raise FileInputError(msg)
zones = fh[zones_dset, row_slice, col_slice]
else:
shape = (
row_slice.stop - row_slice.start,
col_slice.stop - col_slice.start
)
zones = np.ones(shape, dtype="uint32")

return zones

@staticmethod
def _parse_gen_index(gen_fpath):
"""Parse gen outputs for an array of generation gids corresponding to
Expand Down

0 comments on commit 063ab4f

Please sign in to comment.