Skip to content

Commit

Permalink
Moved file reading methods to own module, added legacy file name hand…
Browse files Browse the repository at this point in the history
…ling from reV, allowed for multiple generation datasets in timeseries.
  • Loading branch information
WilliamsTravis committed Oct 22, 2024
1 parent 3a9f4f6 commit 7d06033
Show file tree
Hide file tree
Showing 25 changed files with 754 additions and 659 deletions.
3 changes: 2 additions & 1 deletion configs/bespoke_fy22.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"project_name": "Bespoke - FY22",
"directory": "~/review_datasets/bespoke_fy22"
"directory": "~/review_datasets/bespoke_fy22",
"current": "ac"
}
3 changes: 2 additions & 1 deletion configs/seto_fy23.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"project_name": "SETO - FY23",
"directory": "~/review_datasets/seto_fy23"
"directory": "~/review_datasets/seto_fy23",
"current": "dc"
}
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
- nrel
dependencies:
- python=3.9
- python=3.12
- addfips>=0.3.1,<1
- colorama>=0.4.4,<1
- dash>=2.3.0,<3
Expand Down
6 changes: 4 additions & 2 deletions reView/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from flask_caching import Cache

from reView.layout.layout import layout
from reView.layout.layout import get_layout


DATA_DIR = Path("~/.review/cache-directory").expanduser()
Expand All @@ -22,11 +22,13 @@
app = dash.Dash(
__name__,
suppress_callback_exceptions=True,
serve_locally=True,
external_stylesheets=[dbc.themes.BOOTSTRAP],
)
app.layout = layout
app.layout = get_layout
server = app.server


# Dash adds a StreamHandler by default, as do we,
# so we get rid of the Dash handler instance in favor of our own
for handler in app.logger.handlers:
Expand Down
14 changes: 7 additions & 7 deletions reView/components/divs/chart.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Chart Divs
"""Chart Divs.
Functions for generating a chart divs with a given element type and class.
"""
Expand All @@ -18,7 +18,7 @@


def above_chart_options_div(id_prefix, class_name="row"):
"""Standard "above chart" options div.
"""Build standard "above chart" options div.
Parameters
----------
Expand Down Expand Up @@ -76,7 +76,7 @@ def above_chart_options_div(id_prefix, class_name="row"):
multi=False,
value="cumsum",
)
],
]
),

# X-axis Variable
Expand All @@ -94,16 +94,16 @@ def above_chart_options_div(id_prefix, class_name="row"):
}
],
multi=False,
value="capacity",
value="capacity_ac_mw",
)
],
]
)
]
)


def below_chart_options_div(id_prefix, class_name=None):
"""Standard "below chart" options div.
"""Build standard "below chart" options div.
Parameters
----------
Expand Down Expand Up @@ -202,7 +202,7 @@ def below_chart_options_div(id_prefix, class_name=None):

# pylint: disable=redefined-builtin,invalid-name
def chart_div(id_prefix, class_name=None):
"""Standard reView chart div.
"""Build standard reView chart div.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion reView/components/divs/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


def above_map_options_div(id_prefix, class_name=None):
"""Standard "above map" options div.
"""Build standard "above map" options div.
Parameters
----------
Expand Down
33 changes: 6 additions & 27 deletions reView/components/divs/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@
TAB_STYLE,
TABLET_STYLE,
)
from reView.layout.options import (
BASEMAP_OPTIONS,
COLOR_OPTIONS,
REGION_OPTIONS,
STATE_OPTIONS,
)


def above_time_options_div(id_prefix, class_name=None):
"""Standard "above map" options div.
"""Build standard "above map" options div.
Parameters
----------
Expand Down Expand Up @@ -146,33 +140,18 @@ def above_time_options_div(id_prefix, class_name=None):
id=f"{id_prefix}_time_var_options",
style={"width": "100%"},
clearable=False,
multi=False
multi=True
)
)
]
),

# Placeholder Second Options
html.Div(
id=f"{id_prefix}_options_2",
style={"display": "none"},
children=[
dcc.Dropdown(
id=f"{id_prefix}_option_2_options",
clearable=False,
# options=COLOR_OPTIONS,
multi=False,
value="Viridis",
)
],
),
],
)
]
)


# pylint: disable=redefined-builtin,invalid-name
def time_div(id_prefix, class_name=None):
"""Standard reView time div.
"""Build standard reView time div.
Parameters
----------
Expand Down Expand Up @@ -256,7 +235,7 @@ def time_div(id_prefix, class_name=None):


