Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Calibration
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Calibration
Commits
a726052b
Commit
a726052b
authored
Apr 01, 2019
by
Peter Jansweijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feed popt instead of individual parameters
parent
5079ebce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
analyze_sellmeier.py
sw/insitu_alpha/analyze_sellmeier.py
+20
-14
No files found.
sw/insitu_alpha/analyze_sellmeier.py
View file @
a726052b
...
...
@@ -248,7 +248,7 @@ def calc_alpha_tangent(l, crtt_l, tangent, fixed_lambda):
############################################################################
def
calc_alpha_sellmeier
(
l
,
fixed_lambda
,
A
,
B
,
C
,
D
,
E
):
def
calc_alpha_sellmeier
(
l
,
fixed_lambda
,
popt
):
"""
calc_alpha_sellmeier calculates the alpha factor for the wavelength lambda l
while using fixed_lambda for the return path.
...
...
@@ -265,6 +265,12 @@ def calc_alpha_sellmeier(l, fixed_lambda, A, B, C, D, E):
"""
A
=
popt
[
0
]
B
=
popt
[
1
]
C
=
popt
[
2
]
D
=
popt
[
3
]
E
=
popt
[
4
]
bb
=
l
**
2
-
fixed_lambda
**
2
cc
=
l
**-
2
-
fixed_lambda
**-
2
dd
=
l
**
4
-
fixed_lambda
**
4
...
...
@@ -347,7 +353,7 @@ def group_delay(l, A, B, C, D, E):
############################################################################
def
alpha_err_writeln
(
alpha_err_file
,
l1
,
l2
,
l_fix
,
l_idx
,
A
,
B
,
C
,
D
,
E
,
crtt_fixed_lambda
,
alpha_3wl
,
time_err
):
def
alpha_err_writeln
(
alpha_err_file
,
l1
,
l2
,
l_fix
,
l_idx
,
popt
,
crtt_fixed_lambda
,
alpha_3wl
,
time_err
):
"""
write a line to the alpha_err file in a pre formatted way.
...
...
@@ -366,9 +372,9 @@ def alpha_err_writeln(alpha_err_file, l1, l2, l_fix, l_idx, A, B, C, D, E, crtt_
l1_str
=
"{0:.2f}"
.
format
(
l1
)
l2_str
=
"{0:.2f}"
.
format
(
l2
)
crtt_l1_str
=
"{0:.0f}"
.
format
(
group_delay
(
l1
,
A
,
B
,
C
,
D
,
E
))
crtt_l2_str
=
"{0:.0f}"
.
format
(
group_delay
(
l2
,
A
,
B
,
C
,
D
,
E
))
alpha_sel_str
=
"{0:.3e}"
.
format
(
calc_alpha_sellmeier
(
l1
/
1e9
,
l_fix
,
A
,
B
,
C
,
D
,
E
))
crtt_l1_str
=
"{0:.0f}"
.
format
(
group_delay
(
l1
,
popt
[
0
],
popt
[
1
],
popt
[
2
],
popt
[
3
],
popt
[
4
]
))
crtt_l2_str
=
"{0:.0f}"
.
format
(
group_delay
(
l2
,
popt
[
0
],
popt
[
1
],
popt
[
2
],
popt
[
3
],
popt
[
4
]
))
alpha_sel_str
=
"{0:.3e}"
.
format
(
calc_alpha_sellmeier
(
l1
/
1e9
,
l_fix
,
popt
))
alpha_3wl_str
=
"{0:.3e}"
.
format
(
alpha_3wl
[
l_idx
])
alpha_spec_3wl_str
=
"{0:.0f}"
.
format
(
spec_alpha
(
alpha_3wl
[
l_idx
]))
time_err_str
=
"{0:.3e}"
.
format
(
time_err
[
l_idx
])
...
...
@@ -480,8 +486,8 @@ def analyze_plot(insitu_file, analyse_single, x, y, name, tolerance, use_itu_cha
# Method = trf = Trust Region Reflective algorithm
popt
,
pcov
=
curve_fit
(
group_delay
,
x
,
y
,
method
=
'trf'
)
perr
=
numpy
.
sqrt
(
numpy
.
diag
(
pcov
))
print
(
pcov
)
print
(
perr
)
#
print(pcov)
#
print(perr)
# define the best fit line based on array (still with outliers):
ly
=
[]
...
...
@@ -568,8 +574,8 @@ def analyze_plot(insitu_file, analyse_single, x, y, name, tolerance, use_itu_cha
ly_clean
.
append
(
clean_y
)
# 5-t Sellmeier
alpha_tan
=
calc_alpha_tangent
(
i
/
1e9
,
clean_y
,
tangent
*
1e9
,
fixed_lambda
)
alpha_sel
=
calc_alpha_sellmeier
(
i
/
1e9
,
fixed_lambda
,
popt
[
0
],
popt
[
1
],
popt
[
2
],
popt
[
3
],
popt
[
4
]
)
alpha_sel
=
calc_alpha_sellmeier
(
i
/
1e9
,
fixed_lambda
,
popt
)
alpha_tangent
.
append
(
alpha_tan
)
#alpha_tangent.append(calc_alpha_tangent(i/1e9, clean_y, dispersion, fixed_lambda))
alpha_sellmeier
.
append
(
alpha_sel
)
...
...
@@ -700,7 +706,7 @@ def analyze_plot(insitu_file, analyse_single, x, y, name, tolerance, use_itu_cha
crtt_l1
=
group_delay
(
l1
,
popt
[
0
],
popt
[
1
],
popt
[
2
],
popt
[
3
],
popt
[
4
])
crtt_l2
=
group_delay
(
l2
,
popt
[
0
],
popt
[
1
],
popt
[
2
],
popt
[
3
],
popt
[
4
])
alpha_3wl
=
calc_alpha_l1
(
l1
/
1e9
,
l2
/
1e9
,
crtt_l1
,
crtt_l2
,
fixed_lambda
)
alpha_3wlsel
=
calc_alpha_sellmeier
(
l1
/
1e9
,
fixed_lambda
,
popt
[
0
],
popt
[
1
],
popt
[
2
],
popt
[
3
],
popt
[
4
]
)
alpha_3wlsel
=
calc_alpha_sellmeier
(
l1
/
1e9
,
fixed_lambda
,
popt
)
alpha_err
=
alpha_3wlsel
-
alpha_3wl
time_err
=
calc_alpha_error
(
alpha_3wlsel
,
alpha_3wl
,
crtt_fixed_lambda
)
time_err_relative
=
time_err
/
crtt_fixed_lambda
...
...
@@ -766,7 +772,7 @@ def analyze_plot(insitu_file, analyse_single, x, y, name, tolerance, use_itu_cha
itu_ch
=
itu_conv
.
wavelength_2_itu
(
wavelength
/
1e9
)
alpha_file
.
write
(
str
(
itu_ch
)
+
", "
+
str
(
wavelength
)
+
", "
+
str
(
alpha_sellmeier
[
i
])
+
", "
+
str
(
spec_alpha
(
alpha_sellmeier
[
i
]))
+
", "
+
str
(
alpha_tangent
[
i
])
+
", "
+
str
(
alpha_sellmeier
[
i
]
-
alpha_tangent
[
i
])
+
", "
+
str
(
t_clean
[
i
])
+
"
\n
"
)
alpha_file
.
close
()
# =====================================================
# Output 3 wavelength alpha_error values in file
# Also prepare a file for PPS delta delay measurement that
...
...
@@ -821,7 +827,7 @@ def analyze_plot(insitu_file, analyse_single, x, y, name, tolerance, use_itu_cha
itu_ch
=
itu_conv
.
wavelength_2_itu
(
lambda1
/
1e9
)
time_err_str
=
"{0:.3e}"
.
format
(
time_err
[
lambda_idx
]
*
1e-12
)
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_err_writeln
(
alpha_err_file
,
lambda1
,
lambda2
,
fixed_lambda
,
lambda_idx
,
popt
,
crtt_fixed_lambda
,
alpha_3wl
,
time_err
)
alpha_ddelay_file
.
write
(
str
(
lambda1
)
+
", "
+
str
(
itu_ch
)
+
", "
+
str
(
alpha_spec_3wl
)
+
", "
+
str
(
lambda2
)
+
", "
+
time_err_str
+
"
\n
"
)
alpha_err_file
.
write
(
"============================
\n
"
)
...
...
@@ -841,7 +847,7 @@ def analyze_plot(insitu_file, analyse_single, x, y, name, tolerance, use_itu_cha
itu_ch
=
itu_conv
.
wavelength_2_itu
(
lambda1
/
1e9
)
time_err_str
=
"{0:.3e}"
.
format
(
time_err
[
lambda_idx
]
*
1e-12
)
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_err_writeln
(
alpha_err_file
,
lambda1
,
lambda2
,
fixed_lambda
,
lambda_idx
,
popt
,
crtt_fixed_lambda
,
alpha_3wl
,
time_err
)
alpha_ddelay_file
.
write
(
str
(
lambda1
)
+
", "
+
str
(
itu_ch
)
+
", "
+
str
(
alpha_spec_3wl
)
+
", "
+
str
(
lambda2
)
+
", "
+
time_err_str
+
"
\n
"
)
alpha_err_file
.
write
(
"============================
\n
"
)
...
...
@@ -852,7 +858,7 @@ def analyze_plot(insitu_file, analyse_single, x, y, name, tolerance, use_itu_cha
lambda1
=
l1
[
l1_idx
][
l2_idx
]
lambda2
=
l2
[
l1_idx
][
l2_idx
]
lambda_idx
=
l1_idx
,
l2_idx
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_err_writeln
(
alpha_err_file
,
lambda1
,
lambda2
,
fixed_lambda
,
lambda_idx
,
popt
,
crtt_fixed_lambda
,
alpha_3wl
,
time_err
)
#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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment