Files
sf-rf/script/KR84_test.py
2016-07-01 09:54:57 +02:00

70 lines
2.4 KiB
Python

# struct definition to hold all relevant statistics data
class statistics_data (object):
min = 0.0
mean = 0.0
max = 0.0
sigma = 0.0
# struct definition for statistics dat aof all three amplitude levels
class all_statistics_data (object):
sat = statistics_data()
m5 = statistics_data()
m10 = statistics_data()
def return_string(self):
ret_str = "Statistics:\tmin\tmean\tmax\tstdev"
ret_str = ret_str + "\nSaturation :\t" + str(self.sat.min)[:7] + "\t" + str(self.sat.mean)[:7] + "\t" + str(self.sat.max)[:7] + "\t" + str(self.sat.stdev)[:7]
ret_str = ret_str + "\n5% out of sat :\t" + str(self.m5.min)[:7] + "\t" + str(self.m5.mean)[:7] + "\t" + str(self.m5.max)[:7] + "\t" + str(self.m5.stdev)[:7]
ret_str = ret_str + "\n10% out of sat:\t" + str(self.m10.min)[:7] + "\t" + str(self.m10.mean)[:7] + "\t" + str(self.m10.max)[:7] + "\t" + str(self.m10.stdev)[:7]
return ret_str
def statistics_calc(data_in):
"function calculates the min/max/mean/stdev of an array"
temp = statistics_data();
temp.mean = mean (data_in)
temp.min = min (data_in)
temp.max = max (data_in)
temp.stdev = stdev(data_in)
return temp
def all_statistics_calc(data_in):
"function calculates for all three amplitudes the statistics data."
temp = all_statistics_data();
temp.m10 = statistics_calc (data_in[0:35])
temp.m5 = statistics_calc (data_in[36:71])
temp.sat = statistics_calc (data_in[72:107])
return temp
# create emtpy structs
ref_jit_amplt = all_statistics_data()
ref_jit_phase = all_statistics_data()
iqm_jit_amplt = all_statistics_data()
iqm_jit_phase = all_statistics_data()
pre_jit_amplt = all_statistics_data()
pre_jit_phase = all_statistics_data()
kly_jit_amplt = all_statistics_data()
kly_jit_phase = all_statistics_data()
# calculate statistics
ref_jit_amplt = all_statistics_calc(scan_result.getReadable(0))
ref_jit_phase = all_statistics_calc(scan_result.getReadable(1))
iqm_jit_amplt = all_statistics_calc(scan_result.getReadable(2))
iqm_jit_phase = all_statistics_calc(scan_result.getReadable(3))
pre_jit_amplt = all_statistics_calc(scan_result.getReadable(4))
pre_jit_phase = all_statistics_calc(scan_result.getReadable(5))
kly_jit_amplt = all_statistics_calc(scan_result.getReadable(6))
kly_jit_phase = all_statistics_calc(scan_result.getReadable(7))
mystr = ref_jit_amplt.return_string()
print mystr