#%matplotlib inline
%matplotlib notebook
#%matplotlib widget
import sys
import os
try:
hostname = os.environ['HOSTNAME']
except KeyError:
hostname = 'juno'
print('HOSTNAME:', hostname)
#os.path.exists('/home/chust/tch')
if hostname == 'juno' and not '/home/chust/tch' in sys.path:
sys.path.append('/home/chust/tch')
print('sys.path:', sys.path, '\n')
import matplotlib.pyplot as plt
import numpy as np
import glob
from time import time, localtime
from lib_lfr.global_params import *
from lib_lfr.load_routines import load_SCM_TF_comp_CDF, load_LFR_TF_B_CDF, load_LFR_TF_E_CDF
from lib_lfr.interp_routines import (SCM_TF_comp_interp, SCM_TF_mat_interp, load_BIAS_TF_func,
LFR_TF_mean_B_interp, LFR_TF_mean_E_interp)
from lib_maths.conversion_routines import linfromdB
from lib_io.store_routines import save2Dtxt, save2json, json2data
from lib_plot.curves_routines import fig_waveforms
dir_root = '/WIN/Users/chust/DD CHUST' if hostname == 'PC-CHUST2.lpp.polytechnnique.fr' else \
'/home/chust/DD pc-p-chust' if hostname == 'pc-p-chust' else \
'/home/thomas/Labo' if hostname == 'pc-tango2' else 'ERROR!'
dir_DATA = '/DATA1' if hostname == 'PC-CHUST2.lpp.polytechnnique.fr' else \
'/home/chust/DATA' if hostname in ['pc-p-chust', 'juno'] else \
'/home/thomas/Labo/DATA' if hostname == 'pc-tango2' else 'ERROR!'
dir_plots = '/home/thomas/Labo/Plots' if hostname == 'pc-tango2' else '/home/chust/Plots'
dir_storage = '/home/thomas/Labo/Storage' if hostname == 'pc-tango2' else '/home/chust/Storage'
HOSTNAME: PC-CHUST2.lpp.polytechnnique.fr sys.path: ['/WIN/Users/chust/DD CHUST/Missions/Solar Orbiter/LFR/Python/Alexis', '/WIN/Users/chust/DD CHUST/Missions/Solar Orbiter/LFR/Python/tch', '/usr/lib64/python39.zip', '/usr/lib64/python3.9', '/usr/lib64/python3.9/lib-dynload', '', '/home/lab-lpp.local/chust/venv_py3/lib64/python3.9/site-packages', '/home/lab-lpp.local/chust/venv_py3/lib/python3.9/site-packages', '/usr/lib64/python3.9/site-packages', '/usr/lib/python3.9/site-packages', '/home/lab-lpp.local/chust/venv_py3/lib/python3.9/site-packages/IPython/extensions', '/home/lab-lpp.local/chust/.ipython']
/home/lab-lpp.local/chust/venv_py3/lib64/python3.9/site-packages/spacepy/time.py:2294: UserWarning: Leapseconds may be out of date. Use spacepy.toolbox.update(leapsecs=True) warnings.warn('Leapseconds may be out of date.'
TC_LFR_LOAD_KCOEFFICIENTS / TC_LFR_DUMP_K_COEFFICIENTS / TM_LFR_KCOEFFICIENTS_DUMP : https://hephaistos.lpp.polytechnique.fr/redmine/issues/385
On peut envoyer 36 jeux de coefficients avec les commandes load: 11 pour F0, 13 pour F1 et 12 pour F2. Chaque jeu contient 32 coefficients.
Lors d'un load, le parametre sy_lfr_kcoeff_frequency permet d'identifier le jeu de coefficients transmis:
=> 0 .. 10, pour les jeux de coefficients F0
=> 11 .. 23, pour les jeux de coefficients F1
=> 24 .. 35, pour les jeux de coefficients F2
On va rajouter 1 fréquence en bout de chaque bande => 11+1, 13+1, 12+1 = 36+3 fréquences à transmettre
# ANT transfer matrix expressed in the SO' coordinate system
def load_interp_A_E_SOprime(cdffile_ANT_TF_SOprime, freqs):
"""
Transfer matrix of the electric antennas where the Y'Z' plane
is the effective plane of the electric field measurements
~ YZ plane SRF (see the ANT_géométrie notebook or Chust et al. 2021, A&A)
A_E = [ A1Y A1Z
A2Y A2Z ]
"""
n = len(freqs)
# up to now we neglect the frequency dependency ...
A1Y = +3.5 * np.ones(n, dtype=complex)
A1Z = -7.0 * np.ones(n, dtype=complex)
A2Y = -7.0 * np.ones(n, dtype=complex)
A2Z = 0.0 * np.ones(n, dtype=complex)
return A1Y, A1Z, A2Y, A2Z
def load_interp_Atilde_SOprime(cdffile_ANT_TF_SOprime, freqs, echo=True):
"""
Normalized transfer matrix of the ANT antennas expressed in the SO' coordinate system
(see "spectral_matrix_calibration_2021-02-16_V3_corrected.pdf")
A_E^-1 = [ A2Z -A1Z
-A2Y A1Y ] x (A1Y*A2Z-A1Z*A2Y)^-1
A_tilde = sqrt(A2Y^2 + A2Z^2) . A_E^-1
"""
A1Y, A1Z, A2Y, A2Z = load_interp_A_E_SOprime(cdffile_ANT_TF_SOprime, freqs)
k_ant = np.sqrt(abs(A2Y)**2 + abs(A2Z)**2)
denominator = A1Y*A2Z - A1Z*A2Y
atilde_Y1 = +k_ant * A2Z / denominator
atilde_Y2 = -k_ant * A1Z / denominator
atilde_Z1 = -k_ant * A2Y / denominator
atilde_Z2 = +k_ant * A1Y / denominator
return (atilde_Y1, atilde_Y2,
atilde_Z1, atilde_Z2), k_ant
# SCM transfer matrix and transformation into the SO' coordinate system
def load_interp_Mtilde_SOprime(cdffile_SCM_TF, freqs, echo=True):
"""
Normalized transfer matrix of the SCM antennas and transformation into the SO' coordinate system
(see "BP_2020-06-18_V8_corrected.pdf" or Chust et al. 2021, A&A)
A_M = C1Y * c
c^-1 = C1Y * A_M^-1
M_tilde = M_SOprime_SCM . c^-1
SOprime ~ SRF (see the SCM_géométrie notebook)
"""
M_UARF_to_SOprime = np.array([[ 0.50087005, 0.5995206 , -0.62426296],
[ 0.74385771, -0.6669109 , -0.04365272],
[-0.44249848, -0.44249848, -0.77999372]])
M_SCM_to_UARF = np.array([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
M_SCM_to_SOprime = np.dot(M_UARF_to_SOprime, M_SCM_to_UARF)
if echo: print("cdffile_SCM_TF: ", cdffile_SCM_TF)
SCM_TF_comp = load_SCM_TF_comp_CDF(cdffile_SCM_TF, temp=-50., lfr_on=True, echo=echo)
A_M_inv = SCM_TF_mat_interp(freqs, SCM_TF_comp, dB=False, reverse=True, UARF=False)
A_M = SCM_TF_mat_interp(freqs, SCM_TF_comp, dB=False, reverse=False, UARF=False)
C1Y = A_M[:, 0, 0]
n = len(freqs)
c_inv = np.array([C1Y[ifreq] * A_M_inv[ifreq, ...] for ifreq in range(n)])
M_tilde = np.array([np.dot(M_SCM_to_SOprime, c_inv[ifreq, ...]) for ifreq in range(n)])
return M_tilde, C1Y
def matrix2comp_Mtilde(M_tilde):
dim = M_tilde.ndim
mtilde_X1 = M_tilde[:, 0, 0] if dim == 3 else M_tilde[0, 0]
mtilde_X2 = M_tilde[:, 0, 1] if dim == 3 else M_tilde[0, 1]
mtilde_X3 = M_tilde[:, 0, 2] if dim == 3 else M_tilde[0, 2]
mtilde_Y1 = M_tilde[:, 1, 0] if dim == 3 else M_tilde[1, 0]
mtilde_Y2 = M_tilde[:, 1, 1] if dim == 3 else M_tilde[1, 1]
mtilde_Y3 = M_tilde[:, 1, 2] if dim == 3 else M_tilde[1, 2]
mtilde_Z1 = M_tilde[:, 2, 0] if dim == 3 else M_tilde[2, 0]
mtilde_Z2 = M_tilde[:, 2, 1] if dim == 3 else M_tilde[2, 1]
mtilde_Z3 = M_tilde[:, 2, 2] if dim == 3 else M_tilde[2, 2]
return (mtilde_X1, mtilde_X2, mtilde_X3,
mtilde_Y1, mtilde_Y2, mtilde_Y3,
mtilde_Z1, mtilde_Z2, mtilde_Z3)
def merge_all_F(kcoeff):
kcoeff_all = np.concatenate( [kcoeff[2], [np.nan], kcoeff[1], [np.nan], kcoeff[0]] )
kcoeff_all_arg = np.concatenate( [np.rad2deg(np.unwrap(np.angle(kcoeff[2]))), [np.nan],
np.rad2deg(np.unwrap(np.angle(kcoeff[1]))), [np.nan],
np.rad2deg(np.unwrap(np.angle(kcoeff[0])))] )
return kcoeff_all, kcoeff_all_arg
def plot_kcoeff(kname, freq, kcoeff, figsize=(9,5), title='', ylabel='', fname=None,
no_ishow=False, close=False):
"""
freq and kcoeff are list for F=0, 1, 2
"""
freq_all = np.concatenate( [freq[2], [np.nan], freq[1], [np.nan], freq[0]] )
kcoeff_all, kcoeff_all_arg = merge_all_F(kcoeff)
fig, axarr = plt.subplots(3, 1, squeeze=True, figsize=figsize, sharex=True, sharey=False)
plt.subplots_adjust(hspace=0.0)
axarr[0].set_title(title, fontsize=14)
axarr[0].plot(freq_all, kcoeff_all.real, label='RE', color=None, linewidth=2)
axarr[0].set_ylim([None, None])
axarr[0].set_ylabel(ylabel, fontsize=None)
axarr[0].legend(loc='best')
axarr[0].semilogx()
axarr[1].plot(freq_all, kcoeff_all.imag, label='IM', color='darkorange', linewidth=2)
axarr[1].set_ylabel(ylabel, fontsize=None)
axarr[1].legend(loc='best')
axarr[2].plot(freq_all, abs(kcoeff_all), label='ABS', color='k', linewidth=2)
axarr[2].set_ylabel(ylabel, fontsize=None)
axarr[2].semilogy([None, None])
#axarr[2].legend(loc='best')
axarr[2].legend(loc='lower left')
axarr[2].set_xlabel('Frequency (Hz)', fontsize=12)
ax2 = axarr[2].twinx()
ax2.plot(freq_all, kcoeff_all_arg, label='ARG', color='C3', linewidth=2)
ax2.set_ylabel('degree', fontsize=None)
ax2.legend(loc='upper right')
#ax2.legend(loc='best')
if fname != None: plt.savefig(fname, bbox_inches='tight', pad_inches=0.2)
if close: plt.close(fig)
if no_ishow: plt.ion()
# BP frequency table used in NM
print("BP frequency table used in NM")
bp_n_freq = 3*[None]
for F in [0,1,2]:
nfreq_n = [11, 13, 12][F]
df_n = [8*96., 8*16., 8*1.][F]
fstart_n = [1968, 152, 10.5][F]
bp_n_freq[F] = np.arange(fstart_n, fstart_n+nfreq_n*df_n, df_n)
print("F%s: "%(F), bp_n_freq[F])
BP frequency table used in NM F0: [1968. 2736. 3504. 4272. 5040. 5808. 6576. 7344. 8112. 8880. 9648.] F1: [ 152. 280. 408. 536. 664. 792. 920. 1048. 1176. 1304. 1432. 1560. 1688.] F2: [10.5 18.5 26.5 34.5 42.5 50.5 58.5 66.5 74.5 82.5 90.5 98.5]
# Flight Software Release
fsw = 'R3.3'
# Full ASM frequency table (for which the calibration coefficients for the onboard calibration are defined)
print()
print("Full ASM frequency table for which the default kcoefficients for onboard calibration are defined")
freq_cal_full = 3*[None]
for F in [0,1,2]:
nfreq_cal_full = [8*11, 8*13, 8*12][F]
df_cal_full = [96., 16., 1.][F]
i0_cal_full = [17, 6, 7][F]
freq_cal_full[F] = np.arange(i0_cal_full*df_cal_full,
i0_cal_full*df_cal_full+nfreq_cal_full*df_cal_full,
df_cal_full)
print("F%s: "%(F), freq_cal_full[F])
# Reduced ASM frequency table (close to the BP frequency table used in NM) corresponding
# to the kcoefficients transmitted for the onboard calibration by linear interpolation
print()
print("Reduced ASM frequency table for which the kcoefficients to be transmitted for onboard calibration")
print("by linear interpolation are defined (close to the BP frequency table used in NM)")
freq_cal_redu = 3*[None]
freq_cal_sent = 3*[None]
for F in [0,1,2]:
nfreq_cal_redu = [11+1, 13+1, 12+1][F]
df_cal_redu = [8*96., 8*16., 8*1.][F]
fstart_cal_redu = [1632, 96, 7][F]
freq_cal_redu[F] = np.arange(fstart_cal_redu, fstart_cal_redu+nfreq_cal_redu*df_cal_redu, df_cal_redu)
print("F%s: "%(F), freq_cal_redu[F])
freq_cal_sent[F] = freq_cal_redu[F][:-1]
# kcoefficient indexes
icoeff = {
"Mtilde_X1_RE": 0,
"Mtilde_X1_IM": 1,
"Mtilde_X2_RE": 2,
"Mtilde_X2_IM": 3,
"Mtilde_X3_RE": 4,
"Mtilde_X3_IM": 5,
"Mtilde_Y1_RE": 6,
"Mtilde_Y1_IM": 7,
"Mtilde_Y2_RE": 8,
"Mtilde_Y2_IM": 9,
"Mtilde_Y3_RE": 10,
"Mtilde_Y3_IM": 11,
"Mtilde_Z1_RE": 12,
"Mtilde_Z1_IM": 13,
"Mtilde_Z2_RE": 14,
"Mtilde_Z2_IM": 15,
"Mtilde_Z3_RE": 16,
"Mtilde_Z3_IM": 17,
"Atilde_Y1_RE": 18,
"Atilde_Y1_IM": 19,
"Atilde_Y2_RE": 20,
"Atilde_Y2_IM": 21,
"Atilde_Z1_RE": 22,
"Atilde_Z1_IM": 23,
"Atilde_Z2_RE": 24,
"Atilde_Z2_IM": 25,
"free_1" : 26,
"free_2" : 27,
"free_3" : 28,
"free_4" : 29,
"free_5" : 30,
"free_6" : 31,
}
# ASM calibration coefficients to be interpolated on board,
# and transmitted formally as the old "kcoefficients"
k_coefficients_f0 = np.zeros((11, 32))
k_coefficients_f1 = np.zeros((13, 32))
k_coefficients_f2 = np.zeros((12, 32))
k_coefficients = [k_coefficients_f0, k_coefficients_f1, k_coefficients_f2]
# a numerical constant for the onboard calibrated ASM products to match the digital
# output dynamics of the LFR, i.e. their magnitudes should be between 2^-27 and 2^37
# (for simplicity, here we have chosen no dependence with F = 0, 1, 2),
kappa = [1e-4, 1e-4, 1e-4]
print()
print("kappa:", kappa)
print("min output LFR value (2^⁻27): %e"%2**-27)
print("max output LFR value (2^+37): %e"%2**+37)
Full ASM frequency table for which the default kcoefficients for onboard calibration are defined F0: [1632. 1728. 1824. 1920. 2016. 2112. 2208. 2304. 2400. 2496. 2592. 2688. 2784. 2880. 2976. 3072. 3168. 3264. 3360. 3456. 3552. 3648. 3744. 3840. 3936. 4032. 4128. 4224. 4320. 4416. 4512. 4608. 4704. 4800. 4896. 4992. 5088. 5184. 5280. 5376. 5472. 5568. 5664. 5760. 5856. 5952. 6048. 6144. 6240. 6336. 6432. 6528. 6624. 6720. 6816. 6912. 7008. 7104. 7200. 7296. 7392. 7488. 7584. 7680. 7776. 7872. 7968. 8064. 8160. 8256. 8352. 8448. 8544. 8640. 8736. 8832. 8928. 9024. 9120. 9216. 9312. 9408. 9504. 9600. 9696. 9792. 9888. 9984.] F1: [ 96. 112. 128. 144. 160. 176. 192. 208. 224. 240. 256. 272. 288. 304. 320. 336. 352. 368. 384. 400. 416. 432. 448. 464. 480. 496. 512. 528. 544. 560. 576. 592. 608. 624. 640. 656. 672. 688. 704. 720. 736. 752. 768. 784. 800. 816. 832. 848. 864. 880. 896. 912. 928. 944. 960. 976. 992. 1008. 1024. 1040. 1056. 1072. 1088. 1104. 1120. 1136. 1152. 1168. 1184. 1200. 1216. 1232. 1248. 1264. 1280. 1296. 1312. 1328. 1344. 1360. 1376. 1392. 1408. 1424. 1440. 1456. 1472. 1488. 1504. 1520. 1536. 1552. 1568. 1584. 1600. 1616. 1632. 1648. 1664. 1680. 1696. 1712. 1728. 1744.] F2: [ 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102.] Reduced ASM frequency table for which the kcoefficients to be transmitted for onboard calibration by linear interpolation are defined (close to the BP frequency table used in NM) F0: [ 1632. 2400. 3168. 3936. 4704. 5472. 6240. 7008. 7776. 8544. 9312. 10080.] F1: [ 96. 224. 352. 480. 608. 736. 864. 992. 1120. 1248. 1376. 1504. 1632. 1760.] F2: [ 7. 15. 23. 31. 39. 47. 55. 63. 71. 79. 87. 95. 103.] kappa: [0.0001, 0.0001, 0.0001] min output LFR value (2^⁻27): 7.450581e-09 max output LFR value (2^+37): 1.374390e+11
17*96
#dir_SCM_TF = dir_DATA + '/SO/DATA_CALBUT/Tables_de_cal'
#cdffiles = glob.glob(dir_SCM_TF + '/*RCT-SCM_*V20190519*')
dir_SCM_TF = dir_root + '/Missions/Solar Orbiter/LFR/SCM'
cdffiles = glob.glob(dir_SCM_TF + '/*SOLO*V20200428000000*.cdf')
cdffiles.sort()
for file in cdffiles:
print(os.path.basename(file))
cdffile_SCM_TF = cdffiles[0]
SCM_TF_bname = os.path.basename(cdffile_SCM_TF)[:-4]
print()
print(SCM_TF_bname)
SCM_TF_comp = load_SCM_TF_comp_CDF(cdffile_SCM_TF, temp=-50., lfr_on=True, echo=True)
freq_range = [1,10000]
fig=plt.figure(figsize=(7,4))
plt.xlabel('Frequency (Hz)', fontsize=12)
plt.ylabel('Gain dB(V/nT)', fontsize=14)
for k in [key for key in SCM_TF_comp.keys() if key[-5:] == 'gains' and key[0] == 'B']:
#plt.plot(TF_comp['LF-Freqs'], TF_comp[k], label=k)
plt.plot(SCM_TF_comp['LF-Freqs'], (SCM_TF_comp[k]), label=k, linewidth=2)
plt.legend(loc='best', fontsize=12)
plt.xlim(freq_range)
plt.semilogx()
plt.grid(True)
plt.show()
fig=plt.figure(figsize=(7,4))
plt.xlabel('Frequency (Hz)', fontsize=12)
plt.ylabel('Phase (°)', fontsize=14)
for k in [key for key in SCM_TF_comp.keys() if key[-6:] == 'phases' and key[0] == 'B']:
plt.plot(SCM_TF_comp['LF-Freqs'], SCM_TF_comp[k], label=k)
plt.legend(loc='best', fontsize=12)
plt.xlim(freq_range)
plt.semilogx()
freq_range = [1,10000]
fig=plt.figure(figsize=(7,4))
plt.xlabel('Frequency (Hz)', fontsize=12)
plt.ylabel('Gain dB(nT/V)', fontsize=14)
for k in [key for key in SCM_TF_comp.keys() if key[-5:] == 'gains' and key[0:2] == 'rB']:
#plt.plot(SCM_TF_comp['LF-Freqs'], SCM_TF_comp[k], label=k)
plt.plot(SCM_TF_comp['LF-Freqs'], SCM_TF_comp[k], label=k, linewidth=2)
plt.legend(loc='best', fontsize=12)
plt.xlim(freq_range)
#plt.ylim([0,2])
plt.semilogx()
plt.show()
fig=plt.figure(figsize=(7,4))
plt.xlabel('Frequency (Hz)', fontsize=12)
plt.ylabel('Phase (°)', fontsize=14)
for k in [key for key in SCM_TF_comp.keys() if key[-6:] == 'phases' and key[0:2] == 'rB']:
plt.plot(SCM_TF_comp['LF-Freqs'], SCM_TF_comp[k], label=k)
plt.legend(loc='best', fontsize=12)
plt.xlim(freq_range)
plt.semilogx()
SOLO_CAL_RPW-SCM_SCM-FS-MEB-PFM_V20200428000000.cdf SOLO_CAL_RPW-SCM_SCM-FS-MEB-PFM_V20200428000000 PRINT cdf: ANALYZERS_STATUS: CDF_CHAR*40 [2] NRV B11-LF-gains: CDF_REAL4 [162, 512] B11-LF-phases: CDF_REAL4 [162, 512] B12-LF-gains: CDF_REAL4 [162, 512] B12-LF-phases: CDF_REAL4 [162, 512] B13-LF-gains: CDF_REAL4 [162, 512] B13-LF-phases: CDF_REAL4 [162, 512] B21-LF-gains: CDF_REAL4 [162, 512] B21-LF-phases: CDF_REAL4 [162, 512] B22-LF-gains: CDF_REAL4 [162, 512] B22-LF-phases: CDF_REAL4 [162, 512] B23-LF-gains: CDF_REAL4 [162, 512] B23-LF-phases: CDF_REAL4 [162, 512] B31-LF-gains: CDF_REAL4 [162, 512] B31-LF-phases: CDF_REAL4 [162, 512] B32-LF-gains: CDF_REAL4 [162, 512] B32-LF-phases: CDF_REAL4 [162, 512] B33-LF-gains: CDF_REAL4 [162, 512] B33-LF-phases: CDF_REAL4 [162, 512] B4-MF-gains: CDF_REAL4 [81, 512] B4-MF-phases: CDF_REAL4 [81, 512] Comments: CDF_CHAR*40 [162] LF-Freqs: CDF_REAL4 [162, 512] MF-Freqs: CDF_REAL4 [81, 512] SCM_TEMPERATURES: CDF_REAL4 [81] NRV TF_INDEX: CDF_UINT4 [2, 81] NRV nLF-Freqs: CDF_UINT4 [162] nMF-Freqs: CDF_UINT4 [81] rB11-LF-gains: CDF_REAL4 [162, 512] rB11-LF-phases: CDF_REAL4 [162, 512] rB12-LF-gains: CDF_REAL4 [162, 512] rB12-LF-phases: CDF_REAL4 [162, 512] rB13-LF-gains: CDF_REAL4 [162, 512] rB13-LF-phases: CDF_REAL4 [162, 512] rB21-LF-gains: CDF_REAL4 [162, 512] rB21-LF-phases: CDF_REAL4 [162, 512] rB22-LF-gains: CDF_REAL4 [162, 512] rB22-LF-phases: CDF_REAL4 [162, 512] rB23-LF-gains: CDF_REAL4 [162, 512] rB23-LF-phases: CDF_REAL4 [162, 512] rB31-LF-gains: CDF_REAL4 [162, 512] rB31-LF-phases: CDF_REAL4 [162, 512] rB32-LF-gains: CDF_REAL4 [162, 512] rB32-LF-phases: CDF_REAL4 [162, 512] rB33-LF-gains: CDF_REAL4 [162, 512] rB33-LF-phases: CDF_REAL4 [162, 512] rB4-MF-gains: CDF_REAL4 [81, 512] rB4-MF-phases: CDF_REAL4 [81, 512] temp = -50.0 temp_index = 15, tf_index[0, 15] = 15 LFR ON, TDS MF at -50. degrees nLF-Freqs[15]: 400
[]
dir_LFR_TF_PFM2_B_ROC = dir_root + '/Missions/Solar Orbiter/LFR/Ground Segment/Tables de calibration'
#cdffiles_B = glob.glob(dir_LFR_TF_PFM2_B_ROC + '/*SCM_V20180724*.cdf')
cdffiles_B = glob.glob(dir_LFR_TF_PFM2_B_ROC + '/*SCM_V20190123*171020*.cdf')
cdffiles_B.sort()
for file in cdffiles_B:
print(os.path.basename(file))
cdffile_LFR_TF_B = file
(LFR_TF_B_ampli, LFR_TF_B_phase, LFR_TF_B_freqs) = load_LFR_TF_B_CDF(cdffile_LFR_TF_B, echo=True)
LFR_TF_B = 4*[None]
for F in range(4):
LFR_TF_B[F] = { 'Freq': LFR_TF_B_freqs[F],
'Gain': LFR_TF_B_ampli[F],
'Phase': LFR_TF_B_phase[F] }
#data_version = LFR_TF_PFM2_B1B2B3[0]['Filecomment'][-10:]
data_version = "..."
freq_range = [0.1,12500]
fig=plt.figure(figsize=(10,4))
plt.xlabel('Frequency (Hz)', fontsize=12)
plt.ylabel('Gain (count/V)', fontsize=14)
plt.title("LFR PFM2 transfer functions @F0, F1, F2 and F3 - %s - CDF"%(data_version), fontsize=18)
for i in range(3):
for F in range(4): plt.plot(LFR_TF_B_freqs[F], LFR_TF_B_ampli[F][:,i], linewidth=2, color=colors_sm[i],
marker=markers_sm[i], label=chs_sm[i] if F == 0 else None)
plt.legend(loc='best')
plt.xlim(freq_range)
plt.ylim([7200,9200])
#plt.ylim([8700,8740])
plt.semilogx()
fig=plt.figure(figsize=(10,4))
plt.xlabel('Frequency (Hz)', fontsize=12)
plt.ylabel('Phase (°)', fontsize=14)
plt.title("LFR PFM2 transfer functions @F0, F1, F2 and F3 - %s - CDF"%(data_version), fontsize=18)
for i in range(3):
for F in range(4): plt.plot(LFR_TF_B_freqs[F], LFR_TF_B_phase[F][:,i], linewidth=2, color=colors_sm[i],
marker=markers_sm[i], label=chs_sm[i] if F == 0 else None)
plt.legend(loc='best')
plt.xlim(freq_range)
plt.ylim([-360,10])
plt.semilogx()
plt.show()
SOLO_CAL_RCT-LFR-SCM_V20190123171020.cdf PRINT cdf: Freqs_F0: CDF_FLOAT [1024] Freqs_F1: CDF_FLOAT [2066] Freqs_F2: CDF_FLOAT [1035] Freqs_F3: CDF_FLOAT [89] TF_B1B2B3_amplitude_F0: CDF_FLOAT [1024, 3] TF_B1B2B3_amplitude_F1: CDF_FLOAT [2066, 3] TF_B1B2B3_amplitude_F2: CDF_FLOAT [1035, 3] TF_B1B2B3_amplitude_F3: CDF_FLOAT [89, 3] TF_B1B2B3_phase_F0: CDF_FLOAT [1024, 3] TF_B1B2B3_phase_F1: CDF_FLOAT [2066, 3] TF_B1B2B3_phase_F2: CDF_FLOAT [1035, 3] TF_B1B2B3_phase_F3: CDF_FLOAT [89, 3]
Mtilde_SOprime_redu = 3*[None]
C1Y_redu = 3*[None]
alpha_redu = 3*[None]
Mtilde_X1_redu = 3*[None]
Mtilde_X2_redu = 3*[None]
Mtilde_X3_redu = 3*[None]
Mtilde_Y1_redu = 3*[None]
Mtilde_Y2_redu = 3*[None]
Mtilde_Y3_redu = 3*[None]
Mtilde_Z1_redu = 3*[None]
Mtilde_Z2_redu = 3*[None]
Mtilde_Z3_redu = 3*[None]
Mtilde_Alpha_over_Kappa_X1_redu = 3*[None]
Mtilde_Alpha_over_Kappa_X2_redu = 3*[None]
Mtilde_Alpha_over_Kappa_X3_redu = 3*[None]
Mtilde_Alpha_over_Kappa_Y1_redu = 3*[None]
Mtilde_Alpha_over_Kappa_Y2_redu = 3*[None]
Mtilde_Alpha_over_Kappa_Y3_redu = 3*[None]
Mtilde_Alpha_over_Kappa_Z1_redu = 3*[None]
Mtilde_Alpha_over_Kappa_Z2_redu = 3*[None]
Mtilde_Alpha_over_Kappa_Z3_redu = 3*[None]
for F in [0,1,2]:
Mtilde_SOprime_redu[F], C1Y_redu[F] = load_interp_Mtilde_SOprime(cdffile_SCM_TF, freq_cal_redu[F], echo=False)
alpha_redu[F] = 1 / ( C1Y_redu[F] * LFR_TF_mean_B_interp(freq_cal_redu[F], LFR_TF_B[F]) )
(Mtilde_X1_redu[F], Mtilde_X2_redu[F], Mtilde_X3_redu[F],
Mtilde_Y1_redu[F], Mtilde_Y2_redu[F], Mtilde_Y3_redu[F],
Mtilde_Z1_redu[F], Mtilde_Z2_redu[F], Mtilde_Z3_redu[F]) = matrix2comp_Mtilde(Mtilde_SOprime_redu[F])
Mtilde_Alpha_over_Kappa_X1_redu[F] = Mtilde_X1_redu[F] * alpha_redu[F] / kappa[F]
Mtilde_Alpha_over_Kappa_X2_redu[F] = Mtilde_X2_redu[F] * alpha_redu[F] / kappa[F]
Mtilde_Alpha_over_Kappa_X3_redu[F] = Mtilde_X3_redu[F] * alpha_redu[F] / kappa[F]
Mtilde_Alpha_over_Kappa_Y1_redu[F] = Mtilde_Y1_redu[F] * alpha_redu[F] / kappa[F]
Mtilde_Alpha_over_Kappa_Y2_redu[F] = Mtilde_Y2_redu[F] * alpha_redu[F] / kappa[F]
Mtilde_Alpha_over_Kappa_Y3_redu[F] = Mtilde_Y3_redu[F] * alpha_redu[F] / kappa[F]
Mtilde_Alpha_over_Kappa_Z1_redu[F] = Mtilde_Z1_redu[F] * alpha_redu[F] / kappa[F]
Mtilde_Alpha_over_Kappa_Z2_redu[F] = Mtilde_Z2_redu[F] * alpha_redu[F] / kappa[F]
Mtilde_Alpha_over_Kappa_Z3_redu[F] = Mtilde_Z3_redu[F] * alpha_redu[F] / kappa[F]
freq_all_redu = np.concatenate( [freq_cal_redu[2], [np.nan], freq_cal_redu[1], [np.nan], freq_cal_redu[0]] )
alpha_all_redu = np.concatenate( [alpha_redu[2], [np.nan], alpha_redu[1], [np.nan], alpha_redu[0]] )
alpha_all_arg_redu = np.concatenate( [np.rad2deg(np.unwrap(np.angle(alpha_redu[2]))), [np.nan],
np.rad2deg(np.unwrap(np.angle(alpha_redu[1]))), [np.nan],
np.rad2deg(np.unwrap(np.angle(alpha_redu[0])))] )
freq_all_redu
Mtilde_SOprime_full = 3*[None]
C1Y_full = 3*[None]
alpha_full = 3*[None]
Mtilde_X1_full = 3*[None]
Mtilde_X2_full = 3*[None]
Mtilde_X3_full = 3*[None]
Mtilde_Y1_full = 3*[None]
Mtilde_Y2_full = 3*[None]
Mtilde_Y3_full = 3*[None]
Mtilde_Z1_full = 3*[None]
Mtilde_Z2_full = 3*[None]
Mtilde_Z3_full = 3*[None]
Mtilde_Alpha_over_Kappa_X1_full = 3*[None]
Mtilde_Alpha_over_Kappa_X2_full = 3*[None]
Mtilde_Alpha_over_Kappa_X3_full = 3*[None]
Mtilde_Alpha_over_Kappa_Y1_full = 3*[None]
Mtilde_Alpha_over_Kappa_Y2_full = 3*[None]
Mtilde_Alpha_over_Kappa_Y3_full = 3*[None]
Mtilde_Alpha_over_Kappa_Z1_full = 3*[None]
Mtilde_Alpha_over_Kappa_Z2_full = 3*[None]
Mtilde_Alpha_over_Kappa_Z3_full = 3*[None]
for F in [0,1,2]:
Mtilde_SOprime_full[F], C1Y_full[F] = load_interp_Mtilde_SOprime(cdffile_SCM_TF, freq_cal_full[F], echo=False)
alpha_full[F] = 1 / ( C1Y_full[F] * LFR_TF_mean_B_interp(freq_cal_full[F], LFR_TF_B[F]) )
(Mtilde_X1_full[F], Mtilde_X2_full[F], Mtilde_X3_full[F],
Mtilde_Y1_full[F], Mtilde_Y2_full[F], Mtilde_Y3_full[F],
Mtilde_Z1_full[F], Mtilde_Z2_full[F], Mtilde_Z3_full[F]) = matrix2comp_Mtilde(Mtilde_SOprime_full[F])
Mtilde_Alpha_over_Kappa_X1_full[F] = Mtilde_X1_full[F] * alpha_full[F] / kappa[F]
Mtilde_Alpha_over_Kappa_X2_full[F] = Mtilde_X2_full[F] * alpha_full[F] / kappa[F]
Mtilde_Alpha_over_Kappa_X3_full[F] = Mtilde_X3_full[F] * alpha_full[F] / kappa[F]
Mtilde_Alpha_over_Kappa_Y1_full[F] = Mtilde_Y1_full[F] * alpha_full[F] / kappa[F]
Mtilde_Alpha_over_Kappa_Y2_full[F] = Mtilde_Y2_full[F] * alpha_full[F] / kappa[F]
Mtilde_Alpha_over_Kappa_Y3_full[F] = Mtilde_Y3_full[F] * alpha_full[F] / kappa[F]
Mtilde_Alpha_over_Kappa_Z1_full[F] = Mtilde_Z1_full[F] * alpha_full[F] / kappa[F]
Mtilde_Alpha_over_Kappa_Z2_full[F] = Mtilde_Z2_full[F] * alpha_full[F] / kappa[F]
Mtilde_Alpha_over_Kappa_Z3_full[F] = Mtilde_Z3_full[F] * alpha_full[F] / kappa[F]
freq_all_full = np.concatenate( [freq_cal_full[2], [np.nan], freq_cal_full[1], [np.nan], freq_cal_full[0]] )
alpha_all_full = np.concatenate( [alpha_full[2], [np.nan], alpha_full[1], [np.nan], alpha_full[0]] )
alpha_all_arg_full = np.concatenate( [np.rad2deg(np.unwrap(np.angle(alpha_full[2]))), [np.nan],
np.rad2deg(np.unwrap(np.angle(alpha_full[1]))), [np.nan],
np.rad2deg(np.unwrap(np.angle(alpha_full[0])))] )
freq_all_full
fig, axarr = plt.subplots(2, 1, squeeze=True, figsize=(9,5), sharex=True, sharey=False)
plt.subplots_adjust(hspace=0.0)
axarr[0].set_title(r'alpha = $(TF_{SCM} \times TF_{LFR}^{SCM})^{-1}$ - reduced grid', fontsize=14)
axarr[0].plot(freq_all_redu, alpha_all_redu.real, label='RE', color=None, linewidth=2)
axarr[0].set_ylim([None, None])
axarr[0].set_ylabel('nT / count', fontsize=None)
axarr[0].semilogx()
axarr[0].plot(freq_all_redu, alpha_all_redu.imag, label='IM', color=None, linewidth=2)
axarr[0].legend(loc='best')
axarr[1].plot(freq_all_redu, abs(alpha_all_redu), label='ABS', color='k', linewidth=2)
#axarr[1].set_ylim([None, None])
axarr[1].set_ylabel('nT / count', fontsize=None)
axarr[1].semilogy([None, None])
#axarr[1].legend(loc='best')
axarr[1].legend(loc='center left')
axarr[1].set_xlabel('Frequency (Hz)', fontsize=12)
ax2 = axarr[1].twinx()
ax2.plot(freq_all_redu, alpha_all_arg_redu, label='ARG', color='C3', linewidth=2)
ax2.set_ylabel('degree', fontsize=None)
ax2.legend(loc='center right')
#ax2.legend(loc='lower right')
fname = dir_plots+ '/kcoefficients-alpha-redu_FSW_%s.png'%(fsw)
plt.savefig(fname, bbox_inches='tight', pad_inches=0.2)
fig, axarr = plt.subplots(2, 1, squeeze=True, figsize=(9,5), sharex=True, sharey=False)
plt.subplots_adjust(hspace=0.0)
axarr[0].set_title(r'alpha = $(TF_{SCM} \times TF_{LFR}^{SCM})^{-1}$ - full grid', fontsize=14)
axarr[0].plot(freq_all_full, alpha_all_full.real, label='RE', color=None, linewidth=2)
axarr[0].set_ylim([None, None])
axarr[0].set_ylabel('nT / count', fontsize=None)
axarr[0].semilogx()
axarr[0].plot(freq_all_full, alpha_all_full.imag, label='IM', color=None, linewidth=2)
axarr[0].legend(loc='best')
axarr[1].plot(freq_all_full, abs(alpha_all_full), label='ABS', color='k', linewidth=2)
#axarr[1].set_ylim([None, None])
axarr[1].set_ylabel('nT / count', fontsize=None)
axarr[1].semilogy([None, None])
#axarr[1].legend(loc='best')
axarr[1].legend(loc='center left')
axarr[1].set_xlabel('Frequency (Hz)', fontsize=12)
ax2 = axarr[1].twinx()
ax2.plot(freq_all_full, alpha_all_arg_full, label='ARG', color='C3', linewidth=2)
ax2.set_ylabel('degree', fontsize=None)
ax2.legend(loc='center right')
#ax2.legend(loc='lower right')
fname = dir_plots+ '/kcoefficients-alpha-full_FSW_%s.png'%(fsw)
plt.savefig(fname, bbox_inches='tight', pad_inches=0.2)
print("%.e"%(kappa[0]))
kcoeff_list_redu = (Mtilde_Alpha_over_Kappa_X1_redu, Mtilde_Alpha_over_Kappa_X2_redu, Mtilde_Alpha_over_Kappa_X3_redu,
Mtilde_Alpha_over_Kappa_Y1_redu, Mtilde_Alpha_over_Kappa_Y2_redu, Mtilde_Alpha_over_Kappa_Y3_redu,
Mtilde_Alpha_over_Kappa_Z1_redu, Mtilde_Alpha_over_Kappa_Z2_redu, Mtilde_Alpha_over_Kappa_Z3_redu)
kname_list_redu = ['Mtilde_Alpha_over_Kappa_%s%s_redu'%(i,j) for i in ['X', 'Y', 'Z'] for j in [1, 2, 3]]
title_list_redu = ['Mtilde_Alpha_over_Kappa_%s%s_redu'%(i,j) + \
r' = $\left[\,\alpha / \kappa \times \mathbf{M}_\mathit{SCM-SRF}^{-1} '+ \
r'\,\cdot\,\mathbf{c}^{-1}\right]_{i\!=\!%s, j\!=\!%s}$'%(i,j) \
for i in ['X', 'Y', 'Z'] for j in [1, 2, 3]]
fname_list_redu = [dir_plots+ '/kcoefficients_%s_FSW_%s_kappa=%.e.png'%(kname_list_redu[i], fsw, kappa[0]) \
for i in range(len(kname_list_redu))]
for (kname, kcoeff, title, fname) in zip(kname_list_redu, kcoeff_list_redu, title_list_redu, fname_list_redu):
plot_kcoeff(kname, freq_cal_redu, kcoeff, figsize=(9,5), title=title, ylabel='nT / count',
fname=fname, no_ishow=True, close=True)
# plot_kcoeff(kname, freq_cal_redu, kcoeff, figsize=(9,5), title=title, ylabel='nT / count',
# fname=fname, no_ishow=True, close=True)
kcoeff_list_full = (Mtilde_Alpha_over_Kappa_X1_full, Mtilde_Alpha_over_Kappa_X2_full, Mtilde_Alpha_over_Kappa_X3_full,
Mtilde_Alpha_over_Kappa_Y1_full, Mtilde_Alpha_over_Kappa_Y2_full, Mtilde_Alpha_over_Kappa_Y3_full,
Mtilde_Alpha_over_Kappa_Z1_full, Mtilde_Alpha_over_Kappa_Z2_full, Mtilde_Alpha_over_Kappa_Z3_full)
kname_list_full = ['Mtilde_Alpha_over_Kappa_%s%s_full'%(i,j) for i in ['X', 'Y', 'Z'] for j in [1, 2, 3]]
title_list_full = ['Mtilde_Alpha_over_Kappa_%s%s_full'%(i,j) + \
r' = $\left[\,\alpha / \kappa \times \mathbf{M}_\mathit{SCM-SRF}^{-1} '+ \
r'\,\cdot\,\mathbf{c}^{-1}\right]_{i\!=\!%s, j\!=\!%s}$'%(i,j) \
for i in ['X', 'Y', 'Z'] for j in [1, 2, 3]]
fname_list_full = [dir_plots+ '/kcoefficients_%s_FSW_%s_kappa=%.e.png'%(kname_list_full[i], fsw, kappa[0]) \
for i in range(len(kname_list_full))]
for (kname, kcoeff, title, fname) in zip(kname_list_full, kcoeff_list_full, title_list_full, fname_list_full):
plot_kcoeff(kname, freq_cal_full, kcoeff, figsize=(9,5), title=title, ylabel='nT / count',
fname=fname, no_ishow=True, close=True)
# plot_kcoeff(kname, freq_cal_full, kcoeff, figsize=(9,5), title=title, ylabel='nT / count',
# fname=fname, no_ishow=True, close=True)
#cdffiles=glob.glob(dir_root + '/Missions/Solar Orbiter/LFR/BIAS/*V202003101607*.cdf')
cdffiles=glob.glob(dir_root + '/Missions/Solar Orbiter/LFR/BIAS/*V202011191204*.cdf')
cdffiles.sort()
for file in cdffiles:
print(os.path.basename(file))
cdffile_BIAS_TF = file
BIAS_TF = load_BIAS_TF_func(cdffile_BIAS_TF, echo=True)
bias_conf = ['ac_diff_G5', 'dc_diff_G1']
# R0 R1 R2 (R=0 => BIAS4 BIAS5, R=1 => BIAS2 BIAS3)
r_conf = [0, 0, 0]
#r_conf = [0, 0, 1]
r = r_conf[2]
freqs = np.linspace(1, 10000, int(4e4))
fig=plt.figure(figsize=(7,4))
plt.xlabel('Frequency (Hz)', fontsize=12)
plt.ylabel('Gain', fontsize=12)
plt.title('BIAS transfer function', fontsize=14)
plt.plot(freqs, np.abs( BIAS_TF(freqs, conf=bias_conf[r]) ), linewidth=2)
#plt.legend(loc='best')
#plt.ylim([10,15])
plt.semilogx()
fig=plt.figure(figsize=(7,4))
plt.xlabel('Frequency (Hz)', fontsize=12)
plt.ylabel('Phase (degree)', fontsize=12)
plt.title('BIAS transfer function', fontsize=14)
plt.plot(freqs, np.angle(BIAS_TF(freqs, conf=bias_conf[r]), deg=True), linewidth=2)
#plt.legend(loc='best')
#plt.ylim([10,15])
plt.semilogx()
SOLO_CAL_RPW-BIAS_V202011191204.cdf PRINT cdf: BIAS_CURRENT_GAIN: CDF_DOUBLE [3, 1] NRV BIAS_CURRENT_OFFSET: CDF_DOUBLE [3, 1] NRV E_LABEL: CDF_UCHAR*3 [3] NRV E_OFFSET: CDF_DOUBLE [3, 1] NRV Epoch_H: CDF_TIME_TT2000 [1] NRV Epoch_L: CDF_TIME_TT2000 [1] NRV TRANSFER_FUNCTION_COEFFS: CDF_DOUBLE [2, 8, 4] NRV TRANSFER_FUNCTION_COEFF_LABEL: CDF_UCHAR*3 [8] NRV TRANSFER_FUNCTION_LABEL: CDF_UCHAR*12 [4] NRV TRANSFER_FUNCTION_ND_LABEL: CDF_UCHAR*11 [2] NRV V_LABEL: CDF_UCHAR*2 [3] NRV V_OFFSET: CDF_DOUBLE [3, 1] NRV TRANSFER_FUNCTION_COEFFS: [[[ 5.00900e+20 2.31100e+23 0.00000e+00 0.00000e+00] [-8.14800e+14 1.00900e+18 1.33551e+40 6.91633e+41] [ 1.04100e+10 -2.66400e+11 1.84960e+34 2.13364e+37] [ 0.00000e+00 0.00000e+00 -1.52549e+27 3.89496e+32] [ 0.00000e+00 0.00000e+00 2.66744e+19 0.00000e+00] [ 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00] [ 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00] [ 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00]] [[ 8.55600e+21 2.32900e+23 1.27572e+41 3.42020e+41] [ 2.57800e+17 4.41100e+18 2.62533e+39 7.05355e+39] [ 2.04200e+12 7.34400e+12 4.71518e+34 4.33219e+35] [ 8.23800e+05 3.86800e+06 3.59175e+28 1.05546e+31] [ 1.00000e+00 1.00000e+00 6.98964e+21 9.97355e+25] [ 0.00000e+00 0.00000e+00 5.94792e+14 1.71685e+20] [ 0.00000e+00 0.00000e+00 1.00000e+00 1.00000e+00] [ 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00]]] TRANSFER_FUNCTION_COEFF_LABEL: ['c_0' 'c_1' 'c_2' 'c_3' 'c_4' 'c_5' 'c_6' 'c_7'] TRANSFER_FUNCTION_LABEL: ['DC single ' 'DC diff ' 'AC low-gain ' 'AC high-gain'] TRANSFER_FUNCTION_ND_LABEL: ['Numerator ' 'Denominator'] TRANSFER_FUNCTION_COEFFS : (2, 8, 4)
[]
dir_LFR_TF_E_ROC = dir_root + '/Missions/Solar Orbiter/LFR/Ground Segment/Tables de calibration'
cdffiles_E = glob.glob(dir_LFR_TF_E_ROC + '/*BIAS_V20190123*171020*.cdf')
cdffiles_E.sort()
for file in cdffiles_E:
print(os.path.basename(file))
cdffile_LFR_TF_E = file
(LFR_TF_E_ampli, LFR_TF_E_phase, LFR_TF_E_freqs) = load_LFR_TF_E_CDF(cdffile_LFR_TF_E, echo=True)
LFR_TF_E = 4*[None]
for F in range(4):
LFR_TF_E[F] = { 'Freq': LFR_TF_E_freqs[F],
'Gain': LFR_TF_E_ampli[F],
'Phase': LFR_TF_E_phase[F]}
#data_version = LFR_TF_PFM2_E1E2E3E4E5[0]['Filecomments'][0][-10:]
data_version = "..."
freq_range = [0.1,12500]
fig=plt.figure(figsize=(10,4))
plt.xlabel('Frequency (Hz)', fontsize=12)
plt.ylabel('Gain (count/V)', fontsize=14)
plt.title("LFR PFM2 transfer functions @F0, F1, F2 and F3 - %s - CDF"%(data_version), fontsize=18)
for F in range(4):
for i in range(3 if F==3 else 5):
plt.plot(LFR_TF_E_freqs[F], LFR_TF_E_ampli[F][:,i], linewidth=2, color=colors_bias[i],
marker=markers_bias[i], label=chs_bias[i] if F == 0 else None)
plt.legend(loc='best')
plt.xlim(freq_range)
plt.ylim([6200,8500])
plt.ylim([5000,8500])
plt.semilogx()
fig=plt.figure(figsize=(10,4))
plt.xlabel('Frequency (Hz)', fontsize=12)
plt.ylabel('Phase (°)', fontsize=14)
plt.title("LFR PFM2 transfer functions @F0, F1, F2 and F3 - %s - CDF"%(data_version), fontsize=18)
for F in range(4):
for i in range(3 if F==3 else 5):
plt.plot(LFR_TF_E_freqs[F], LFR_TF_E_phase[F][:,i], linewidth=2, color=colors_bias[i],
marker=markers_bias[i], label=chs_bias[i] if F == 0 else None)
plt.legend(loc='best')
plt.xlim(freq_range)
plt.ylim([-360,90])
plt.semilogx()
plt.show()
SOLO_CAL_RCT-LFR-BIAS_V20190123171020.cdf PRINT cdf: Freqs_F0: CDF_FLOAT [1024] Freqs_F1: CDF_FLOAT [2066] Freqs_F2: CDF_FLOAT [1035] Freqs_F3: CDF_FLOAT [89] TF_BIAS_12345_amplitude_F0: CDF_FLOAT [1024, 5] TF_BIAS_12345_amplitude_F1: CDF_FLOAT [2066, 5] TF_BIAS_12345_amplitude_F2: CDF_FLOAT [1035, 5] TF_BIAS_12345_phase_F0: CDF_FLOAT [1024, 5] TF_BIAS_12345_phase_F1: CDF_FLOAT [2066, 5] TF_BIAS_12345_phase_F2: CDF_FLOAT [1035, 5] TF_BIAS_123_amplitude_F3: CDF_FLOAT [89, 3] TF_BIAS_123_phase_F3: CDF_FLOAT [89, 3]
Atilde_Y1_redu = 3*[None]
Atilde_Y2_redu = 3*[None]
Atilde_Z1_redu = 3*[None]
Atilde_Z2_redu = 3*[None]
k_ANT_redu = 3*[None]
beta_redu = 3*[None]
Atilde_Beta_over_Kappa_Y1_redu = 3*[None]
Atilde_Beta_over_Kappa_Y2_redu = 3*[None]
Atilde_Beta_over_Kappa_Z1_redu = 3*[None]
Atilde_Beta_over_Kappa_Z2_redu = 3*[None]
for F in [0,1,2]:
r = r_conf[F]
(Atilde_Y1_redu[F], Atilde_Y2_redu[F], Atilde_Z1_redu[F], Atilde_Z2_redu[F]), k_ANT_redu[F] = \
load_interp_Atilde_SOprime('cdffile_ANT_TF', freq_cal_redu[F])
beta_redu[F] = 1 / ( k_ANT_redu[F] * BIAS_TF(freq_cal_redu[F], conf=bias_conf[r]) * \
LFR_TF_mean_E_interp(freq_cal_redu[F], LFR_TF_E[F], R=r) )
Atilde_Beta_over_Kappa_Y1_redu[F] = Atilde_Y1_redu[F] * beta_redu[F] / kappa[F]
Atilde_Beta_over_Kappa_Y2_redu[F] = Atilde_Y2_redu[F] * beta_redu[F] / kappa[F]
Atilde_Beta_over_Kappa_Z1_redu[F] = Atilde_Z1_redu[F] * beta_redu[F] / kappa[F]
Atilde_Beta_over_Kappa_Z2_redu[F] = Atilde_Z2_redu[F] * beta_redu[F] / kappa[F]
beta_all_redu = np.concatenate( [beta_redu[2], [np.nan], beta_redu[1], [np.nan], beta_redu[0]] )
beta_all_arg_redu = np.concatenate( [np.rad2deg(np.unwrap(np.angle(beta_redu[2]))), [np.nan],
np.rad2deg(np.unwrap(np.angle(beta_redu[1]))), [np.nan],
np.rad2deg(np.unwrap(np.angle(beta_redu[0])))] )
Atilde_Y1_full = 3*[None]
Atilde_Y2_full = 3*[None]
Atilde_Z1_full = 3*[None]
Atilde_Z2_full = 3*[None]
k_ANT_full = 3*[None]
beta_full = 3*[None]
Atilde_Beta_over_Kappa_Y1_full = 3*[None]
Atilde_Beta_over_Kappa_Y2_full = 3*[None]
Atilde_Beta_over_Kappa_Z1_full = 3*[None]
Atilde_Beta_over_Kappa_Z2_full = 3*[None]
for F in [0,1,2]:
r = r_conf[F]
(Atilde_Y1_full[F], Atilde_Y2_full[F], Atilde_Z1_full[F], Atilde_Z2_full[F]), k_ANT_full[F] = \
load_interp_Atilde_SOprime('cdffile_ANT_TF', freq_cal_full[F])
beta_full[F] = 1 / ( k_ANT_full[F] * BIAS_TF(freq_cal_full[F], conf=bias_conf[r]) * \
LFR_TF_mean_E_interp(freq_cal_full[F], LFR_TF_E[F], R=r) )
Atilde_Beta_over_Kappa_Y1_full[F] = Atilde_Y1_full[F] * beta_full[F] / kappa[F]
Atilde_Beta_over_Kappa_Y2_full[F] = Atilde_Y2_full[F] * beta_full[F] / kappa[F]
Atilde_Beta_over_Kappa_Z1_full[F] = Atilde_Z1_full[F] * beta_full[F] / kappa[F]
Atilde_Beta_over_Kappa_Z2_full[F] = Atilde_Z2_full[F] * beta_full[F] / kappa[F]
beta_all_full = np.concatenate( [beta_full[2], [np.nan], beta_full[1], [np.nan], beta_full[0]] )
beta_all_arg_full = np.concatenate( [np.rad2deg(np.unwrap(np.angle(beta_full[2]))), [np.nan],
np.rad2deg(np.unwrap(np.angle(beta_full[1]))), [np.nan],
np.rad2deg(np.unwrap(np.angle(beta_full[0])))] )
fig, axarr = plt.subplots(2, 1, squeeze=True, figsize=(9,5), sharex=True, sharey=False)
plt.subplots_adjust(hspace=0.0)
axarr[0].set_title(r'beta = $(TF_{ANT} \times TF_{BIAS} \times TF_{LFR}^{BIAS})^{-1}$ reduced grid', fontsize=14)
axarr[0].plot(freq_all_redu, beta_all_redu.real, label='RE', color=None, linewidth=2)
axarr[0].set_ylim([None, None])
axarr[0].set_ylabel('V/m / count', fontsize=None)
axarr[0].semilogx()
axarr[0].plot(freq_all_redu, beta_all_redu.imag, label='IM', color=None, linewidth=2)
axarr[0].legend(loc='best')
axarr[1].plot(freq_all_redu, abs(beta_all_redu), label='ABS', color='k', linewidth=2)
#axarr[1].set_ylim([None, None])
axarr[1].set_ylabel('V/m / count', fontsize=None)
axarr[1].semilogy([None, None])
axarr[1].legend(loc='best')
axarr[1].legend(loc='upper center')
axarr[1].set_xlabel('Frequency (Hz)', fontsize=12)
ax2 = axarr[1].twinx()
ax2.plot(freq_all_redu, beta_all_arg_redu, label='ARG', color='C3', linewidth=2)
ax2.set_ylabel('degree', fontsize=None)
ax2.legend(loc='lower right')
fname = dir_plots+ '/kcoefficients-beta-redu_FSW_%s_%s_or_%s_R=%s-%s-%s.png'%(fsw, bias_conf[0].upper(),
bias_conf[1].upper(), *r_conf)
plt.savefig(fname, bbox_inches='tight', pad_inches=0.2)
fig, axarr = plt.subplots(2, 1, squeeze=True, figsize=(9,5), sharex=True, sharey=False)
plt.subplots_adjust(hspace=0.0)
axarr[0].set_title(r'beta = $(TF_{ANT} \times TF_{BIAS} \times TF_{LFR}^{BIAS})^{-1}$ full grid', fontsize=14)
axarr[0].plot(freq_all_full, beta_all_full.real, label='RE', color=None, linewidth=2)
axarr[0].set_ylim([None, None])
axarr[0].set_ylabel('V/m / count', fontsize=None)
axarr[0].semilogx()
axarr[0].plot(freq_all_full, beta_all_full.imag, label='IM', color=None, linewidth=2)
axarr[0].legend(loc='best')
axarr[1].plot(freq_all_full, abs(beta_all_full), label='ABS', color='k', linewidth=2)
#axarr[1].set_ylim([None, None])
axarr[1].set_ylabel('V/m / count', fontsize=None)
axarr[1].semilogy([None, None])
axarr[1].legend(loc='best')
axarr[1].legend(loc='upper center')
axarr[1].set_xlabel('Frequency (Hz)', fontsize=12)
ax2 = axarr[1].twinx()
ax2.plot(freq_all_full, beta_all_arg_full, label='ARG', color='C3', linewidth=2)
ax2.set_ylabel('degree', fontsize=None)
ax2.legend(loc='lower right')
fname = dir_plots+ '/kcoefficients-beta-full_FSW_%s_%s_or_%s_R=%s-%s-%s.png'%(fsw, bias_conf[0].upper(),
bias_conf[1].upper(), *r_conf)
plt.savefig(fname, bbox_inches='tight', pad_inches=0.2)
kcoeff_list_redu = (Atilde_Beta_over_Kappa_Y1_redu, Atilde_Beta_over_Kappa_Y2_redu,
Atilde_Beta_over_Kappa_Z1_redu, Atilde_Beta_over_Kappa_Z2_redu)
kname_list_redu = ['Atilde_Beta_over_Kappa_%s%s_redu'%(i,j) for i in ['Y', 'Z'] for j in [1,2]]
title_list_redu = ['Atilde_Beta_over_Kappa_%s%s_redu'%(i,j) + \
r' = $\left[ \,\beta / \kappa \times \tilde{\mathbf{A}}_\mathit{SRF-ANT} '+ \
r'\right]_{i\!=\!%s, j\!=\!%s}$'%(i,j) for i in ['Y', 'Z'] for j in [1,2]]
fname_list_redu = [dir_plots+ '/kcoefficients_%s_FSW_%s_%s_or_%s_R=%s-%s-%s_kappa=%.e.png'%(kname_list_redu[i],
fsw, bias_conf[0].upper(), bias_conf[1].upper(),
*r_conf, kappa[0]) for i in range(len(kname_list_redu))]
for (kname, kcoeff, title, fname) in zip(kname_list_redu, kcoeff_list_redu, title_list_redu, fname_list_redu):
plot_kcoeff(kname, freq_cal_redu, kcoeff, figsize=(9,5), title=title, ylabel='V/m / nT',
fname=fname, no_ishow=True, close=True)
# plot_kcoeff(kname, freq_cal_redu, kcoeff, figsize=(9,5), title=title, ylabel='V/m / nT',
# fname=fname, no_ishow=False, close=False)
kcoeff_list_full = (Atilde_Beta_over_Kappa_Y1_full, Atilde_Beta_over_Kappa_Y2_full,
Atilde_Beta_over_Kappa_Z1_full, Atilde_Beta_over_Kappa_Z2_full)
kname_list_full = ['Atilde_Beta_over_Kappa_%s%s_full'%(i,j) for i in ['Y', 'Z'] for j in [1,2]]
title_list_full = ['Atilde_Beta_over_Kappa_%s%s_full'%(i,j) + \
r' = $\left[ \,\beta / \kappa \times \tilde{\mathbf{A}}_\mathit{SRF-ANT} '+ \
r'\right]_{i\!=\!%s, j\!=\!%s}$'%(i,j) for i in ['Y', 'Z'] for j in [1,2]]
fname_list_full = [dir_plots+ '/kcoefficients_%s_FSW_%s_%s_or_%s_R=%s-%s-%s_kappa=%.e.png'%(kname_list_full[i],
fsw, bias_conf[0].upper(), bias_conf[1].upper(),
*r_conf, kappa[0]) for i in range(len(kname_list_full))]
for (kname, kcoeff, title, fname) in zip(kname_list_full, kcoeff_list_full, title_list_full, fname_list_full):
plot_kcoeff(kname, freq_cal_full, kcoeff, figsize=(9,5), title=title, ylabel='V/m / nT',
fname=fname, no_ishow=True, close=True)
# plot_kcoeff(kname, freq_cal_full, kcoeff, figsize=(9,5), title=title, ylabel='V/m / nT',
# fname=fname, no_ishow=False, close=False)
for F in [0,1,2]:
for ifreq in range(len(freq_cal_redu[F])-1):
k_coefficients[F][ifreq, icoeff["Mtilde_X1_RE"]] = Mtilde_Alpha_over_Kappa_X1_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Mtilde_X1_IM"]] = Mtilde_Alpha_over_Kappa_X1_redu[F][ifreq].imag
k_coefficients[F][ifreq, icoeff["Mtilde_X2_RE"]] = Mtilde_Alpha_over_Kappa_X2_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Mtilde_X2_IM"]] = Mtilde_Alpha_over_Kappa_X2_redu[F][ifreq].imag
k_coefficients[F][ifreq, icoeff["Mtilde_X3_RE"]] = Mtilde_Alpha_over_Kappa_X3_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Mtilde_X3_IM"]] = Mtilde_Alpha_over_Kappa_X3_redu[F][ifreq].imag
k_coefficients[F][ifreq, icoeff["Mtilde_Y1_RE"]] = Mtilde_Alpha_over_Kappa_Y1_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Mtilde_Y1_IM"]] = Mtilde_Alpha_over_Kappa_Y1_redu[F][ifreq].imag
k_coefficients[F][ifreq, icoeff["Mtilde_Y2_RE"]] = Mtilde_Alpha_over_Kappa_Y2_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Mtilde_Y2_IM"]] = Mtilde_Alpha_over_Kappa_Y2_redu[F][ifreq].imag
k_coefficients[F][ifreq, icoeff["Mtilde_Y3_RE"]] = Mtilde_Alpha_over_Kappa_Y3_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Mtilde_Y3_IM"]] = Mtilde_Alpha_over_Kappa_Y3_redu[F][ifreq].imag
k_coefficients[F][ifreq, icoeff["Mtilde_Z1_RE"]] = Mtilde_Alpha_over_Kappa_Z1_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Mtilde_Z1_IM"]] = Mtilde_Alpha_over_Kappa_Z1_redu[F][ifreq].imag
k_coefficients[F][ifreq, icoeff["Mtilde_Z2_RE"]] = Mtilde_Alpha_over_Kappa_Z2_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Mtilde_Z2_IM"]] = Mtilde_Alpha_over_Kappa_Z2_redu[F][ifreq].imag
k_coefficients[F][ifreq, icoeff["Mtilde_Z3_RE"]] = Mtilde_Alpha_over_Kappa_Z3_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Mtilde_Z3_IM"]] = Mtilde_Alpha_over_Kappa_Z3_redu[F][ifreq].imag
k_coefficients[F][ifreq, icoeff["Atilde_Y1_RE"]] = Atilde_Beta_over_Kappa_Y1_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Atilde_Y1_IM"]] = Atilde_Beta_over_Kappa_Y1_redu[F][ifreq].imag
k_coefficients[F][ifreq, icoeff["Atilde_Y2_RE"]] = Atilde_Beta_over_Kappa_Y2_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Atilde_Y2_IM"]] = Atilde_Beta_over_Kappa_Y2_redu[F][ifreq].imag
k_coefficients[F][ifreq, icoeff["Atilde_Z1_RE"]] = Atilde_Beta_over_Kappa_Z1_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Atilde_Z1_IM"]] = Atilde_Beta_over_Kappa_Z1_redu[F][ifreq].imag
k_coefficients[F][ifreq, icoeff["Atilde_Z2_RE"]] = Atilde_Beta_over_Kappa_Z2_redu[F][ifreq].real
k_coefficients[F][ifreq, icoeff["Atilde_Z2_IM"]] = Atilde_Beta_over_Kappa_Z2_redu[F][ifreq].imag
ifreq = -1
k_coefficients[F][0, icoeff["free_1"]] = Mtilde_Alpha_over_Kappa_X1_redu[F][ifreq].real
k_coefficients[F][0, icoeff["free_2"]] = Mtilde_Alpha_over_Kappa_X1_redu[F][ifreq].imag
k_coefficients[F][0, icoeff["free_3"]] = Mtilde_Alpha_over_Kappa_X2_redu[F][ifreq].real
k_coefficients[F][0, icoeff["free_4"]] = Mtilde_Alpha_over_Kappa_X2_redu[F][ifreq].imag
k_coefficients[F][0, icoeff["free_5"]] = Mtilde_Alpha_over_Kappa_X3_redu[F][ifreq].real
k_coefficients[F][0, icoeff["free_6"]] = Mtilde_Alpha_over_Kappa_X3_redu[F][ifreq].imag
k_coefficients[F][1, icoeff["free_1"]] = Mtilde_Alpha_over_Kappa_Y1_redu[F][ifreq].real
k_coefficients[F][1, icoeff["free_2"]] = Mtilde_Alpha_over_Kappa_Y1_redu[F][ifreq].imag
k_coefficients[F][1, icoeff["free_3"]] = Mtilde_Alpha_over_Kappa_Y2_redu[F][ifreq].real
k_coefficients[F][1, icoeff["free_4"]] = Mtilde_Alpha_over_Kappa_Y2_redu[F][ifreq].imag
k_coefficients[F][1, icoeff["free_5"]] = Mtilde_Alpha_over_Kappa_Y3_redu[F][ifreq].real
k_coefficients[F][1, icoeff["free_6"]] = Mtilde_Alpha_over_Kappa_Y3_redu[F][ifreq].imag
k_coefficients[F][2, icoeff["free_1"]] = Mtilde_Alpha_over_Kappa_Z1_redu[F][ifreq].real
k_coefficients[F][2, icoeff["free_2"]] = Mtilde_Alpha_over_Kappa_Z1_redu[F][ifreq].imag
k_coefficients[F][2, icoeff["free_3"]] = Mtilde_Alpha_over_Kappa_Z2_redu[F][ifreq].real
k_coefficients[F][2, icoeff["free_4"]] = Mtilde_Alpha_over_Kappa_Z2_redu[F][ifreq].imag
k_coefficients[F][2, icoeff["free_5"]] = Mtilde_Alpha_over_Kappa_Z3_redu[F][ifreq].real
k_coefficients[F][2, icoeff["free_6"]] = Mtilde_Alpha_over_Kappa_Z3_redu[F][ifreq].imag
k_coefficients[F][3, icoeff["free_1"]] = Atilde_Beta_over_Kappa_Y1_redu[F][ifreq].real
k_coefficients[F][3, icoeff["free_2"]] = Atilde_Beta_over_Kappa_Y1_redu[F][ifreq].imag
k_coefficients[F][3, icoeff["free_3"]] = Atilde_Beta_over_Kappa_Y2_redu[F][ifreq].real
k_coefficients[F][3, icoeff["free_4"]] = Atilde_Beta_over_Kappa_Y2_redu[F][ifreq].imag
k_coefficients[F][4, icoeff["free_1"]] = Atilde_Beta_over_Kappa_Z1_redu[F][ifreq].real
k_coefficients[F][4, icoeff["free_2"]] = Atilde_Beta_over_Kappa_Z1_redu[F][ifreq].imag
k_coefficients[F][4, icoeff["free_3"]] = Atilde_Beta_over_Kappa_Z2_redu[F][ifreq].real
k_coefficients[F][4, icoeff["free_4"]] = Atilde_Beta_over_Kappa_Z2_redu[F][ifreq].imag
test_Bruno = True
if test_Bruno:
for F in [0,1,2]:
for ifreq in range(len(freq_cal_redu[F])-1):
k_coefficients[F][ifreq, icoeff["Mtilde_X1_RE"]] = 1.
k_coefficients[F][ifreq, icoeff["Mtilde_X1_IM"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_X2_RE"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_X2_IM"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_X3_RE"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_X3_IM"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_Y1_RE"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_Y1_IM"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_Y2_RE"]] = 1.
k_coefficients[F][ifreq, icoeff["Mtilde_Y2_IM"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_Y3_RE"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_Y3_IM"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_Z1_RE"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_Z1_IM"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_Z2_RE"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_Z2_IM"]] = 0.
k_coefficients[F][ifreq, icoeff["Mtilde_Z3_RE"]] = 1.
k_coefficients[F][ifreq, icoeff["Mtilde_Z3_IM"]] = 0.
k_coefficients[F][ifreq, icoeff["Atilde_Y1_RE"]] = 1.
k_coefficients[F][ifreq, icoeff["Atilde_Y1_IM"]] = 0.
k_coefficients[F][ifreq, icoeff["Atilde_Y2_RE"]] = 0.
k_coefficients[F][ifreq, icoeff["Atilde_Y2_IM"]] = 0.
k_coefficients[F][ifreq, icoeff["Atilde_Z1_RE"]] = 0.
k_coefficients[F][ifreq, icoeff["Atilde_Z1_IM"]] = 0.
k_coefficients[F][ifreq, icoeff["Atilde_Z2_RE"]] = 1.
k_coefficients[F][ifreq, icoeff["Atilde_Z2_IM"]] = 0.
ifreq = -1
k_coefficients[F][0, icoeff["free_1"]] = 1.
k_coefficients[F][0, icoeff["free_2"]] = 0.
k_coefficients[F][0, icoeff["free_3"]] = 0.
k_coefficients[F][0, icoeff["free_4"]] = 0.
k_coefficients[F][0, icoeff["free_5"]] = 0.
k_coefficients[F][0, icoeff["free_6"]] = 0.
k_coefficients[F][1, icoeff["free_1"]] = 0.
k_coefficients[F][1, icoeff["free_2"]] = 0.
k_coefficients[F][1, icoeff["free_3"]] = 1.
k_coefficients[F][1, icoeff["free_4"]] = 0.
k_coefficients[F][1, icoeff["free_5"]] = 0.
k_coefficients[F][1, icoeff["free_6"]] = 0.
k_coefficients[F][2, icoeff["free_1"]] = 0.
k_coefficients[F][2, icoeff["free_2"]] = 0.
k_coefficients[F][2, icoeff["free_3"]] = 0.
k_coefficients[F][2, icoeff["free_4"]] = 0.
k_coefficients[F][2, icoeff["free_5"]] = 1.
k_coefficients[F][2, icoeff["free_6"]] = 0.
k_coefficients[F][3, icoeff["free_1"]] = 1.
k_coefficients[F][3, icoeff["free_2"]] = 0.
k_coefficients[F][3, icoeff["free_3"]] = 0.
k_coefficients[F][3, icoeff["free_4"]] = 0.
k_coefficients[F][4, icoeff["free_1"]] = 0.
k_coefficients[F][4, icoeff["free_2"]] = 0.
k_coefficients[F][4, icoeff["free_3"]] = 1.
k_coefficients[F][4, icoeff["free_4"]] = 0.
time_struc = localtime(time())
date = '{:4}-{:02}-{:02}'.format(time_struc.tm_year, time_struc.tm_mon, time_struc.tm_mday)
if test_Bruno:
fname = dir_storage + '/kcoefficients_FSW_%s_test1_'%(fsw) + date
else:
fname = dir_storage + '/kcoefficients_FSW_%s_%s_or_%s_R=%s-%s-%s_kappa=%.e_'%(fsw, bias_conf[0].upper(),
bias_conf[1].upper(),
*r_conf, kappa[0]) + date
header = 'Adapted for LFR FSW: ' + fsw
header += '\nBIAS calibration file used: ' + os.path.basename(cdffile_BIAS_TF)
header += '\nSCM calibration file used: ' + os.path.basename(cdffile_SCM_TF)
header += '\nLFR BIAS calibration file used: ' + os.path.basename(cdffile_LFR_TF_E)
header += '\nLFR SCM calibration file used: ' + os.path.basename(cdffile_LFR_TF_B)
header += '\nBIAS analogue signals used: ' + bias_conf[0].upper() + ' or ' + bias_conf[1].upper()
header += '\nLFR electric signals used: R0={:d}, R1={:d}, R2={:d}'.format(*r_conf)
header += '\nConstant kappa used: k0={:.2e}, k1={:.2e}, k2={:.2e}'.format(*kappa)
header += '\ndate: ' + date
header += '\nkcoeff_frequency kcoeff_frequency'
for i in range(1,32+1,1):
header += '{:>14s}'.format('kcoeff_' + str(i))
header += '\n (index) (Hz)' + 32*' (float)'
fmt = ['%18d','%17.2f'] + 32*['%+13.6e']
save2Dtxt(np.arange(0,11+13+12,1), np.concatenate(freq_cal_sent), np.concatenate(k_coefficients).T,
fname=fname+'.txt', fmt=fmt, header=header, T=False, delimiter=' ')
header = 'kcoeff_frequency;kcoeff_frequency'
for i in range(1,32+1,1):
header += '{:s}'.format(';kcoeff_' + str(i))
header += '\n(index);(Hz)' + 32*';(float)'
fmt = ['%d','%.2f'] + 32*['%+.6e']
save2Dtxt(np.arange(0,11+13+12,1), np.concatenate(freq_cal_sent), np.concatenate(k_coefficients).T,
fname=fname+'.csv', fmt=fmt, header=header, T=False, delimiter=';', comments='')
36*32*4
# full set of ASM calibration coefficients to be used onboard by default
freq_cal_alexis = 3*[None]
B_cal_alexis = 3*[None]
E_cal_alexis = 3*[None]
for F in [0, 1, 2]:
freq_cal_alexis[F] = np.zeros(128)
B_cal_alexis[F] = np.zeros([128, 3, 3], dtype=complex)
E_cal_alexis[F] = np.zeros([128, 2, 2], dtype=complex)
# in the VHDL code one starts at 1*df and not at 0 Hz as for the L1 CDF ASM data
i0 = [17-1, 6-1, 7-1][F]
nfreq = len(freq_cal_full[F])
freq_cal_alexis[F][i0:i0+nfreq] = freq_cal_full[F]
B_cal_alexis[F][i0:i0+nfreq, 0, 0] = Mtilde_Alpha_over_Kappa_X1_full[F]
B_cal_alexis[F][i0:i0+nfreq, 0, 1] = Mtilde_Alpha_over_Kappa_X2_full[F]
B_cal_alexis[F][i0:i0+nfreq, 0, 2] = Mtilde_Alpha_over_Kappa_X3_full[F]
B_cal_alexis[F][i0:i0+nfreq, 1, 0] = Mtilde_Alpha_over_Kappa_Y1_full[F]
B_cal_alexis[F][i0:i0+nfreq, 1, 1] = Mtilde_Alpha_over_Kappa_Y2_full[F]
B_cal_alexis[F][i0:i0+nfreq, 1, 2] = Mtilde_Alpha_over_Kappa_Y3_full[F]
B_cal_alexis[F][i0:i0+nfreq, 2, 0] = Mtilde_Alpha_over_Kappa_Z1_full[F]
B_cal_alexis[F][i0:i0+nfreq, 2, 1] = Mtilde_Alpha_over_Kappa_Z2_full[F]
B_cal_alexis[F][i0:i0+nfreq, 2, 2] = Mtilde_Alpha_over_Kappa_Z3_full[F]
E_cal_alexis[F][i0:i0+nfreq, 0, 0] = Atilde_Beta_over_Kappa_Y1_full[F]
E_cal_alexis[F][i0:i0+nfreq, 0, 1] = Atilde_Beta_over_Kappa_Y2_full[F]
E_cal_alexis[F][i0:i0+nfreq, 1, 0] = Atilde_Beta_over_Kappa_Z1_full[F]
E_cal_alexis[F][i0:i0+nfreq, 1, 1] = Atilde_Beta_over_Kappa_Z2_full[F]
fname = dir_storage + '/ASM_calibration_default-full-tables' + \
'_FSW_%s_%s_or_%s_R=%s-%s-%s_kappa=%.e_'%(fsw, bias_conf[0].upper(),
bias_conf[1].upper(),
*r_conf, kappa[0]) + date +'.json'
save2json([freq_cal_alexis, B_cal_alexis, E_cal_alexis], fname)
# [freq_cal, B_cal, E_cal] = json2data(fname)
(37 - (1 << 6)) + 1
(1 << 6)