#! /usr/bin/python3

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.ioff()
plt.style.use('bmh')

data = pd.read_csv("./log_2kw_direct.csv")

print(data)

#plt.errorbar(
#    data['time'],
#    data['act_curr_ps'], 
#    yerr=data['act_curr_ps']*.002, 
#    label="Spannungsquelle Ausgang",
#    fmt='.'
#)
#plt.errorbar(
#    data['time'],
#    data['act_curr_el']-.125, 
#    label="Elektronische Last Eingang",
#    fmt='.'
#)
data['act_curr_el'] = data['act_curr_el']-.125
meandist = np.mean(data['act_curr_el'] - data['act_curr_ps'])
plt.bar(data['set_curr'], (data['act_curr_el']-data['act_curr_ps']-meandist), .2, aa=True)

data['nom_max_delta_i'] = np.sqrt(2*(data['set_curr']*.002)**2)
plt.errorbar(
    data['set_curr'],
    data['nom_max_delta_i'],
    fmt='.'
)
plt.errorbar(
    data['set_curr'],
    -data['nom_max_delta_i'],
    fmt='.'
)

plt.ylabel('$\Delta$I/A')
plt.xlabel('I$_{set}$/A')
plt.legend()
plt.savefig("2kw_direct.png")
