thaneshwari
thaneshwari

Reputation: 9

Plot of the two dataset having different sampling rate with proper alignment

I have two dataset are the sensor values recorded with different equipment with different sampling rate. I want to plot both in same graph and it's peak should be aligned so that we can compare it properly.

I am adding example data here in link https://docs.google.com/spreadsheets/d/12LnRRqu8C6jXineI_7ihhcZAu_U3zTsTQ915wNkK4Pw/edit?usp=sharing

Upvotes: -1

Views: 57

Answers (1)

Sandip Dutta
Sandip Dutta

Reputation: 71

Based on the CSV file, this is a minimal example: Would require more information on start times, end times and sampling rates to improve the answer.

# pip install pandas matplotlib
import pandas as pd
from matplotlib import pyplot as plt

filename = "plot.png"

"""
# CSV file Format

time,Sentea,Smartscan
0,1541.089577,1551.491018
1,1541.089379,1551.491802
2,1541.089379,1551.491018
3,1541.089455,1551.491018
4,1541.089181,1551.491802
5,1541.089295,1551.491802
...
~ 90k samples
"""

df = pd.read_csv("example.csv", index_col=0)

# Assumed for example
start_time_sentea = 16_000
start_time_smartscan = 16_000

end_time_sentea = -1
end_time_smartscan = -1

# Need more information on start time, sampling rates and end times improve
plt.plot(
    df.index[start_time_sentea:end_time_sentea],
    df["Sentea"][start_time_sentea:end_time_sentea],
    "r",
)
plt.plot(
    df.index[start_time_smartscan:end_time_smartscan],
    df["Smartscan"][start_time_smartscan:end_time_smartscan],
    "b",
)
plt.title("Scan Plots wrt Time")

plt.savefig(filename)

Also, would request you to make the CSV public for all so that more people can answer.

Upvotes: 0

Related Questions