"""
evaluation of the standard deviation for different numbers of point
if the noise is such that we have sigma as a standard deviations
then averaging N points should give a std of sigma/N**0.5
"""

from struct import*
import ctypes
import array
import numpy as np
import matplotlib.pyplot as plt
import time

from ADUCv2p0 import*




chip1 = ADUCv2p0(0x50,True)

chip1.set_channel(3) #ADC

chip1.set_remote_trigg(1)

chip1.set_pga_state(0x18)

chip1.set_Vout(0,800)

Nwf = 100

dat1 = np.zeros(Nwf)
dat10 = np.zeros(Nwf)
dat100 = np.zeros(Nwf)

for k in range(0,Nwf):
    data = chip1.read_data()
    dat1[k] = data[50]
    dat10[k] = np.mean(data[50:60])
    dat100[k] = np.mean(data[50:150])
    print(k)
    
print(np.std(dat1))
print(np.std(dat10))
print(np.std(dat100))


