Last active
October 6, 2022 01:44
-
-
Save jinschoi/e184f2676cca1bf249d3d3041b9b6730 to your computer and use it in GitHub Desktop.
Plot Flipper RAW .sub captures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.express as px | |
import pandas as pd | |
import re | |
filename = 'Gar.sub' | |
points = [(0, 0)] | |
t = 0 | |
with open(filename, 'r') as f: | |
for line in f: | |
m = re.match(r'RAW_Data:\s*([-0-9 ]+)\s*$', line) | |
if m: | |
for seg in [int(seg) for seg in m[1].split(r' ')]: | |
if seg > 0: | |
points.append((t, 1)) | |
t += seg | |
points.append((t, 1)) | |
else: | |
points.append((t, 0)) | |
t -= seg | |
points.append((t, 0)) | |
df = pd.DataFrame(points, columns=['µs', 'signal']) | |
fig = px.line(df, x='ms', y='signal', title=re.sub(r'\.sub$', '', filename)) | |
fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment