Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 20 additions & 21 deletions pages/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
three_var_graph,
)
from pages.lib.global_element_ids import ElementIds
from pages.lib.global_column_names import ColNames
from pages.lib.global_variables import Variables
from pages.lib.global_id_buttons import IdButtons
from pages.lib.global_tab_names import TabNames
from pages.lib.global_scheme import (
Expand Down Expand Up @@ -93,25 +93,19 @@ def section_one():
id_button=IdButtons.EXPLORE_YEARLY_CHART_LABEL,
doc_link=DocLinks.TEMP_HUMIDITY_EXPLAINED,
),
dcc.Loading(
type="circle", children=dmc.Paper(id=ElementIds.YEARLY_EXPLORE, p="sm")
),
dcc.Loading(type="circle", children=dmc.Paper(id=ElementIds.YEARLY_EXPLORE)),
title_with_link(
text="Daily chart",
id_button=IdButtons.EXPLORE_DAILY_CHART_LABEL,
doc_link=DocLinks.TEMP_HUMIDITY_EXPLAINED,
),
dcc.Loading(
type="circle", children=dmc.Paper(id=ElementIds.QUERY_DAILY, p="sm")
),
dcc.Loading(type="circle", children=dmc.Paper(id=ElementIds.QUERY_DAILY)),
title_with_link(
text="Heatmap chart",
id_button=IdButtons.EXPLORE_HEATMAP_CHART_LABEL,
doc_link=DocLinks.TEMP_HUMIDITY_EXPLAINED,
),
dcc.Loading(
type="circle", children=dmc.Paper(id=ElementIds.QUERY_HEATMAP, p="sm")
),
dcc.Loading(type="circle", children=dmc.Paper(id=ElementIds.QUERY_HEATMAP)),
title_with_tooltip(
text="Descriptive statistics",
tooltip_text="count, mean, std, min, max, and percentiles",
Expand Down Expand Up @@ -209,7 +203,7 @@ def section_two_inputs():
dropdown(
id=ElementIds.SEC2_VAR_DROPDOWN,
options=explore_dropdown_names,
value=ColNames.RH,
value=Variables.RH.col_name,
),
flex=1,
),
Expand Down Expand Up @@ -293,7 +287,7 @@ def section_two_inputs():
dropdown(
id=ElementIds.SEC2_DATA_FILTER_VAR,
options=explore_dropdown_names,
value=ColNames.RH,
value=Variables.RH.col_name,
),
flex=1,
),
Expand Down Expand Up @@ -396,7 +390,7 @@ def section_three_inputs():
dropdown(
id=ElementIds.TAB6_SEC3_VAR_Y_DROPDOWN,
options=explore_dropdown_names,
value=ColNames.RH,
value=Variables.RH.col_name,
),
flex=1,
),
Expand Down Expand Up @@ -484,7 +478,7 @@ def section_three_inputs():
dropdown(
id=ElementIds.TAB6_SEC3_FILTER_VAR_DROPDOWN,
options=explore_dropdown_names,
value=ColNames.RH,
value=Variables.RH.col_name,
),
flex=1,
),
Expand Down Expand Up @@ -536,14 +530,12 @@ def section_three():
type="circle",
children=dmc.Paper(
id=ElementIds.THREE_VAR,
p="sm",
),
),
dcc.Loading(
type="circle",
children=dmc.Paper(
id=ElementIds.TWO_VAR,
p="sm",
),
),
],
Expand Down Expand Up @@ -888,13 +880,20 @@ def update_table(
)

filtered_df = df[
(df[ColNames.MONTH] >= start_month)
& (df[ColNames.MONTH] <= end_month)
& (df[ColNames.HOUR] >= start_hour)
& (df[ColNames.HOUR] <= end_hour)
(df[Variables.MONTH.col_name] >= start_month)
& (df[Variables.MONTH.col_name] <= end_month)
& (df[Variables.HOUR.col_name] >= start_hour)
& (df[Variables.HOUR.col_name] <= end_hour)
]
return summary_table_tmp_rh_tab(
filtered_df[[ColNames.MONTH, ColNames.HOUR, dd_value, ColNames.MONTH_NAMES]],
filtered_df[
[
Variables.MONTH.col_name,
Variables.HOUR.col_name,
dd_value,
Variables.MONTH_NAMES.col_name,
]
],
dd_value,
si_ip,
)
60 changes: 37 additions & 23 deletions pages/lib/charts_data_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import plotly.express as px
import plotly.graph_objects as go
from pages.lib.utils import get_max_min_value
from pages.lib.global_scheme import template, mapping_dictionary, month_lst
from pages.lib.global_column_names import ColNames
from pages.lib.global_scheme import template, month_lst
from pages.lib.global_variables import Variables, VariableInfo


def custom_heatmap(df, global_local, var, time_filter_info, data_filter_info, si_ip):
Expand All @@ -29,12 +29,16 @@ def custom_heatmap(df, global_local, var, time_filter_info, data_filter_info, si
if df.dropna(subset=[var]).shape[0] == 0:
return None

var_unit = mapping_dictionary[var][si_ip][ColNames.UNIT]
var_range = mapping_dictionary[var][si_ip][ColNames.RANGE]
var_name = mapping_dictionary[var][ColNames.NAME]
var_color = mapping_dictionary[var][ColNames.COLOR]
filter_name = mapping_dictionary[filter_var][ColNames.NAME]
filter_unit = mapping_dictionary[filter_var][si_ip][ColNames.UNIT]
variable = VariableInfo.from_col_name(var)
filter_variable = VariableInfo.from_col_name(filter_var)

var_name = variable.get_name()
var_unit = variable.get_unit(si_ip)
var_range = variable.get_range(si_ip)
var_color = variable.get_color()

filter_name = filter_variable.get_name()
filter_unit = filter_variable.get_unit(si_ip)

if global_local == "global":
# Set Global values for Max and minimum
Expand All @@ -58,15 +62,18 @@ def custom_heatmap(df, global_local, var, time_filter_info, data_filter_info, si

fig = go.Figure(
data=go.Heatmap(
y=df[ColNames.HOUR],
x=df[ColNames.DOY],
y=df[Variables.HOUR.col_name],
x=df[Variables.DOY.col_name],
z=df[var],
colorscale=var_color,
zmin=range_z[0],
zmax=range_z[1],
connectgaps=False,
hoverongaps=False,
customdata=np.stack((df[ColNames.MONTH_NAMES], df[ColNames.DAY]), axis=-1),
customdata=np.stack(
(df[Variables.MONTH_NAMES.col_name], df[Variables.DAY.col_name]),
axis=-1,
),
hovertemplate=(
"<b>"
+ var
Expand Down Expand Up @@ -109,12 +116,16 @@ def three_var_graph(
min_val = data_filter_info3[2]
max_val = data_filter_info3[3]

var_unit_x = mapping_dictionary[var_x][si_ip][ColNames.UNIT]
var_unit_y = mapping_dictionary[var_y][si_ip][ColNames.UNIT]
variable_x = VariableInfo.from_col_name(var_x)
variable_y = VariableInfo.from_col_name(var_y)
variable_color = VariableInfo.from_col_name(color_by)

var_unit_x = variable_x.get_unit(si_ip)
var_unit_y = variable_y.get_unit(si_ip)
var_range = variable_color.get_range(si_ip)
var_color = variable_color.get_color()

var = color_by
var_range = mapping_dictionary[var][si_ip][ColNames.RANGE]
var_color = mapping_dictionary[var][ColNames.COLOR]

if global_local != "global":
# Set maximum and minimum according to data
Expand All @@ -129,15 +140,15 @@ def three_var_graph(
else:
df.loc[(df[filter_var] >= max_val) & (df[filter_var] <= min_val)] = None

if df.dropna(subset=[ColNames.MONTH]).shape[0] == 0:
if df.dropna(subset=[Variables.MONTH.col_name]).shape[0] == 0:
return None

title = (
mapping_dictionary[var_x][ColNames.NAME]
variable_x.get_name()
+ " vs "
+ mapping_dictionary[var_y][ColNames.NAME]
+ variable_y.get_name()
+ " colored by "
+ mapping_dictionary[color_by][ColNames.NAME]
+ variable_color.get_name()
)

fig = px.scatter(
Expand All @@ -162,15 +173,18 @@ def three_var_graph(


def two_var_graph(df, var_x, var_y, si_ip):
variable_x = VariableInfo.from_col_name(var_x)
variable_y = VariableInfo.from_col_name(var_y)

title = (
"Simultaneous frequency of "
+ mapping_dictionary[var_x][ColNames.NAME]
+ variable_x.get_name()
+ " and "
+ mapping_dictionary[var_y][ColNames.NAME]
+ variable_y.get_name()
)

var_unit_x = mapping_dictionary[var_x][si_ip][ColNames.UNIT]
var_unit_y = mapping_dictionary[var_y][si_ip][ColNames.UNIT]
var_unit_x = variable_x.get_unit(si_ip)
var_unit_y = variable_y.get_unit(si_ip)

fig = px.density_heatmap(
df,
Expand Down
12 changes: 6 additions & 6 deletions pages/lib/charts_summary.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import pandas as pd
import plotly.express as px
from pages.lib.global_column_names import ColNames
from pages.lib.global_variables import Variables


def world_map(meta):
"""Return the world map showing the current location."""
latitude = float(meta[ColNames.LAT])
longitude = float(meta[ColNames.LON])
city = meta[ColNames.CITY]
country = meta[ColNames.COUNTRY]
time_zone = float(meta[ColNames.TIME_ZONE])
latitude = float(meta[Variables.LAT.col_name])
longitude = float(meta[Variables.LON.col_name])
city = meta[Variables.CITY.col_name]
country = meta[Variables.COUNTRY.col_name]
time_zone = float(meta[Variables.TIME_ZONE.col_name])
lat_long_df = pd.DataFrame(
data={
"Lat": [latitude],
Expand Down
Loading
Loading