def below_time_options_div(id_prefix, class_name=None):
"""Standard "below time" options div.
"""Build standard "below time" options div.
Parameters
----------
Expand Down
4 changes: 2 additions & 2 deletions reView/components/divs/toptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@
options=[
{
"label": "Capacity",
"value": "capacity",
"value": "capacity_ac_mw",
}
],
value="capacity",
value="capacity_ac_mw",
),
],
className="three columns",
Expand Down
3 changes: 1 addition & 2 deletions reView/components/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def tab_styles(tab_choice, options):


def format_capacity_title(
map_capacity, map_selection=None, capacity_col_name="capacity"
map_capacity, map_selection=None, capacity_col_name="capacity_ac_mw"
):
"""Calculate total remaining capacity after all filters are applied.
Expand All @@ -54,7 +54,6 @@ def format_capacity_title(
str
Number of selected sites, formatted as a string.
"""

if not map_capacity:
return "--", "--"

Expand Down
17 changes: 7 additions & 10 deletions reView/components/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
from reView.utils.classes import DiffUnitOptions
from reView.utils.config import Config
from reView.utils.constants import COLORS, DEFAULT_LAYOUT
from reView.utils.functions import (
convert_to_title,
strip_rev_filename_endings
)
from reView.utils.functions import convert_to_title
from reView.utils.readers import strip_rev_filename_endings
from reView.pages.rev.model import point_filter

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -54,7 +52,6 @@
)



def make_view(df):
"""Return an updated center view object for mapbox."""
layout = copy.deepcopy(MAP_LAYOUT)
Expand Down Expand Up @@ -226,19 +223,19 @@ def _apply_aggregation(self, units, agg_type):
try:
weights = df["area_sq_km"]
except KeyError:
weights = df["wind_area_sq_km"]
weights = df["wind_area_developable_sq_km"]

elif "solar" in self.color_var:
try:
weights = df["area_sq_km"]
except KeyError:
weights = df["solar_area_sq_km"]
elif "area_sq_km" not in df: # Quick fix change for bespoke hybrids
weights = df["solar_area_developable_sq_km"]
elif "area_developable_sq_km" not in df: # Quick fix change for bespoke hybrids
weights = df[self.capcol]
else:
weights = df["area_sq_km"]
weights = df["area_developable_sq_km"]

skippers = [self.capcol, "area_sq_km"] # Don't use weights for these
skippers = [self.capcol, "area_developable_sq_km"] # Don't use weights for these

if (agg_type == "mean" and self.color_var not in skippers):
aggregation = np.average(
Expand Down
35 changes: 35 additions & 0 deletions reView/devindex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# pylint: skip-file
"""reView project index file."""
import reView.pages.reeds.controller.callbacks
import reView.pages.rev.controller.callbacks

from reView.app import app, server
from reView.environment.settings import (
APP_HOST,
APP_PORT,
DASH_DEBUG,
LOG_LEVEL,
)
from reView.routes import render_page_content
from reView.utils.log import init_logger, log_versions
from reView.utils import calls


def main():
"""Run reView."""
init_logger(level=LOG_LEVEL)
log_versions()
app.run(
host=APP_HOST,
port=APP_PORT,
debug=True,
# dev_tools_ui=True,
# dev_tools_hot_reload=True,
# dev_tools_hot_reload_interval=5000,
# dev_tools_hot_reload_max_retry=300
)


if __name__ == "__main__":
main()
5 changes: 2 additions & 3 deletions reView/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
LOG_LEVEL,
)
from reView.routes import render_page_content
from reView.utils.log import init_logger, log_versions
from reView.utils import calls
from reView.utils.log import init_logger, log_versions


def main():
Expand All @@ -23,8 +23,7 @@ def main():
app.run_server(
host=APP_HOST,
port=APP_PORT,
debug=False,
dev_tools_hot_reload=True
debug=False
)


Expand Down
15 changes: 9 additions & 6 deletions reView/layout/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@


# fmt: off
layout = html.Div([
navbar.NAVBAR,
dcc.Location(id="url", refresh=False),
html.Div(id="page_content"),
navbar.SIDE_BUTTON,
])
def get_layout():
"""Get the application layout."""
layout = html.Div([
navbar.NAVBAR,
dcc.Location(id="url", refresh=True),
html.Div(id="page_content"),
navbar.SIDE_BUTTON,
])
return layout
Loading

0 comments on commit 7d06033

Please sign in to comment.