Exemple #1
0
plt.show()
fig.savefig(os.path.join("images", "spam.png"))

# write out as the internal format
from resistics.ioHandlers.dataWriterInternal import DataWriterInternal

spam_2internal = os.path.join("timeData", "spamInternal")
writer = DataWriterInternal()
writer.setOutPath(spam_2internal)
writer.writeDataset(spamReader, physical=True)

# read in the internal format dataset and see what's in the comments
from resistics.ioHandlers.dataReaderInternal import DataReaderInternal

internalReader = DataReaderInternal(spam_2internal)
internalReader.printInfo()
internalReader.printComments()
physicalInternalData = internalReader.getPhysicalData(startTime, stopTime)
physicalInternalData.printInfo()

# now plot the two datasets together
fig = plt.figure(figsize=(16, 3 * physicalSPAMData.numChans))
physicalSPAMData.view(fig=fig, sampleStop=500, label="SPAM format")
physicalInternalData.view(fig=fig,
                          sampleStop=500,
                          label="Internal format",
                          legend=True)
fig.tight_layout(rect=[0, 0.02, 1, 0.96])
plt.show()
fig.savefig(os.path.join("images", "spam_vs_internal.png"))
plt.show()
fig.savefig(os.path.join("images", "ascii.png"))

# now write out as internal format
from resistics.ioHandlers.dataWriterInternal import DataWriterInternal

ascii_2intenrnal = os.path.join("timeData", "asciiInternal")
writer = DataWriterInternal()
writer.setOutPath(ascii_2intenrnal)
writer.writeDataset(asciiReader, physical=True)

# read in internal format
from resistics.ioHandlers.dataReaderInternal import DataReaderInternal

internalReader = DataReaderInternal(ascii_2intenrnal)
internalReader.printInfo()
internalReader.printComments()
internalData = internalReader.getPhysicalSamples()
internalData.printInfo()

# now plot the two datasets together
fig = plt.figure(figsize=(16, 3 * asciiData.numChans))
asciiData.view(fig=fig, sampleStop=500, label="ASCII format", legend=True)
internalData.view(fig=fig,
                  sampleStop=500,
                  label="Internal format",
                  legend=True)
fig.tight_layout(rect=[0, 0.02, 1, 0.96])
plt.show()
fig.savefig(os.path.join("images", "ascii_vs_internal.png"))
Exemple #3
0
chanHeaders, chanMap = spamReader.getChanHeaders()
writer = DataWriterInternal()
writer.setOutPath(interpPath)
writer.writeData(
    headers,
    chanHeaders,
    interpData,
    physical=True,
)
writer.printInfo()

# read in the internal data
from resistics.ioHandlers.dataReaderInternal import DataReaderInternal

interpReader = DataReaderInternal(interpPath)
interpReader.printInfo()
interpReader.printComments()

# get data between a time range
startTime = "2016-02-07 02:10:00"
stopTime = "2016-02-07 02:30:00"
spamData = spamReader.getPhysicalData(startTime, stopTime)
interpData = interpReader.getPhysicalData(startTime, stopTime)

# plot the datasets
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(12, 8))
plt.plot(spamData.getDateArray()[0:100], spamData.data["Ex"][0:100], "o--")
plt.plot(interpData.getDateArray()[0:100], interpData.data["Ex"][0:100], "x:")
plt.legend(["Original", "Interpolated"], loc=2)