Пример #1
0
def dashboard_performance_plots(myDataDF, runPeriodDF, myID):
    print 'Now make plots for ', myDataDF
    xKey='timeStamp'
    myPdf = PdfPages('images/plots_for_ID' + str(myID) + '.pdf')
    chartOptionsDict = {'InsideTemp': {'color': 'mediumturquoise', 'style': '-', 'desc': 'Inside Temp', 'linewidth':2},
                        'OutsideTemp': {'color': 'mediumvioletred', 'style': '-', 'desc': 'Outside Temp', 'linewidth':2},
                        'SetPoint': {'color': 'blue', 'style': '-', 'desc': 'Setpoint', 'linewidth':2}
                        }
    plotOptionsDict = {'xlabel': 'Time', 'ylabel': 'Temperature', 'grid': True, 'doDates': True, 'figsize': (15,10),
                      'xAxisFontSize': 25, 'yAxisFontSize': 25, 'xLabelSize': 28, 'yLabelSize': 28, 'xMarginXtra': 10.0,
                      'y_limit': [45,135]}
    print 'datetime values are: ', myDataDF[xKey]
    drawLegOutputs, drawLegLabels = drawing.overlayChartsFromPandasDF(plt, myDataDF, xKey, chartOptionsDict, plotOptionsDict)
    plt.legend(drawLegOutputs, drawLegLabels, prop={'size':28})
    #plt.show()
    myPdf.savefig()
    plt.close()

#    ### now do runPeriodDF
    print 'Will draw duration from runPeriodDF: ', runPeriodDF
    chartOptionsDict = {'duration': {'type': 'bar', 'maxBarWidth': 30. / (60.*24.), 'color': 'gold', 'style': '-'}}
    plotOptionsDict = {'xlabel': 'Time', 'ylabel': 'Run Duration [minutes]', 'grid': True, 'doDates': True, 'figsize': (15,10),
                       'xAxisFontSize': 25, 'yAxisFontSize': 25, 'xLabelSize': 28, 'yLabelSize': 28, 'xMarginXtra': 2.0}
    drawOutput = drawing.overlayChartsFromPandasDF(plt, runPeriodDF, 'beginRunTime', chartOptionsDict, plotOptionsDict)
    myPdf.savefig()
    plt.close()

    #print 'Now draw performance plot'
    chartOptionsDict = {'performance': {'type': 'bar', 'maxBarWidth': 30. / (60.*24.), 'color': 'lightseagreen', 'style': '-'}}
    plotOptionsDict = {'xlabel': 'Time', 'ylabel': 'Performance', 'grid': True, 'doDates': True,'figsize': (15,10),
                       'xAxisFontSize': 25, 'yAxisFontSize': 25, 'xLabelSize': 28, 'yLabelSize': 28, 'xMarginXtra': 2.0}
    drawing.overlayChartsFromPandasDF(plt, runPeriodDF, 'beginRunTime', chartOptionsDict, plotOptionsDict)
    myPdf.savefig()
    plt.close()

    myPdf.close()
