Commit d0c19e72 authored by Samuël Weber's avatar Samuël Weber
Browse files

use sidebar nav

parent fbe8939a
......@@ -245,7 +245,7 @@ def get_boxplot_options_component(id=None):
)
return boxplot_options_component
def get_timeserie_component():
def get_rawdata_monthly_component():
monthly_boxplot_component = [
get_boxplot_options_component(id="monthly"),
dcc.Loading(
......@@ -255,6 +255,9 @@ def get_timeserie_component():
)
)
]
return monthly_boxplot_component
def get_rawdata_seasonal_component():
seasonal_boxplot_component = [
get_boxplot_options_component(id="seasonal"),
dcc.Loading(
......@@ -264,6 +267,9 @@ def get_timeserie_component():
)
)
]
return seasonal_boxplot_component
def get_rawdata_timeserie_component():
timeserie_component = [
dcc.Loading(
dcc.Graph(
......@@ -272,25 +278,7 @@ def get_timeserie_component():
)
)
]
rawdata_component = html.Div(
id='tab-timeserie',
children=[
html.Div(
children=[
dcc.Tabs(
value="timeserie",
id="tab-rawdata",
children=[
dcc.Tab(label="Timeserie", value="timeserie", children=timeserie_component),
dcc.Tab(label="Monthly", value="monthly", children=monthly_boxplot_component),
dcc.Tab(label="Seasonal", value="seasonal", children=seasonal_boxplot_component),
]
),
]
)
]
)
return rawdata_component
return timeserie_component
def get_profile_component():
profile_component = html.Div(
......@@ -395,19 +383,21 @@ def get_specie_repartition_component():
specie_repartition_component = html.Div(
id="specie-repartition-component",
children=[
dcc.Graph(
id="repartition-graph",
figure={
'data': [],
'layout': {
'title': 'Specie repartition among factors (Loading...)',
}
}
)
dcc.Loading(
dcc.Graph(
id="repartition-graph",
figure={
'data': [],
'layout': {
'title': 'Specie repartition among factors (Loading...)',
}
}
)
)
])
return specie_repartition_component
def get_model_component():
def get_op_beta_component():
"""Get the OP model
:returns: TODO
......@@ -415,12 +405,15 @@ def get_model_component():
model_component = html.Div(
id="model-component",
children=[
dcc.Graph(
id="beta-coefficient-graph",
figure={
'data': [],
'layout': {'title': 'Intrisic OP'}
}
html.H3("Intrinsic OP of the PMF factors"),
dcc.Loading(
dcc.Graph(
id="beta-coefficient-graph",
figure={
'data': [],
'layout': {'title': 'Intrisic OP'}
}
)
)
],
)
......@@ -434,12 +427,34 @@ def get_op_contribution_component():
contribution_component = html.Div(
id="op-contribution-component",
children=[
dcc.Graph(
id="op-contribution-graph",
figure={
'data': [],
'layout': {'title': 'OP contribution'}
}
html.H3("Contribution of PMF factors to the OP"),
dcc.RadioItems(
id='op-contribution-plottype',
className='options-items',
options=[
{'label': 'Daily barplot', 'value': 'daily'},
{'label': 'Seasonal barplot', 'value': 'seasonal'},
{'label': 'Daily timeserie', 'value': 'ts'}
],
value='daily',
),
dcc.RadioItems(
id='op-contribution-estimator',
className='options-items',
options=[
{'label': 'Mean', 'value': 'mean'},
{'label': 'Median', 'value': 'median'},
],
value='median',
),
dcc.Loading(
dcc.Graph(
id="op-contribution-graph",
figure={
'data': [],
'layout': {'title': 'OP contribution (Loading...)'}
}
)
)
]
)
......@@ -931,3 +946,55 @@ def add_month(df, season=False):
if season:
df_tmp["season"] = df_tmp["month_number"].replace(month_to_season)
return df_tmp
def add_season(df, month=True, month_to_season=None):
"""
Add a season column to the DataFrame df.
parameters
----------
df: Pandas DataFrame.
The DataFrame to work with.
month : add month number, default True
return
------
dfnew: a new pandas DataFrame with a 'season' columns.
"""
if month_to_season is None:
month_to_season = {1:'Winter', 2:'Winter', 3:'Spring', 4:'Spring', 5:'Spring', 6:'Summer',
7:'Summer', 8:'Summer', 9:'Fall', 10:'Fall', 11:'Fall',
12:'Winter'}
dfnew = df.copy()
# ensure we have date in index
if isinstance(dfnew.index, pd.DatetimeIndex):
dfnew["Date"] = dfnew.index
dropDate = True
elif 'Date' in dfnew.columns:
dfnew["Date"] = pd.to_datetime(dfnew["Date"])
dropDate = False
else:
print("No date given")
return
# add a new column with the number of the month (Jan=1, etc)
dfnew["month"] = dfnew["Date"].apply(lambda x: x.month)
# sort it. This is not mandatory.
dfnew.sort_values(by="month", inplace=True)
# add the season based on the month number
dfnew["season"] = dfnew["month"].replace(month_to_season)
if not month:
dfnew.drop(columns=["month"], inplace=True)
if dropDate:
dfnew.drop(columns=["Date"], inplace=True)
# and return the new dataframe
return dfnew
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment