Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flicker refactor #161

Merged
merged 42 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d848a9f
Added geotiff output option
ppinchuk Sep 15, 2022
a679fff
Refactor class methods and parallel execution
ppinchuk Sep 15, 2022
5095dfb
Minor typo fixes and such
ppinchuk Sep 15, 2022
f15c1e7
Grid cell size and max flicker exclusion range can now be set in init…
ppinchuk Sep 16, 2022
29eb61d
Added two new options to config
ppinchuk Sep 16, 2022
204c4e0
Minor formatting
ppinchuk Sep 16, 2022
42605eb
Removed extra spaces
ppinchuk Sep 16, 2022
8769c85
Linter fixes
ppinchuk Sep 16, 2022
4cd2084
Refactored to add new obj attributes
ppinchuk Sep 16, 2022
f1bc36f
Updated property names
ppinchuk Sep 16, 2022
b4bd3cd
reduced import path for upcoming refactor
ppinchuk Sep 16, 2022
2f43839
Reduced another import path
ppinchuk Sep 16, 2022
3bdc03e
First major refactor, WIP
ppinchuk Sep 19, 2022
85c7952
max_flicker_exclusion_range can now be str
ppinchuk Sep 19, 2022
212ad11
Linter fixes
ppinchuk Sep 19, 2022
07ef0d5
Added `out_layers` option to setbacks in anticipation of the flicker …
ppinchuk Sep 19, 2022
93d24b8
Flake8 fixes
ppinchuk Sep 19, 2022
fa4b630
Delete irrelevant method and call
ppinchuk Sep 19, 2022
9932825
Updated order of args in function
ppinchuk Sep 19, 2022
aaf0c41
Minor docstring update
ppinchuk Sep 19, 2022
4ae7bd9
Parse features no longer part of interface
ppinchuk Sep 19, 2022
1701dc3
Add hsds arg
ppinchuk Sep 19, 2022
e780ad9
Use kwargs to initiate class
ppinchuk Sep 20, 2022
000057f
Linter updates
ppinchuk Sep 20, 2022
45f2bb2
fips no longer required for generic run
ppinchuk Sep 20, 2022
de3e295
(WIP) All tests passing (WIP)
ppinchuk Sep 20, 2022
1f38863
(WIP) Can now input tiff file (WIP)
ppinchuk Sep 20, 2022
fb8ee63
(WIP) Added `input_output_filenames` (WIP)
ppinchuk Sep 21, 2022
59bc95e
(WIP) `feature_fpath` now an instance attr (WIP)
ppinchuk Sep 22, 2022
7551c08
Linter fixes
ppinchuk Sep 22, 2022
0780b26
(WIP) Added `max_workers` to `compute_generic_exclusions` (WIP)
ppinchuk Sep 22, 2022
cfaf64e
(WIP) Profile now a property of exclusions (WIP)
ppinchuk Sep 30, 2022
30d8831
(WIP) Added `no_exclusions_array` to AEC interface (WIP)
ppinchuk Sep 30, 2022
38e02ab
(WIP) Major regulations file refactor (WIP)
ppinchuk Sep 30, 2022
6d81972
(WIP) Added tests for allow both building layer and features fpath in…
ppinchuk Sep 30, 2022
95a12a7
Added missing docstring
ppinchuk Sep 30, 2022
40ffee5
(WIP) Added test for empty local regulations (WIP)
ppinchuk Sep 30, 2022
a61edc8
(WIP) Added description property (WIP)
ppinchuk Sep 30, 2022
bd667f2
(WIP) Added test for TM mapping (WIP)
ppinchuk Sep 30, 2022
61d238d
Cleanup
ppinchuk Sep 30, 2022
0e9d337
Linter updates
ppinchuk Sep 30, 2022
e7fff82
Increment version number
ppinchuk Oct 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion reVX/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from rex.utilities.utilities import safe_json_load

from reVX.offshore.dist_to_ports_converter import DistToPortsConverter
from reVX.utilities.exclusions_converter import ExclusionsConverter
from reVX.utilities import ExclusionsConverter
from reVX.utilities.forecasts import FcstUtils
from reVX.utilities.output_extractor import output_extractor
from reVX.utilities.region_classifier import RegionClassifier
Expand Down
14 changes: 10 additions & 4 deletions reVX/config/setbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging

from reV.config.base_analysis_config import AnalysisConfig
from reVX.setbacks.regulations import validate_regulations_input
from reVX.setbacks.regulations import validate_setback_regulations_input
from reVX.setbacks import SETBACKS

