Commit 7c6b58e2 authored by Peter Jansweijer's avatar Peter Jansweijer

added StdError in result file

added fig_aplha_error but commented it out since it is wrong
parent d3e65158
......@@ -331,6 +331,7 @@ if __name__ == "__main__":
result_file = open(os.path.join(name, "result.txt"),"w")
result_file.write("file: outlier-count, tangent, min-temperature, max-temperature\n")
numb_of_meas = 0 # Keep track of the number of scans that is recorded in the result file
elif os.path.isfile(name) == True:
isfile = True
......@@ -424,7 +425,7 @@ if __name__ == "__main__":
ly_lin_clean=[]
alpha_clean=[]
alpha_lin_clean=[]
fixed_lambda = itu_conv.itu_2_wavelength(fixed_itu_channel)
# Scan through all wavelengths and calculate the individual alpha's
......@@ -496,16 +497,38 @@ if __name__ == "__main__":
ax.plot(x_clean, alpha_lin_clean, color='blue', dashes=[5,5,5,5], label='linear')
ax.legend(loc='lower right', fontsize='medium')
"""
fig_alpha_error = plt.figure("Sellmeier/Linear Error wavelength")
ax = fig_alpha_error.add_subplot(111)
ax.set_title("Sellmeier/Linear Error a function of wavelength")
if use_itu_channels:
ax.set_xlabel('ITU Channel number')
else:
ax.set_xlabel('Wavelenth [nm]')
ax.set_ylabel('% error')
#ax1.text(0.01, 0.95, 'fiber delayCoefficient (alpha) derived using', transform=ax.transAxes)
#ax1.text(0.01, 0.90, 'linear and 5-term Sellmeier fit', transform=ax.transAxes)
ax.axhline(0, color='gray')
ax.axvline(fixed_lambda*1e9, color='red')
arr_clean=numpy.array(alpha_clean)
arr_lin_clean=numpy.array(alpha_lin_clean)
alpha_error1 = (arr_clean - arr_lin_clean)*100/arr_clean
alpha_error2 = (arr_clean - arr_lin_clean)*200/(arr_clean + arr_lin_clean)
ax.plot(x_clean, alpha_error1, label='error')
ax.plot(x_clean, alpha_error2, label='error')
ax.legend(loc='lower right', fontsize='medium')
"""
alpha_file = open(name+".out","w")
alpha_file.write("file: " + insitu_file + "\n")
alpha_file.write("outlier-count: " + str(outlier_cnt) + "\n")
alpha_file.write("first order linear fit tangent: " + str(tangent)+ " [ps]/[nm]\n")
alpha_file.write("============================\n")
alpha_file.write("ITU_Channel, Lambda, alpha, aplha(SPEC format), alpha_lineair, temperature\n")
alpha_file.write("ITU_Channel, Lambda, alpha, aplha(SPEC format), alpha_lineair, alpha-alpha_linear temperature\n")
for i in range(len(x_clean)):
wavelength = x_clean[i]
itu_ch = itu_conv.wavelength_2_itu(wavelength/1e9)
alpha_file.write(str(itu_ch) + ", " + str(wavelength) + ", " + str(alpha_clean[i]) + ", " + str (spec_alpha(alpha_clean[i])) + ", " + str(alpha_lin_clean[i]) + ", " + str(t_clean[i]) + "\n")
alpha_file.write(str(itu_ch) + ", " + str(wavelength) + ", " + str(alpha_clean[i]) + ", " + str (spec_alpha(alpha_clean[i])) + ", " + str(alpha_lin_clean[i]) + ", " + str(alpha_clean[i]- alpha_lin_clean[i]) + ", " + str(t_clean[i]) + "\n")
alpha_file.close()
#pdb.set_trace()
......@@ -518,6 +541,7 @@ if __name__ == "__main__":
else: # Analyze multiple files => output result file
fig.clf() # clear figure (it was stored in a png file)
numb_of_meas = numb_of_meas + 1
result_file.write(insitu_file + ": " + str(outlier_cnt) + ", " + str(tangent) + ", " + str(temperature_min) + ", " + str(temperature_max) + "\n")
except:
......@@ -534,6 +558,7 @@ if __name__ == "__main__":
result_file.write("tangent:\n")
result_file.write("Mean: " + str(tangent_array.mean()) +"\n")
result_file.write("StDev: " + str(tangent_array.std(ddof=1)) +"\n")
result_file.write("StErr: " + str(tangent_array.std(ddof=1)/(numb_of_meas**0.5)) +"\n")
sys.exit()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment