diff --git a/dashboard/callbacks.py b/dashboard/callbacks.py index de1768c..b469f71 100644 --- a/dashboard/callbacks.py +++ b/dashboard/callbacks.py @@ -5,6 +5,7 @@ from dash import Input, Output, State from aerosense_tools.plots import plot_connection_statistic, plot_pressure_bar_chart, plot_sensors +from aerosense_tools.preprocess import RawSignal from aerosense_tools.queries import ROW_LIMIT, BigQuery from aerosense_tools.utils import generate_time_range, get_cleaned_sensor_column_names @@ -192,7 +193,15 @@ def plot_sensors_graph( finish=finish, ) - figure = plot_sensors(df, line_descriptions=sensor_types[sensor_name]["variable"]) + # Extract only data columns and set index to 'datetime', so that DataFrame is accepted by RawSignal class + data_columns = df.columns[df.columns.str.startswith('f')].tolist() + sensor_data = df[["datetime"] + data_columns].set_index('datetime') + raw_data = RawSignal(sensor_data, sensor_name) + raw_data.measurement_to_variable() # Convert raw data int to float value in SI units + plot_df = raw_data.dataframe.reset_index() # reset index to pass DataFrame to plot_sensors function + + figure = plot_sensors(plot_df, line_descriptions=sensor_types[sensor_name]["variable"]) + figure.update_layout(height=800) if data_limit_applied: return (figure, f"Large amount of data - the query has been limited to the latest {ROW_LIMIT} datapoints.") diff --git a/dashboard/layouts.py b/dashboard/layouts.py index bb54887..f283172 100644 --- a/dashboard/layouts.py +++ b/dashboard/layouts.py @@ -40,38 +40,94 @@ def create_sensors_tab_layout(app, tab_name, sensor_names, graph_id, data_limit_ TimeRangeSelect(), html.Br(), html.Label(html.B("Custom time range")), - html.Label("Start datetime"), - dcc.DatePickerSingle( - id="start-date", - date=datetime.datetime.now().date().isoformat(), - display_format="Do MMM Y", - persistence=True, - disabled=True, + html.Div( + [ + html.Div( + [ + html.Label("Start datetime"), + dcc.DatePickerSingle( + id="start-date", + date=datetime.datetime.now().date().isoformat(), + display_format="Do MMM Y", + persistence=True, + disabled=True, + ), + ], + style={"display": "inline-block"}, + ), + html.Div( + [ + html.Label("Hour"), + dash_daq.NumericInput( + id="start-hour", value=0, min=0, max=23, persistence=True + ), + ], + style={"display": "inline-block"}, + ), + html.Div( + [ + html.Label("Minute"), + dash_daq.NumericInput( + id="start-minute", value=0, min=0, max=59, persistence=True + ), + ], + style={"display": "inline-block"}, + ), + html.Div( + [ + html.Label("Second"), + dash_daq.NumericInput( + id="start-second", value=0, min=0, max=59, persistence=True + ), + ], + style={"display": "inline-block"}, + ), + ], + style={"margin": "10px 0"}, ), - html.Br(), - html.Label("Hour"), - dash_daq.NumericInput(id="start-hour", value=0, min=0, max=23, persistence=True), - html.Label("Minute"), - dash_daq.NumericInput(id="start-minute", value=0, min=0, max=59, persistence=True), - html.Label("Second"), - dash_daq.NumericInput(id="start-second", value=0, min=0, max=59, persistence=True), - html.Br(), - html.Label("End datetime"), - dcc.DatePickerSingle( - id="end-date", - display_format="Do MMM Y", - persistence=True, - disabled=True, + html.Div( + [ + html.Div( + [ + html.Label("End datetime"), + dcc.DatePickerSingle( + id="end-date", + display_format="Do MMM Y", + persistence=True, + disabled=True, + ), + ], + style={"display": "inline-block"}, + ), + html.Div( + [ + html.Label("Hour"), + dash_daq.NumericInput(id="end-hour", value=0, min=0, max=23, persistence=True), + ], + style={"display": "inline-block"}, + ), + html.Div( + [ + html.Label("Minute"), + dash_daq.NumericInput( + id="end-minute", value=0, min=0, max=59, persistence=True + ), + ], + style={"display": "inline-block"}, + ), + html.Div( + [ + html.Label("Second"), + dash_daq.NumericInput( + id="end-second", value=0, min=0, max=59, persistence=True + ), + ], + style={"display": "inline-block"}, + ), + ], + style={"margin": "10px 0"}, ), html.Br(), - html.Label("Hour"), - dash_daq.NumericInput(id="end-hour", value=0, min=0, max=23, persistence=True), - html.Label("Minute"), - dash_daq.NumericInput(id="end-minute", value=0, min=0, max=59, persistence=True), - html.Label("Second"), - dash_daq.NumericInput(id="end-second", value=0, min=0, max=59, persistence=True), - html.Br(), - html.Br(), html.Button("Plot", id="refresh-button", n_clicks=0), html.Button("Check for new installations", id="installation-check-button", n_clicks=0), ], diff --git a/docs/source/deploying_the_dashboard.rst b/docs/source/deploying_the_dashboard.rst index f2f8050..2e7527a 100644 --- a/docs/source/deploying_the_dashboard.rst +++ b/docs/source/deploying_the_dashboard.rst @@ -2,4 +2,3 @@ Deployment ========== - diff --git a/docs/source/index.rst b/docs/source/index.rst index 1fd3c5f..c673601 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -4,7 +4,7 @@ Aerosense Dashboard ``aerosense-dashboard`` is a data dashboard allowing high-level visualisation of data from the aerosense system. - - The ``data-gateway`` library is responsible for the data collection and ingress to GretaDB and GretaStore. + - The ``data-gateway`` library is responsible for the data collection and ingress to GretaDB and GretaStore. - The ``aerosense-tools`` library can access and manipulate data from GretaDB or the GretaStore by any python client. This dashboard uses a combination of its own code and ``aerosense-tools`` to access and visualise data from GretaDB. diff --git a/pyproject.toml b/pyproject.toml index f0b3eb2..6f869bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ [tool.poetry] name = "aerosense-dashboard" -version = "0.4.4" +version = "0.4.5" description = "High-level visualisation for aerosense" authors = ["Tom Clark", "Marcus Lugg", "Yuriy Marykovsky"] license = "BSD-3"