Skip to content

Commit

Permalink
add check_layers kwarg added in reV #128
Browse files Browse the repository at this point in the history
  • Loading branch information
MRossol committed Feb 25, 2020
1 parent c689127 commit 2c9e7cf
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions reVX/red_e/tech_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class TechPotential(ExclusionMaskFromDict):
RED-E Tech Potential tool
"""
def __init__(self, h5_path, base_layer, layer_dict, power_density=1,
hsds=False, min_area=None, kernel='queen'):
hsds=False, min_area=None, kernel='queen',
check_layers=False):
"""
Parameters
----------
Expand All @@ -32,11 +33,14 @@ def __init__(self, h5_path, base_layer, layer_dict, power_density=1,
Minimum required contiguous area in sq-km
kernel : str
Contiguous filter method to use on final exclusion
check_layers : bool
Run a pre-flight check on each layer to ensure they contain
un-excluded values
"""
excl_dict = layer_dict.copy()
excl_dict[base_layer] = {"use_as_weights": True}
super().__init__(h5_path, excl_dict, hsds=hsds, min_area=min_area,
kernel=kernel)
kernel=kernel, check_layers=check_layers)
self._pd = power_density

@property
Expand Down Expand Up @@ -65,7 +69,8 @@ def generation(self):

@classmethod
def run(cls, h5_path, base_layer, layer_dict, power_density=1,
hsds=False, min_area=None, kernel='queen'):
hsds=False, min_area=None, kernel='queen',
check_layers=False):
"""
compute tech-potential
Expand All @@ -86,21 +91,26 @@ def run(cls, h5_path, base_layer, layer_dict, power_density=1,
Minimum required contiguous area in sq-km
kernel : str
Contiguous filter method to use on final exclusion
check_layers : bool
Run a pre-flight check on each layer to ensure they contain
un-excluded values
Returns
-------
mask : ndarray
Base layer with exclusions masked out
"""
with cls(h5_path, base_layer, layer_dict, power_density=power_density,
hsds=hsds, min_area=min_area, kernel=kernel) as f:
hsds=hsds, min_area=min_area, kernel=kernel,
check_layers=check_layers) as f:
mask = f.mask

return mask

@classmethod
def run_generation(cls, h5_path, base_layer, layer_dict, power_density=1,
hsds=False, min_area=None, kernel='queen'):
hsds=False, min_area=None, kernel='queen',
check_layers=False):
"""
compute tech-potential
Expand All @@ -121,14 +131,18 @@ def run_generation(cls, h5_path, base_layer, layer_dict, power_density=1,
Minimum required contiguous area in sq-km
kernel : str
Contiguous filter method to use on final exclusion
check_layers : bool
Run a pre-flight check on each layer to ensure they contain
un-excluded values
Returns
-------
gen : ndarray
Tech-potentail as generation
"""
with cls(h5_path, base_layer, layer_dict, power_density=power_density,
hsds=hsds, min_area=min_area, kernel=kernel) as f:
hsds=hsds, min_area=min_area, kernel=kernel,
check_layers=check_layers) as f:
gen = f.generation

return gen

0 comments on commit 2c9e7cf

Please sign in to comment.