Commit 76f9af24 authored by Peter Jansweijer's avatar Peter Jansweijer

INSITU_ALPHA: added output for Data Delay measurement proposal

parent 518ad15e
......@@ -718,7 +718,7 @@ if __name__ == "__main__":
time_err = calc_alpha_error(alpha_3wlsel, alpha_3wl, crtt_fixed_lambda)
time_err_relative = time_err/crtt_fixed_lambda
pdb.set_trace()
#pdb.set_trace()
"""
# =====================================================
......@@ -782,6 +782,8 @@ if __name__ == "__main__":
# =====================================================
# Output 3 wavelength alpha_error values in file
# Also prepare a file for PPS delta delay measurement that
# contains lambda1 and alpha (in SPEC format).
# =====================================================
alpha_err_file = open(name+"_err.out","w")
alpha_err_file.write("file: " + insitu_file + "\n")
......@@ -794,6 +796,12 @@ if __name__ == "__main__":
alpha_err_file.write("D: " + str(popt[3]) + "\n")
alpha_err_file.write("E: " + str(popt[4]) + "\n")
alpha_ddelay_file = open(name+"_ddelay.out","w")
alpha_ddelay_file.write("# Proposed Delta Delay measurements\n")
alpha_ddelay_file.write("# file: " + insitu_file + "\n")
alpha_ddelay_file.write("# reference file: " + ref_insitu_file + "\n")
alpha_ddelay_file.write("# fixed_lambda: " + str(fixed_lambda) + " = ITU-ch: "+str(itu_conv.wavelength_2_itu(fixed_lambda))+"\n")
alpha_err_file.write("min time_err: " + str(numpy.nanmin(time_err)) + "\n")
l1_idx,l2_idx = numpy.where(time_err==numpy.nanmin(time_err))
alpha_err_file.write(" @ l1: " + str(l2[l1_idx][0][0]) + "\n")
......@@ -807,6 +815,8 @@ if __name__ == "__main__":
rng = 1 # [ps]
alpha_err_file.write("============================\n")
alpha_err_file.write("time_err within range: " +str(rng) + " [ps]\n")
alpha_ddelay_file.write("# ============================\n")
alpha_ddelay_file.write("# time_err within range: " +str(rng) + " [ps]\n")
#alpha_err_file.write(" @l1\tl2\n")
rng_sel = numpy.argwhere(numpy.logical_and(time_err<rng,time_err>-rng))
#pdb.set_trace()
......@@ -814,12 +824,18 @@ if __name__ == "__main__":
# alpha_err_file.write(str(l2[i[0]][0]) + "\t" + str(l2[i[1]][0]) + "\n")
alpha_err_file.write("l1[nm]\tl2[nm]\tcrtt_(l1)[ps]\tcrtt(l2)[ps]\talpha_sel(l1)\talpha_3wl(l1)\tSPEC_alpha_3wl(l1)\ttime_err[ps]\ttime_relative_err[t_err ps/link_length ps]\n")
alpha_ddelay_file.write("# lambda-1[nm]\tITU-ch\tSPEC_alpha_3wl(l1)\tlambda-2[nm]\n")
for i in rng_sel:
lambda1 = l2[i[0]][0]
lambda2 = l2[i[1]][0]
lambda_idx = i[1],i[0]
alpha_spec_3wl=spec_alpha(alpha_3wl[lambda_idx])
itu_ch = itu_conv.wavelength_2_itu(lambda1/1e9)
alpha_err_writeln(alpha_err_file, lambda1, lambda2, fixed_lambda, lambda_idx, popt[0], popt[1], popt[2], popt[3], popt[4], crtt_fixed_lambda, alpha_3wl, time_err)
alpha_ddelay_file.write(str(lambda1)+", "+str(itu_ch)+", "+str(alpha_spec_3wl)+", "+str(lambda2)+"\n")
alpha_err_file.write("============================\n")
alpha_err_file.write("all possible combinations and their results:\n")
alpha_err_file.write("l1[nm]\tl2[nm]\tcrtt_(l1)[ps]\tcrtt(l2)[ps]\talpha_sel(l1)\talpha_3wl(l1)\tSPEC_alpha_3wl(l1)\ttime_err[ps]\ttime_relative_err[t_err ps/link_length ps]\n")
......@@ -832,6 +848,7 @@ if __name__ == "__main__":
#alpha_err_file.write(str(l1[l1_idx][l2_idx]) + "\t" + str(l2[l1_idx][l2_idx]) + "\t" + str(group_delay(l1[l1_idx][l2_idx],popt[0],popt[1],popt[2],popt[3],popt[4])) + "\t " + str(group_delay(l2[l1_idx][l2_idx],popt[0],popt[1],popt[2],popt[3],popt[4])) + "\t" + str(calc_alpha_sellmeier(l1[l1_idx][l2_idx]/1e9, fixed_lambda,popt[0],popt[1],popt[2],popt[3],popt[4])) + "\t " + str(alpha_3wl[l1_idx][l2_idx]) + "\t " + str(spec_alpha(alpha_3wl[l1_idx][l2_idx])) + "\t" + str(time_err[l1_idx][l2_idx]) + "\t" + str(time_err[l1_idx][l2_idx]/crtt_fixed_lambda) + "\n")
alpha_err_file.close()
alpha_ddelay_file.close()
#plt.subplot_tool()
......
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