def plot_coverage(self, sequence_name, coverage, num_bins=100): try: import plotext as plt except: self.run.warning( "You don't have the `plotext` library to plot data :/ You can " "install it by running `pip install plotext` in your anvi'o " "environment.", header="NO PLOT FOR YOU :(") return plt.clp() plt.title(f"{sequence_name}") plt.xlabel("Position") plt.ylabel("Coverage") plt.plot(coverage, fillx=True) plt.plotsize(self.progress.terminal_width, 25) plt.canvas_color("cloud") plt.axes_color("cloud") plt.ticks_color("iron") try: plt.show() except OSError: self.run.warning( "Redirecting things into files and working with funny TTYs confuse " "the plotting services. Is ok tho.", header="NO PLOT FOR YOU :(") pass
def show_points( points: t.Sequence[t.Tuple[datetime.datetime, t.Union[int, float]]], title: str, y_label: str, ) -> None: if not points: print('No data') return import plotext as plt dates, values = zip(*points) date_time_stamps = [d.timestamp() for d in dates] plt.plot(date_time_stamps, values) plt.xticks(date_time_stamps, (d.strftime('%Y/%m/%d') for d in dates)) plt.title(title) plt.xlabel('Date') plt.ylabel(y_label) plt.ylim(0, max(values) * 1.1) plt.canvas_color('iron') plt.axes_color('cloud') plt.grid(False, True) plt.show()
def main(filea, fileb): if filea is None: # take the second most recent profiling_files = parse_and_sort_profiling_files() filea = profiling_files[-2] if fileb is None: # take the most recent profiling_files = parse_and_sort_profiling_files() fileb = profiling_files[-1] profile_a = pd.read_pickle(filea) profile_b = pd.read_pickle(fileb) merged = pd.merge( profile_a, profile_b, how='left', on=['document_length','document_depth', 'working_depth', 'item_length'] ) plt.clp() bins = 30 plt.hist(merged['tottime_x'], bins, label="profile a") plt.hist(merged['tottime_y'], bins, label="profile b") plt.title("tottime distribution") plt.xlabel("time bins") plt.ylabel("frequency") plt.canvas_color("none") plt.axes_color("none") plt.ticks_color("cloud") plt.figsize(50, 15) plt.show() merged['diff'] = merged['tottime_x'] - merged['tottime_y'] print("") print(f"## avg improvement: {merged['diff'].mean()} seconds ##") print("")
''' small auxiliary script that uses the lammps log parser to quickly plot data to terminal usage: plot_thermo.py <thermo_key> ''' import lammps_log_parser as lmp import plotext as pt import sys yvar = sys.argv[1] data = lmp.parse_log_to_pandas_df('*log') pt.plot(data['Step'], data[yvar]) pt.xlabel('simulation steps') pt.ylabel(yvar) pt.nocolor() pt.figsize(160, 40) pt.show()
def show_statistics(rule_file=None, rule_set=None, indx=None): interface = None if rule_set == "-e": interface = "external" elif rule_set == "-i": interface = "internal" logs = utils.load_logs('logs.json') print("") print("-" * 13, "OVERALL FIREWALL STATISTICS", "-" * 13) print("TOTAL PACkETS RECEIVED BY THE FIREWALL: ", logs["total_packets"]) print("TOTAL PACkETS DROPPED BY THE FIREWALL: ", logs["total_dropped"]) if rule_file != None: if interface != None: print("") print("-" * 12, interface.upper(), "INTERFACE STATISTICS", "-" * 12) print("TOTAL PACKETS RECEIVED ON", interface.upper(), "INTERFACE: ", logs[rule_file][interface]["total_packets"]) print("TOTAL PACKETS DROPPED ON", interface.upper(), "INTERFACE: ", logs[rule_file][interface]["total_dropped"]) if indx != None: if indx in logs[rule_file][interface]: print("\nTOTAL PACKETS DROPPED DUE TO RULE", indx, "ON", interface.upper(), "INTERFACE :", logs[rule_file][interface][indx]) else: print("Invalid rule index!") else: print("") print("-" * 12, "EXTERNAL INTERFACE STATISTICS", "-" * 12) print("TOTAL PACKETS RECEIVED ON EXTERNAL INTERFACE: ", logs[rule_file]["external"]["total_packets"]) print("TOTAL PACKETS DROPPED ON EXTERNAL INTERFACE: ", logs[rule_file]["external"]["total_dropped"]) print("") print("-" * 12, "INTERNAL INTERFACE STATISTICS", "-" * 12) print("TOTAL PACKETS RECEIVED ON INTERNAL INTERFACE: ", logs[rule_file]["internal"]["total_packets"]) print("TOTAL PACKETS DROPPED ON INTERNAL INTERFACE: ", logs[rule_file]["internal"]["total_dropped"]) else: print("") print("-" * 16, "ICMP FLOOD STATISTICS", "-" * 16) print("FLOODS ENCOUNTERED SO FAR: ", logs["icmp_floods"]) print("PACKETS DROPPED DURING ICMP BLOCK:", logs["icmp_dropped"]) print("") print("-" * 22, "PPS INFO", "-" * 22) print("MAXIMUM PPS SO FAR: ", logs["max_pps"]) print("") title = "-" * 18 + "NETWORK TRAFFIC" + "-" * 18 net_traffic = logs["traffic"] max_sec = max(np.array(list(net_traffic.keys())).astype(int)) packets_num = np.zeros(max_sec + 1) for i in net_traffic: packets_num[int(i)] = net_traffic[i] packets_num = packets_num.astype(int) plt.scatter(np.arange(max_sec + 1), packets_num, fillx=True) plt.figsize(80, 20) plt.title(title) plt.xlabel("Time") plt.ylabel("Packets") plt.show()