##// END OF EJS Templates
version 2.5: mise en conformité LOGISCOPE + déclarations extern pour les utilities
chust -
r22:29f7f58cbebc TCH draft
parent child
Show More
@@ -0,0 +1,165
1 Hello World!
2
3 The multi-byte quantities are laid out in a LSB FIRST (little endian) fashion
4
5 Compressed_spectral_matrix_f0 :
6 Number of bins: 1
7 Number of values per spectral matrix: 25
8 Size of compressed_spectral_matrix_f0 : 100
9
10 Bin number: 0
11 Element 01 (S11) (00 & --) => Re: 4.00109575e+06 Im: 0.00000000e+00
12 Element 02 (S12) (01 & 02) => Re: -2.19891187e+03 Im: 1.73193325e+06
13 Element 03 (S13) (03 & 04) => Re: 1.88106079e+03 Im: -1.00001638e+06
14 Element 04 (S14) (05 & 06) => Re: 6.23724854e+02 Im: 2.00016860e+07
15 Element 05 (S15) (07 & 08) => Re: -3.46422920e+07 Im: -1.44333826e+03
16 Element 06 (S22) (09 & --) => Re: 7.54424812e+05 Im: 0.00000000e+00
17 Element 07 (S23) (10 & 11) => Re: -4.36785375e+05 Im: 2.34538879e+02
18 Element 08 (S24) (12 & 13) => Re: 8.65882200e+06 Im: -3.31611108e+03
19 Element 09 (S25) (14 & 15) => Re: 2.71719702e+03 Im: 1.50027590e+07
20 Element 10 (S33) (16 & --) => Re: 2.53229094e+05 Im: 0.00000000e+00
21 Element 11 (S34) (17 & 18) => Re: -4.99895450e+06 Im: 2.90329712e+03
22 Element 12 (S35) (19 & 20) => Re: -2.17048022e+03 Im: -8.66275100e+06
23 Element 13 (S44) (21 & --) => Re: 1.00002952e+08 Im: 0.00000000e+00
24 Element 14 (S45) (22 & 23) => Re: -2.94739111e+03 Im: 1.73206224e+08
25 Element 15 (S55) (24 & --) => Re: 3.00003392e+08 Im: 0.00000000e+00
26
27 F0 data: initialization of the intercalibration k-coefficients
28 F1 data: initialization of the intercalibration k-coefficients
29 F2 data: initialization of the intercalibration k-coefficients
30
31
32 BP1 :
33 Number of bins: 1
34 nbitexp : 6, expmax : 37, expmin : -26
35 nbitsig : 10, rangesig : 1023
36
37 Bin number: 0
38 PSDB : 5.00874950e+06
39 significand : 5.97089469e-01
40 exponent : 23
41 psd for PSDB significand : 199
42 exp for PSDB exponent : 49
43 pt_uint8[1] for PSDB exponent + significand: 196 or c4
44 pt_uint8[0] for PSDB significand: 199 or c7
45 lfr_bp1[i*NB_BYTES_BP1+2] : 196 or c4
46 lfr_bp1[i*NB_BYTES_BP1+3] : 199 or c7
47 PSDE : 2.26797168e+08
48 significand : 8.44885290e-01
49 exponent : 28
50 psd for PSDE significand : 706
51 exp for PSDE exponent : 54
52 pt_uint8[1] for PSDE exponent + significand: 218 or da
53 pt_uint8[0] for PSDE significand: 194 or c2
54 lfr_bp1[i*NB_BYTES_BP1+0] : 218 or da
55 lfr_bp1[i*NB_BYTES_BP1+1] : 194 or c2
56 NVEC_V0 : 1.17274933e-04
57 NVEC_V1 : 5.00031590e-01
58 NVEC_V2 : 8.66007149e-01
59 lfr_bp1[i*NB_BYTES_BP1+4] for NVEC_V0 : 128
60 lfr_bp1[i*NB_BYTES_BP1+5] for NVEC_V1 : 191
61 lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 : 0
62 ellipticity : 7.98565149e-01
63 tmp_uint8 for ellipticity : 12
64 lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity : 96
65 DOP : 9.96131897e-01
66 tmp_uint8 for DOP : 7
67 lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity + DOP : 103
68 ReaSX : -4.64141500e+06
69 |ReaSX| : 4.64141500e+06
70 significand : 5.53299785e-01
71 exponent : 23
72 tmp_uint8 for ReaSX exponent : 49
73 lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX sign + RealSX exponent : 177
74 lfr_bp1[i*NB_BYTES_BP1+8] for ReaSX significand : 27
75 ImaSX : -5.73210880e+07
76 |ImaSX| : 5.73210880e+07
77 ArgSX sign : 64
78 lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX & ArgSX signs + ReaSX exponent : 241
79 n_cross_e_scal_b_re : 9.66053400e+06
80 n_cross_e_scal_b_im : -2.58822900e+06
81 |VPHI| : 1.02704735e+01
82 significand : 6.41904593e-01
83 exponent : 4
84 tmp_uint8 for VPHI exponent : 30
85 lfr_bp1[i*NB_BYTES_BP1+9] for VPHI sign + VPHI exponent : 30
86 lfr_bp1[i*NB_BYTES_BP1+10] for VPHI significand : 72
87 |n_cross_e_scal_b_im| : 2.58822900e+06
88 |n_cross_e_scal_b_im|/bx_bx_star : 2.75164270e+00
89 ArgNEBX sign : 0
90 lfr_bp1[i*NB_BYTES_BP1+9] for VPHI & ArgNEBX signs + VPHI exponent : 30
91
92 BP2 :
93 Number of bins: 1
94 nbitexp : 6, expmax : 37, expmin : -26
95 nbitsig : 10, rangesig : 1023
96
97 Bin number: 0
98 lfr_bp2[i*NB_BYTES_BP2+10] for cross12_re ( -1.26564049e-03) : 127
99 lfr_bp2[i*NB_BYTES_BP2+20] for cross12_im ( 9.96858895e-01) : 255
100 lfr_bp2[i*NB_BYTES_BP2+11] for cross13_re ( 1.86877302e-03) : 128
101 lfr_bp2[i*NB_BYTES_BP2+21] for cross13_im ( -9.93483901e-01) : 001
102 lfr_bp2[i*NB_BYTES_BP2+12] for cross14_re ( 3.11815129e-05) : 128
103 lfr_bp2[i*NB_BYTES_BP2+22] for cross14_im ( 9.99932587e-01) : 255
104 lfr_bp2[i*NB_BYTES_BP2+13] for cross15_re ( -9.99894261e-01) : 000
105 lfr_bp2[i*NB_BYTES_BP2+23] for cross15_im ( -4.16596449e-05) : 127
106 lfr_bp2[i*NB_BYTES_BP2+14] for cross23_re ( -9.99317050e-01) : 000
107 lfr_bp2[i*NB_BYTES_BP2+24] for cross23_im ( 5.36599255e-04) : 128
108 lfr_bp2[i*NB_BYTES_BP2+15] for cross24_re ( 9.96883571e-01) : 255
109 lfr_bp2[i*NB_BYTES_BP2+25] for cross24_im ( -3.81781341e-04) : 127
110 lfr_bp2[i*NB_BYTES_BP2+16] for cross25_re ( 1.80613439e-04) : 128
111 lfr_bp2[i*NB_BYTES_BP2+26] for cross25_im ( 9.97240901e-01) : 255
112 lfr_bp2[i*NB_BYTES_BP2+17] for cross34_re ( -9.93381321e-01) : 001
113 lfr_bp2[i*NB_BYTES_BP2+27] for cross34_im ( 5.76936873e-04) : 128
114 lfr_bp2[i*NB_BYTES_BP2+18] for cross35_re ( -2.49020959e-04) : 127
115 lfr_bp2[i*NB_BYTES_BP2+28] for cross35_im ( -9.93884504e-01) : 001
116 lfr_bp2[i*NB_BYTES_BP2+19] for cross45_re ( -1.70164221e-05) : 127
117 lfr_bp2[i*NB_BYTES_BP2+29] for cross45_im ( 9.99986172e-01) : 255
118 S11 : 4.00109575e+06
119 significand : 9.53935564e-01
120 exponent : 22
121 autocor for S11 significand : 929
122 exp for S11 exponent : 48
123 pt_uint8[1] for S11 exponent + significand : 195 or c3
124 pt_uint8[0] for S11 significand : 161 or a1
125 lfr_bp2[i*NB_BYTES_BP2+0] : 195 or c3
126 lfr_bp2[i*NB_BYTES_BP2+1] : 161 or a1
127 S22 : 7.54424812e+05
128 significand : 7.19475567e-01
129 exponent : 20
130 autocor for S22 significand : 449
131 exp for S11 exponent : 46
132 pt_uint8[1] for S22 exponent + significand : 185 or b9
133 pt_uint8[0] for S22 significand : 193 or c1
134 lfr_bp2[i*NB_BYTES_BP2+2] : 185 or b9
135 lfr_bp2[i*NB_BYTES_BP2+3] : 193 or c1
136 S33 : 2.53229094e+05
137 significand : 9.65992332e-01
138 exponent : 18
139 autocor for S33 significand : 953
140 exp for S33 exponent : 44
141 pt_uint8[1] for S33 exponent + significand : 179 or b3
142 pt_uint8[0] for S33 significand : 185 or b9
143 lfr_bp2[i*NB_BYTES_BP2+4] : 179 or b3
144 lfr_bp2[i*NB_BYTES_BP2+5] : 185 or b9
145 S44 : 1.00002952e+08
146 significand : 7.45080054e-01
147 exponent : 27
148 autocor for S44 significand : 501
149 exp for S44 exponent : 53
150 pt_uint8[1] for S44 exponent + significand : 213 or d5
151 pt_uint8[0] for S44 significand : 245 or f5
152 lfr_bp2[i*NB_BYTES_BP2+6] : 213 or d5
153 lfr_bp2[i*NB_BYTES_BP2+7] : 245 or f5
154 S55 : 3.00003392e+08
155 significand : 5.58799863e-01
156 exponent : 29
157 autocor for S55 significand : 120
158 exp for S55 exponent : 55
159 pt_uint8[1] for S55 exponent + significand : 220 or dc
160 pt_uint8[0] for S55 significand : 120 or 78
161 lfr_bp2[i*NB_BYTES_BP2+8] : 220 or dc
162 lfr_bp2[i*NB_BYTES_BP2+9] : 120 or 78
163 Press <RETURN> to close this window...
164
165
@@ -0,0 +1,20
1 TEMPLATE = app
2 CONFIG += console
3 CONFIG -= app_bundle
4 CONFIG -= qt
5
6 DEFINES += DEBUG_TCH
7 DEFINES += LSB_FIRST_TCH # PC convention
8 #DEFINES += MSB_FIRST_TCH # SPARC convention
9
10 SOURCES += main.c \
11 basic_parameters.c \
12 file_utilities.c
13
14 HEADERS += \
15 basic_parameters.h \
16 basic_parameters_params.h \
17 basic_parameters_utilities.h \
18 file_utilities.h
19
20
@@ -13,6 +13,33
13 // version 2.1: 22/06/2015 (modifs de Paul)
13 // version 2.1: 22/06/2015 (modifs de Paul)
14 // version 2.2: 23/06/2015 (modifs de l'ordre de déclaration/définition de init_k_coefficients dans basic_parameters.c ... + maintien des declarations dans le .h)
14 // version 2.2: 23/06/2015 (modifs de l'ordre de déclaration/définition de init_k_coefficients dans basic_parameters.c ... + maintien des declarations dans le .h)
15 // version 2.3: 01/07/2015 (affectation initiale des octets 7 et 9 dans les BP1 corrigée ...)
15 // version 2.3: 01/07/2015 (affectation initiale des octets 7 et 9 dans les BP1 corrigée ...)
16 // version 2.4: 05/10/2018 (added GPL headers)
17 // version 2.5: 09/10/2018 (dans main.c #include "basic_parameters_utilities.h" est changé par les déclarations extern correspondantes ...!
18 // + delta mise en conformité LOGISCOPE)
19
20 /*------------------------------------------------------------------------------
21 -- Solar Orbiter's Low Frequency Receiver Flight Software (LFR FSW),
22 -- This file is a part of the LFR FSW
23 -- Copyright (C) 2012-2018, Plasma Physics Laboratory - CNRS
24 --
25 -- This program is free software; you can redistribute it and/or modify
26 -- it under the terms of the GNU General Public License as published by
27 -- the Free Software Foundation; either version 2 of the License, or
28 -- (at your option) any later version.
29 --
30 -- This program is distributed in the hope that it will be useful,
31 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
32 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 -- GNU General Public License for more details.
34 --
35 -- You should have received a copy of the GNU General Public License
36 -- along with this program; if not, write to the Free Software
37 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 -------------------------------------------------------------------------------*/
39 /*-- Author : Thomas Chust
40 -- Contact : Thomas Chust
41 -- Mail : thomas.chust@lpp.polytechnique.fr
42 ----------------------------------------------------------------------------*/
16
43
17 #include <stdio.h>
44 #include <stdio.h>
18 #include <stdint.h>
45 #include <stdint.h>
@@ -13,6 +13,33
13 // version 2.1: 22/06/2015 (modifs de Paul)
13 // version 2.1: 22/06/2015 (modifs de Paul)
14 // version 2.2: 23/06/2015 (modifs de l'ordre de déclaration/définition de init_k_coefficients dans basic_parameters.c ... + maintien des declarations dans le .h)
14 // version 2.2: 23/06/2015 (modifs de l'ordre de déclaration/définition de init_k_coefficients dans basic_parameters.c ... + maintien des declarations dans le .h)
15 // version 2.3: 01/07/2015 (affectation initiale des octets 7 et 9 dans les BP1 corrigée ...)
15 // version 2.3: 01/07/2015 (affectation initiale des octets 7 et 9 dans les BP1 corrigée ...)
16 // version 2.4: 05/10/2018 (mise en conformité LOGISCOPE)
17 // version 2.5: 09/10/2018 (dans main.c #include "basic_parameters_utilities.h" est changé par les déclarations extern correspondantes ...!
18 // + delta mise en conformité LOGISCOPE)
19
20 /*------------------------------------------------------------------------------
21 -- Solar Orbiter's Low Frequency Receiver Flight Software (LFR FSW),
22 -- This file is a part of the LFR FSW
23 -- Copyright (C) 2012-2018, Plasma Physics Laboratory - CNRS
24 --
25 -- This program is free software; you can redistribute it and/or modify
26 -- it under the terms of the GNU General Public License as published by
27 -- the Free Software Foundation; either version 2 of the License, or
28 -- (at your option) any later version.
29 --
30 -- This program is distributed in the hope that it will be useful,
31 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
32 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 -- GNU General Public License for more details.
34 --
35 -- You should have received a copy of the GNU General Public License
36 -- along with this program; if not, write to the Free Software
37 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 -------------------------------------------------------------------------------*/
39 /*-- Author : Thomas Chust
40 -- Contact : Thomas Chust
41 -- Mail : thomas.chust@lpp.polytechnique.fr
42 ----------------------------------------------------------------------------*/
16
43
17 #ifndef BASIC_PARAMETERS_H_INCLUDED
44 #ifndef BASIC_PARAMETERS_H_INCLUDED
18 #define BASIC_PARAMETERS_H_INCLUDED
45 #define BASIC_PARAMETERS_H_INCLUDED
@@ -78,7 +105,7 void BP1_set( float * compressed_spec_ma
78 // initialization for managing the exponents of the floating point data:
105 // initialization for managing the exponents of the floating point data:
79 nbitexp = 6; // number of bits for the exponent
106 nbitexp = 6; // number of bits for the exponent
80 expmax = 32+5; // maximum value of the exponent
107 expmax = 32+5; // maximum value of the exponent
81 expmin = expmax - (1 << nbitexp) + 1; // accordingly the minimum exponent value
108 expmin = (expmax - (1 << nbitexp)) + 1; // accordingly the minimum exponent value
82 // for floating point data to be recorded on 16-bit words:
109 // for floating point data to be recorded on 16-bit words:
83 nbitsig = 16 - nbitexp; // number of bits for the significand
110 nbitsig = 16 - nbitexp; // number of bits for the significand
84 rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
111 rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
@@ -92,8 +119,8 void BP1_set( float * compressed_spec_ma
92 //==============================================
119 //==============================================
93 // BP1 PSDB == PA_LFR_SC_BP1_PB_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand)
120 // BP1 PSDB == PA_LFR_SC_BP1_PB_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand)
94 PSDB = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] // S11
121 PSDB = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] // S11
95 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] // S22
122 + compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 9] // S22
96 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]; // S33
123 + compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 16]; // S33
97
124
98 significand = frexpf(PSDB, &exponent); // 0.5 <= significand < 1
125 significand = frexpf(PSDB, &exponent); // 0.5 <= significand < 1
99 // PSDB = significand * 2^exponent
126 // PSDB = significand * 2^exponent
@@ -111,7 +138,7 void BP1_set( float * compressed_spec_ma
111 significand = 0.5; // min value that can be recorded
138 significand = 0.5; // min value that can be recorded
112 }
139 }
113
140
114 psd = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
141 psd = (uint16_t) ((((significand*2) - 1)*rangesig) + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
115 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
142 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
116 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
143 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
117 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
144 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
@@ -120,12 +147,12 void BP1_set( float * compressed_spec_ma
120 // making the 16-bit word to be recorded
147 // making the 16-bit word to be recorded
121 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
148 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
122 #ifdef MSB_FIRST_TCH
149 #ifdef MSB_FIRST_TCH
123 lfr_bp1[i*NB_BYTES_BP1+2] = pt_uint8[0]; // Record MSB of tmp_uint16
150 lfr_bp1[(i*NB_BYTES_BP1)+2] = pt_uint8[0]; // Record MSB of tmp_uint16
124 lfr_bp1[i*NB_BYTES_BP1+3] = pt_uint8[1]; // Record LSB of tmp_uint16
151 lfr_bp1[(i*NB_BYTES_BP1)+3] = pt_uint8[1]; // Record LSB of tmp_uint16
125 #endif
152 #endif
126 #ifdef LSB_FIRST_TCH
153 #ifdef LSB_FIRST_TCH
127 lfr_bp1[i*NB_BYTES_BP1+2] = pt_uint8[1]; // Record MSB of tmp_uint16
154 lfr_bp1[(i*NB_BYTES_BP1)+2] = pt_uint8[1]; // Record MSB of tmp_uint16
128 lfr_bp1[i*NB_BYTES_BP1+3] = pt_uint8[0]; // Record LSB of tmp_uint16
155 lfr_bp1[(i*NB_BYTES_BP1)+3] = pt_uint8[0]; // Record LSB of tmp_uint16
129 #endif
156 #endif
130 #ifdef DEBUG_TCH
157 #ifdef DEBUG_TCH
131 printf("\nBin number: %d\n", i);
158 printf("\nBin number: %d\n", i);
@@ -141,10 +168,10 void BP1_set( float * compressed_spec_ma
141 #endif
168 #endif
142 //==============================================
169 //==============================================
143 // BP1 PSDE == PA_LFR_SC_BP1_PE_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand)
170 // BP1 PSDE == PA_LFR_SC_BP1_PE_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand)
144 PSDE = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K44_PE] // S44
171 PSDE = (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 21] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K44_PE]) // S44
145 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K55_PE] // S55
172 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 24] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K55_PE]) // S55
146 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+22] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K45_PE_RE] // S45 Re
173 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 22] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K45_PE_RE]) // S45 Re
147 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+23] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K45_PE_IM]; // S45 Im
174 - (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 23] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K45_PE_IM]); // S45 Im
148
175
149 significand = frexpf(PSDE, &exponent); // 0.5 <= significand < 1
176 significand = frexpf(PSDE, &exponent); // 0.5 <= significand < 1
150 // PSDE = significand * 2^exponent
177 // PSDE = significand * 2^exponent
@@ -162,7 +189,7 void BP1_set( float * compressed_spec_ma
162 significand = 0.5; // min value that can be recorded
189 significand = 0.5; // min value that can be recorded
163 }
190 }
164
191
165 psd = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
192 psd = (uint16_t) ((((significand*2)-1)*rangesig) + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
166 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
193 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
167 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
194 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
168 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
195 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
@@ -171,12 +198,12 void BP1_set( float * compressed_spec_ma
171 // making the 16-bit word to be recorded
198 // making the 16-bit word to be recorded
172 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
199 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
173 #ifdef MSB_FIRST_TCH
200 #ifdef MSB_FIRST_TCH
174 lfr_bp1[i*NB_BYTES_BP1+0] = pt_uint8[0]; // Record MSB of tmp_uint16
201 lfr_bp1[(i*NB_BYTES_BP1) + 0] = pt_uint8[0]; // Record MSB of tmp_uint16
175 lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[1]; // Record LSB of tmp_uint16
202 lfr_bp1[(i*NB_BYTES_BP1) + 1] = pt_uint8[1]; // Record LSB of tmp_uint16
176 #endif
203 #endif
177 #ifdef LSB_FIRST_TCH
204 #ifdef LSB_FIRST_TCH
178 lfr_bp1[i*NB_BYTES_BP1+0] = pt_uint8[1]; // Record MSB of tmp_uint16
205 lfr_bp1[(i*NB_BYTES_BP1) + 0] = pt_uint8[1]; // Record MSB of tmp_uint16
179 lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[0]; // Record LSB of tmp_uint16
206 lfr_bp1[(i*NB_BYTES_BP1) + 1] = pt_uint8[0]; // Record LSB of tmp_uint16
180 #endif
207 #endif
181 #ifdef DEBUG_TCH
208 #ifdef DEBUG_TCH
182 printf("PSDE : %16.8e\n",PSDE);
209 printf("PSDE : %16.8e\n",PSDE);
@@ -193,14 +220,14 void BP1_set( float * compressed_spec_ma
193 // BP1 normal wave vector == PA_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
220 // BP1 normal wave vector == PA_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
194 // == PA_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
221 // == PA_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
195 // == PA_LFR_SC_BP1_NVEC_V2_F0 == 1 sign bit
222 // == PA_LFR_SC_BP1_NVEC_V2_F0 == 1 sign bit
196 tmp = sqrt( compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] //Im S12
223 tmp = sqrt( (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 2] *compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 2]) //Im S12
197 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] //Im S13
224 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 4] *compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 4]) //Im S13
198 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11] //Im S23
225 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 11]*compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 11]) //Im S23
199 );
226 );
200 if (tmp != 0.) { // no division by 0.
227 if (tmp != 0.) { // no division by 0.
201 NVEC_V0 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]/ tmp; // S23 Im => n1
228 NVEC_V0 = compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 11] / tmp; // S23 Im => n1
202 NVEC_V1 = -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / tmp; // S13 Im => n2
229 NVEC_V1 = (-compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 4]) / tmp; // S13 Im => n2
203 NVEC_V2 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / tmp; // S12 Im => n3
230 NVEC_V2 = compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 2] / tmp; // S12 Im => n3
204 }
231 }
205 else
232 else
206 {
233 {
@@ -208,15 +235,15 void BP1_set( float * compressed_spec_ma
208 NVEC_V1 = 0.;
235 NVEC_V1 = 0.;
209 NVEC_V2 = 0.;
236 NVEC_V2 = 0.;
210 }
237 }
211 lfr_bp1[i*NB_BYTES_BP1+4] = (uint8_t) (NVEC_V0*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
238 lfr_bp1[(i*NB_BYTES_BP1) + 4] = (uint8_t) ((NVEC_V0*127.5) + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
212 lfr_bp1[i*NB_BYTES_BP1+5] = (uint8_t) (NVEC_V1*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
239 lfr_bp1[(i*NB_BYTES_BP1) + 5] = (uint8_t) ((NVEC_V1*127.5) + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
213 pt_uint8 = (uint8_t*) &NVEC_V2; // Affect an uint8_t pointer with the adress of NVEC_V2
240 pt_uint8 = (uint8_t*) &NVEC_V2; // Affect an uint8_t pointer with the adress of NVEC_V2
214 #ifdef LSB_FIRST_TCH
241 #ifdef LSB_FIRST_TCH
215 lfr_bp1[i*NB_BYTES_BP1+6] = pt_uint8[3] & 0x80; // Extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 4th octet:PC convention)
242 lfr_bp1[(i*NB_BYTES_BP1) + 6] = pt_uint8[3] & 0x80; // Extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 4th octet:PC convention)
216 // Record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
243 // Record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
217 #endif
244 #endif
218 #ifdef MSB_FIRST_TCH
245 #ifdef MSB_FIRST_TCH
219 lfr_bp1[i*NB_BYTES_BP1+6] = pt_uint8[0] & 0x80; // Extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 1th octet:SPARC convention)
246 lfr_bp1[(i*NB_BYTES_BP1) + 6] = pt_uint8[0] & 0x80; // Extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 1th octet:SPARC convention)
220 // Record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
247 // Record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
221 #endif
248 #endif
222 #ifdef DEBUG_TCH
249 #ifdef DEBUG_TCH
@@ -236,9 +263,9 void BP1_set( float * compressed_spec_ma
236 {
263 {
237 aux = 0.;
264 aux = 0.;
238 }
265 }
239 tmp_uint8 = (uint8_t) (aux*15 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
266 tmp_uint8 = (uint8_t) ((aux*15) + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
240 // where just the first 4 bits are used (0, ..., 15)
267 // where just the first 4 bits are used (0, ..., 15)
241 lfr_bp1[i*NB_BYTES_BP1+6] = lfr_bp1[i*NB_BYTES_BP1+6] | (tmp_uint8 << 3); // Put these 4 bits next to the right place
268 lfr_bp1[(i*NB_BYTES_BP1) + 6] = lfr_bp1[(i*NB_BYTES_BP1) + 6] | (tmp_uint8 << 3); // Put these 4 bits next to the right place
242 // of the sign bit of NVEC_V2 (recorded
269 // of the sign bit of NVEC_V2 (recorded
243 // previously in lfr_bp1[i*NB_BYTES_BP1+6])
270 // previously in lfr_bp1[i*NB_BYTES_BP1+6])
244 #ifdef DEBUG_TCH
271 #ifdef DEBUG_TCH
@@ -248,15 +275,15 void BP1_set( float * compressed_spec_ma
248 #endif
275 #endif
249 //==============================================================
276 //==============================================================
250 // BP1 degree of polarization == PA_LFR_SC_BP1_DOP_F0 == 3 bits
277 // BP1 degree of polarization == PA_LFR_SC_BP1_DOP_F0 == 3 bits
251 tr_SB_SB = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]
278 tr_SB_SB = (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX])
252 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]
279 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 9] * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 9])
253 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]
280 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 16] * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 16])
254 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1]
281 + (2 * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 1] * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 1])
255 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2]
282 + (2 * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 2] * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 2])
256 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3]
283 + (2 * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 3] * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 3])
257 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4]
284 + (2 * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 4] * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 4])
258 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]
285 + (2 * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 10]* compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 10])
259 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11];
286 + (2 * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 11]* compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 11]);
260 aux = PSDB*PSDB;
287 aux = PSDB*PSDB;
261 if (aux != 0.) { // no division by 0.
288 if (aux != 0.) { // no division by 0.
262 tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); // Compute the degree of polarisation
289 tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); // Compute the degree of polarisation
@@ -265,9 +292,9 void BP1_set( float * compressed_spec_ma
265 {
292 {
266 tmp = 0.;
293 tmp = 0.;
267 }
294 }
268 tmp_uint8 = (uint8_t) (tmp*7 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
295 tmp_uint8 = (uint8_t) ((tmp*7) + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
269 // where just the first 3 bits are used (0, ..., 7)
296 // where just the first 3 bits are used (0, ..., 7)
270 lfr_bp1[i*NB_BYTES_BP1+6] = lfr_bp1[i*NB_BYTES_BP1+6] | tmp_uint8; // Record these 3 bits at the 3 first bit positions
297 lfr_bp1[(i*NB_BYTES_BP1) + 6] = lfr_bp1[(i*NB_BYTES_BP1) + 6] | tmp_uint8; // Record these 3 bits at the 3 first bit positions
271 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
298 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
272 #ifdef DEBUG_TCH
299 #ifdef DEBUG_TCH
273 printf("DOP : %16.8e\n",tmp);
300 printf("DOP : %16.8e\n",tmp);
@@ -278,45 +305,45 void BP1_set( float * compressed_spec_ma
278 // BP1 X_SO-component of the Poynting flux == PA_LFR_SC_BP1_SX_F0 == 16 bits
305 // BP1 X_SO-component of the Poynting flux == PA_LFR_SC_BP1_SX_F0 == 16 bits
279 // = 1 sign bit + 1 argument bit (two sectors)
306 // = 1 sign bit + 1 argument bit (two sectors)
280 // + 6 bits (exponent) + 8 bits (significand)
307 // + 6 bits (exponent) + 8 bits (significand)
281 e_cross_b_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_RE] //S34 Re
308 e_cross_b_re = (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 17] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K34_SX_RE]) //S34 Re
282 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_RE] //S35 Re
309 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 19] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K35_SX_RE]) //S35 Re
283 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_RE] //S14 Re
310 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 5] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K14_SX_RE]) //S14 Re
284 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_RE] //S15 Re
311 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 7] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K15_SX_RE]) //S15 Re
285 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_RE] //S24 Re
312 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 12] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K24_SX_RE]) //S24 Re
286 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_RE] //S25 Re
313 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 14] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K25_SX_RE]) //S25 Re
287 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_IM] //S34 Im
314 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 18] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K34_SX_IM]) //S34 Im
288 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_IM] //S35 Im
315 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 20] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K35_SX_IM]) //S35 Im
289 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_IM] //S14 Im
316 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 6] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K14_SX_IM]) //S14 Im
290 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_IM] //S15 Im
317 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 8] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K15_SX_IM]) //S15 Im
291 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_IM] //S24 Im
318 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 13] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K24_SX_IM]) //S24 Im
292 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_IM]; //S25 Im
319 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 15] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K25_SX_IM]); //S25 Im
293 // Im(S_ji) = -Im(S_ij)
320 // Im(S_ji) = -Im(S_ij)
294 // k_ji = k_ij
321 // k_ji = k_ij
295 e_cross_b_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_IM] //S34 Re
322 e_cross_b_im = (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 17]*k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K34_SX_IM]) //S34 Re
296 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_IM] //S35 Re
323 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 19]*k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K35_SX_IM]) //S35 Re
297 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_IM] //S14 Re
324 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 5] *k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K14_SX_IM]) //S14 Re
298 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_IM] //S15 Re
325 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 7] *k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K15_SX_IM]) //S15 Re
299 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_IM] //S24 Re
326 + (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 12]*k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K24_SX_IM]) //S24 Re
300 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_IM] //S25 Re
327 + ((compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 14]*k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K25_SX_IM]) //S25 Re
301 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_RE] //S34 Im
328 - (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 18]*k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K34_SX_RE]) //S34 Im
302 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_RE] //S35 Im
329 - (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 20]*k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K35_SX_RE]) //S35 Im
303 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_RE] //S14 Im
330 - (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 6] *k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K14_SX_RE]) //S14 Im
304 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_RE] //S15 Im
331 - (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 8] *k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K15_SX_RE]) //S15 Im
305 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_RE] //S24 Im
332 - (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 13]*k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K24_SX_RE]) //S24 Im
306 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_RE]; //S25 Im
333 - (compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 15]*k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K25_SX_RE])); //S25 Im
307 #ifdef DEBUG_TCH
334 #ifdef DEBUG_TCH
308 printf("ReaSX : %16.8e\n",e_cross_b_re);
335 printf("ReaSX : %16.8e\n",e_cross_b_re);
309 #endif
336 #endif
310 pt_uint8 = (uint8_t*) &e_cross_b_re; // Affect an uint8_t pointer with the adress of e_cross_b_re
337 pt_uint8 = (uint8_t*) &e_cross_b_re; // Affect an uint8_t pointer with the adress of e_cross_b_re
311 #ifdef LSB_FIRST_TCH
338 #ifdef LSB_FIRST_TCH
312
339
313 lfr_bp1[i*NB_BYTES_BP1+7] = (uint8_t) (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention)
340 lfr_bp1[(i*NB_BYTES_BP1) + 7] = (uint8_t) (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention)
314 // Record it at the 8th bit position (from the right to the left)
341 // Record it at the 8th bit position (from the right to the left)
315 // of lfr_bp1[i*NB_BYTES_BP1+7]
342 // of lfr_bp1[i*NB_BYTES_BP1+7]
316 pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
343 pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
317 #endif
344 #endif
318 #ifdef MSB_FIRST_TCH
345 #ifdef MSB_FIRST_TCH
319 lfr_bp1[i*NB_BYTES_BP1+7] = (uint8_t) (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention)
346 lfr_bp1[(i*NB_BYTES_BP1) + 7] = (uint8_t) (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention)
320 // Record it at the 8th bit position (from the right to the left)
347 // Record it at the 8th bit position (from the right to the left)
321 // of lfr_bp1[i*NB_BYTES_BP1+7]
348 // of lfr_bp1[i*NB_BYTES_BP1+7]
322 pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
349 pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
@@ -336,7 +363,7 void BP1_set( float * compressed_spec_ma
336 significand = 0.5; // min value that can be recorded
363 significand = 0.5; // min value that can be recorded
337 }
364 }
338
365
339 lfr_bp1[i*NB_BYTES_BP1+8] = (uint8_t) ((significand*2-1)*255 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
366 lfr_bp1[(i*NB_BYTES_BP1) + 8] = (uint8_t) ((((significand*2)-1)*255) + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
340 // where all bits are used (0, ..., 255)
367 // where all bits are used (0, ..., 255)
341 tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
368 tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
342 // just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
369 // just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
@@ -346,7 +373,7 void BP1_set( float * compressed_spec_ma
346 printf("exponent : %d\n" ,exponent);
373 printf("exponent : %d\n" ,exponent);
347 printf("tmp_uint8 for ReaSX exponent : %d\n",tmp_uint8);
374 printf("tmp_uint8 for ReaSX exponent : %d\n",tmp_uint8);
348 #endif
375 #endif
349 lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | tmp_uint8; // Record these nbitexp bits in the nbitexp first bits
376 lfr_bp1[(i*NB_BYTES_BP1) + 7] = lfr_bp1[(i*NB_BYTES_BP1) + 7] | tmp_uint8; // Record these nbitexp bits in the nbitexp first bits
350 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+7]
377 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+7]
351 #ifdef DEBUG_TCH
378 #ifdef DEBUG_TCH
352 printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX sign + RealSX exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
379 printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX sign + RealSX exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
@@ -360,9 +387,16 void BP1_set( float * compressed_spec_ma
360 #ifdef MSB_FIRST_TCH
387 #ifdef MSB_FIRST_TCH
361 pt_uint8[0] = pt_uint8[0] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX| (32-bit float, sign bit in the 1th octet:SPARC convention)
388 pt_uint8[0] = pt_uint8[0] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX| (32-bit float, sign bit in the 1th octet:SPARC convention)
362 #endif
389 #endif
363 tmp_uint8 = (e_cross_b_im > e_cross_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect
390 // Determine the sector argument of SX. If |Im| > |Re| affect
364 // an unsigned 8-bit char with 01000000; otherwise with null.
391 // an unsigned 8-bit char with 01000000; otherwise with null.
365 lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right
392 if (e_cross_b_im > e_cross_b_re) {
393 tmp_uint8 = 0x40;
394 }
395 else {
396 tmp_uint8 = 0x00;
397 }
398
399 lfr_bp1[(i*NB_BYTES_BP1) + 7] = lfr_bp1[(i*NB_BYTES_BP1) + 7] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right
366 // to the left) of lfr_bp1[i*NB_BYTES_BP1+7], by simple logical addition.
400 // to the left) of lfr_bp1[i*NB_BYTES_BP1+7], by simple logical addition.
367 #ifdef DEBUG_TCH
401 #ifdef DEBUG_TCH
368 printf("|ImaSX| : %16.8e\n",e_cross_b_im);
402 printf("|ImaSX| : %16.8e\n",e_cross_b_im);
@@ -373,46 +407,46 void BP1_set( float * compressed_spec_ma
373 // BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 16 bits
407 // BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 16 bits
374 // = 1 sign bit + 1 argument bit (two sectors)
408 // = 1 sign bit + 1 argument bit (two sectors)
375 // + 6 bits (exponent) + 8 bits (significand)
409 // + 6 bits (exponent) + 8 bits (significand)
376 ny = sin(alpha_M)*NVEC_V1 + cos(alpha_M)*NVEC_V2;
410 ny = (sin(alpha_M)*NVEC_V1) + (cos(alpha_M)*NVEC_V2);
377 nz = NVEC_V0;
411 nz = NVEC_V0;
378 bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] // S22 Re
412 bx_bx_star = (cos(alpha_M)*cos(alpha_M)*compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 9]) // S22 Re
379 + sin(alpha_M)*sin(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] // S33 Re
413 + ((sin(alpha_M)*sin(alpha_M)*compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 16]) // S33 Re
380 - 2*sin(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]; // S23 Re
414 - (2*sin(alpha_M)*cos(alpha_M)*compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 10])); // S23 Re
381
415
382 n_cross_e_scal_b_re = ny * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_RE] //S24 Re
416 n_cross_e_scal_b_re = (ny * ((compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 12] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K24_NY_RE]) //S24 Re
383 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_RE] //S25 Re
417 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 14] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K25_NY_RE]) //S25 Re
384 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_RE] //S34 Re
418 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 17] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K34_NY_RE]) //S34 Re
385 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_RE] //S35 Re
419 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 19] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K35_NY_RE]) //S35 Re
386 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_IM] //S24 Im
420 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 13] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K24_NY_IM]) //S24 Im
387 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_IM] //S25 Im
421 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 15] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K25_NY_IM]) //S25 Im
388 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_IM] //S34 Im
422 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 18] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K34_NY_IM]) //S34 Im
389 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_IM]) //S35 Im
423 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 20] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K35_NY_IM]))) //S35 Im
390 + nz * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] //S24 Re
424 + (nz * ((compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 12] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K24_NZ_RE]) //S24 Re
391 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] //S25 Re
425 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 14] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K25_NZ_RE]) //S25 Re
392 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] //S34 Re
426 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 17] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K34_NZ_RE]) //S34 Re
393 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_RE] //S35 Re
427 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 19] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K35_NZ_RE]) //S35 Re
394 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] //S24 Im
428 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 13] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K24_NZ_IM]) //S24 Im
395 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] //S25 Im
429 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 15] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K25_NZ_IM]) //S25 Im
396 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] //S34 Im
430 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 18] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K34_NZ_IM]) //S34 Im
397 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_IM]);//S35 Im
431 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 20] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K35_NZ_IM])));//S35 Im
398 // Im(S_ji) = -Im(S_ij)
432 // Im(S_ji) = -Im(S_ij)
399 // k_ji = k_ij
433 // k_ji = k_ij
400 n_cross_e_scal_b_im = ny * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_IM] //S24 Re
434 n_cross_e_scal_b_im = (ny * ((compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 12] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K24_NY_IM]) //S24 Re
401 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_IM] //S25 Re
435 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 14] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K25_NY_IM]) //S25 Re
402 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_IM] //S34 Re
436 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 17] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K34_NY_IM]) //S34 Re
403 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_IM] //S35 Re
437 +((compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 19] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K35_NY_IM]) //S35 Re
404 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_RE] //S24 Im
438 -(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 13] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K24_NY_RE]) //S24 Im
405 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_RE] //S25 Im
439 -(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 15] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K25_NY_RE]) //S25 Im
406 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_RE] //S34 Im
440 -(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 18] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K34_NY_RE]) //S34 Im
407 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_RE]) //S35 Im
441 -(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 20] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K35_NY_RE])))) //S35 Im
408 + nz * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] //S24 Re
442 + (nz * ((compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 12] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K24_NZ_IM]) //S24 Re
409 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] //S25 Re
443 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 14] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K25_NZ_IM]) //S25 Re
410 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] //S34 Re
444 +(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 17] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K34_NZ_IM] ) //S34 Re
411 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_IM] //S35 Re
445 +((compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 19] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K35_NZ_IM]) //S35 Re
412 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] //S24 Im
446 -(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 13] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K24_NZ_RE]) //S24 Im
413 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] //S25 Im
447 -(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 15] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K25_NZ_RE]) //S25 Im
414 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] //S34 Im
448 -(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 18] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K34_NZ_RE]) //S34 Im
415 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_RE]);//S35 Im
449 -(compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 20] * k_coeff_intercalib[(i*NB_K_COEFF_PER_BIN) + K35_NZ_RE]))));//S35 Im
416 #ifdef DEBUG_TCH
450 #ifdef DEBUG_TCH
417 printf("n_cross_e_scal_b_re : %16.8e\n",n_cross_e_scal_b_re);
451 printf("n_cross_e_scal_b_re : %16.8e\n",n_cross_e_scal_b_re);
418 printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im);
452 printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im);
@@ -420,13 +454,13 void BP1_set( float * compressed_spec_ma
420 // vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re)
454 // vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re)
421 pt_uint8 = (uint8_t*) &n_cross_e_scal_b_re; // Affect an uint8_t pointer with the adress of n_cross_e_scal_b_re
455 pt_uint8 = (uint8_t*) &n_cross_e_scal_b_re; // Affect an uint8_t pointer with the adress of n_cross_e_scal_b_re
422 #ifdef LSB_FIRST_TCH
456 #ifdef LSB_FIRST_TCH
423 lfr_bp1[i*NB_BYTES_BP1+9] = (uint8_t) (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention)
457 lfr_bp1[(i*NB_BYTES_BP1) + 9] = (uint8_t) (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention)
424 // Record it at the 8th bit position (from the right to the left)
458 // Record it at the 8th bit position (from the right to the left)
425 // of lfr_bp1[i*NB_BYTES_BP1+9]
459 // of lfr_bp1[i*NB_BYTES_BP1+9]
426 pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re|
460 pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re|
427 #endif
461 #endif
428 #ifdef MSB_FIRST_TCH
462 #ifdef MSB_FIRST_TCH
429 lfr_bp1[i*NB_BYTES_BP1+9] = (uint8_t) (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention)
463 lfr_bp1[(i*NB_BYTES_BP1) + 9] = (uint8_t) (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention)
430 // Record it at the 8th bit position (from the right to the left)
464 // Record it at the 8th bit position (from the right to the left)
431 // of lfr_bp1[i*NB_BYTES_BP1+9]
465 // of lfr_bp1[i*NB_BYTES_BP1+9]
432 pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re|
466 pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re|
@@ -453,7 +487,7 void BP1_set( float * compressed_spec_ma
453 significand = 0.5; // min value that can be recorded
487 significand = 0.5; // min value that can be recorded
454 }
488 }
455
489
456 lfr_bp1[i*NB_BYTES_BP1+10] = (uint8_t) ((significand*2-1)*255 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
490 lfr_bp1[(i*NB_BYTES_BP1) + 10] = (uint8_t) ((((significand*2)-1)*255) + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
457 // where all the bits are used (0, ..., 255)
491 // where all the bits are used (0, ..., 255)
458 tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
492 tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
459 // just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
493 // just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
@@ -463,7 +497,7 void BP1_set( float * compressed_spec_ma
463 printf("exponent : %d\n" ,exponent);
497 printf("exponent : %d\n" ,exponent);
464 printf("tmp_uint8 for VPHI exponent : %d\n",tmp_uint8);
498 printf("tmp_uint8 for VPHI exponent : %d\n",tmp_uint8);
465 #endif
499 #endif
466 lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | tmp_uint8; // Record these nbitexp bits in the nbitexp first bits
500 lfr_bp1[(i*NB_BYTES_BP1) + 9] = lfr_bp1[(i*NB_BYTES_BP1) + 9] | tmp_uint8; // Record these nbitexp bits in the nbitexp first bits
467 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+9]
501 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+9]
468 #ifdef DEBUG_TCH
502 #ifdef DEBUG_TCH
469 printf("lfr_bp1[i*NB_BYTES_BP1+9] for VPHI sign + VPHI exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+9]);
503 printf("lfr_bp1[i*NB_BYTES_BP1+9] for VPHI sign + VPHI exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+9]);
@@ -476,9 +510,17 void BP1_set( float * compressed_spec_ma
476 #ifdef MSB_FIRST_TCH
510 #ifdef MSB_FIRST_TCH
477 pt_uint8[0] = pt_uint8[0] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaNEBX| (32-bit float, sign bit in the 1th octet:SPARC convention)
511 pt_uint8[0] = pt_uint8[0] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaNEBX| (32-bit float, sign bit in the 1th octet:SPARC convention)
478 #endif
512 #endif
479 tmp_uint8 = (n_cross_e_scal_b_im > n_cross_e_scal_b_re) ? 0x40 : 0x00; // Determine the sector argument of NEBX. If |Im| > |Re| affect
513
480 // an unsigned 8-bit char with 01000000; otherwise with null.
514 // Determine the sector argument of NEBX. If |Im| > |Re| affect
481 lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right
515 // an unsigned 8-bit char with 01000000; otherwise with null.
516 if (n_cross_e_scal_b_im > n_cross_e_scal_b_re) {
517 tmp_uint8 = 0x40;
518 }
519 else {
520 tmp_uint8 = 0x00;
521 }
522
523 lfr_bp1[(i*NB_BYTES_BP1) + 9] = lfr_bp1[(i*NB_BYTES_BP1) + 9] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right
482 // to the left) of lfr_bp1[i*NB_BYTES_BP1+9], by simple logical addition.
524 // to the left) of lfr_bp1[i*NB_BYTES_BP1+9], by simple logical addition.
483 #ifdef DEBUG_TCH
525 #ifdef DEBUG_TCH
484 printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im);
526 printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im);
@@ -517,7 +559,7 void BP2_set( float * compressed_spec_ma
517 nbitsig = 16 - nbitexp; // number of bits for the significand
559 nbitsig = 16 - nbitexp; // number of bits for the significand
518 rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
560 rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
519 expmax = 32 + 5;
561 expmax = 32 + 5;
520 expmin = expmax - (1 << nbitexp) + 1;
562 expmin = (expmax - (1 << nbitexp)) + 1;
521
563
522 #ifdef DEBUG_TCH
564 #ifdef DEBUG_TCH
523
565
@@ -549,172 +591,172 void BP2_set( float * compressed_spec_ma
549 // == PA_LFR_SC_BP2_CROSS_RE_9_F0 == 8 bits
591 // == PA_LFR_SC_BP2_CROSS_RE_9_F0 == 8 bits
550 // == PA_LFR_SC_BP2_CROSS_IM_9_F0 == 8 bits
592 // == PA_LFR_SC_BP2_CROSS_IM_9_F0 == 8 bits
551 // S12
593 // S12
552 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]);
594 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 9]);
553 if (aux != 0.) { // no division by 0.
595 if (aux != 0.) { // no division by 0.
554 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] / aux;
596 cross_re = compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 1] / aux;
555 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / aux;
597 cross_im = compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 2] / aux;
556 }
598 }
557 else
599 else
558 {
600 {
559 cross_re = 0.;
601 cross_re = 0.;
560 cross_im = 0.;
602 cross_im = 0.;
561 }
603 }
562 lfr_bp2[i*NB_BYTES_BP2+10] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
604 lfr_bp2[(i*NB_BYTES_BP2) + 10] = (uint8_t) ((cross_re*127.5) + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
563 lfr_bp2[i*NB_BYTES_BP2+20] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
605 lfr_bp2[(i*NB_BYTES_BP2) + 20] = (uint8_t) ((cross_im*127.5) + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
564 #ifdef DEBUG_TCH
606 #ifdef DEBUG_TCH
565 printf("\nBin number: %d\n", i);
607 printf("\nBin number: %d\n", i);
566 printf("lfr_bp2[i*NB_BYTES_BP2+10] for cross12_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+10]);
608 printf("lfr_bp2[i*NB_BYTES_BP2+10] for cross12_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+10]);
567 printf("lfr_bp2[i*NB_BYTES_BP2+20] for cross12_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+20]);
609 printf("lfr_bp2[i*NB_BYTES_BP2+20] for cross12_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+20]);
568 #endif
610 #endif
569 // S13
611 // S13
570 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
612 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] * compressed_spec_mat[(i*NB_VALUES_PER_SPECTRAL_MATRIX) + 16]);