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()
Exemple #2
0
def testRemoveNans():
    breakPrint()
    generalPrint("testsSignalProcess", "Running test function: testRemoveNans")
    # read in data
    spamReader = DataReaderSPAM(spamPath)
    spamReader.printInfo()
    # now get some data
    startTime = "2016-02-07 02:30:00"
    stopTime = "2016-02-07 02:35:00"
    timeData = spamReader.getPhysicalData(startTime, stopTime)
    timeData.printInfo()
    numSamples = timeData.numSamples
    # let's set some samples to zero
    sampleStart = int(0.3 * numSamples)
    sampleStop = int(0.4 * numSamples)
    for c in timeData.chans:
        timeData.data[c][sampleStart:sampleStop] = np.nan
    # now plot
    timeDataProcessed = copy.deepcopy(timeData)
    timeDataProcessed.data = removeNans(timeDataProcessed.data)
    fig = plt.figure(figsize=(20, 10))
    timeData.view(sampleStop=timeData.numSamples, fig=fig, label="With nans")
    timeDataProcessed.view(sampleStop=timeData.numSamples,
                           fig=fig,
                           label="Without nans")
    fig.tight_layout(rect=[0, 0.02, 1, 0.96])
    addLegends(fig)
    plt.show()
Exemple #3
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()
Exemple #4
0
def testResample():
    breakPrint()
    generalPrint("testsSignalProcess", "Running test function: testResample")
    # read in data
    spamReader = DataReaderSPAM(spamPath)
    # now get some data
    startTime = "2016-02-07 02:00:00"
    stopTime = "2016-02-07 03:00:00"
    # let's get some unscaled data
    timeData = spamReader.getUnscaledData(startTime, stopTime)
    timeData.printInfo()
    timeDataSave = copy.deepcopy(timeData)
    timeData.printInfo()
    # now do some signal processing
    sproc = SignalProcessor()
    timeData = sproc.resample(timeData, 50)
    timeData.printInfo()
    # now let's plot and see what happens
    fig = plt.figure(figsize=(20, 10))
    x = timeData.getDateArray()
    xlim = [timeDataSave.startTime, x[4000]]
    timeDataSave.view(sampleStop=20000, fig=fig, xlim=xlim, label="Raw data")
    timeData.view(sampleStop=4000, fig=fig, xlim=xlim, label="Resampled data")
    fig.tight_layout(rect=[0, 0.02, 1, 0.96])
    addLegends(fig)
    plt.show()
Exemple #5
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()
def testCompareSpectra():
    breakPrint()
    generalPrint("testsWindowDecimate",
                 "Running test function: testCompareSpectra")      
    # read in no notch
    specReader = SpectrumReader(specPath)
    specReader.openBinaryForReading("spectra", 0)
    numWindows = specReader.getNumWindows()
    specReader.printInfo()
    win = int(numWindows / 2)
    fig = plt.figure(figsize=(14, 10))
    specData = specReader.readBinaryWindowLocal(win)
    specData.printInfo()
    specData.view(fig=fig, label="No notch")
    # now the notched version
    specReader = SpectrumReader(specPathNotch)
    specReader.openBinaryForReading("spectra", 0)
    specDataNotch = specReader.readBinaryWindowLocal(win)
    specDataNotch.printInfo()
    specDataNotch.view(fig=fig, label="Notched")
    # plot
    fig.tight_layout(rect=[0, 0.02, 1, 0.96])
    addLegends(fig)
    plt.show()
Exemple #7
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()