def dashboard_performance_plots(myDataDF, myID):
    #print 'Now make plots for ', myDataDF
    xKey='timeStamp'
    myPdf = PdfPages('images/plots_for_ID' + str(myID) + '_AggregatedResults.pdf')

    # draw avgTemperatures
    chartOptionsDict = collections.OrderedDict([
                        ('maxInsideTemp', {'color': 'mediumturquoise', 'style': '--', 'desc': 'DayMaxInsideTemp', 'linewidth':6}),
                        ('avgInsideTemp', {'color': 'mediumturquoise', 'style': '-', 'desc': 'DayAvgInsideTemp', 'linewidth':6}),
                        ('minInsideTemp', {'color': 'mediumturquoise', 'style': '--', 'desc': 'DayMinInsideTemp', 'linewidth':6}),
                        ('maxOutsideTemp', {'color': 'mediumvioletred', 'style': '--', 'desc': 'DayMaxOutsideTemp', 'linewidth':6}),
                        ('avgOutsideTemp', {'color': 'mediumvioletred', 'style': '-', 'desc': 'DayAvgOutsideTemp', 'linewidth':6}),
                        ('minOutsideTemp', {'color': 'mediumvioletred', 'style': '--', 'desc': 'DayMinOutsideTemp', 'linewidth':6}),
                        ('avgSetPoint', {'color': 'blue', 'style': '-', 'desc': 'Setpoint', 'linewidth':6})
                       ])
    plotOptionsDict = {'xlabel': 'Time', 'ylabel': 'Temperature', 'grid': True, 'doDates': True, 'figsize': (20,10),
        'xAxisFontSize': 25, 'yAxisFontSize': 25, 'xLabelSize': 35, 'yLabelSize': 35, 'xMarginXtra': 10.0,
        'y_limit': [20,150]}

  #  print 'datetime values are: ', myDataDF[xKey]

    drawLegOutputs, drawLegLabels = drawing.overlayChartsFromPandasDF(plt, myDataDF, xKey, chartOptionsDict,plotOptionsDict)
    plt.legend(drawLegOutputs, drawLegLabels, prop={'size':28})
    #plt.show()
    myPdf.savefig()
    plt.close()

    #### Run the Suggested filter functions: remove days with no runtime, such as avgDuration < 0.000001
    myDataDF = filterData(myDataDF)


    
    # draw now  avgRunningMode
    #print 'Will draw average running time'
    chartOptionsDict = {'avgRunningMode': {'type': 'bar', 'color': 'gold', 'style': '-'}}
    plotOptionsDict = {'xlabel': 'Time', 'ylabel': 'Fraction Run Time', 'grid': True, 'doDates': True, 'figsize': (20,10),
        'xAxisFontSize': 25, 'yAxisFontSize': 25, 'xLabelSize': 35, 'yLabelSize': 35, 'xMarginXtra': 2.0}
    drawOutput = drawing.overlayChartsFromPandasDF(plt, myDataDF, xKey, chartOptionsDict, plotOptionsDict)
    myPdf.savefig()
    plt.close()
    
    # draw  avgPerformance plot
    chartOptionsDict = {'avgPerformance': {'type': 'bar', 'color': 'lightseagreen', 'style': '-'}}
    plotOptionsDict = {'xlabel': 'Time', 'ylabel': 'avgPerformance', 'grid': True, 'doDates': True,'figsize': (20,10),
        'xAxisFontSize': 25, 'yAxisFontSize': 25, 'xLabelSize': 28, 'yLabelSize': 28, 'xMarginXtra': 2.0}
    drawOutput = drawing.overlayChartsFromPandasDF(plt, myDataDF, xKey, chartOptionsDict, plotOptionsDict)
    myPdf.savefig()
    plt.close()
   
    #draw avgDuration plot
    chartOptionsDict = {'avgDuration': {'type': 'bar', 'color': 'pink', 'style': '-'}}
    plotOptionsDict = {'xlabel': 'Time', 'ylabel': 'avgDuration [minute]', 'grid': True, 'doDates': True,'figsize': (20,10),
       'xAxisFontSize': 25, 'yAxisFontSize': 25, 'xLabelSize': 28, 'yLabelSize': 28, 'xMarginXtra': 2.0}
    drawOutput = drawing.overlayChartsFromPandasDF(plt, myDataDF, xKey, chartOptionsDict, plotOptionsDict)
    myPdf.savefig()
    plt.close()


    #draw numCycles plot
    chartOptionsDict = {'numCycles': {'type': 'bar', 'color': 'blue', 'style': '-'}}
    plotOptionsDict = {'xlabel': 'Time', 'ylabel': 'Number Of Cycles', 'grid': True, 'doDates': True,'figsize': (20,10),
        'xAxisFontSize': 25, 'yAxisFontSize': 25, 'xLabelSize': 28, 'yLabelSize': 28, 'xMarginXtra': 2.0}
    drawOutput = drawing.overlayChartsFromPandasDF(plt, myDataDF, xKey, chartOptionsDict, plotOptionsDict)
    myPdf.savefig()
    plt.close()
    
    myPdf.close()
