Skip to content

Instantly share code, notes, and snippets.

@irevoire
Created December 3, 2019 13:29
Show Gist options
  • Save irevoire/3d892bd94c8afe8f9eb4bfc2e130068c to your computer and use it in GitHub Desktop.
Save irevoire/3d892bd94c8afe8f9eb4bfc2e130068c to your computer and use it in GitHub Desktop.
draw python
import sys
import numpy as np
import scipy.stats as stats
from scipy.fftpack import fft
import matplotlib.pyplot as plt
import sys
if len(sys.argv) < 2:
print("mettre le nom du / des fichiers en argument")
sys.exit()
data = {}
for fileindex in range(1, len(sys.argv)):
fd = open(sys.argv[fileindex])
for line in fd:
if line[0] == "#":
continue
name, phy, target, os, size, device = line[:-1].split(",")
# macbookpro2017, iphone7, iphoneXS
if device == "nil":
continue
if not data.__contains__(device):
data[device] = []
time = int(phy) - int(target)
data[device].append(time)
i = 0
for key in data:
i += 1
plt.subplot(1, len(data), i)
plt.hist(data[key], bins=np.arange(0, np.max(data[key]), 5))
plt.xlabel('t [µs]')
plt.xlim(0, 200)
plt.ylabel(key)
plt.draw()
# print('mode', stats.mode(np.array(data[key])), key)
print('mean %5.5f => %s' % (np.mean(np.array(data[key])), key)) # stats.trim_mean(np.array(data[key]), 0.05)
print('std %5.5f => %s' % (np.std(np.array(data[key])), key))
print('skew %5.5f => %s' % (stats.skew(np.array(data[key])), key))
print('kurt %5.5f => %s' % (stats.kurtosis(np.array(data[key])), key))
print()
# S = fft(data[key])/len(data[key])
# plt.subplot(2, len(data), i+len(data))
# plt.plot(abs(S))
# plt.draw()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment