def plot(config, graph_type, group_by, sample_width, weekends_only, business_days_only, no_outliers, out_file=None, included_channels=None, limit_value=None): """Plot the gathered data. """ # We import plotly local to the function not to slow down the rest of the program, # for example printing the help text. Import plotly adds 1.4s to execution time. import plotly rows = csvio.loadAll(config) device_name = rows[0][1] channel_labels = data.get_labels(rows) rows = rows[data.get_first_data_point_index(rows):] if weekends_only: rows = data.filter_weekends(rows, True) if business_days_only: rows = data.filter_weekends(rows, False) if not rows: raise RuntimeError("After filtering the data for weekends or weekdays " "there was no data left to plot.") if graph_type == 'scatter': columns = data.get_columns(rows) figure = construct_line_or_scatter(channel_labels, columns, included_channels, device_name, 'markers', limit_value) elif graph_type == 'line': columns = data.get_columns(rows) figure = construct_line_or_scatter(channel_labels, columns, included_channels, device_name, 'line', limit_value) elif graph_type == 'box': groups = data.group(rows, group_by, sample_width) groups = data.rotate_group_with_time_to_start(groups, datetime.time(3, 0)) figure = construct_box(channel_labels, groups, group_by, included_channels, device_name, no_outliers, limit_value) if not out_file: out_file = graph_type + '-plot_grouped_by_' + group_by + '.html' plotly.offline.plot(figure, filename=out_file)
def dump(config, out_path): """Output one big csv file containing all the data gathered thus far.""" if config.verbose: click.echo('Dumping to' + out_path) rows = csvio.loadAll() csvio.writeRows(rows, out_path)