Пример #3
0
def draw_plots(myDataDF, peakInfoObjects, myID):
    #print 'Now make plots for ', myDataDF
    
    #### First make inclusive plot:
    xKey='timeStamp'    
    #myPdf = PdfPages('images/plots_for_ID_'+ str(myID) + 'PowerSummary_LightBulb.pdf')
    #myPdf = PdfPages('images/plots_for_ID_'+ str(myID) + 'PowerSummary_Microwave.pdf')
    #myPdf = PdfPages('images/plots_for_ID_'+ str(myID) + 'PowerSummary_HairDryer.pdf')
    myPdf = PdfPages('images/plots_for_ID_'+ str(myID) + 'PowerSummary_LaundaryDryer.pdf')
    
    
    chartOptionsDict = {'powerUsage': {'color': 'blue', 'style': '-'}
    }
    plotOptionsDict = {'xlabel': 'Time', 'ylabel': 'Power usage [Watts]', 
        'grid': True, 'figsize': (50,10), 'doDates': True,
        'xAxisFontSize': 24, 'yAxisFontSize': 24,
        'xLabelSize': 28, 'yLabelSize': 28,
        'xMarginXtra': 2.0}
    #        for item in ([ax.title, ax.xaxis.label, ax.yaxis.label] +
    #                             ax.get_xticklabels() + ax.get_yticklabels()):
    #                item.set_fontsize(20)
    #plt.figure(figsize=(50,10))
    # print 'datetime values are: ', myDataDF[xKey]
    drawing.overlayChartsFromPandasDF(plt, myDataDF, xKey, chartOptionsDict, plotOptionsDict)
    #plt.show()
    myPdf.savefig()
    plt.close()
    
    #### Now make peak plots:
    print 'Now draw peaks: ', peakInfoObjects
    for peak in peakInfoObjects:
        #        'peakInfoObject['startWindowPower']
        #        'peakInfoObject['endWindowPower']
        peakDataDF = myDataDF[peak['startTestIndex']-2:peak['endTestIndex']+ 3]
        chartOptionsDict = {
            'powerUsage': {'color': 'blue', 'style': '-'}
            }
        plotOptionsDict = {'xlabel': 'Time', 'ylabel': 'Power usage [Watts]', 'grid': True, 'doDates': True}
        xKey = 'timeStamp'
        print 'draw for this peak:'
        #drawBackgroundAndPeak()
        
        ax = drawing.getPlotFrame(plotOptionsDict)
        startSidebandOut = drawing.drawDatetimeOnePtBarPlot(ax, startTime=peak['startTime']-datetime.timedelta(minutes=6),
                                                            endTime=peak['startTime'],
                                                            value=peak['startWindowPower'], color='mediumvioletred')
        endSidebandOut = drawing.drawDatetimeOnePtBarPlot(ax, startTime=peak['endTime'],
                                                          endTime=peak['endTime']+datetime.timedelta(minutes=6),
                                                          value=peak['endWindowPower'], color='mediumvioletred')
        peakOut = drawing.drawDatetimeOnePtBarPlot(ax, startTime=peak['startTime'], endTime=peak['endTime'],
                                                   value=peak['peakPower'], color='powderblue')
        bkgOut = drawing.drawDatetimeOnePtBarPlot(ax, startTime=peak['startTime'], endTime=peak['endTime'],
                                                  value=peak['bkgPower'], color='pink')
        
        
        timeSeriesOut = drawing.overlayChartsFromPandasDF(plt, peakDataDF, xKey, chartOptionsDict, plotOptionsDict, createNewFig=False, ax=ax)
        startTestTime = peak['startTestTime']
        endTestTime = peak['endTestTime']
        startEndTestTimeValues = [drawing.convertDatetime64ToDatetime(ele) for ele in [startTestTime, endTestTime]]
        startEndTestTimeDates = matplotlib.dates.date2num(startEndTestTimeValues)
        canvasStartTestTime = startEndTestTimeDates[0]
        canvasEndTestTime = startEndTestTimeDates[1]
        ymin, ymax = ax.get_ylim()
        startTestOut = ax.plot([canvasStartTestTime,canvasStartTestTime],[ymin, ymax],color='black',linestyle='--', linewidth=2)
        endTestTout = ax.plot([canvasEndTestTime,canvasEndTestTime],[ymin, ymax],color='black',linestyle='--', linewidth=2)
        ax.legend((startSidebandOut[0], bkgOut[0], peakOut[0], timeSeriesOut[0], startTestOut[0]),
                  ('Sideband', 'Background', 'Device power', 'Power usage', 'Test begin/end'))
        myPdf.savefig()
        plt.close()
    
    myPdf.close()