diff --git a/helper.py b/visualise/helper.py similarity index 91% rename from helper.py rename to visualise/helper.py index fac9f882a818aae8ad89ac12dd8b0eb7fdf2b795..d6020174c5d893e944f052ac6b7c39c079ba7350 100644 --- a/helper.py +++ b/visualise/helper.py @@ -126,31 +126,36 @@ parameters["dst_app_cdo"] = r".*\) Initiating transfer.*(?P<parameter>dst app \d mpl.rcParams.update({'font.size': 14}) bar_width = 0.2 -def initPlot(components, title="", zoom=""): +def initPlot(components, title="", zoom=[]): #print(len(components)) - y_pos = np.arange(len(components)) # the width - if zoom != "": - fig, [ax, ax1] = plt.subplots(2, 1, figsize=(40, 12), gridspec_kw={'height_ratios': [1, 3]}) - ax1.set_title("Zoom", fontsize=46, y = 1.015) - data = [0] * len(components) - ax1.barh(y_pos, data , height = bar_width, align='center', color='gray') - ax1.set_yticks(y_pos) - ax1.set_yticklabels(components) - ax1.set_ylim(0,len(components)+1) - ax.set_ylim(0,len(components)+6) - axes = [ax, ax1] + y_pos = np.arange(len(components)) # height + + if zoom != []: + nZoomed = int(len(zoom)/2) + h = 9*nZoomed + 3 + hRatio = [1] + for v in np.arange(nZoomed): + hRatio.append(3) + print(zoom) + print(len(zoom)) + print(nZoomed) + print(hRatio) + fig, axes = plt.subplots(nZoomed+1, 1, figsize=(40, h), gridspec_kw={'height_ratios': hRatio}) + for ax in axes: + ax.set_title("Zoom", fontsize=46, y = 1.015) + ax.set_yticks(y_pos) + ax.set_yticklabels(components) + ax.set_ylim(0,len(components)+1) + #set title and limit for non zoomed image + axes[0].set_ylim(0,len(components)+6) + axes[0].set_title(title, y = 1.015) else: fig, ax = plt.subplots(figsize=(100, 4)) axes = ax ax.set_ylim(0,len(components)+6) - if title != "": ax.set_title(title, y = 1.015) - - data = [0] * len(components) - results = ax.barh(y_pos, data , height = bar_width, align='center', color='gray') - - ax.set_yticks(y_pos) - ax.set_yticklabels(components) + ax.set_yticks(y_pos) + ax.set_yticklabels(components) fig.tight_layout() @@ -163,36 +168,32 @@ def fetchComponentID(processID, components, componentsList): return componentID -def plotEvents(axes, events, componentsList, plotStart=0, tlimits = [], listAxes=0): +def plotEvents(axes, events, componentsList, plotStart=0, listAxes=0): if listAxes == 1: for ax in axes: - plotEventsCore(ax, events, componentsList, plotStart, tlimits) + plotEventsCore(ax, events, componentsList, plotStart) else: - plotEventsCore(axes, events, componentsList, plotStart, tlimits) + plotEventsCore(axes, events, componentsList, plotStart) -def plotEventsCore(ax, events, componentsList, plotStart=0, tlimits = []): +def plotEventsCore(ax, events, componentsList, plotStart=0): for event in events: #print(event) if event ==[]: continue - plotEventCore(ax, event, componentsList, plotStart, tlimits) + plotEventCore(ax, event, componentsList, plotStart) -def plotEvent(axes, event, componentsList, plotStart=0, tlimits = [], listAxes=0): +def plotEvent(axes, event, componentsList, plotStart=0, listAxes=0): if listAxes == 1: for ax in axes: - plotEventCore(ax, event, componentsList, plotStart, tlimits) + plotEventCore(ax, event, componentsList, plotStart) else: - plotEventCore(axes, event, componentsList, plotStart, tlimits) - -def plotEventCore(ax, event, componentsList, plotStart=0, tlimits = []): + plotEventCore(axes, event, componentsList, plotStart) +def plotEventCore(ax, event, componentsList, plotStart=0): - #if tlimits != []: - # if ((event.start- plotStart) < (tlimits[0])) or ((event.start - plotStart+ event.duration) > (tlimits[1])): - # return if event.duration == 0: # nothing to do there return @@ -341,6 +342,12 @@ def getEventsWithParameters(filename, processID, eventName, components, componen return events +def zoomIN(axs, limits): + + i = 0 + for ax in axs: + ax.set_xbound(limits[i],limits[i+1]) + i = i + 2 def getComponentListFromTelemetry(filename): componentsList = [] diff --git a/vis.py b/visualise/vis.py similarity index 82% rename from vis.py rename to visualise/vis.py index c17da520ee82d6bf76997048e2a0a9fab2db5521..5919d3964801ffff5521e71b8d6b54199471dd17 100644 --- a/vis.py +++ b/visualise/vis.py @@ -18,9 +18,11 @@ import matplotlib """ python3 vis.py --path check_pm_declare.sh.log --zoom 30000000,300000000 +python3 vis.py --path check_pm_declare.sh.log --zoom 30000000,50000000,1040000000,1045000000 python3 vis.py --path check_pm_interlock.sh.log --zoom 35000000,80000000 + """ parser = OptionParser() @@ -58,7 +60,7 @@ componentsList = hp.dict2List(components) -ax = hp.initPlot(componentsList, zoom=options.tlimits) +ax = hp.initPlot(componentsList, zoom=tlimits) #skip PM start time ...take the minimum of the components s = [] @@ -75,48 +77,48 @@ for key in components.keys(): continue init = hp.getEvent(options.path, key, "mstro_*_init", components, componentsList) #print(init.duration) - hp.plotEvent(ax, init, componentsList, startTime, tlimits, listAxes) + hp.plotEvent(ax, init, componentsList, startTime, listAxes) #print(init.start - startTime - tlimits[0]) #plot "mstro_cdo_declare" events = hp.getEventsWithParameters(options.path, key, "mstro_cdo_declare", components, componentsList, hp.parameters["cdo_name"]) #print(events) - hp.plotEvents(ax, events, componentsList, startTime, tlimits, listAxes) + hp.plotEvents(ax, events, componentsList, startTime, listAxes) #plot "mstro_cdo_offer" events = hp.getEventsWithParameters(options.path, key, "mstro_cdo_offer", components, componentsList, hp.parameters["cdo_name"]) #print(events) - hp.plotEvents(ax, events, componentsList, startTime, tlimits, listAxes) + hp.plotEvents(ax, events, componentsList, startTime, listAxes) #plot "mstro_cdo_withdraw" events = hp.getEventsWithParameters(options.path, key, "mstro_cdo_withdraw", components, componentsList, hp.parameters["cdo_name"]) #print(events) - hp.plotEvents(ax, events, componentsList, startTime, tlimits, listAxes) + hp.plotEvents(ax, events, componentsList, startTime, listAxes) #plot "mstro_cdo_demand" events = hp.getEventsWithParameters(options.path, key, "mstro_cdo_demand", components, componentsList, hp.parameters["cdo_name"]) #print(events) - hp.plotEvents(ax, events, componentsList, startTime, tlimits, listAxes) + hp.plotEvents(ax, events, componentsList, startTime, listAxes) #plot "mstro_cdo_dispose" events = hp.getEventsWithParameters(options.path, key, "mstro_cdo_dispose", components, componentsList, hp.parameters["cdo_name"]) #print(events) - hp.plotEvents(ax, events, componentsList, startTime, tlimits, listAxes) + hp.plotEvents(ax, events, componentsList, startTime, listAxes) events = hp.getEventsWithParameters(options.path, key, "mstro_pc_handle_msg", components, componentsList, hp.parameters["msg_type"], oneofakind=1) #print(events) - hp.plotEvents(ax, events, componentsList, startTime, tlimits, listAxes) + hp.plotEvents(ax, events, componentsList, startTime, listAxes) events = hp.getEventsWithParameters(options.path, key, "mstro_pc__handle_initiate_transfer", components, componentsList, hp.parameters["dst_app_cdo"], oneofakind=1) #print(events) - hp.plotEvents(ax, events, componentsList, startTime, tlimits, listAxes) + hp.plotEvents(ax, events, componentsList, startTime, listAxes) #events = hp.getEventsWithParameters(options.path, key, "mstro_pc_app_befriend", components, componentsList, hp.parameters["friends"], oneofakind=1) @@ -127,13 +129,13 @@ for key in components.keys(): fini = hp.getEvent(options.path, key, "mstro_*_finalize", components, componentsList) #print(fini) - hp.plotEvent(ax, fini, componentsList, startTime, tlimits, listAxes) + hp.plotEvent(ax, fini, componentsList, startTime, listAxes) #print("fini") #print(fini.start + fini.duration - startTime - tlimits[1]) attach = hp.getEvent(options.path, key, "mstro_pm_attach", components, componentsList) #print(fini) - hp.plotEvent(ax, attach, componentsList, startTime, tlimits, listAxes) + hp.plotEvent(ax, attach, componentsList, startTime, listAxes) @@ -149,19 +151,20 @@ for key in components.keys(): events = hp.getEventsWithParameters(options.path, list(components.keys())[0], "mstro_pm_handle_msg", components, componentsList, hp.parameters["msg_type"], oneofakind=1) #print(events) -hp.plotEvents(ax, events, componentsList, startTime, tlimits, listAxes) +hp.plotEvents(ax, events, componentsList, startTime, listAxes) #read telemetry events teleEvents = hp.readTelemetryEvents(options.path, componentsList) -hp.plotEvents(ax, teleEvents, componentsList, startTime, tlimits, listAxes) +hp.plotEvents(ax, teleEvents, componentsList, startTime, listAxes) legendcols = 7 if tlimits != []: #ax.set_xlim(tlimits) #ax.set_xlim(xmin = tlimits[0], xmax=tlimits[1]) - ax[1].set_xbound(tlimits) + hp.zoomIN(ax[1:], tlimits) + #ax[1].set_xbound(tlimits) ax[0].legend(ncol = legendcols, fontsize = 12, bbox_to_anchor=(0., 1.02, 1., .102), loc=3, mode="expand", borderaxespad=0.) #plt.xlim(tlimits) else: