diff --git a/tools/plotting/fastnnlo_runtime.py b/tools/plotting/fastnnlo_runtime.py index 642336937d52631be753d46cbd42b974243c703c..ff535542d5d2da795ee02146d8cd075aea0673b2 100755 --- a/tools/plotting/fastnnlo_runtime.py +++ b/tools/plotting/fastnnlo_runtime.py @@ -173,26 +173,22 @@ def get_files(files): def get_loginformation(files): + # always in hours for simplicity runtimes = [] + unit = 'hours' for file in files: runtimes_temp = [] with open(file) as origin: for line in origin: - # extract elapsed time with time unit + # extract elapsed time in hours if 'Time elapsed' in line: line = line.split(':') hours = float(line[1]) minutes = float(line[2]) seconds = float(line[3]) - - if hours != 0.: - runtimes_temp.append(hours + minutes/60 + seconds/360) - unit = 'hours' - else: - runtimes_temp.append(minutes + seconds/60) - unit = 'minutes' + runtimes_temp.append(hours + minutes/60 + seconds/3600) runtimes.append(runtimes_temp[-1]) @@ -235,7 +231,7 @@ def get_runinformation(files): def plot_elapsed_time(infodict, out_path, out_name, formats): times = infodict['runtime'] - unit = infodict['runtime_unit'] + unit = infodict['runtime_unit'] channels = infodict['channels'] events = infodict['events'] @@ -252,7 +248,7 @@ def plot_elapsed_time(infodict, out_path, out_name, formats): median = np.median(times) iqd = np.subtract(*np.percentile(times, [75, 25], interpolation='linear'))/2. - CPUtime = np.sum(times) / (1 if unit == 'hours' else 60) + CPUtime = np.sum(times) # set figure fig = plt.figure(figsize=(16, 12)) @@ -314,10 +310,7 @@ def plot_events_per_hour(infodict, out_path, out_name, formats): exit(11) eph = [] for i, time in enumerate(times): - if unit == 'hours': - eph.append(float(events[i])/time) - else: - eph.append(float(events[i])/(time/60)) + eph.append(float(events[i])/time) ephchn = [] for i, val in enumerate(eph): for j, chn in enumerate(_channels): @@ -336,7 +329,7 @@ def plot_events_per_hour(infodict, out_path, out_name, formats): ephmin = np.min(eph) ephmax = np.max(eph) logbins = np.geomspace(ephmin, ephmax, 100) - CPUtime = np.sum(times) / (1 if unit == 'hours' else 60) + CPUtime = np.sum(times) # create figure fig = plt.figure(figsize=(16, 12)) @@ -344,11 +337,9 @@ def plot_events_per_hour(infodict, out_path, out_name, formats): # plot (multistack-)histogram evrs = [] - lastch = 'LO' for chn in _channels: if chn in unique_channels: evrs.append(ephchn[masks[_channel_number[chn]]][:,0]) - lastch = chn if len(unique_channels) == 1: # plot each unique number in different color @@ -362,9 +353,10 @@ def plot_events_per_hour(infodict, out_path, out_name, formats): else: chnlab = [] chncol = [] - for chn in unique_channels: - chnlab.append(chn) - chncol.append(_channel_colors[_channel_number[chn]]) + for chn in _channels: + if chn in unique_channels: + chnlab.append(chn) + chncol.append(_channel_colors[_channel_number[chn]]) n, batches, _ = ax.hist(evrs, histtype='barstacked', log=True, stacked=True, bins=logbins, edgecolor='black', color=chncol, label=chnlab) ax.set_xlim(0.9*ephmin, 1.1*ephmax) ax.set_xscale('log')