Loading raps/plotting.py +73 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ Plotter """ import matplotlib.pyplot as plt import numpy as np from uncertainties import unumpy class BasePlotter: Loading Loading @@ -158,6 +159,78 @@ class Plotter(BasePlotter): self.save_and_close_plot(self.save_path) def plot_nodes_histogram(nr_list, num_bins=25): print("plotting nodes required histogram...") # Create logarithmically spaced bins bins = np.logspace(np.log2(min(nr_list)), np.log2(max(nr_list)), num=num_bins, base=2) # Set up the figure plt.clf() plt.figure(figsize=(10, 3)) # Create the histogram plt.hist(nr_list, bins=bins, edgecolor='black') # Add a title and labels plt.xlabel('Number of Nodes') plt.ylabel('Frequency') # Set the axes to logarithmic scale plt.xscale('log', base=2) plt.yscale('log') # Customize the x-ticks: Choose positions like 1, 8, 64, etc. ticks = [2**i for i in range(0, 14)] plt.xticks(ticks, labels=[str(tick) for tick in ticks]) # Set min-max axis bounds plt.xlim(1, max(nr_list)) # Save the histogram to a file plt.savefig('histogram.png', dpi=300, bbox_inches='tight') def plot_submit_times(submit_times, nr_list): """Plot number of nodes over time""" print("plotting submit times...") # Determine the time scale max_time = max(submit_times) if max_time >= 3600 * 24 * 7: # If more than a week convert time to days submit_times = [time / (3600 * 24) for time in submit_times] time_label = 'Submit Time (days)' elif max_time >= 3600 * 24: # If more than 24 hours convert time to hours submit_times = [time / 3600 for time in submit_times] time_label = 'Submit Time (hours)' else: time_label = 'Submit Time (s)' plt.clf() plt.figure(figsize=(10, 2)) # Create a bar chart bar_width = (max(submit_times) - min(submit_times)) / len(submit_times) * 0.8 plt.bar(submit_times, nr_list, width=bar_width, color='blue', edgecolor='black', alpha=0.7) # Add labels and title plt.xlabel(time_label) plt.ylabel('Number of Nodes') # Set min-max axis bounds plt.xlim(1, max(submit_times)) # Set the y-axis to logarithmic scale with base 2 plt.yscale('log', base=2) y_ticks = [2**i for i in range(0, 14)] plt.yticks(y_ticks, labels=[str(tick) for tick in y_ticks]) # Save the plot to a file plt.savefig('submit_times.png', dpi=300, bbox_inches='tight') if __name__ == "__main__": plotter = Plotter() #plotter.plot_history([1, 2, 3, 4]) raps/telemetry.py +3 −46 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import re from datetime import datetime from tqdm import tqdm from .scheduler import Job from .plotting import plot_submit_times, plot_nodes_histogram from .utils import next_arrival Loading Loading @@ -105,50 +106,6 @@ if __name__ == "__main__": print(f'Nodes required (max): {np.max(nr_list)}') print(f'Nodes required (std): {np.std(nr_list):.2f}') if args.plot: import matplotlib.pyplot as plt print("plotting nodes required histogram...") # Define the number of bins you want num_bins = 25 data = nr_list # Create logarithmically spaced bins bins = np.logspace(np.log2(min(data)), np.log2(max(data)), num=num_bins, base=2) # Set up the figure plt.figure(figsize=(10, 3)) # Create the histogram plt.hist(nr_list, bins=bins, edgecolor='black') # Add a title and labels plt.xlabel('Number of Nodes') plt.ylabel('Frequency') # Set the axes to logarithmic scale plt.xscale('log', base=2) plt.yscale('log') # Customize the x-ticks: Choose the positions (1, 8, 64, etc.) ticks = [2**i for i in range(0, 14)] plt.xticks(ticks, labels=[str(tick) for tick in ticks]) # Set min-max axis bounds plt.xlim(1, max(data)) # Save the histogram to a file plt.savefig('histogram.png', dpi=300, bbox_inches='tight') print("plotting submit times...") # Plot number of nodes over time plt.clf() plt.figure(figsize=(10, 2)) # Create a bar chart plt.bar(submit_times, nr_list, width=10.0, color='blue', edgecolor='black', alpha=0.7) # Add labels and title plt.xlabel('Submit Time (s)') plt.ylabel('Number of Nodes') # Set min-max axix bounds plt.xlim(1, max(submit_times)) # Set the y-axis to logarithmic scale with base 2 plt.yscale('log', base=2) y_ticks = [2**i for i in range(0, 14)] plt.yticks(y_ticks, labels=[str(tick) for tick in y_ticks]) # Save the plot to a file plt.savefig('submit_times.png', dpi=300, bbox_inches='tight') plot_nodes_histogram(nr_list) plot_submit_times(submit_times, nr_list) Loading
raps/plotting.py +73 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ Plotter """ import matplotlib.pyplot as plt import numpy as np from uncertainties import unumpy class BasePlotter: Loading Loading @@ -158,6 +159,78 @@ class Plotter(BasePlotter): self.save_and_close_plot(self.save_path) def plot_nodes_histogram(nr_list, num_bins=25): print("plotting nodes required histogram...") # Create logarithmically spaced bins bins = np.logspace(np.log2(min(nr_list)), np.log2(max(nr_list)), num=num_bins, base=2) # Set up the figure plt.clf() plt.figure(figsize=(10, 3)) # Create the histogram plt.hist(nr_list, bins=bins, edgecolor='black') # Add a title and labels plt.xlabel('Number of Nodes') plt.ylabel('Frequency') # Set the axes to logarithmic scale plt.xscale('log', base=2) plt.yscale('log') # Customize the x-ticks: Choose positions like 1, 8, 64, etc. ticks = [2**i for i in range(0, 14)] plt.xticks(ticks, labels=[str(tick) for tick in ticks]) # Set min-max axis bounds plt.xlim(1, max(nr_list)) # Save the histogram to a file plt.savefig('histogram.png', dpi=300, bbox_inches='tight') def plot_submit_times(submit_times, nr_list): """Plot number of nodes over time""" print("plotting submit times...") # Determine the time scale max_time = max(submit_times) if max_time >= 3600 * 24 * 7: # If more than a week convert time to days submit_times = [time / (3600 * 24) for time in submit_times] time_label = 'Submit Time (days)' elif max_time >= 3600 * 24: # If more than 24 hours convert time to hours submit_times = [time / 3600 for time in submit_times] time_label = 'Submit Time (hours)' else: time_label = 'Submit Time (s)' plt.clf() plt.figure(figsize=(10, 2)) # Create a bar chart bar_width = (max(submit_times) - min(submit_times)) / len(submit_times) * 0.8 plt.bar(submit_times, nr_list, width=bar_width, color='blue', edgecolor='black', alpha=0.7) # Add labels and title plt.xlabel(time_label) plt.ylabel('Number of Nodes') # Set min-max axis bounds plt.xlim(1, max(submit_times)) # Set the y-axis to logarithmic scale with base 2 plt.yscale('log', base=2) y_ticks = [2**i for i in range(0, 14)] plt.yticks(y_ticks, labels=[str(tick) for tick in y_ticks]) # Save the plot to a file plt.savefig('submit_times.png', dpi=300, bbox_inches='tight') if __name__ == "__main__": plotter = Plotter() #plotter.plot_history([1, 2, 3, 4])
raps/telemetry.py +3 −46 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import re from datetime import datetime from tqdm import tqdm from .scheduler import Job from .plotting import plot_submit_times, plot_nodes_histogram from .utils import next_arrival Loading Loading @@ -105,50 +106,6 @@ if __name__ == "__main__": print(f'Nodes required (max): {np.max(nr_list)}') print(f'Nodes required (std): {np.std(nr_list):.2f}') if args.plot: import matplotlib.pyplot as plt print("plotting nodes required histogram...") # Define the number of bins you want num_bins = 25 data = nr_list # Create logarithmically spaced bins bins = np.logspace(np.log2(min(data)), np.log2(max(data)), num=num_bins, base=2) # Set up the figure plt.figure(figsize=(10, 3)) # Create the histogram plt.hist(nr_list, bins=bins, edgecolor='black') # Add a title and labels plt.xlabel('Number of Nodes') plt.ylabel('Frequency') # Set the axes to logarithmic scale plt.xscale('log', base=2) plt.yscale('log') # Customize the x-ticks: Choose the positions (1, 8, 64, etc.) ticks = [2**i for i in range(0, 14)] plt.xticks(ticks, labels=[str(tick) for tick in ticks]) # Set min-max axis bounds plt.xlim(1, max(data)) # Save the histogram to a file plt.savefig('histogram.png', dpi=300, bbox_inches='tight') print("plotting submit times...") # Plot number of nodes over time plt.clf() plt.figure(figsize=(10, 2)) # Create a bar chart plt.bar(submit_times, nr_list, width=10.0, color='blue', edgecolor='black', alpha=0.7) # Add labels and title plt.xlabel('Submit Time (s)') plt.ylabel('Number of Nodes') # Set min-max axix bounds plt.xlim(1, max(submit_times)) # Set the y-axis to logarithmic scale with base 2 plt.yscale('log', base=2) y_ticks = [2**i for i in range(0, 14)] plt.yticks(y_ticks, labels=[str(tick) for tick in y_ticks]) # Save the plot to a file plt.savefig('submit_times.png', dpi=300, bbox_inches='tight') plot_nodes_histogram(nr_list) plot_submit_times(submit_times, nr_list)