import u12
import time
import sys
sys.path.insert(0, '/home/albert/Documents/Albert Work/Scripts')
from thermocouple import temperature_read

d=u12.U12()
i=0
max=1000000
frequency=1
while i<max:
    t=temperature_read(d)
    if i%100==0:
        print t
    # time.sleep(frequency)
    i+=1
    if i==max:
        check=input("continue? press enter for yes, all else for no")
        if check=='':
            i=0
            continue
        else:
            break
    file_name='power_temp-' + time_stamp
    rewrite=False
else:
    file_name='power_temp-' + time_stamp
    rewrite=True
write_to_csv(data, file_name, rewrite)

voltage=input("Initial volts: ")
amperage=input("Initial amps: ")
resistance=input("Initial Resistance: ")
print "Enter Cntrl+C to KeyboardInterrupt and input new power state"
initial=time()
k=0
for i in range(time_length/iter):
    resistances.append(resistance)
    meas_temp=temperature_read(d)
    temps.append(meas_temp)
    meas_pressure=pressure_read(d, time=0)
    pressures.append(meas_pressure)
    current_t=time()
    actual=current_t-initial
    times.append(actual)
    # sstemps.append(sstemp)
    amps.append(amperage)
    volts.append(voltage)
    calc_power=amperage*voltage
    power.append(calc_power)
    data_row=[actual,resistance,amperage, voltage, calc_power, meas_temp, meas_pressure]
    write_to_csv(data_row,file_name)
    if(k%10==0):
        print("Running Temp: " + str(meas_temp) + " deg C")
import u12
import sys
import time
sys.path.insert(0, '/home/albert/Documents/Albert Work/Scripts')
from funcs import PID
from thermocouple import temperature_read
import matplotlib.pyplot as plt
import pylab as pylab
import numpy as np

d = u12.U12()
i = 0
max = 1000000
frequency = 1
t_init = temperature_read(d)
t_min = t_init
t_max = t_init
temps = []
sum = 0
k_5000 = []
k = j = 0
k_avg = j_avg = 0
j_5000 = []
while i < max:
    t = temperature_read(d)
    temps.append(t)
    if i > 5000:
        k_5000 = temps[i - 5000:]
        k_avg = np.average(k_5000)
        k += 1
    if k > 5000: