def plot(rcdb_context, query, views_or_runs): """ Command allows to select runs and get values from it""" assert isinstance(rcdb_context.db, RCDBProvider) args = [str(query)] args.extend([str(v) for v in views_or_runs]) run_range_str, query, view = _process_sel_args(args) (run_min, run_max) = parse_run_range(run_range_str, rcdb_context.db.get_run_periods()) if run_min is None: run_min = 0 if run_max is None: run_max = sys.maxint if query == '@' or query is None: query = '' if not view: view = "event_count run_config" conditions_to_show = view.split() import matplotlib.pyplot as plt values = rcdb_context.db.select_runs(query, run_min, run_max).get_values(conditions_to_show, True) x_col = [v[0] for v in values] plot_data = [x_col, [v[1] for v in values], "ro"] plt.plot(*plot_data, label=conditions_to_show[0]) plt.show()
def sel(rcdb_context, query, views_or_runs, is_dump_view, is_descending): """ Command allows to select runs and get values from it""" assert isinstance(rcdb_context.db, RCDBProvider) args = [str(query)] args.extend([str(v) for v in views_or_runs]) run_range_str, query, view = _process_sel_args(args) (run_min, run_max) = parse_run_range(run_range_str, rcdb_context.db.get_run_periods()) if run_min is None: run_min = 0 if run_max is None: run_max = sys.maxint if query == '@' or query is None: query = '' if not view: view = "event_count run_config" conditions_to_show = view.split() values = rcdb_context.db.select_values([], query, run_min, run_max) if not is_dump_view: try: from prettytable import PrettyTable table = PrettyTable(["run_num"] + conditions_to_show) for row in values: table.add_row(row) click.echo(table) return except ImportError: click.echo( "# (!) no prettytable module is installed. Using regular table" ) is_dump_view = True click.echo("#! {}".format(" ".join(["run_num" ].extend(conditions_to_show)))) for row in values: click.echo(" ".join(row))
def sel(rcdb_context, query, views_or_runs, is_dump_view, is_descending): """ Command allows to select runs and get values from it""" assert isinstance(rcdb_context.db, RCDBProvider) args = [str(query)] args.extend([str(v) for v in views_or_runs]) run_range_str, query, view = _process_sel_args(args) (run_min, run_max) = parse_run_range(run_range_str, rcdb_context.db.get_run_periods()) if run_min is None: run_min = 0 if run_max is None: run_max = sys.maxint if query == '@' or query is None: query = '' if not view: view = "event_count run_config" conditions_to_show = view.split() values = rcdb_context.db.select_runs(query, run_min, run_max).get_values(conditions_to_show, is_descending) if not is_dump_view: try: from prettytable import PrettyTable table = PrettyTable(["run_num"] + conditions_to_show) for row in values: table.add_row(row) click.echo(table) return except ImportError: click.echo("# (!) no prettytable module is installed. Using regular table") is_dump_view = True click.echo("#! {}".format(" ".join(["run_num"].extend(conditions_to_show)))) for row in values: click.echo(" ".join(row))