Skip to content

[DO NOT MERGE] #119 global filter and #159 code sanitisation #192

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
14 changes: 9 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ def display_page(pathname):
[
Input("tabs", "value"),
Input("si-ip-radio-input", "value"),
State("month-range-filter-store", "data"),
State("hour-range-filter-store", "data"),
State("month-invert-filter-store", "data"),
State("hour-invert-filter-store", "data"),
],
)
def render_content(tab, si_ip):
def render_content(tab, si_ip, month_range_filter_store, hour_range_filter_store, month_invert_filter_store, hour_invert_filter_store):
"""Update the contents of the page depending on what tab the user selects."""
if tab == "tab-select":
return layout_select()
Expand All @@ -69,18 +73,18 @@ def render_content(tab, si_ip):
elif tab == "tab-data-explorer":
return layout_data_explorer()
elif tab == "tab-outdoor-comfort":
return layout_outdoor_comfort()
return layout_outdoor_comfort(month_range_filter_store, hour_range_filter_store, month_invert_filter_store, hour_invert_filter_store)
elif tab == "tab-natural-ventilation":
return layout_natural_ventilation(si_ip)
return layout_natural_ventilation(si_ip, month_range_filter_store, hour_range_filter_store, month_invert_filter_store, hour_invert_filter_store)
elif tab == "tab-psy-chart":
return layout_psy_chart()
return layout_psy_chart(month_range_filter_store, hour_range_filter_store, month_invert_filter_store, hour_invert_filter_store)
else:
return "404"


if __name__ == "__main__":
app.run_server(
debug=False,
debug=True,
host="0.0.0.0",
port=8080,
processes=1,
Expand Down
110 changes: 110 additions & 0 deletions my_project/callbackMonthHourFilter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
from dash import ctx
from dash.dependencies import Input, Output, State
from app import app

triggersAndCorresponding = {
"month-hour-filter": {
"month-range": "psy-month-slider",
"month-invert": "invert-month-psy",
"hour-range": "psy-hour-slider",
"hour-invert": "invert-hour-psy"
},
"nv-month-hour-filter": {
"month-range": "nv-month-slider",
"month-invert": "invert-month-nv",
"hour-range": "nv-hour-slider",
"hour-invert": "invert-hour-nv"
},
"month-hour-filter-outdoor-comfort": {
"month-range": "outdoor-comfort-month-slider",
"month-invert": "invert-month-outdoor-comfort",
"hour-range": "outdoor-comfort-hour-slider",
"hour-invert": "invert-hour-outdoor-comfort"
},
"sec1-time-filter-input": {
"month-range": "sec1-month-slider",
"month-invert": "",
"hour-range": "sec1-hour-slider",
"hour-invert": ""
},
"sec2-time-filter-input": {
"month-range": "sec2-month-slider",
"month-invert": "invert-month-explore-heatmap",
"hour-range": "sec2-hour-slider",
"hour-invert": "invert-hour-explore-heatmap"
},
"tab6-sec3-time-filter-input": {
"month-range": "tab6-sec3-query-month-slider",
"month-invert": "invert-month-explore-more-charts",
"hour-range": "tab6-sec3-query-hour-slider",
"hour-invert": "invert-hour-explore-more-charts"
},
}

#
# @app.callback(
# Output("month-range-filter-store", "data"),
# [
# State("month-range-filter-store", "data"),
# *[State(triggersAndCorresponding[trigger]["month-range"], "value") for trigger in triggersAndCorresponding.keys()]
# ],
# [
# Input(triggerKey, "n_clicks") for triggerKey in triggersAndCorresponding.keys()
# ]
# )
# def update_month_range_filter_store(global_data_store, *args):
# trigger = ctx.triggered_id
# if trigger is not None and trigger != 0:
# return {"data": triggersAndCorresponding[trigger]["month-range"]}
# return global_data_store
#
#
# @app.callback(
# Output("hour-range-filter-store", "data"),
# [
# State("hour-range-filter-store", "data"),
# *[State(triggersAndCorresponding[trigger]["hour-range"], "value") for trigger in triggersAndCorresponding.keys()]
# ],
# [
# Input(triggerKey, "n_clicks") for triggerKey in triggersAndCorresponding.keys()
# ]
# )
# def update_hour_range_filter_store(global_data_store, *args):
# trigger = ctx.triggered_id
# if trigger is not None and trigger != 0:
# return {"data": triggersAndCorresponding[trigger]["hour-range"]}
# return global_data_store
#
#
# @app.callback(
# Output("month-invert-filter-store", "data"),
# [
# State("month-invert-filter-store", "data"),
# *[State(triggersAndCorresponding[trigger]["month-invert"], "value") for trigger in triggersAndCorresponding.keys()]
# ],
# [
# Input(triggerKey, "n_clicks") for triggerKey in triggersAndCorresponding.keys()
# ]
# )
# def update_month_invert_filter_store(global_data_store, *args):
# trigger = ctx.triggered_id
# if trigger is not None and trigger != 0:
# return {"data": triggersAndCorresponding[trigger]["month-invert"]}
# return global_data_store
#
#
# @app.callback(
# Output("hour-invert-filter-store", "data"),
# [
# State("hour-invert-filter-store", "data"),
# *[State(triggersAndCorresponding[trigger]["hour-invert"], "value") for trigger in triggersAndCorresponding.keys()]
# ],
# [
# Input(triggerKey, "n_clicks") for triggerKey in triggersAndCorresponding.keys()
# ]
# )
# def update_hour_invert_filter_store(global_data_store, *args):
# trigger = ctx.triggered_id
# if trigger is not None and trigger != 0:
# return {"data": triggersAndCorresponding[trigger]["hour-invert"]}
# return global_data_store
65 changes: 65 additions & 0 deletions my_project/columns_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
class ColumnNames:
year = "year"
month = "month"
day = "day"
hour = "hour"
dbt = "DBT"
dpt = "DPT"
rh = "RH"
p_atm = "p_atm"
extr_hor_rad = "extr_hor_rad"
hor_ir_rad = "hor_ir_rad"
glob_hor_rad = "glob_hor_rad"
dir_nor_rad = "dir_nor_rad"
dif_hor_rad = "dif_hor_rad"
glob_hor_ill = "glob_hor_ill"
dir_nor_ill = "dir_nor_ill"
dif_hor_ill = "dif_hor_ill"
zlumi = "Zlumi"
wind_dir = "wind_d ir"
wind_speed = "wind_speed"
tot_sky_cover = "tot_sky_cover"
oskycover = "Oskycover"
vis = "Vis"
cheight = "Cheight"
pwobs = "PW obs"
pwcodes = "PWcodes"
pwater = "Pwater"
asolOptD = "AsolOptD"
snowD = "SnowD"
daySSnow = "DaySSnow"
fake_year = "fake_year"
month_names = "month_names"
doy = "DOY"
utc_time = "UTC_time"
times = "times"
apparent_zenith = "apparent_zenith"
zenith = "zenith"
apparent_elevation = "apparent_elevation"
elevation = "elevation"
azimuth = "azimuth"
equation_of_time = "equation_of_time"
erf = "erf"
delta_mrt = "delta_mrt"
mrt = "MRT"
wind_speed_utci = "wind_speed_utci"
wind_speed_utci_0 = "wind_speed_utci_0"
utci_noSun_Wind = "utci_noSun_Wind"
utci_noSun_noWind = "utci_noSun_noWind"
utci_Sun_Wind = "utci_Sun_Wind"
utci_Sun_noWind = "utci_Sun_noWind"
utci_noSun_Wind_categories = "utci_noSun_Wind_categories"
utci_noSun_noWind_categories = "utci_noSun_noWind_categories"
utci_Sun_Wind_categories = "utci_Sun_Wind_categories"
utci_Sun_noWind_categories = "utci_Sun_noWind_categories"
p_sat = "p_sat"
p_vap = "p_vap"
hr = "hr"
t_wb = "t_wb"
t_dp = "t_dp"
h = "h"
adaptive_comfort = "adaptive_comfort"
adaptive_cmf_80_low = "adaptive_cmf_80_low"
adaptive_cmf_80_up = "adaptive_cmf_80_up"
adaptive_cmf_90_low = "adaptive_cmf_90_low"
adaptive_cmf_90_up = "adaptive_cmf_90_up"
4 changes: 4 additions & 0 deletions my_project/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ def store():
dcc.Store(id="url-store", storage_type="session"),
dcc.Store(id="si-ip-unit-store", storage_type="session"),
dcc.Store(id="lines-store", storage_type="session"),
dcc.Store(id="month-range-filter-store", storage_type="session"),
dcc.Store(id="hour-range-filter-store", storage_type="session"),
dcc.Store(id="month-invert-filter-store", storage_type="session"),
dcc.Store(id="hour-invert-filter-store", storage_type="session"),
],
fullscreen=True,
type="dot",
Expand Down
33 changes: 18 additions & 15 deletions my_project/tab_natural_ventilation/app_natural_ventilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
generate_units,
generate_custom_inputs_nv,
determine_month_and_hour_filter,
get_valid_month_and_hour_from_store
)

from app import app


def layout_natural_ventilation(si_ip):
def layout_natural_ventilation(si_ip, month_range_filter_store, hour_range_filter_store, month_invert_filter_store, hour_invert_filter_store):
if si_ip == "ip":
tdb_set_min = 50
tdb_set_max = 75
Expand All @@ -39,7 +40,7 @@ def layout_natural_ventilation(si_ip):
return html.Div(
className="container-col",
children=[
inputs_tab(tdb_set_min, tdb_set_max, dpt_set),
inputs_tab(tdb_set_min, tdb_set_max, dpt_set, month_range_filter_store, hour_range_filter_store, month_invert_filter_store, hour_invert_filter_store),
dcc.Loading(
html.Div(
id="nv-heatmap-chart",
Expand Down Expand Up @@ -86,7 +87,7 @@ def layout_natural_ventilation(si_ip):
)


def inputs_tab(t_min, t_max, d_set):
def inputs_tab(t_min, t_max, d_set, month_range_filter_store, hour_range_filter_store, month_invert_filter_store, hour_invert_filter_store):
return html.Div(
className="container-row full-width three-inputs-container",
children=[
Expand Down Expand Up @@ -151,7 +152,7 @@ def inputs_tab(t_min, t_max, d_set):
min=1,
max=12,
step=1,
value=[1, 12],
value=[1, 12] if (month_range_filter_store is None or len(month_range_filter_store["data"]) == 0) else month_range_filter_store["data"],
marks={1: "1", 12: "12"},
tooltip={
"always_visible": False,
Expand All @@ -165,7 +166,7 @@ def inputs_tab(t_min, t_max, d_set):
options=[
{"label": "Invert", "value": "invert"},
],
value=[],
value=[] if (month_invert_filter_store is None or len(month_invert_filter_store["data"]) == 0) else month_invert_filter_store["data"],
id="invert-month-nv",
labelStyle={"flex": "30%"},
),
Expand All @@ -181,7 +182,7 @@ def inputs_tab(t_min, t_max, d_set):
min=1,
max=24,
step=1,
value=[1, 24],
value=[1, 24] if (hour_range_filter_store is None or len(hour_range_filter_store["data"]) == 0) else hour_range_filter_store["data"],
marks={1: "1", 24: "24"},
tooltip={
"always_visible": False,
Expand All @@ -195,7 +196,7 @@ def inputs_tab(t_min, t_max, d_set):
options=[
{"label": "Invert", "value": "invert"},
],
value=[],
value=[] if (hour_invert_filter_store is None or len(hour_invert_filter_store["data"]) == 0) else hour_invert_filter_store["data"],
id="invert-hour-nv",
labelStyle={"flex": "30%"},
),
Expand Down Expand Up @@ -264,14 +265,14 @@ def inputs_tab(t_min, t_max, d_set):
],
[
State("df-store", "data"),
State("nv-month-slider", "value"),
State("nv-hour-slider", "value"),
State("month-range-filter-store", "data"),
State("hour-range-filter-store", "data"),
State("nv-tdb-min-val", "value"),
State("nv-tdb-max-val", "value"),
State("nv-dpt-max-val", "value"),
State("meta-store", "data"),
State("invert-month-nv", "value"),
State("invert-hour-nv", "value"),
State("month-invert-filter-store", "data"),
State("hour-invert-filter-store", "data"),
State("si-ip-unit-store", "data"),
],
)
Expand All @@ -293,6 +294,7 @@ def nv_heatmap(
invert_hour,
si_ip,
):
month, invert_month, hour, invert_hour = get_valid_month_and_hour_from_store(month, invert_month, hour, invert_hour)

# enable or disable button apply filter DPT
dpt_data_filter = enable_dew_point_data_filter(condensation_enabled)
Expand Down Expand Up @@ -439,14 +441,14 @@ def nv_heatmap(
],
[
State("df-store", "data"),
State("nv-month-slider", "value"),
State("nv-hour-slider", "value"),
State("month-range-filter-store", "data"),
State("hour-range-filter-store", "data"),
State("nv-tdb-min-val", "value"),
State("nv-tdb-max-val", "value"),
State("nv-dpt-max-val", "value"),
State("meta-store", "data"),
State("invert-month-nv", "value"),
State("invert-hour-nv", "value"),
State("month-invert-filter-store", "data"),
State("hour-invert-filter-store", "data"),
State("si-ip-unit-store", "data"),
],
)
Expand All @@ -468,6 +470,7 @@ def nv_bar_chart(
invert_hour,
si_ip,
):
month, invert_month, hour, invert_hour = get_valid_month_and_hour_from_store(month, invert_month, hour, invert_hour)

# enable or disable button apply filter DPT
dpt_data_filter = enable_dew_point_data_filter(condensation_enabled)
Expand Down
Loading