コード例 #1
0
def smallDataTest():
    breakPrint()
    generalPrint("testsSpectralCalc", "Running test function: smallDataTest")
    # read in data
    reader = DataReaderATS(atsPath)
    startTime1 = "2016-02-21 03:00:00"
    stopTime1 = "2016-02-21 03:30:00"
    timeData = reader.getPhysicalData(startTime1, stopTime1)
    timeData.printInfo()
    # now let's try the calibrator
    cal = Calibrator(calPath)
    cal.printInfo()
    sensors = reader.getSensors(timeData.chans)
    serials = reader.getSerials(timeData.chans)
    choppers = reader.getChoppers(timeData.chans)
    timeData = cal.calibrate(timeData, sensors, serials, choppers)
    timeData.printInfo()
    specCal = SpectrumCalculator(timeData.sampleFreq, timeData.numSamples)
    specData = specCal.calcFourierCoeff(timeData)
    specData.printInfo()
    fig = plt.figure(figsize=(10, 10))
    specData.view(fig=fig, label="Raw spectral data")
    # now let's try and process something
    sproc = SignalProcessor()
    timeData2 = reader.getPhysicalData(startTime1, stopTime1)
    timeData2 = cal.calibrate(timeData2, sensors, serials, choppers)
    timeData2 = sproc.notchFilter(timeData2, 50.0)
    timeData2 = sproc.notchFilter(timeData2, 16.6667)
    specData2 = specCal.calcFourierCoeff(timeData2)
    specData2.printInfo()
    specData2.view(fig=fig, label="Notch filtered")
    # set plot properties
    fig.tight_layout(rect=[0, 0.02, 1, 0.96])
    addLegends(fig)
    plt.show()
コード例 #2
0
def plotTest():
    breakPrint()
    generalPrint("testsSignalProcess", "Running test function: plotTest")
    # read in data
    atsReader = DataReaderATS(atsPath)
    # now get some data
    startTime1 = "2016-02-21 03:00:00"
    stopTime1 = "2016-02-21 03:05:00"
    timeData1 = atsReader.getPhysicalData(startTime1, stopTime1)
    timeData1.printInfo()
    # get a second set of data
    startTime2 = "2016-02-21 03:03:00"
    stopTime2 = "2016-02-21 03:05:00"
    timeData2 = atsReader.getPhysicalData(startTime2, stopTime2)
    timeData2.printInfo()
    # now plot
    fig = plt.figure(figsize=(20, 10))
    timeData1.view(sampleStop=timeData1.numSamples - 1,
                   fig=fig,
                   xlim=[timeData1.startTime, timeData2.stopTime])
    timeData2.view(sampleStop=timeData2.numSamples - 1,
                   fig=fig,
                   xlim=[timeData1.startTime, timeData2.stopTime])
    fig.tight_layout(rect=[0, 0.02, 1, 0.96])
    addLegends(fig)
    plt.show()
コード例 #3
0
def testATS():
    breakPrint()
    generalPrint("testsDataReader", "Running test function: testATS")
    # read in ATS data
    atsReader = DataReaderATS(atsPath)
    atsReader.printInfo()
    # now get some data
    startTime = "2016-02-21 03:00:00"
    stopTime = "2016-02-21 04:00:00"
    # let's get some unscaled data
    unscaledData = atsReader.getUnscaledData(startTime, stopTime)
    unscaledData.printInfo()
    # now let's look at the data
    unscaledData.view(sampleEnd=20000)
    # let's try physical data
    physicalData = atsReader.getPhysicalData(startTime, stopTime)
    physicalData.printInfo()
    # let's view it
    physicalData.view()
    # but all we see is 50Hz and 16Hz noise
    # so we can apply a low pass filter
    physicalData.view(sampleEnd=20000, lpfilt=4)
    # now let's try and write it out
    # as the ascii format
    writer = DataWriterAscii()
    writer.setOutPath(ats_2ascii)
    writer.writeDataset(atsReader)
