Commit d1726297 authored by Peter Jansweijer's avatar Peter Jansweijer

added stddev to time_error function

parent 7ce67bc7
......@@ -292,9 +292,9 @@ def calc_alpha_sellmeier_stddev(l, l_stddev, fixed_lambda, fixed_lambda_stddev,
perr -- <float> std-dev for Sellmeier terms
returns:
alpha -- <float> alpha value for lambda l when using fixed_lambda
as return channel
alpha -- <float> std-dev of alpha value
alpha -- <float> alpha value for lambda l when using fixed_lambda
as return channel
alpha_stddev -- <float> std-dev of alpha value
"""
......@@ -352,6 +352,45 @@ 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)
############################################################################
def line(x, a, b):
return a * x + b
......@@ -628,7 +667,9 @@ def analyze_plot(insitu_file, analyse_single, x, y, name, tolerance, use_itu_cha
alpha_tangent.append(alpha_tan)
#alpha_tangent.append(calc_alpha_tangent(i/1e9, clean_y, dispersion, fixed_lambda))
alpha_sellmeier.append(alpha_sel)
alpha_time_error.append(calc_alpha_error(alpha_sel, alpha_tan, crtt_fixed_lambda))
#alpha_time_error.append(calc_alpha_error(alpha_sel, alpha_tan, crtt_fixed_lambda))
time_err, time_err_stddev = calc_alpha_error_stddev(alpha_sel, alpha_stddev_sel, alpha_tan, 0, crtt_fixed_lambda, l_stddev)
alpha_time_error.append(time_err)
# =====================================================
# Plot CRTT versus ITU Channel number
......@@ -757,7 +798,8 @@ def analyze_plot(insitu_file, analyse_single, x, y, name, tolerance, use_itu_cha
alpha_3wl = calc_alpha_l1(l1/1e9, l2/1e9, crtt_l1, crtt_l2, fixed_lambda)
alpha_3wlsel, alpha_stddev_3wlsel = calc_alpha_sellmeier_stddev(l1/1e9, l_stddev, fixed_lambda, fixed_lambda_stddev, popt, perr)
alpha_err = alpha_3wlsel - alpha_3wl
time_err = calc_alpha_error(alpha_3wlsel, alpha_3wl, crtt_fixed_lambda)
#time_err = calc_alpha_error(alpha_3wlsel, alpha_3wl, crtt_fixed_lambda)
time_err, time_err_stddev = calc_alpha_error_stddev(alpha_3wlsel, alpha_stddev_3wlsel, alpha_3wl, 0, crtt_fixed_lambda, l_stddev)
time_err_relative = time_err/crtt_fixed_lambda
#pdb.set_trace()
......
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