Commit b9965a45 authored by Peter Jansweijer's avatar Peter Jansweijer

include stddev for calculated time error

parent c2affb46
......@@ -36,6 +36,47 @@ def calc_alpha_error(alpha1, alpha2, crtt_fixed_lambda):
############################################################################
def calc_alpha_error_stddev(alpha1, alpha1_stddev, alpha2, alpha2_stddev, crtt_fixed_lambda, crtt_fixed_lambda_stddev):
"""
calc_alpha_error calculates the timing error between the PPS-ses of Master
and Slave that will be the result of an "imperfect" alpha2 with respect to a
"perfect" alpha1.
The timing error scales linear with the round trip time (i.e. the length of
your fiber)
alpha1 -- <float> alpha to be considered the correct value
alpha1_stddev -- <float> stddev for alpha1
alpha2 -- <float> alpha for which timing error needs to be calculated
alpha2_stddev -- <float> stddev for alpha2
crtt_fixed_lambda -- <float> crtt value at the fixed wavelenght.
note that this is the virtual crtt for which
master2slave and slave2master wavelengths would be
equal. It can be estimated by extrapolating the crtt
array.
crtt_fixed_lambda_stddev -- <float> stddev for crtt_fixed_lambda
returns:
t_err, t_err_stddev -- <float> PPS time error
"""
# Calculate the (mean) value of t_err
t_err = calc_alpha_error(alpha1, alpha2, crtt_fixed_lambda)
# Calculate the stddev contribution to t_err of each of the parameters alpha1, alpha2 and crtt_fixed_lambda
t_err_stddev_alpha1 = calc_alpha_error(alpha1 + alpha1_stddev, alpha2, crtt_fixed_lambda) - t_err
t_err_stddev_alpha2 = calc_alpha_error(alpha1, alpha2 + alpha2_stddev, crtt_fixed_lambda) - t_err
t_err_stddev_crtt_fixed_lambda = calc_alpha_error(alpha1, alpha2, crtt_fixed_lambda + crtt_fixed_lambda_stddev) - t_err
# Calculate the RMS stddev of alpha
t_err_stddev = numpy.sqrt(t_err_stddev_alpha1**2 + t_err_stddev_alpha2 **2 + t_err_stddev_crtt_fixed_lambda **2)
return(t_err, t_err_stddev)
############################################################################
############################################################################
if __name__ == "__main__":
#############################################################################################
......@@ -46,17 +87,23 @@ if __name__ == "__main__":
# data source: data_180914/averaged_err.out => crtt_(l1)
alpha_sel = numpy.array([6.424e-06, 6.424e-06, 3.207e-06, 3.207e-06, 3.207e-06, -3.197e-06, -3.197e-06, -3.197e-06, -6.384e-06, -6.384e-06, 2.922e-05, 2.922e-05, 2.922e-05, -2.529e-05, -2.529e-05, -2.529e-05, -7.391e-05, -7.391e-05, -7.391e-05, -1.226e-04, -1.226e-04, -1.226e-04])
alpha_sel_stddev = numpy.array([1.682e-08, 1.682e-08, 1.674e-08, 1.674e-08, 1.674e-08, 1.671e-08, 1.671e-08, 1.671e-08, 1.675e-08, 1.675e-08, 1.843e-08, 1.843e-08, 1.843e-08, 1.786e-08, 1.786e-08, 1.786e-08, 2.600e-08, 2.600e-08, 2.600e-08, 3.850e-08, 3.850e-08, 3.850e-08])
# data source: data_180926/180926_15_47_01_3_lambda_insitu_alpha_scan_result.txt
alpha_3wl_b = numpy.array([6.393e-06, 6.449e-06, 3.154e-06, 3.262e-06, 3.214e-06, -3.224e-06, -3.193e-06, -3.298e-06, -6.488e-06, -6.348e-06, 2.898e-05, 2.847e-05, 2.788e-05, -2.551e-05, -2.454e-05, -2.402e-05, -7.464e-05, -7.303e-05, -7.009e-05, -1.238e-04, -1.211e-04, -1.188e-04])
alpha_3wl_b_stddev = numpy.array([1.186e-06, 1.970e-07, 2.856e-07, 2.100e-07, 1.185e-07, 1.181e-07, 1.576e-07, 3.871e-07, 2.387e-07, 6.540e-07, 1.858e-07, 1.025e-07, 6.481e-08, 1.591e-07, 1.510e-07, 8.868e-08, 3.042e-07, 4.437e-07, 5.724e-07, 2.455e-07, 3.260e-07, 7.897e-07])
# data source: data_180914/averaged_err.out => crtt_(l1)
crtt_fixed_lambda = numpy.array([491284316, 491284316, 491283526, 491283526, 491283526, 491281953, 491281953, 491281953, 491281170, 491281170, 491289916, 491289916, 491289916, 491276526, 491276526, 491276526, 491264582, 491264582, 491264582, 491252613, 491252613, 491252613])
crtt_fixed_lambda_stddev = numpy.array([124, 124, 124, 124, 124, 125, 125, 125, 125, 125, 123, 123, 123, 126, 126, 126, 129, 129, 129, 133, 133, 133])
# calculate time error of the 3-wavelength determined alpha while taking the Sellmeier determined alpha as a reference.
time_err_calc_3wl = calc_alpha_error(alpha_sel, alpha_3wl_b, crtt_fixed_lambda)
#time_err_calc_3wl = calc_alpha_error(alpha_sel, alpha_3wl_b, crtt_fixed_lambda)
time_err_calc_3wl, time_err_calc_3wl_stddev = calc_alpha_error_stddev(alpha_sel, alpha_sel_stddev, alpha_3wl_b, alpha_3wl_b_stddev, crtt_fixed_lambda, crtt_fixed_lambda_stddev)
result_file = open(("time_error_result.txt"),"w")
result_file.write("time_err_calc_3wl, time_err_calc_3wl_stddev\n")
for i in time_err_calc_3wl:
result_file.write("{0:.1f}".format(i) + "\n")
for i in range(len(time_err_calc_3wl)):
result_file.write("{0:.1f}".format(time_err_calc_3wl[i]) + ", " + "{0:.1f}".format(time_err_calc_3wl_stddev[i]) + "\n")
result_file.close()
##############################################################
......@@ -224,7 +271,7 @@ if __name__ == "__main__":
lns_b.append(ax.errorbar(selected_x_10, selected_time_err_b_10, yerr = selected_time_err_b_10_stddev, fmt='v', capsize=6, color='C8', label=r'$t_{err\_m}$ B, $\lambda_{2}$ =1559.79 [nm]'))
lns.append(ax.errorbar(x, time_err_calc_sel, yerr = 0, fmt='*', color='blue', label=r'$t_{err\_c}$ A'))
lns.append(ax.errorbar(x, time_err_calc_3wl[0:10], yerr = 0, fmt='o', color='red', label=r'$t_{err\_c}$ B'))
lns.append(ax.errorbar(x, time_err_calc_3wl[0:10], yerr = time_err_calc_3wl_stddev[0:10], fmt='o', color='red', label=r'$t_{err\_c}$ B'))
#############################################################################################
labels = [l.get_label() for l in lns]
......@@ -461,7 +508,7 @@ if __name__ == "__main__":
#lns_b.append(ax.errorbar(selected_x_10, selected_time_err_b_10, yerr = selected_time_err_b_10_stddev, fmt='v', capsize=6, color='C8', label=r'$t_{err\_m}$ B, $\lambda_{2}$ =1559.79 [nm]'))
lns.append(ax.errorbar(x, time_err_calc_sel, yerr = 0, fmt='*', color='blue', label=r'$t_{err\_c}$ A'))
lns.append(ax.errorbar(x, time_err_calc_3wl[10:23], yerr = 0, fmt='o', color='red', label=r'$t_{err\_c}$ B'))
lns.append(ax.errorbar(x, time_err_calc_3wl[10:23], yerr = time_err_calc_3wl_stddev[10:23], fmt='o', color='red', label=r'$t_{err\_c}$ B'))
#############################################################################################
labels = [l.get_label() for l in lns]
......
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