from sympy import Matrix, Symbol
import sympy
from IPython.display import display, Markdown
B_CAL = Matrix([
[Symbol("B11", complex=True, commutative = True), Symbol("B12", complex=True, commutative = True), Symbol("B13", complex=True, commutative = True)],
[Symbol("B21", complex=True, commutative = True), Symbol("B22", complex=True, commutative = True), Symbol("B23", complex=True, commutative = True)],
[Symbol("B31", complex=True, commutative = True), Symbol("B32", complex=True, commutative = True), Symbol("B33", complex=True, commutative = True)]
])
E_CAL = Matrix([
[Symbol("E11", complex=True, commutative = True), Symbol("E12", complex=True, commutative = True)],
[Symbol("E21", complex=True, commutative = True), Symbol("E22", complex=True, commutative = True)]
])
display(Markdown('''
# LFR calibration matrices for each frequency bin:
LFR stores two calibration matrices per ASM frequency bin, one matrix for B and one for E.
'''))
display(Markdown("## Magnetic calibration matrice:"))
display(B_CAL)
display(Markdown("## Electric calibration matrice:"))
display(E_CAL)
LFR stores two calibration matrices per ASM frequency bin, one matrix for B and one for E.
From index 0 to N-1:
Magnetic: [ Real(B11), Imag(B11), Real(B12), Imag(B12), Real(B13), Imag(B13), ... , Real(B31), Imag(B31), Real(B32), Imag(B32), Real(B33), Imag(B33)]
Electric: [ Real(E11), Imag(E11), Real(E12), Imag(E12), Real(E21), Imag(E21), Real(E22), Imag(E22)]
This representation is used in all the following packets descriptions.
To set all calibration matrices we need to send 36 TC with 0 <= sy_lfr_kcoeff_frequency
<= 35, and they must be sent in order from sy_lfr_kcoeff_frequency
=0 to sy_lfr_kcoeff_frequency
=35
Since 36 packets are not enough to fill all calibration matrices for F0,F1 and F2 we set one matrice each 8 frequency bins then we interpolate them.
In the following description B_F0_Bin_16
means B calibration matrice at F0 for the frequency bin 16.
offset = 0
for s,f,c in ((16,0,11), (5,1,13), (6,2,12)):
display(Markdown(f"## F{f}"))
for i in range(c):
fbin= s+i*8
if i<3:
extra = f', B_F{f}_Bin_{s+c*8}_Line{i+1}'
elif i<5:
extra = f', E_F{f}_Bin_{s+c*8}_Line{i-2}'
else:
extra = ''
display(Markdown(f'''
- sy_lfr_kcoeff_frequency = {offset+i}:
F{f} calibration matrix bin {fbin}
`LFR_KCOEFFICIENTS_PARAMETERS` = `[ B_F{f}_Bin_{fbin}, E_F{f}_Bin_{fbin}{extra} ]`
'''))
offset += c
sy_lfr_kcoeff_frequency = 0: F0 calibration matrix bin 16
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F0_Bin_16, E_F0_Bin_16, B_F0_Bin_104_Line1 ]
sy_lfr_kcoeff_frequency = 1: F0 calibration matrix bin 24
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F0_Bin_24, E_F0_Bin_24, B_F0_Bin_104_Line2 ]
sy_lfr_kcoeff_frequency = 2: F0 calibration matrix bin 32
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F0_Bin_32, E_F0_Bin_32, B_F0_Bin_104_Line3 ]
sy_lfr_kcoeff_frequency = 3: F0 calibration matrix bin 40
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F0_Bin_40, E_F0_Bin_40, E_F0_Bin_104_Line1 ]
sy_lfr_kcoeff_frequency = 4: F0 calibration matrix bin 48
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F0_Bin_48, E_F0_Bin_48, E_F0_Bin_104_Line2 ]
sy_lfr_kcoeff_frequency = 5: F0 calibration matrix bin 56
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F0_Bin_56, E_F0_Bin_56 ]
sy_lfr_kcoeff_frequency = 6: F0 calibration matrix bin 64
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F0_Bin_64, E_F0_Bin_64 ]
sy_lfr_kcoeff_frequency = 7: F0 calibration matrix bin 72
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F0_Bin_72, E_F0_Bin_72 ]
sy_lfr_kcoeff_frequency = 8: F0 calibration matrix bin 80
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F0_Bin_80, E_F0_Bin_80 ]
sy_lfr_kcoeff_frequency = 9: F0 calibration matrix bin 88
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F0_Bin_88, E_F0_Bin_88 ]
sy_lfr_kcoeff_frequency = 10: F0 calibration matrix bin 96
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F0_Bin_96, E_F0_Bin_96 ]
sy_lfr_kcoeff_frequency = 11: F1 calibration matrix bin 5
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_5, E_F1_Bin_5, B_F1_Bin_109_Line1 ]
sy_lfr_kcoeff_frequency = 12: F1 calibration matrix bin 13
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_13, E_F1_Bin_13, B_F1_Bin_109_Line2 ]
sy_lfr_kcoeff_frequency = 13: F1 calibration matrix bin 21
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_21, E_F1_Bin_21, B_F1_Bin_109_Line3 ]
sy_lfr_kcoeff_frequency = 14: F1 calibration matrix bin 29
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_29, E_F1_Bin_29, E_F1_Bin_109_Line1 ]
sy_lfr_kcoeff_frequency = 15: F1 calibration matrix bin 37
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_37, E_F1_Bin_37, E_F1_Bin_109_Line2 ]
sy_lfr_kcoeff_frequency = 16: F1 calibration matrix bin 45
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_45, E_F1_Bin_45 ]
sy_lfr_kcoeff_frequency = 17: F1 calibration matrix bin 53
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_53, E_F1_Bin_53 ]
sy_lfr_kcoeff_frequency = 18: F1 calibration matrix bin 61
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_61, E_F1_Bin_61 ]
sy_lfr_kcoeff_frequency = 19: F1 calibration matrix bin 69
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_69, E_F1_Bin_69 ]
sy_lfr_kcoeff_frequency = 20: F1 calibration matrix bin 77
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_77, E_F1_Bin_77 ]
sy_lfr_kcoeff_frequency = 21: F1 calibration matrix bin 85
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_85, E_F1_Bin_85 ]
sy_lfr_kcoeff_frequency = 22: F1 calibration matrix bin 93
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_93, E_F1_Bin_93 ]
sy_lfr_kcoeff_frequency = 23: F1 calibration matrix bin 101
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F1_Bin_101, E_F1_Bin_101 ]
sy_lfr_kcoeff_frequency = 24: F2 calibration matrix bin 6
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_6, E_F2_Bin_6, B_F2_Bin_102_Line1 ]
sy_lfr_kcoeff_frequency = 25: F2 calibration matrix bin 14
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_14, E_F2_Bin_14, B_F2_Bin_102_Line2 ]
sy_lfr_kcoeff_frequency = 26: F2 calibration matrix bin 22
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_22, E_F2_Bin_22, B_F2_Bin_102_Line3 ]
sy_lfr_kcoeff_frequency = 27: F2 calibration matrix bin 30
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_30, E_F2_Bin_30, E_F2_Bin_102_Line1 ]
sy_lfr_kcoeff_frequency = 28: F2 calibration matrix bin 38
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_38, E_F2_Bin_38, E_F2_Bin_102_Line2 ]
sy_lfr_kcoeff_frequency = 29: F2 calibration matrix bin 46
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_46, E_F2_Bin_46 ]
sy_lfr_kcoeff_frequency = 30: F2 calibration matrix bin 54
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_54, E_F2_Bin_54 ]
sy_lfr_kcoeff_frequency = 31: F2 calibration matrix bin 62
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_62, E_F2_Bin_62 ]
sy_lfr_kcoeff_frequency = 32: F2 calibration matrix bin 70
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_70, E_F2_Bin_70 ]
sy_lfr_kcoeff_frequency = 33: F2 calibration matrix bin 78
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_78, E_F2_Bin_78 ]
sy_lfr_kcoeff_frequency = 34: F2 calibration matrix bin 86
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_86, E_F2_Bin_86 ]
sy_lfr_kcoeff_frequency = 35: F2 calibration matrix bin 94
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_94, E_F2_Bin_94 ]
The TM_LFR_KCOEFFICIENTS_DUMP si splitted into two packets where:
F0=', '.join([f'B_F0_Bin_{i},E_F0_Bin_{i}' for i in range(16,112,8)])
F1=', '.join([f'B_F1_Bin_{i},E_F1_Bin_{i}' for i in range(5,117,8)])
F2=', '.join([f'B_F2_Bin_{i},E_F2_Bin_{i}' for i in range(6,110,8)])
display(Markdown(f'''
- Packet 1 contains:
`LFR_KCOEFFICIENTS_PARAMETERS` = `[ {F0}, {F1} ]`
- Packet 2 contains:
`LFR_KCOEFFICIENTS_PARAMETERS` = `[ {F2} ]`
'''))
Packet 1 contains:
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F0_Bin_16,E_F0_Bin_16, B_F0_Bin_24,E_F0_Bin_24, B_F0_Bin_32,E_F0_Bin_32, B_F0_Bin_40,E_F0_Bin_40, B_F0_Bin_48,E_F0_Bin_48, B_F0_Bin_56,E_F0_Bin_56, B_F0_Bin_64,E_F0_Bin_64, B_F0_Bin_72,E_F0_Bin_72, B_F0_Bin_80,E_F0_Bin_80, B_F0_Bin_88,E_F0_Bin_88, B_F0_Bin_96,E_F0_Bin_96, B_F0_Bin_104,E_F0_Bin_104, B_F1_Bin_5,E_F1_Bin_5, B_F1_Bin_13,E_F1_Bin_13, B_F1_Bin_21,E_F1_Bin_21, B_F1_Bin_29,E_F1_Bin_29, B_F1_Bin_37,E_F1_Bin_37, B_F1_Bin_45,E_F1_Bin_45, B_F1_Bin_53,E_F1_Bin_53, B_F1_Bin_61,E_F1_Bin_61, B_F1_Bin_69,E_F1_Bin_69, B_F1_Bin_77,E_F1_Bin_77, B_F1_Bin_85,E_F1_Bin_85, B_F1_Bin_93,E_F1_Bin_93, B_F1_Bin_101,E_F1_Bin_101, B_F1_Bin_109,E_F1_Bin_109 ]
Packet 2 contains:
LFR_KCOEFFICIENTS_PARAMETERS
= [ B_F2_Bin_6,E_F2_Bin_6, B_F2_Bin_14,E_F2_Bin_14, B_F2_Bin_22,E_F2_Bin_22, B_F2_Bin_30,E_F2_Bin_30, B_F2_Bin_38,E_F2_Bin_38, B_F2_Bin_46,E_F2_Bin_46, B_F2_Bin_54,E_F2_Bin_54, B_F2_Bin_62,E_F2_Bin_62, B_F2_Bin_70,E_F2_Bin_70, B_F2_Bin_78,E_F2_Bin_78, B_F2_Bin_86,E_F2_Bin_86, B_F2_Bin_94,E_F2_Bin_94, B_F2_Bin_102,E_F2_Bin_102 ]