コード例 #4
0
def hpFilterTest():
    breakPrint()
    generalPrint("testsSignalProcess", "Running test function: hpFilterTest")
    # read in data
    atsReader = DataReaderATS(atsPath)
    # now get some data
    startTime = "2016-02-21 03:00:00"
    stopTime = "2016-02-21 04:00:00"
    timeData = atsReader.getPhysicalData(startTime, stopTime)
    timeDataSave = copy.deepcopy(timeData)
    timeData.printInfo()
    # now do some signal processing
    sproc = SignalProcessor()
    timeData = sproc.highPass(timeData, 24)
    timeData.printInfo()
    # now let's plot and see what happens
    fig = plt.figure(figsize=(20, 10))
    timeDataSave.view(fig=fig, label="Raw data")
    timeData.view(fig=fig, label="High pass filtered")
    fig.tight_layout(rect=[0, 0.02, 1, 0.96])
    addLegends(fig)
    plt.show()
コード例 #5
0
def testFillGap():
    breakPrint()
    generalPrint("testsSignalProcess", "Running test function: testFillGap")
    # read in data
    atsReader = DataReaderATS(atsPath)
    # now get some data
    startTime1 = "2016-02-21 03:00:00"
    stopTime1 = "2016-02-21 03:08:00"
    timeData1 = atsReader.getPhysicalData(startTime1, stopTime1)
    # more data
    startTime2 = "2016-02-21 03:10:00"
    stopTime2 = "2016-02-21 03:15:00"
    timeData2 = atsReader.getPhysicalData(startTime2, stopTime2)
    # now do some signal processing
    sproc = SignalProcessor()
    timeData = sproc.fillGap(timeData1, timeData2)
    timeData.printInfo()
    # now let's plot and see what happens
    fig = plt.figure(figsize=(20, 10))
    x = timeData.getDateArray()
    xlim = [timeData1.startTime, timeData2.stopTime]
    timeData.view(sampleStop=timeData.numSamples - 1,
                  fig=fig,
                  xlim=xlim,
                  label="Gap filled")
    timeData1.view(sampleStop=timeData1.numSamples - 1,
                   fig=fig,
                   xlim=xlim,
                   label="Section1")
    timeData2.view(sampleStop=timeData2.numSamples - 1,
                   fig=fig,
                   xlim=xlim,
                   label="Section2")
    fig.tight_layout(rect=[0, 0.02, 1, 0.96])
    addLegends(fig)
    plt.show()

    # now test with spam data
    spamReader = DataReaderSPAM(spamPath)
    # now get some data
    startTime1 = "2016-02-07 02:00:00"
    stopTime1 = "2016-02-07 02:08:00"
    timeData1 = spamReader.getPhysicalData(startTime1, stopTime1)
    # more data
    startTime2 = "2016-02-07 02:10:00"
    stopTime2 = "2016-02-07 02:15:00"
    timeData2 = spamReader.getPhysicalData(startTime2, stopTime2)
    # now do some signal processing
    sproc = SignalProcessor()
    timeData = sproc.fillGap(timeData1, timeData2)
    timeData.printInfo()
    # now let's plot and see what happens
    fig = plt.figure(figsize=(20, 10))
    x = timeData.getDateArray()
    xlim = [timeData1.startTime, timeData2.stopTime]
    timeData.view(sampleStop=timeData.numSamples - 1,
                  fig=fig,
                  xlim=xlim,
                  label="Gap filled")
    timeData1.view(sampleStop=timeData1.numSamples - 1,
                   fig=fig,
                   xlim=xlim,
                   label="Section1")
    timeData2.view(sampleStop=timeData2.numSamples - 1,
                   fig=fig,
                   xlim=xlim,
                   label="Section2")
    fig.tight_layout(rect=[0, 0.02, 1, 0.96])
    addLegends(fig)
    plt.show()