Teiknum nú graf af gagnaskránni log_temps.log
import matplotlib.pyplot as plt import numpy as np import datetime import math filename = 'log_temps.log' with open(filename) as f: content = f.readlines() f.close() content = [x.strip().split("\t") for x in content] # Define a starting time so that we can plot by total seconds since start: datetime_begin = datetime.datetime.strptime(content[0][0], '%Y-%m-%d %H:%M:%S.%f') # Process the data points: X = np.array([((datetime.datetime.strptime(line[0], '%Y-%m-%d %H:%M:%S.%f')-datetime_begin).total_seconds()) for line in content]) Y = np.array([line[1] for line in content]) plt.plot(X,Y) plt.show() # Recalculate the y-values: Y = np.array([math.log(float(line[1])) for line in content]) plt.plot(X,Y) plt.show() # Strip out the first 93 elements X = np.delete(X,range(93)) Y = np.delete(Y,range(93)) plt.plot(X,Y) plt.show()