logger = logging.getLogger(__name__)
Expand All @@ -22,9 +22,10 @@ def _preflight(self):
Run a preflight check for extra requirements based on feature type.
"""
super()._preflight()
validate_regulations_input(base_setback_dist=self.base_setback_dist,
hub_height=self.hub_height,
rotor_diameter=self.rotor_diameter)
validate_setback_regulations_input(
base_setback_dist=self.base_setback_dist,
hub_height=self.hub_height,
rotor_diameter=self.rotor_diameter)

@property
def feature_type(self):
Expand Down Expand Up @@ -88,3 +89,8 @@ def hsds(self):
def weights_calculation_upscale_factor(self):
"""Get upscale factor for weights calculation. """
return self.get("weights_calculation_upscale_factor", None)

@property
def out_layers(self):
"""Get out_layers dictionary. """
return self.get("out_layers", None)
77 changes: 74 additions & 3 deletions reVX/config/turbine_flicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class TurbineFlickerConfig(AnalysisConfig):
"""Config framework for turbine flicker calculation"""

NAME = 'TurbineFlicker'
REQUIREMENTS = ('excl_fpath', 'res_fpath', 'building_layer', 'hub_height',
'rotor_diameter')
REQUIREMENTS = ('excl_fpath', 'res_fpath', 'hub_height', 'rotor_diameter')

def __init__(self, config):
"""
Expand All @@ -23,8 +22,13 @@ def __init__(self, config):
super().__init__(config)
self._default_tm_dset = 'techmap_wtk'
self._default_resolution = 128
self._default_grid_cell_size = 90
self._default_max_flicker_exclusion_range = "10x"
self._default_building_threshold = 0
self._default_flicker_threshold = 30
self._default_hsds_flag = False
validate_feature_input(features_path=self.features_path,
building_layer=self.building_layer)

@property
def excl_fpath(self):
Expand All @@ -36,10 +40,20 @@ def res_fpath(self):
"""Get the resource .h5 file path (required)."""
return self['res_fpath']

@property
def regs_fpath(self):
"""Get regulations .csv path"""
return self.get('regs_fpath', None)

@property
def features_path(self):
"""Get path to features file or directory (required)."""
return self.get('features_path', None)

@property
def building_layer(self):
"""Get the building layer name."""
return self['building_layer']
return self.get('building_layer', None)

@property
def hub_height(self):
Expand All @@ -65,6 +79,20 @@ def resolution(self):
"""Get the supply curve resolution."""
return self.get('resolution', self._default_resolution)

@property
def grid_cell_size(self):
"""Get the length (m) of a side of each grid cell in `excl_fpath`."""
return self.get('grid_cell_size', self._default_grid_cell_size)

@property
def max_flicker_exclusion_range(self):
"""
Get the max distance (m) that flicker exclusions will extend in
any of the cardinal directions.
"""
return self.get('max_flicker_exclusion_range',
self._default_max_flicker_exclusion_range)

@property
def building_threshold(self):
"""
Expand All @@ -88,3 +116,46 @@ def out_layer(self):
be saved
"""
return self.get('out_layer', None)

@property
def replace(self):
"""Get replace flag"""
return self.get('replace', False)

@property
def hsds(self):
"""Get hsds flag"""
return self.get('hsds', self._default_hsds_flag)


def validate_feature_input(features_path=None, building_layer=None):
"""Validate the feature input.

Specifically, this function raises an error unless exactly one of
the following inputs are provided:
- features_path
- building_layer

Parameters
----------
features_path : str | int
Path to input tif containing buildings from which turbine
flicker exclusions will be computed. By default, `None`.
building_layer : float | int
Exclusion layer containing buildings from which turbine
flicker exclusions will be computed. By default, `None`.

Raises
------
RuntimeError
If not enough info is provided (all inputs are `None`), or too
much info is given (all inputs are not `None`).
"""
no_features_path = features_path is None
no_building_layer = building_layer is None

not_enough_info = no_features_path and no_building_layer
too_much_info = not no_features_path and not no_building_layer
if not_enough_info or too_much_info:
raise RuntimeError("Must provide either `features_path` or "
"`building_layer` (but not both).")
2 changes: 1 addition & 1 deletion reVX/least_cost_xmission/cost_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from reV.handlers.exclusions import ExclusionLayers

from reVX.handlers.geotiff import Geotiff
from reVX.utilities.exclusions_converter import ExclusionsConverter
from reVX.utilities import ExclusionsConverter
from reVX.least_cost_xmission.config import XmissionConfig

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion reVX/least_cost_xmission/least_cost_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from rex.utilities.loggers import log_mem

from reVX.least_cost_xmission.trans_cap_costs import TieLineCosts
from reVX.utilities.exclusions_converter import ExclusionsConverter
from reVX.utilities import ExclusionsConverter

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion reVX/offshore/dist_to_ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from warnings import warn

from reV.handlers.exclusions import ExclusionLayers
from reVX.utilities.exclusions_converter import ExclusionsConverter
from reVX.utilities import ExclusionsConverter
from reVX.utilities.utilities import log_versions, coordinate_distance
from rex.utilities.execution import SpawnProcessPool
from rex.utilities.loggers import log_mem
Expand Down
2 changes: 1 addition & 1 deletion reVX/offshore/dist_to_ports_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from reVX.handlers.geotiff import Geotiff
from reVX.handlers.outputs import Outputs
from reVX.utilities.exclusions_converter import ExclusionsConverter
from reVX.utilities import ExclusionsConverter

logger = logging.getLogger(__name__)

Expand Down
Loading