##// END OF EJS Templates
version 2.3 : bug affectation initiale des octets 7 et 9 de BP1 corrigé
chust -
r21:3081d1f9bb20 TCH
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.58822950e+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.58822950e+06
88 |n_cross_e_scal_b_im|/bx_bx_star : 2.75164318e+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
@@ -1,183 +1,184
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
2 // version 1.0: 31/07/2013
2 // version 1.0: 31/07/2013
3 // version 1.1: 02/04/2014
3 // version 1.1: 02/04/2014
4 // version 1.2: 30/04/2014
4 // version 1.2: 30/04/2014
5 // version 1.3: 02/05/2014
5 // version 1.3: 02/05/2014
6 // version 1.4: 16/05/2014
6 // version 1.4: 16/05/2014
7 // version 1.5: 20/05/2014
7 // version 1.5: 20/05/2014
8 // version 1.6: 19/12/2014
8 // version 1.6: 19/12/2014
9 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
9 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
10 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
10 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
11 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
11 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
12 // version 2.0: 19/06/2015
12 // version 2.0: 19/06/2015
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
16
16 #include <stdio.h>
17 #include <stdio.h>
17 #include <stdint.h>
18 #include <stdint.h>
18
19
19 #include "basic_parameters_params.h"
20 #include "basic_parameters_params.h"
20
21
21 void init_k_coefficients_f0(float *k_coefficients,
22 void init_k_coefficients_f0(float *k_coefficients,
22 unsigned char nb_binscompressed_matrix )
23 unsigned char nb_binscompressed_matrix )
23 {
24 {
24
25
25 uint8_t i; // 8 bits unsigned
26 uint8_t i; // 8 bits unsigned
26 for(i=0; i<nb_binscompressed_matrix; i++){
27 for(i=0; i<nb_binscompressed_matrix; i++){
27 k_coefficients[i*NB_K_COEFF_PER_BIN+K44_PE] = 1;
28 k_coefficients[i*NB_K_COEFF_PER_BIN+K44_PE] = 1;
28 k_coefficients[i*NB_K_COEFF_PER_BIN+K55_PE] = 1;
29 k_coefficients[i*NB_K_COEFF_PER_BIN+K55_PE] = 1;
29 k_coefficients[i*NB_K_COEFF_PER_BIN+K45_PE_RE] = 1;
30 k_coefficients[i*NB_K_COEFF_PER_BIN+K45_PE_RE] = 1;
30 k_coefficients[i*NB_K_COEFF_PER_BIN+K45_PE_IM] = 1;
31 k_coefficients[i*NB_K_COEFF_PER_BIN+K45_PE_IM] = 1;
31 k_coefficients[i*NB_K_COEFF_PER_BIN+K14_SX_RE] = 1;
32 k_coefficients[i*NB_K_COEFF_PER_BIN+K14_SX_RE] = 1;
32 k_coefficients[i*NB_K_COEFF_PER_BIN+K14_SX_IM] = 1;
33 k_coefficients[i*NB_K_COEFF_PER_BIN+K14_SX_IM] = 1;
33 k_coefficients[i*NB_K_COEFF_PER_BIN+K15_SX_RE] = 1;
34 k_coefficients[i*NB_K_COEFF_PER_BIN+K15_SX_RE] = 1;
34 k_coefficients[i*NB_K_COEFF_PER_BIN+K15_SX_IM] = 1;
35 k_coefficients[i*NB_K_COEFF_PER_BIN+K15_SX_IM] = 1;
35 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_SX_RE] = 1;
36 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_SX_RE] = 1;
36 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_SX_IM] = 1;
37 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_SX_IM] = 1;
37 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_SX_RE] = 1;
38 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_SX_RE] = 1;
38 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_SX_IM] = 1;
39 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_SX_IM] = 1;
39 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_SX_RE] = 1;
40 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_SX_RE] = 1;
40 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_SX_IM] = 1;
41 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_SX_IM] = 1;
41 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_SX_RE] = 1;
42 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_SX_RE] = 1;
42 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_SX_IM] = 1;
43 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_SX_IM] = 1;
43 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NY_RE] = 1;
44 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NY_RE] = 1;
44 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NY_IM] = 1;
45 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NY_IM] = 1;
45 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NY_RE] = 1;
46 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NY_RE] = 1;
46 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NY_IM] = 1;
47 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NY_IM] = 1;
47 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NY_RE] = 1;
48 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NY_RE] = 1;
48 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NY_IM] = 1;
49 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NY_IM] = 1;
49 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NY_RE] = 1;
50 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NY_RE] = 1;
50 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NY_IM] = 1;
51 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NY_IM] = 1;
51 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] = 1;
52 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] = 1;
52 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] = 1;
53 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] = 1;
53 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] = 1;
54 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] = 1;
54 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] = 1;
55 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] = 1;
55 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] = 1;
56 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] = 1;
56 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] = 1;
57 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] = 1;
57 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NZ_RE] = 1;
58 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NZ_RE] = 1;
58 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NZ_IM] = 1;
59 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NZ_IM] = 1;
59 }
60 }
60
61
61 }
62 }
62
63
63
64
64 void init_k_coefficients_f1(float *k_coefficients,
65 void init_k_coefficients_f1(float *k_coefficients,
65 unsigned char nb_binscompressed_matrix )
66 unsigned char nb_binscompressed_matrix )
66 {
67 {
67
68
68 uint8_t i; // 8 bits unsigned
69 uint8_t i; // 8 bits unsigned
69 for(i=0; i<nb_binscompressed_matrix; i++){
70 for(i=0; i<nb_binscompressed_matrix; i++){
70 k_coefficients[i*NB_K_COEFF_PER_BIN+K44_PE] = 1;
71 k_coefficients[i*NB_K_COEFF_PER_BIN+K44_PE] = 1;
71 k_coefficients[i*NB_K_COEFF_PER_BIN+K55_PE] = 1;
72 k_coefficients[i*NB_K_COEFF_PER_BIN+K55_PE] = 1;
72 k_coefficients[i*NB_K_COEFF_PER_BIN+K45_PE_RE] = 1;
73 k_coefficients[i*NB_K_COEFF_PER_BIN+K45_PE_RE] = 1;
73 k_coefficients[i*NB_K_COEFF_PER_BIN+K45_PE_IM] = 1;
74 k_coefficients[i*NB_K_COEFF_PER_BIN+K45_PE_IM] = 1;
74 k_coefficients[i*NB_K_COEFF_PER_BIN+K14_SX_RE] = 1;
75 k_coefficients[i*NB_K_COEFF_PER_BIN+K14_SX_RE] = 1;
75 k_coefficients[i*NB_K_COEFF_PER_BIN+K14_SX_IM] = 1;
76 k_coefficients[i*NB_K_COEFF_PER_BIN+K14_SX_IM] = 1;
76 k_coefficients[i*NB_K_COEFF_PER_BIN+K15_SX_RE] = 1;
77 k_coefficients[i*NB_K_COEFF_PER_BIN+K15_SX_RE] = 1;
77 k_coefficients[i*NB_K_COEFF_PER_BIN+K15_SX_IM] = 1;
78 k_coefficients[i*NB_K_COEFF_PER_BIN+K15_SX_IM] = 1;
78 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_SX_RE] = 1;
79 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_SX_RE] = 1;
79 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_SX_IM] = 1;
80 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_SX_IM] = 1;
80 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_SX_RE] = 1;
81 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_SX_RE] = 1;
81 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_SX_IM] = 1;
82 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_SX_IM] = 1;
82 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_SX_RE] = 1;
83 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_SX_RE] = 1;
83 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_SX_IM] = 1;
84 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_SX_IM] = 1;
84 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_SX_RE] = 1;
85 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_SX_RE] = 1;
85 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_SX_IM] = 1;
86 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_SX_IM] = 1;
86 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NY_RE] = 1;
87 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NY_RE] = 1;
87 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NY_IM] = 1;
88 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NY_IM] = 1;
88 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NY_RE] = 1;
89 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NY_RE] = 1;
89 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NY_IM] = 1;
90 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NY_IM] = 1;
90 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NY_RE] = 1;
91 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NY_RE] = 1;
91 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NY_IM] = 1;
92 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NY_IM] = 1;
92 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NY_RE] = 1;
93 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NY_RE] = 1;
93 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NY_IM] = 1;
94 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NY_IM] = 1;
94 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] = 1;
95 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] = 1;
95 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] = 1;
96 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] = 1;
96 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] = 1;
97 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] = 1;
97 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] = 1;
98 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] = 1;
98 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] = 1;
99 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] = 1;
99 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] = 1;
100 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] = 1;
100 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NZ_RE] = 1;
101 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NZ_RE] = 1;
101 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NZ_IM] = 1;
102 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NZ_IM] = 1;
102 }
103 }
103
104
104 }
105 }
105
106
106
107
107 void init_k_coefficients_f2(float *k_coefficients,
108 void init_k_coefficients_f2(float *k_coefficients,
108 unsigned char nb_binscompressed_matrix )
109 unsigned char nb_binscompressed_matrix )
109 {
110 {
110
111
111 uint8_t i; // 8 bits unsigned
112 uint8_t i; // 8 bits unsigned
112 for(i=0; i<nb_binscompressed_matrix; i++){
113 for(i=0; i<nb_binscompressed_matrix; i++){
113 k_coefficients[i*NB_K_COEFF_PER_BIN+K44_PE] = 1;
114 k_coefficients[i*NB_K_COEFF_PER_BIN+K44_PE] = 1;
114 k_coefficients[i*NB_K_COEFF_PER_BIN+K55_PE] = 1;
115 k_coefficients[i*NB_K_COEFF_PER_BIN+K55_PE] = 1;
115 k_coefficients[i*NB_K_COEFF_PER_BIN+K45_PE_RE] = 1;
116 k_coefficients[i*NB_K_COEFF_PER_BIN+K45_PE_RE] = 1;
116 k_coefficients[i*NB_K_COEFF_PER_BIN+K45_PE_IM] = 1;
117 k_coefficients[i*NB_K_COEFF_PER_BIN+K45_PE_IM] = 1;
117 k_coefficients[i*NB_K_COEFF_PER_BIN+K14_SX_RE] = 1;
118 k_coefficients[i*NB_K_COEFF_PER_BIN+K14_SX_RE] = 1;
118 k_coefficients[i*NB_K_COEFF_PER_BIN+K14_SX_IM] = 1;
119 k_coefficients[i*NB_K_COEFF_PER_BIN+K14_SX_IM] = 1;
119 k_coefficients[i*NB_K_COEFF_PER_BIN+K15_SX_RE] = 1;
120 k_coefficients[i*NB_K_COEFF_PER_BIN+K15_SX_RE] = 1;
120 k_coefficients[i*NB_K_COEFF_PER_BIN+K15_SX_IM] = 1;
121 k_coefficients[i*NB_K_COEFF_PER_BIN+K15_SX_IM] = 1;
121 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_SX_RE] = 1;
122 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_SX_RE] = 1;
122 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_SX_IM] = 1;
123 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_SX_IM] = 1;
123 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_SX_RE] = 1;
124 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_SX_RE] = 1;
124 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_SX_IM] = 1;
125 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_SX_IM] = 1;
125 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_SX_RE] = 1;
126 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_SX_RE] = 1;
126 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_SX_IM] = 1;
127 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_SX_IM] = 1;
127 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_SX_RE] = 1;
128 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_SX_RE] = 1;
128 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_SX_IM] = 1;
129 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_SX_IM] = 1;
129 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NY_RE] = 1;
130 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NY_RE] = 1;
130 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NY_IM] = 1;
131 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NY_IM] = 1;
131 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NY_RE] = 1;
132 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NY_RE] = 1;
132 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NY_IM] = 1;
133 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NY_IM] = 1;
133 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NY_RE] = 1;
134 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NY_RE] = 1;
134 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NY_IM] = 1;
135 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NY_IM] = 1;
135 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NY_RE] = 1;
136 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NY_RE] = 1;
136 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NY_IM] = 1;
137 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NY_IM] = 1;
137 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] = 1;
138 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] = 1;
138 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] = 1;
139 k_coefficients[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] = 1;
139 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] = 1;
140 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] = 1;
140 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] = 1;
141 k_coefficients[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] = 1;
141 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] = 1;
142 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] = 1;
142 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] = 1;
143 k_coefficients[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] = 1;
143 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NZ_RE] = 1;
144 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NZ_RE] = 1;
144 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NZ_IM] = 1;
145 k_coefficients[i*NB_K_COEFF_PER_BIN+K35_NZ_IM] = 1;
145 }
146 }
146
147
147 }
148 }
148
149
149
150
150 void init_k_coefficients(float *k_coefficients,
151 void init_k_coefficients(float *k_coefficients,
151 unsigned char nb_binscompressed_matrix )
152 unsigned char nb_binscompressed_matrix )
152 {
153 {
153 switch (nb_binscompressed_matrix)
154 switch (nb_binscompressed_matrix)
154 {
155 {
155 case NB_BINS_COMPRESSED_MATRIX_f0:
156 case NB_BINS_COMPRESSED_MATRIX_f0:
156 #ifdef DEBUG_TCH
157 #ifdef DEBUG_TCH
157 printf("F0 data: initialization of the intercalibration k-coefficients\n");
158 printf("F0 data: initialization of the intercalibration k-coefficients\n");
158 #endif
159 #endif
159 init_k_coefficients_f0(k_coefficients, nb_binscompressed_matrix);
160 init_k_coefficients_f0(k_coefficients, nb_binscompressed_matrix);
160 break;
161 break;
161
162
162 case NB_BINS_COMPRESSED_MATRIX_f1:
163 case NB_BINS_COMPRESSED_MATRIX_f1:
163 #ifdef DEBUG_TCH
164 #ifdef DEBUG_TCH
164 printf("F1 data: initialization of the intercalibration k-coefficients\n");
165 printf("F1 data: initialization of the intercalibration k-coefficients\n");
165 #endif
166 #endif
166 init_k_coefficients_f1(k_coefficients, nb_binscompressed_matrix);
167 init_k_coefficients_f1(k_coefficients, nb_binscompressed_matrix);
167 break;
168 break;
168
169
169 case NB_BINS_COMPRESSED_MATRIX_f2:
170 case NB_BINS_COMPRESSED_MATRIX_f2:
170 #ifdef DEBUG_TCH
171 #ifdef DEBUG_TCH
171 printf("F2 data: initialization of the intercalibration k-coefficients\n");
172 printf("F2 data: initialization of the intercalibration k-coefficients\n");
172 #endif
173 #endif
173 init_k_coefficients_f2(k_coefficients, nb_binscompressed_matrix);
174 init_k_coefficients_f2(k_coefficients, nb_binscompressed_matrix);
174 break;
175 break;
175
176
176 default:
177 default:
177 #ifdef DEBUG_TCH
178 #ifdef DEBUG_TCH
178 printf("there is a problème !!?\n");
179 printf("there is a problème !!?\n");
179 #endif
180 #endif
180 break;
181 break;
181 }
182 }
182 }
183 }
183
184
@@ -1,959 +1,961
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
2 // version 1.0: 31/07/2013
2 // version 1.0: 31/07/2013
3 // version 1.1: 02/04/2014
3 // version 1.1: 02/04/2014
4 // version 1.2: 30/04/2014
4 // version 1.2: 30/04/2014
5 // version 1.3: 02/05/2014
5 // version 1.3: 02/05/2014
6 // version 1.4: 16/05/2014
6 // version 1.4: 16/05/2014
7 // version 1.5: 20/05/2014
7 // version 1.5: 20/05/2014
8 // version 1.6: 19/12/2014
8 // version 1.6: 19/12/2014
9 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
9 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
10 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
10 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
11 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
11 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
12 // version 2.0: 19/06/2015
12 // version 2.0: 19/06/2015
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
16
16 #ifndef BASIC_PARAMETERS_H_INCLUDED
17 #ifndef BASIC_PARAMETERS_H_INCLUDED
17 #define BASIC_PARAMETERS_H_INCLUDED
18 #define BASIC_PARAMETERS_H_INCLUDED
18
19
19 #include <math.h>
20 #include <math.h>
20 #include <stdio.h>
21 #include <stdio.h>
21 #include <stdint.h>
22 #include <stdint.h>
22
23
23 #include "basic_parameters_params.h"
24 #include "basic_parameters_params.h"
24
25
25 static inline void BP1_set(float * compressed_spec_mat, float * k_coeff_intercalib, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp1);
26 static inline void BP1_set(float * compressed_spec_mat, float * k_coeff_intercalib, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp1);
26 static inline void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp2);
27 static inline void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp2);
27
28
28 void init_k_coefficients_f0( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
29 void init_k_coefficients_f0( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
29 void init_k_coefficients_f1( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
30 void init_k_coefficients_f1( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
30 void init_k_coefficients_f2( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
31 void init_k_coefficients_f2( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
31
32
32 void init_k_coefficients( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
33 void init_k_coefficients( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
33
34
34 //***********************************
35 //***********************************
35 // STATIC INLINE FUNCTION DEFINITIONS
36 // STATIC INLINE FUNCTION DEFINITIONS
36
37
37 void BP1_set( float * compressed_spec_mat, float * k_coeff_intercalib, uint8_t nb_bins_compressed_spec_mat, uint8_t * lfr_bp1 ){
38 void BP1_set( float * compressed_spec_mat, float * k_coeff_intercalib, uint8_t nb_bins_compressed_spec_mat, uint8_t * lfr_bp1 ){
38 float PSDB; // 32-bit floating point
39 float PSDB; // 32-bit floating point
39 float PSDE;
40 float PSDE;
40 float tmp;
41 float tmp;
41 float NVEC_V0;
42 float NVEC_V0;
42 float NVEC_V1;
43 float NVEC_V1;
43 float NVEC_V2;
44 float NVEC_V2;
44 float aux;
45 float aux;
45 float tr_SB_SB;
46 float tr_SB_SB;
46 float e_cross_b_re;
47 float e_cross_b_re;
47 float e_cross_b_im;
48 float e_cross_b_im;
48 float n_cross_e_scal_b_re;
49 float n_cross_e_scal_b_re;
49 float n_cross_e_scal_b_im;
50 float n_cross_e_scal_b_im;
50 float ny;
51 float ny;
51 float nz;
52 float nz;
52 float bx_bx_star;
53 float bx_bx_star;
53 float vphi;
54 float vphi;
54 float significand;
55 float significand;
55 int exponent; // 32-bit signed integer
56 int exponent; // 32-bit signed integer
56 float alpha_M;
57 float alpha_M;
57
58
58 uint8_t nbitexp; // 8-bit unsigned integer
59 uint8_t nbitexp; // 8-bit unsigned integer
59 uint8_t nbitsig;
60 uint8_t nbitsig;
60 uint8_t tmp_uint8;
61 uint8_t tmp_uint8;
61 uint8_t *pt_uint8; // pointer on unsigned 8-bit integer
62 uint8_t *pt_uint8; // pointer on unsigned 8-bit integer
62 int8_t expmin; // 8-bit signed integer
63 int8_t expmin; // 8-bit signed integer
63 int8_t expmax;
64 int8_t expmax;
64 uint16_t rangesig; // 16-bit unsigned integer
65 uint16_t rangesig; // 16-bit unsigned integer
65 uint16_t psd;
66 uint16_t psd;
66 uint16_t exp;
67 uint16_t exp;
67 uint16_t tmp_uint16;
68 uint16_t tmp_uint16;
68 uint16_t i;
69 uint16_t i;
69
70
70 alpha_M = 45 * (3.1415927/180);
71 alpha_M = 45 * (3.1415927/180);
71
72
72 #ifdef DEBUG_TCH
73 #ifdef DEBUG_TCH
73 printf("BP1 : \n");
74 printf("BP1 : \n");
74 printf("Number of bins: %d\n", nb_bins_compressed_spec_mat);
75 printf("Number of bins: %d\n", nb_bins_compressed_spec_mat);
75 #endif
76 #endif
76
77
77 // initialization for managing the exponents of the floating point data:
78 // initialization for managing the exponents of the floating point data:
78 nbitexp = 6; // number of bits for the exponent
79 nbitexp = 6; // number of bits for the exponent
79 expmax = 32+5; // maximum value of the exponent
80 expmax = 32+5; // maximum value of the exponent
80 expmin = expmax - (1 << nbitexp) + 1; // accordingly the minimum exponent value
81 expmin = expmax - (1 << nbitexp) + 1; // accordingly the minimum exponent value
81 // for floating point data to be recorded on 16-bit words:
82 // for floating point data to be recorded on 16-bit words:
82 nbitsig = 16 - nbitexp; // number of bits for the significand
83 nbitsig = 16 - nbitexp; // number of bits for the significand
83 rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
84 rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
84
85
85 #ifdef DEBUG_TCH
86 #ifdef DEBUG_TCH
86 printf("nbitexp : %d, expmax : %d, expmin : %d\n", nbitexp, expmax, expmin);
87 printf("nbitexp : %d, expmax : %d, expmin : %d\n", nbitexp, expmax, expmin);
87 printf("nbitsig : %d, rangesig : %d\n", nbitsig, rangesig);
88 printf("nbitsig : %d, rangesig : %d\n", nbitsig, rangesig);
88 #endif
89 #endif
89
90
90 for(i=0; i<nb_bins_compressed_spec_mat; i++){
91 for(i=0; i<nb_bins_compressed_spec_mat; i++){
91 //==============================================
92 //==============================================
92 // BP1 PSDB == PA_LFR_SC_BP1_PB_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand)
93 // BP1 PSDB == PA_LFR_SC_BP1_PB_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand)
93 PSDB = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] // S11
94 PSDB = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] // S11
94 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] // S22
95 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] // S22
95 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]; // S33
96 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]; // S33
96
97
97 significand = frexpf(PSDB, &exponent); // 0.5 <= significand < 1
98 significand = frexpf(PSDB, &exponent); // 0.5 <= significand < 1
98 // PSDB = significand * 2^exponent
99 // PSDB = significand * 2^exponent
99
100
100 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
101 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
101 exponent = expmin;
102 exponent = expmin;
102 significand = 0.5; // min value that can be recorded
103 significand = 0.5; // min value that can be recorded
103 }
104 }
104 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
105 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
105 exponent = expmax;
106 exponent = expmax;
106 significand = 1.0; // max value that can be recorded
107 significand = 1.0; // max value that can be recorded
107 }
108 }
108 if (significand == 0) { // in that case exponent == 0 too
109 if (significand == 0) { // in that case exponent == 0 too
109 exponent = expmin;
110 exponent = expmin;
110 significand = 0.5; // min value that can be recorded
111 significand = 0.5; // min value that can be recorded
111 }
112 }
112
113
113 psd = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
114 psd = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
114 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
115 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
115 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
116 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
116 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
117 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
117 tmp_uint16 = psd | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
118 tmp_uint16 = psd | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
118 // left place of the significand bits (nbitsig),
119 // left place of the significand bits (nbitsig),
119 // making the 16-bit word to be recorded
120 // making the 16-bit word to be recorded
120 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
121 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
121 #ifdef MSB_FIRST_TCH
122 #ifdef MSB_FIRST_TCH
122 lfr_bp1[i*NB_BYTES_BP1+2] = pt_uint8[0]; // Record MSB of tmp_uint16
123 lfr_bp1[i*NB_BYTES_BP1+2] = pt_uint8[0]; // Record MSB of tmp_uint16
123 lfr_bp1[i*NB_BYTES_BP1+3] = pt_uint8[1]; // Record LSB of tmp_uint16
124 lfr_bp1[i*NB_BYTES_BP1+3] = pt_uint8[1]; // Record LSB of tmp_uint16
124 #endif
125 #endif
125 #ifdef LSB_FIRST_TCH
126 #ifdef LSB_FIRST_TCH
126 lfr_bp1[i*NB_BYTES_BP1+2] = pt_uint8[1]; // Record MSB of tmp_uint16
127 lfr_bp1[i*NB_BYTES_BP1+2] = pt_uint8[1]; // Record MSB of tmp_uint16
127 lfr_bp1[i*NB_BYTES_BP1+3] = pt_uint8[0]; // Record LSB of tmp_uint16
128 lfr_bp1[i*NB_BYTES_BP1+3] = pt_uint8[0]; // Record LSB of tmp_uint16
128 #endif
129 #endif
129 #ifdef DEBUG_TCH
130 #ifdef DEBUG_TCH
130 printf("\nBin number: %d\n", i);
131 printf("\nBin number: %d\n", i);
131 printf("PSDB : %16.8e\n",PSDB);
132 printf("PSDB : %16.8e\n",PSDB);
132 printf("significand : %16.8e\n",significand);
133 printf("significand : %16.8e\n",significand);
133 printf("exponent : %d\n" ,exponent);
134 printf("exponent : %d\n" ,exponent);
134 printf("psd for PSDB significand : %d\n",psd);
135 printf("psd for PSDB significand : %d\n",psd);
135 printf("exp for PSDB exponent : %d\n",exp);
136 printf("exp for PSDB exponent : %d\n",exp);
136 printf("pt_uint8[1] for PSDB exponent + significand: %.3d or %.2x\n",pt_uint8[1], pt_uint8[1]);
137 printf("pt_uint8[1] for PSDB exponent + significand: %.3d or %.2x\n",pt_uint8[1], pt_uint8[1]);
137 printf("pt_uint8[0] for PSDB significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]);
138 printf("pt_uint8[0] for PSDB significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]);
138 printf("lfr_bp1[i*NB_BYTES_BP1+2] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+2], lfr_bp1[i*NB_BYTES_BP1+2]);
139 printf("lfr_bp1[i*NB_BYTES_BP1+2] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+2], lfr_bp1[i*NB_BYTES_BP1+2]);
139 printf("lfr_bp1[i*NB_BYTES_BP1+3] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+3], lfr_bp1[i*NB_BYTES_BP1+3]);
140 printf("lfr_bp1[i*NB_BYTES_BP1+3] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+3], lfr_bp1[i*NB_BYTES_BP1+3]);
140 #endif
141 #endif
141 //==============================================
142 //==============================================
142 // BP1 PSDE == PA_LFR_SC_BP1_PE_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand)
143 // BP1 PSDE == PA_LFR_SC_BP1_PE_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand)
143 PSDE = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K44_PE] // S44
144 PSDE = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K44_PE] // S44
144 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K55_PE] // S55
145 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K55_PE] // S55
145 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+22] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K45_PE_RE] // S45 Re
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
146 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+23] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K45_PE_IM]; // S45 Im
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
147
148
148 significand = frexpf(PSDE, &exponent); // 0.5 <= significand < 1
149 significand = frexpf(PSDE, &exponent); // 0.5 <= significand < 1
149 // PSDE = significand * 2^exponent
150 // PSDE = significand * 2^exponent
150
151
151 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
152 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
152 exponent = expmin;
153 exponent = expmin;
153 significand = 0.5; // min value that can be recorded
154 significand = 0.5; // min value that can be recorded
154 }
155 }
155 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
156 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
156 exponent = expmax;
157 exponent = expmax;
157 significand = 1.0; // max value that can be recorded
158 significand = 1.0; // max value that can be recorded
158 }
159 }
159 if (significand == 0) {// in that case exponent == 0 too
160 if (significand == 0) {// in that case exponent == 0 too
160 exponent = expmin;
161 exponent = expmin;
161 significand = 0.5; // min value that can be recorded
162 significand = 0.5; // min value that can be recorded
162 }
163 }
163
164
164 psd = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
165 psd = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
165 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
166 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
166 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
167 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
167 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
168 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
168 tmp_uint16 = psd | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
169 tmp_uint16 = psd | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
169 // left place of the significand bits (nbitsig),
170 // left place of the significand bits (nbitsig),
170 // making the 16-bit word to be recorded
171 // making the 16-bit word to be recorded
171 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
172 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
172 #ifdef MSB_FIRST_TCH
173 #ifdef MSB_FIRST_TCH
173 lfr_bp1[i*NB_BYTES_BP1+0] = pt_uint8[0]; // Record MSB of tmp_uint16
174 lfr_bp1[i*NB_BYTES_BP1+0] = pt_uint8[0]; // Record MSB of tmp_uint16
174 lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[1]; // Record LSB of tmp_uint16
175 lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[1]; // Record LSB of tmp_uint16
175 #endif
176 #endif
176 #ifdef LSB_FIRST_TCH
177 #ifdef LSB_FIRST_TCH
177 lfr_bp1[i*NB_BYTES_BP1+0] = pt_uint8[1]; // Record MSB of tmp_uint16
178 lfr_bp1[i*NB_BYTES_BP1+0] = pt_uint8[1]; // Record MSB of tmp_uint16
178 lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[0]; // Record LSB of tmp_uint16
179 lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[0]; // Record LSB of tmp_uint16
179 #endif
180 #endif
180 #ifdef DEBUG_TCH
181 #ifdef DEBUG_TCH
181 printf("PSDE : %16.8e\n",PSDE);
182 printf("PSDE : %16.8e\n",PSDE);
182 printf("significand : %16.8e\n",significand);
183 printf("significand : %16.8e\n",significand);
183 printf("exponent : %d\n" ,exponent);
184 printf("exponent : %d\n" ,exponent);
184 printf("psd for PSDE significand : %d\n",psd);
185 printf("psd for PSDE significand : %d\n",psd);
185 printf("exp for PSDE exponent : %d\n",exp);
186 printf("exp for PSDE exponent : %d\n",exp);
186 printf("pt_uint8[1] for PSDE exponent + significand: %.3d or %.2x\n",pt_uint8[1], pt_uint8[1]);
187 printf("pt_uint8[1] for PSDE exponent + significand: %.3d or %.2x\n",pt_uint8[1], pt_uint8[1]);
187 printf("pt_uint8[0] for PSDE significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]);
188 printf("pt_uint8[0] for PSDE significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]);
188 printf("lfr_bp1[i*NB_BYTES_BP1+0] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+0], lfr_bp1[i*NB_BYTES_BP1+0]);
189 printf("lfr_bp1[i*NB_BYTES_BP1+0] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+0], lfr_bp1[i*NB_BYTES_BP1+0]);
189 printf("lfr_bp1[i*NB_BYTES_BP1+1] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+1], lfr_bp1[i*NB_BYTES_BP1+1]);
190 printf("lfr_bp1[i*NB_BYTES_BP1+1] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+1], lfr_bp1[i*NB_BYTES_BP1+1]);
190 #endif
191 #endif
191 //==============================================================================
192 //==============================================================================
192 // BP1 normal wave vector == PA_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
193 // BP1 normal wave vector == PA_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
193 // == PA_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
194 // == PA_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
194 // == PA_LFR_SC_BP1_NVEC_V2_F0 == 1 sign bit
195 // == PA_LFR_SC_BP1_NVEC_V2_F0 == 1 sign bit
195 tmp = sqrt( compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] //Im S12
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
196 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] //Im S13
197 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] //Im S13
197 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11] //Im S23
198 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11] //Im S23
198 );
199 );
199 if (tmp != 0.) { // no division by 0.
200 if (tmp != 0.) { // no division by 0.
200 NVEC_V0 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]/ tmp; // S23 Im => n1
201 NVEC_V0 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]/ tmp; // S23 Im => n1
201 NVEC_V1 = -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / tmp; // S13 Im => n2
202 NVEC_V1 = -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / tmp; // S13 Im => n2
202 NVEC_V2 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / tmp; // S12 Im => n3
203 NVEC_V2 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / tmp; // S12 Im => n3
203 }
204 }
204 else
205 else
205 {
206 {
206 NVEC_V0 = 0.;
207 NVEC_V0 = 0.;
207 NVEC_V1 = 0.;
208 NVEC_V1 = 0.;
208 NVEC_V2 = 0.;
209 NVEC_V2 = 0.;
209 }
210 }
210 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
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
211 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
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
212 pt_uint8 = (uint8_t*) &NVEC_V2; // Affect an uint8_t pointer with the adress of NVEC_V2
213 pt_uint8 = (uint8_t*) &NVEC_V2; // Affect an uint8_t pointer with the adress of NVEC_V2
213 #ifdef LSB_FIRST_TCH
214 #ifdef LSB_FIRST_TCH
214 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)
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)
215 // Record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
216 // Record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
216 #endif
217 #endif
217 #ifdef MSB_FIRST_TCH
218 #ifdef MSB_FIRST_TCH
218 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)
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)
219 // Record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
220 // Record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
220 #endif
221 #endif
221 #ifdef DEBUG_TCH
222 #ifdef DEBUG_TCH
222 printf("NVEC_V0 : %16.8e\n",NVEC_V0);
223 printf("NVEC_V0 : %16.8e\n",NVEC_V0);
223 printf("NVEC_V1 : %16.8e\n",NVEC_V1);
224 printf("NVEC_V1 : %16.8e\n",NVEC_V1);
224 printf("NVEC_V2 : %16.8e\n",NVEC_V2);
225 printf("NVEC_V2 : %16.8e\n",NVEC_V2);
225 printf("lfr_bp1[i*NB_BYTES_BP1+4] for NVEC_V0 : %u\n",lfr_bp1[i*NB_BYTES_BP1+4]);
226 printf("lfr_bp1[i*NB_BYTES_BP1+4] for NVEC_V0 : %u\n",lfr_bp1[i*NB_BYTES_BP1+4]);
226 printf("lfr_bp1[i*NB_BYTES_BP1+5] for NVEC_V1 : %u\n",lfr_bp1[i*NB_BYTES_BP1+5]);
227 printf("lfr_bp1[i*NB_BYTES_BP1+5] for NVEC_V1 : %u\n",lfr_bp1[i*NB_BYTES_BP1+5]);
227 printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
228 printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
228 #endif
229 #endif
229 //=======================================================
230 //=======================================================
230 // BP1 ellipticity == PA_LFR_SC_BP1_ELLIP_F0 == 4 bits
231 // BP1 ellipticity == PA_LFR_SC_BP1_ELLIP_F0 == 4 bits
231 if (PSDB != 0.) { // no division by 0.
232 if (PSDB != 0.) { // no division by 0.
232 aux = 2*tmp / PSDB; // Compute the ellipticity
233 aux = 2*tmp / PSDB; // Compute the ellipticity
233 }
234 }
234 else
235 else
235 {
236 {
236 aux = 0.;
237 aux = 0.;
237 }
238 }
238 tmp_uint8 = (uint8_t) (aux*15 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
239 tmp_uint8 = (uint8_t) (aux*15 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
239 // where just the first 4 bits are used (0, ..., 15)
240 // where just the first 4 bits are used (0, ..., 15)
240 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
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
241 // of the sign bit of NVEC_V2 (recorded
242 // of the sign bit of NVEC_V2 (recorded
242 // previously in lfr_bp1[i*NB_BYTES_BP1+6])
243 // previously in lfr_bp1[i*NB_BYTES_BP1+6])
243 #ifdef DEBUG_TCH
244 #ifdef DEBUG_TCH
244 printf("ellipticity : %16.8e\n",aux);
245 printf("ellipticity : %16.8e\n",aux);
245 printf("tmp_uint8 for ellipticity : %u\n",tmp_uint8);
246 printf("tmp_uint8 for ellipticity : %u\n",tmp_uint8);
246 printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
247 printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
247 #endif
248 #endif
248 //==============================================================
249 //==============================================================
249 // BP1 degree of polarization == PA_LFR_SC_BP1_DOP_F0 == 3 bits
250 // BP1 degree of polarization == PA_LFR_SC_BP1_DOP_F0 == 3 bits
250 tr_SB_SB = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]
251 tr_SB_SB = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]
251 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]
252 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]
252 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]
253 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]
253 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1]
254 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1]
254 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2]
255 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2]
255 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3]
256 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3]
256 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4]
257 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4]
257 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]
258 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]
258 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11];
259 + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11];
259 aux = PSDB*PSDB;
260 aux = PSDB*PSDB;
260 if (aux != 0.) { // no division by 0.
261 if (aux != 0.) { // no division by 0.
261 tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); // Compute the degree of polarisation
262 tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); // Compute the degree of polarisation
262 }
263 }
263 else
264 else
264 {
265 {
265 tmp = 0.;
266 tmp = 0.;
266 }
267 }
267 tmp_uint8 = (uint8_t) (tmp*7 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
268 tmp_uint8 = (uint8_t) (tmp*7 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
268 // where just the first 3 bits are used (0, ..., 7)
269 // where just the first 3 bits are used (0, ..., 7)
269 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
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
270 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
271 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
271 #ifdef DEBUG_TCH
272 #ifdef DEBUG_TCH
272 printf("DOP : %16.8e\n",tmp);
273 printf("DOP : %16.8e\n",tmp);
273 printf("tmp_uint8 for DOP : %u\n",tmp_uint8);
274 printf("tmp_uint8 for DOP : %u\n",tmp_uint8);
274 printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity + DOP : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
275 printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity + DOP : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
275 #endif
276 #endif
276 //=======================================================================================
277 //=======================================================================================
277 // BP1 X_SO-component of the Poynting flux == PA_LFR_SC_BP1_SX_F0 == 16 bits
278 // BP1 X_SO-component of the Poynting flux == PA_LFR_SC_BP1_SX_F0 == 16 bits
278 // = 1 sign bit + 1 argument bit (two sectors)
279 // = 1 sign bit + 1 argument bit (two sectors)
279 // + 6 bits (exponent) + 8 bits (significand)
280 // + 6 bits (exponent) + 8 bits (significand)
280 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
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
281 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_RE] //S35 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
282 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_RE] //S14 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
283 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_RE] //S15 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
284 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_RE] //S24 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
285 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_RE] //S25 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
286 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_IM] //S34 Im
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
287 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_IM] //S35 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
288 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_IM] //S14 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
289 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_IM] //S15 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
290 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_IM] //S24 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
291 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_IM]; //S25 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
292 // Im(S_ji) = -Im(S_ij)
293 // Im(S_ji) = -Im(S_ij)
293 // k_ji = k_ij
294 // k_ji = k_ij
294 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
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
295 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_IM] //S35 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
296 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_IM] //S14 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
297 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_IM] //S15 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
298 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_IM] //S24 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
299 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_IM] //S25 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
300 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_RE] //S34 Im
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
301 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_RE] //S35 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
302 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_RE] //S14 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
303 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_RE] //S15 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
304 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_RE] //S24 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
305 - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_RE]; //S25 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
306 #ifdef DEBUG_TCH
307 #ifdef DEBUG_TCH
307 printf("ReaSX : %16.8e\n",e_cross_b_re);
308 printf("ReaSX : %16.8e\n",e_cross_b_re);
308 #endif
309 #endif
309 pt_uint8 = (uint8_t*) &e_cross_b_re; // Affect an uint8_t pointer with the adress of e_cross_b_re
310 pt_uint8 = (uint8_t*) &e_cross_b_re; // Affect an uint8_t pointer with the adress of e_cross_b_re
310 #ifdef LSB_FIRST_TCH
311 #ifdef LSB_FIRST_TCH
311 lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention)
312
312 // Record it at the 8th bit position (from the right to the left)
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)
313 // of lfr_bp1[i*NB_BYTES_BP1+7]
314 // Record it at the 8th bit position (from the right to the left)
315 // of lfr_bp1[i*NB_BYTES_BP1+7]
314 pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
316 pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
315 #endif
317 #endif
316 #ifdef MSB_FIRST_TCH
318 #ifdef MSB_FIRST_TCH
317 lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention)
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)
318 // Record it at the 8th bit position (from the right to the left)
320 // Record it at the 8th bit position (from the right to the left)
319 // of lfr_bp1[i*NB_BYTES_BP1+7]
321 // of lfr_bp1[i*NB_BYTES_BP1+7]
320 pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
322 pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
321 #endif
323 #endif
322 significand = frexpf(e_cross_b_re, &exponent); // 0.5 <= significand < 1
324 significand = frexpf(e_cross_b_re, &exponent); // 0.5 <= significand < 1
323 // ReaSX = significand * 2^exponent
325 // ReaSX = significand * 2^exponent
324 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
326 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
325 exponent = expmin;
327 exponent = expmin;
326 significand = 0.5; // min value that can be recorded
328 significand = 0.5; // min value that can be recorded
327 }
329 }
328 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
330 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
329 exponent = expmax;
331 exponent = expmax;
330 significand = 1.0; // max value that can be recorded
332 significand = 1.0; // max value that can be recorded
331 }
333 }
332 if (significand == 0) { // in that case exponent == 0 too
334 if (significand == 0) { // in that case exponent == 0 too
333 exponent = expmin;
335 exponent = expmin;
334 significand = 0.5; // min value that can be recorded
336 significand = 0.5; // min value that can be recorded
335 }
337 }
336
338
337 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
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
338 // where all bits are used (0, ..., 255)
340 // where all bits are used (0, ..., 255)
339 tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
341 tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
340 // just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
342 // just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
341 #ifdef DEBUG_TCH
343 #ifdef DEBUG_TCH
342 printf("|ReaSX| : %16.8e\n",e_cross_b_re);
344 printf("|ReaSX| : %16.8e\n",e_cross_b_re);
343 printf("significand : %16.8e\n",significand);
345 printf("significand : %16.8e\n",significand);
344 printf("exponent : %d\n" ,exponent);
346 printf("exponent : %d\n" ,exponent);
345 printf("tmp_uint8 for ReaSX exponent : %d\n",tmp_uint8);
347 printf("tmp_uint8 for ReaSX exponent : %d\n",tmp_uint8);
346 #endif
348 #endif
347 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
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
348 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+7]
350 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+7]
349 #ifdef DEBUG_TCH
351 #ifdef DEBUG_TCH
350 printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX sign + RealSX exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
352 printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX sign + RealSX exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
351 printf("lfr_bp1[i*NB_BYTES_BP1+8] for ReaSX significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]);
353 printf("lfr_bp1[i*NB_BYTES_BP1+8] for ReaSX significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]);
352 printf("ImaSX : %16.8e\n",e_cross_b_im);
354 printf("ImaSX : %16.8e\n",e_cross_b_im);
353 #endif
355 #endif
354 pt_uint8 = (uint8_t*) &e_cross_b_im; // Affect an uint8_t pointer with the adress of e_cross_b_im
356 pt_uint8 = (uint8_t*) &e_cross_b_im; // Affect an uint8_t pointer with the adress of e_cross_b_im
355 #ifdef LSB_FIRST_TCH
357 #ifdef LSB_FIRST_TCH
356 pt_uint8[3] = pt_uint8[3] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX| (32-bit float, sign bit in the 4th octet:PC convention)
358 pt_uint8[3] = pt_uint8[3] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX| (32-bit float, sign bit in the 4th octet:PC convention)
357 #endif
359 #endif
358 #ifdef MSB_FIRST_TCH
360 #ifdef MSB_FIRST_TCH
359 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)
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)
360 #endif
362 #endif
361 tmp_uint8 = (e_cross_b_im > e_cross_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect
363 tmp_uint8 = (e_cross_b_im > e_cross_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect
362 // an unsigned 8-bit char with 01000000; otherwise with null.
364 // an unsigned 8-bit char with 01000000; otherwise with null.
363 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
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
364 // to the left) of lfr_bp1[i*NB_BYTES_BP1+7], by simple logical addition.
366 // to the left) of lfr_bp1[i*NB_BYTES_BP1+7], by simple logical addition.
365 #ifdef DEBUG_TCH
367 #ifdef DEBUG_TCH
366 printf("|ImaSX| : %16.8e\n",e_cross_b_im);
368 printf("|ImaSX| : %16.8e\n",e_cross_b_im);
367 printf("ArgSX sign : %u\n",tmp_uint8);
369 printf("ArgSX sign : %u\n",tmp_uint8);
368 printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX & ArgSX signs + ReaSX exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
370 printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX & ArgSX signs + ReaSX exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
369 #endif
371 #endif
370 //======================================================================
372 //======================================================================
371 // BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 16 bits
373 // BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 16 bits
372 // = 1 sign bit + 1 argument bit (two sectors)
374 // = 1 sign bit + 1 argument bit (two sectors)
373 // + 6 bits (exponent) + 8 bits (significand)
375 // + 6 bits (exponent) + 8 bits (significand)
374 ny = sin(alpha_M)*NVEC_V1 + cos(alpha_M)*NVEC_V2;
376 ny = sin(alpha_M)*NVEC_V1 + cos(alpha_M)*NVEC_V2;
375 nz = NVEC_V0;
377 nz = NVEC_V0;
376 bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] // S22 Re
378 bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] // S22 Re
377 + sin(alpha_M)*sin(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] // S33 Re
379 + sin(alpha_M)*sin(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] // S33 Re
378 - 2*sin(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]; // S23 Re
380 - 2*sin(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]; // S23 Re
379
381
380 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
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
381 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_RE] //S25 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
382 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_RE] //S34 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
383 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_RE] //S35 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
384 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_IM] //S24 Im
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
385 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_IM] //S25 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
386 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_IM] //S34 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
387 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_IM]) //S35 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
388 + 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
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
389 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] //S25 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
390 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] //S34 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
391 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_RE] //S35 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
392 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] //S24 Im
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
393 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] //S25 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
394 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] //S34 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
395 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_IM]);//S35 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
396 // Im(S_ji) = -Im(S_ij)
398 // Im(S_ji) = -Im(S_ij)
397 // k_ji = k_ij
399 // k_ji = k_ij
398 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
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
399 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_IM] //S25 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
400 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_IM] //S34 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
401 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_IM] //S35 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
402 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_RE] //S24 Im
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
403 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_RE] //S25 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
404 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_RE] //S34 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
405 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_RE]) //S35 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
406 + 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
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
407 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] //S25 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
408 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] //S34 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
409 +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_IM] //S35 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
410 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] //S24 Im
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
411 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] //S25 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
412 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] //S34 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
413 -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_RE]);//S35 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
414 #ifdef DEBUG_TCH
416 #ifdef DEBUG_TCH
415 printf("n_cross_e_scal_b_re : %16.8e\n",n_cross_e_scal_b_re);
417 printf("n_cross_e_scal_b_re : %16.8e\n",n_cross_e_scal_b_re);
416 printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im);
418 printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im);
417 #endif
419 #endif
418 // vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re)
420 // vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re)
419 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
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
420 #ifdef LSB_FIRST_TCH
422 #ifdef LSB_FIRST_TCH
421 lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention)
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)
422 // Record it at the 8th bit position (from the right to the left)
424 // Record it at the 8th bit position (from the right to the left)
423 // of lfr_bp1[i*NB_BYTES_BP1+9]
425 // of lfr_bp1[i*NB_BYTES_BP1+9]
424 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|
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|
425 #endif
427 #endif
426 #ifdef MSB_FIRST_TCH
428 #ifdef MSB_FIRST_TCH
427 lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention)
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)
428 // Record it at the 8th bit position (from the right to the left)
430 // Record it at the 8th bit position (from the right to the left)
429 // of lfr_bp1[i*NB_BYTES_BP1+9]
431 // of lfr_bp1[i*NB_BYTES_BP1+9]
430 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|
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|
431 #endif
433 #endif
432 if (bx_bx_star != 0.) { // no division by 0.
434 if (bx_bx_star != 0.) { // no division by 0.
433 vphi = n_cross_e_scal_b_re / bx_bx_star; // Compute |VPHI|
435 vphi = n_cross_e_scal_b_re / bx_bx_star; // Compute |VPHI|
434 }
436 }
435 else
437 else
436 {
438 {
437 vphi = 1.e+20; // Put a huge value
439 vphi = 1.e+20; // Put a huge value
438 }
440 }
439 significand = frexpf(vphi, &exponent); // 0.5 <= significand < 1
441 significand = frexpf(vphi, &exponent); // 0.5 <= significand < 1
440 // vphi = significand * 2^exponent
442 // vphi = significand * 2^exponent
441 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
443 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
442 exponent = expmin;
444 exponent = expmin;
443 significand = 0.5; // min value that can be recorded
445 significand = 0.5; // min value that can be recorded
444 }
446 }
445 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
447 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
446 exponent = expmax;
448 exponent = expmax;
447 significand = 1.0; // max value that can be recorded
449 significand = 1.0; // max value that can be recorded
448 }
450 }
449 if (significand == 0) {// in that case exponent == 0 too
451 if (significand == 0) {// in that case exponent == 0 too
450 exponent = expmin;
452 exponent = expmin;
451 significand = 0.5; // min value that can be recorded
453 significand = 0.5; // min value that can be recorded
452 }
454 }
453
455
454 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
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
455 // where all the bits are used (0, ..., 255)
457 // where all the bits are used (0, ..., 255)
456 tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
458 tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
457 // just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
459 // just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
458 #ifdef DEBUG_TCH
460 #ifdef DEBUG_TCH
459 printf("|VPHI| : %16.8e\n",vphi);
461 printf("|VPHI| : %16.8e\n",vphi);
460 printf("significand : %16.8e\n",significand);
462 printf("significand : %16.8e\n",significand);
461 printf("exponent : %d\n" ,exponent);
463 printf("exponent : %d\n" ,exponent);
462 printf("tmp_uint8 for VPHI exponent : %d\n",tmp_uint8);
464 printf("tmp_uint8 for VPHI exponent : %d\n",tmp_uint8);
463 #endif
465 #endif
464 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
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
465 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+9]
467 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+9]
466 #ifdef DEBUG_TCH
468 #ifdef DEBUG_TCH
467 printf("lfr_bp1[i*NB_BYTES_BP1+9] for VPHI sign + VPHI exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+9]);
469 printf("lfr_bp1[i*NB_BYTES_BP1+9] for VPHI sign + VPHI exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+9]);
468 printf("lfr_bp1[i*NB_BYTES_BP1+10] for VPHI significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+10]);
470 printf("lfr_bp1[i*NB_BYTES_BP1+10] for VPHI significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+10]);
469 #endif
471 #endif
470 pt_uint8 = (uint8_t*) &n_cross_e_scal_b_im; // Affect an uint8_t pointer with the adress of n_cross_e_scal_b_im
472 pt_uint8 = (uint8_t*) &n_cross_e_scal_b_im; // Affect an uint8_t pointer with the adress of n_cross_e_scal_b_im
471 #ifdef LSB_FIRST_TCH
473 #ifdef LSB_FIRST_TCH
472 pt_uint8[3] = pt_uint8[3] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaNEBX| (32-bit float, sign bit in the 4th octet:PC convention)
474 pt_uint8[3] = pt_uint8[3] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaNEBX| (32-bit float, sign bit in the 4th octet:PC convention)
473 #endif
475 #endif
474 #ifdef MSB_FIRST_TCH
476 #ifdef MSB_FIRST_TCH
475 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)
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)
476 #endif
478 #endif
477 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
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
478 // an unsigned 8-bit char with 01000000; otherwise with null.
480 // an unsigned 8-bit char with 01000000; otherwise with null.
479 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
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
480 // to the left) of lfr_bp1[i*NB_BYTES_BP1+9], by simple logical addition.
482 // to the left) of lfr_bp1[i*NB_BYTES_BP1+9], by simple logical addition.
481 #ifdef DEBUG_TCH
483 #ifdef DEBUG_TCH
482 printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im);
484 printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im);
483 printf("|n_cross_e_scal_b_im|/bx_bx_star : %16.8e\n",n_cross_e_scal_b_im/bx_bx_star);
485 printf("|n_cross_e_scal_b_im|/bx_bx_star : %16.8e\n",n_cross_e_scal_b_im/bx_bx_star);
484 printf("ArgNEBX sign : %u\n",tmp_uint8);
486 printf("ArgNEBX sign : %u\n",tmp_uint8);
485 printf("lfr_bp1[i*NB_BYTES_BP1+9] for VPHI & ArgNEBX signs + VPHI exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+9]);
487 printf("lfr_bp1[i*NB_BYTES_BP1+9] for VPHI & ArgNEBX signs + VPHI exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+9]);
486 #endif
488 #endif
487 }
489 }
488 }
490 }
489
491
490 void BP2_set( float * compressed_spec_mat, uint8_t nb_bins_compressed_spec_mat, uint8_t * lfr_bp2 )
492 void BP2_set( float * compressed_spec_mat, uint8_t nb_bins_compressed_spec_mat, uint8_t * lfr_bp2 )
491 {
493 {
492 float cross_re; // 32-bit floating point
494 float cross_re; // 32-bit floating point
493 float cross_im;
495 float cross_im;
494 float aux;
496 float aux;
495 float significand;
497 float significand;
496 int exponent; // 32-bit signed integer
498 int exponent; // 32-bit signed integer
497 uint8_t nbitexp; // 8-bit unsigned integer
499 uint8_t nbitexp; // 8-bit unsigned integer
498 uint8_t nbitsig;
500 uint8_t nbitsig;
499 uint8_t *pt_uint8; // pointer on unsigned 8-bit integer
501 uint8_t *pt_uint8; // pointer on unsigned 8-bit integer
500 int8_t expmin; // 8-bit signed integer
502 int8_t expmin; // 8-bit signed integer
501 int8_t expmax;
503 int8_t expmax;
502 uint16_t rangesig; // 16-bit unsigned integer
504 uint16_t rangesig; // 16-bit unsigned integer
503 uint16_t autocor;
505 uint16_t autocor;
504 uint16_t exp;
506 uint16_t exp;
505 uint16_t tmp_uint16;
507 uint16_t tmp_uint16;
506 uint16_t i;
508 uint16_t i;
507
509
508 #ifdef DEBUG_TCH
510 #ifdef DEBUG_TCH
509 printf("BP2 : \n");
511 printf("BP2 : \n");
510 printf("Number of bins: %d\n", nb_bins_compressed_spec_mat);
512 printf("Number of bins: %d\n", nb_bins_compressed_spec_mat);
511 #endif
513 #endif
512
514
513 // For floating point data to be recorded on 16-bit words :
515 // For floating point data to be recorded on 16-bit words :
514 nbitexp = 6; // number of bits for the exponent
516 nbitexp = 6; // number of bits for the exponent
515 nbitsig = 16 - nbitexp; // number of bits for the significand
517 nbitsig = 16 - nbitexp; // number of bits for the significand
516 rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
518 rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
517 expmax = 32 + 5;
519 expmax = 32 + 5;
518 expmin = expmax - (1 << nbitexp) + 1;
520 expmin = expmax - (1 << nbitexp) + 1;
519
521
520 #ifdef DEBUG_TCH
522 #ifdef DEBUG_TCH
521
523
522 printf("nbitexp : %d, expmax : %d, expmin : %d\n", nbitexp, expmax, expmin);
524 printf("nbitexp : %d, expmax : %d, expmin : %d\n", nbitexp, expmax, expmin);
523 printf("nbitsig : %d, rangesig : %d\n", nbitsig, rangesig);
525 printf("nbitsig : %d, rangesig : %d\n", nbitsig, rangesig);
524 #endif
526 #endif
525
527
526 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
528 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
527 //==============================================
529 //==============================================
528 // BP2 normalized cross correlations == PA_LFR_SC_BP2_CROSS_F0 == 10 * (8+8) bits
530 // BP2 normalized cross correlations == PA_LFR_SC_BP2_CROSS_F0 == 10 * (8+8) bits
529 // == PA_LFR_SC_BP2_CROSS_RE_0_F0 == 8 bits
531 // == PA_LFR_SC_BP2_CROSS_RE_0_F0 == 8 bits
530 // == PA_LFR_SC_BP2_CROSS_IM_0_F0 == 8 bits
532 // == PA_LFR_SC_BP2_CROSS_IM_0_F0 == 8 bits
531 // == PA_LFR_SC_BP2_CROSS_RE_1_F0 == 8 bits
533 // == PA_LFR_SC_BP2_CROSS_RE_1_F0 == 8 bits
532 // == PA_LFR_SC_BP2_CROSS_IM_1_F0 == 8 bits
534 // == PA_LFR_SC_BP2_CROSS_IM_1_F0 == 8 bits
533 // == PA_LFR_SC_BP2_CROSS_RE_2_F0 == 8 bits
535 // == PA_LFR_SC_BP2_CROSS_RE_2_F0 == 8 bits
534 // == PA_LFR_SC_BP2_CROSS_IM_2_F0 == 8 bits
536 // == PA_LFR_SC_BP2_CROSS_IM_2_F0 == 8 bits
535 // == PA_LFR_SC_BP2_CROSS_RE_3_F0 == 8 bits
537 // == PA_LFR_SC_BP2_CROSS_RE_3_F0 == 8 bits
536 // == PA_LFR_SC_BP2_CROSS_IM_3_F0 == 8 bits
538 // == PA_LFR_SC_BP2_CROSS_IM_3_F0 == 8 bits
537 // == PA_LFR_SC_BP2_CROSS_RE_4_F0 == 8 bits
539 // == PA_LFR_SC_BP2_CROSS_RE_4_F0 == 8 bits
538 // == PA_LFR_SC_BP2_CROSS_IM_4_F0 == 8 bits
540 // == PA_LFR_SC_BP2_CROSS_IM_4_F0 == 8 bits
539 // == PA_LFR_SC_BP2_CROSS_RE_5_F0 == 8 bits
541 // == PA_LFR_SC_BP2_CROSS_RE_5_F0 == 8 bits
540 // == PA_LFR_SC_BP2_CROSS_IM_5_F0 == 8 bits
542 // == PA_LFR_SC_BP2_CROSS_IM_5_F0 == 8 bits
541 // == PA_LFR_SC_BP2_CROSS_RE_6_F0 == 8 bits
543 // == PA_LFR_SC_BP2_CROSS_RE_6_F0 == 8 bits
542 // == PA_LFR_SC_BP2_CROSS_IM_6_F0 == 8 bits
544 // == PA_LFR_SC_BP2_CROSS_IM_6_F0 == 8 bits
543 // == PA_LFR_SC_BP2_CROSS_RE_7_F0 == 8 bits
545 // == PA_LFR_SC_BP2_CROSS_RE_7_F0 == 8 bits
544 // == PA_LFR_SC_BP2_CROSS_IM_7_F0 == 8 bits
546 // == PA_LFR_SC_BP2_CROSS_IM_7_F0 == 8 bits
545 // == PA_LFR_SC_BP2_CROSS_RE_8_F0 == 8 bits
547 // == PA_LFR_SC_BP2_CROSS_RE_8_F0 == 8 bits
546 // == PA_LFR_SC_BP2_CROSS_IM_8_F0 == 8 bits
548 // == PA_LFR_SC_BP2_CROSS_IM_8_F0 == 8 bits
547 // == PA_LFR_SC_BP2_CROSS_RE_9_F0 == 8 bits
549 // == PA_LFR_SC_BP2_CROSS_RE_9_F0 == 8 bits
548 // == PA_LFR_SC_BP2_CROSS_IM_9_F0 == 8 bits
550 // == PA_LFR_SC_BP2_CROSS_IM_9_F0 == 8 bits
549 // S12
551 // S12
550 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]);
552 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]);
551 if (aux != 0.) { // no division by 0.
553 if (aux != 0.) { // no division by 0.
552 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] / aux;
554 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] / aux;
553 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / aux;
555 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / aux;
554 }
556 }
555 else
557 else
556 {
558 {
557 cross_re = 0.;
559 cross_re = 0.;
558 cross_im = 0.;
560 cross_im = 0.;
559 }
561 }
560 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
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
561 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
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
562 #ifdef DEBUG_TCH
564 #ifdef DEBUG_TCH
563 printf("\nBin number: %d\n", i);
565 printf("\nBin number: %d\n", i);
564 printf("lfr_bp2[i*NB_BYTES_BP2+10] for cross12_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+10]);
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]);
565 printf("lfr_bp2[i*NB_BYTES_BP2+20] for cross12_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+20]);
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]);
566 #endif
568 #endif
567 // S13
569 // S13
568 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
570 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
569 if (aux != 0.) { // no division by 0.
571 if (aux != 0.) { // no division by 0.
570 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] / aux;
572 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] / aux;
571 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / aux;
573 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / aux;
572 }
574 }
573 else
575 else
574 {
576 {
575 cross_re = 0.;
577 cross_re = 0.;
576 cross_im = 0.;
578 cross_im = 0.;
577 }
579 }
578 lfr_bp2[i*NB_BYTES_BP2+11] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
580 lfr_bp2[i*NB_BYTES_BP2+11] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
579 lfr_bp2[i*NB_BYTES_BP2+21] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
581 lfr_bp2[i*NB_BYTES_BP2+21] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
580 #ifdef DEBUG_TCH
582 #ifdef DEBUG_TCH
581 printf("lfr_bp2[i*NB_BYTES_BP2+11] for cross13_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+11]);
583 printf("lfr_bp2[i*NB_BYTES_BP2+11] for cross13_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+11]);
582 printf("lfr_bp2[i*NB_BYTES_BP2+21] for cross13_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+21]);
584 printf("lfr_bp2[i*NB_BYTES_BP2+21] for cross13_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+21]);
583 #endif
585 #endif
584 // S14
586 // S14
585 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
587 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
586 if (aux != 0.) { // no division by 0.
588 if (aux != 0.) { // no division by 0.
587 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] / aux;
589 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] / aux;
588 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] / aux;
590 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] / aux;
589 }
591 }
590 else
592 else
591 {
593 {
592 cross_re = 0.;
594 cross_re = 0.;
593 cross_im = 0.;
595 cross_im = 0.;
594 }
596 }
595 lfr_bp2[i*NB_BYTES_BP2+12] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
597 lfr_bp2[i*NB_BYTES_BP2+12] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
596 lfr_bp2[i*NB_BYTES_BP2+22] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
598 lfr_bp2[i*NB_BYTES_BP2+22] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
597 #ifdef DEBUG_TCH
599 #ifdef DEBUG_TCH
598 printf("lfr_bp2[i*NB_BYTES_BP2+12] for cross14_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+12]);
600 printf("lfr_bp2[i*NB_BYTES_BP2+12] for cross14_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+12]);
599 printf("lfr_bp2[i*NB_BYTES_BP2+22] for cross14_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+22]);
601 printf("lfr_bp2[i*NB_BYTES_BP2+22] for cross14_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+22]);
600 #endif
602 #endif
601 // S15
603 // S15
602 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
604 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
603 if (aux != 0.) { // no division by 0.
605 if (aux != 0.) { // no division by 0.
604 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] / aux;
606 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] / aux;
605 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] / aux;
607 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] / aux;
606 }
608 }
607 else
609 else
608 {
610 {
609 cross_re = 0.;
611 cross_re = 0.;
610 cross_im = 0.;
612 cross_im = 0.;
611 }
613 }
612 lfr_bp2[i*NB_BYTES_BP2+13] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
614 lfr_bp2[i*NB_BYTES_BP2+13] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
613 lfr_bp2[i*NB_BYTES_BP2+23] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
615 lfr_bp2[i*NB_BYTES_BP2+23] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
614 #ifdef DEBUG_TCH
616 #ifdef DEBUG_TCH
615 printf("lfr_bp2[i*NB_BYTES_BP2+13] for cross15_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+13]);
617 printf("lfr_bp2[i*NB_BYTES_BP2+13] for cross15_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+13]);
616 printf("lfr_bp2[i*NB_BYTES_BP2+23] for cross15_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+23]);
618 printf("lfr_bp2[i*NB_BYTES_BP2+23] for cross15_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+23]);
617 #endif
619 #endif
618 // S23
620 // S23
619 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
621 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
620 if (aux != 0.) { // no division by 0.
622 if (aux != 0.) { // no division by 0.
621 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10] / aux;
623 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10] / aux;
622 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11] / aux;
624 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11] / aux;
623 }
625 }
624 else
626 else
625 {
627 {
626 cross_re = 0.;
628 cross_re = 0.;
627 cross_im = 0.;
629 cross_im = 0.;
628 }
630 }
629 lfr_bp2[i*NB_BYTES_BP2+14] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
631 lfr_bp2[i*NB_BYTES_BP2+14] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
630 lfr_bp2[i*NB_BYTES_BP2+24] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
632 lfr_bp2[i*NB_BYTES_BP2+24] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
631 #ifdef DEBUG_TCH
633 #ifdef DEBUG_TCH
632 printf("lfr_bp2[i*NB_BYTES_BP2+14] for cross23_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+14]);
634 printf("lfr_bp2[i*NB_BYTES_BP2+14] for cross23_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+14]);
633 printf("lfr_bp2[i*NB_BYTES_BP2+24] for cross23_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+24]);
635 printf("lfr_bp2[i*NB_BYTES_BP2+24] for cross23_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+24]);
634 #endif
636 #endif
635 // S24
637 // S24
636 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
638 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
637 if (aux != 0.) { // no division by 0.
639 if (aux != 0.) { // no division by 0.
638 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12] / aux;
640 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12] / aux;
639 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13] / aux;
641 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13] / aux;
640 }
642 }
641 else
643 else
642 {
644 {
643 cross_re = 0.;
645 cross_re = 0.;
644 cross_im = 0.;
646 cross_im = 0.;
645 }
647 }
646 lfr_bp2[i*NB_BYTES_BP2+15] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
648 lfr_bp2[i*NB_BYTES_BP2+15] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
647 lfr_bp2[i*NB_BYTES_BP2+25] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
649 lfr_bp2[i*NB_BYTES_BP2+25] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
648 #ifdef DEBUG_TCH
650 #ifdef DEBUG_TCH
649 printf("lfr_bp2[i*NB_BYTES_BP2+15] for cross24_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+15]);
651 printf("lfr_bp2[i*NB_BYTES_BP2+15] for cross24_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+15]);
650 printf("lfr_bp2[i*NB_BYTES_BP2+25] for cross24_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+25]);
652 printf("lfr_bp2[i*NB_BYTES_BP2+25] for cross24_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+25]);
651 #endif
653 #endif
652 // S25
654 // S25
653 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
655 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
654 if (aux != 0.) { // no division by 0.
656 if (aux != 0.) { // no division by 0.
655 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14] / aux;
657 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14] / aux;
656 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15] / aux;
658 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15] / aux;
657 }
659 }
658 else
660 else
659 {
661 {
660 cross_re = 0.;
662 cross_re = 0.;
661 cross_im = 0.;
663 cross_im = 0.;
662 }
664 }
663 lfr_bp2[i*NB_BYTES_BP2+16] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
665 lfr_bp2[i*NB_BYTES_BP2+16] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
664 lfr_bp2[i*NB_BYTES_BP2+26] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
666 lfr_bp2[i*NB_BYTES_BP2+26] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
665 #ifdef DEBUG_TCH
667 #ifdef DEBUG_TCH
666 printf("lfr_bp2[i*NB_BYTES_BP2+16] for cross25_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+16]);
668 printf("lfr_bp2[i*NB_BYTES_BP2+16] for cross25_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+16]);
667 printf("lfr_bp2[i*NB_BYTES_BP2+26] for cross25_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+26]);
669 printf("lfr_bp2[i*NB_BYTES_BP2+26] for cross25_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+26]);
668 #endif
670 #endif
669 // S34
671 // S34
670 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
672 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
671 if (aux != 0.) { // no division by 0.
673 if (aux != 0.) { // no division by 0.
672 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17] / aux;
674 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17] / aux;
673 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18] / aux;
675 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18] / aux;
674 }
676 }
675 else
677 else
676 {
678 {
677 cross_re = 0.;
679 cross_re = 0.;
678 cross_im = 0.;
680 cross_im = 0.;
679 }
681 }
680 lfr_bp2[i*NB_BYTES_BP2+17] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
682 lfr_bp2[i*NB_BYTES_BP2+17] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
681 lfr_bp2[i*NB_BYTES_BP2+27] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
683 lfr_bp2[i*NB_BYTES_BP2+27] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
682 #ifdef DEBUG_TCH
684 #ifdef DEBUG_TCH
683 printf("lfr_bp2[i*NB_BYTES_BP2+17] for cross34_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+17]);
685 printf("lfr_bp2[i*NB_BYTES_BP2+17] for cross34_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+17]);
684 printf("lfr_bp2[i*NB_BYTES_BP2+27] for cross34_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+27]);
686 printf("lfr_bp2[i*NB_BYTES_BP2+27] for cross34_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+27]);
685 #endif
687 #endif
686 // S35
688 // S35
687 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
689 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
688 if (aux != 0.) { // no division by 0.
690 if (aux != 0.) { // no division by 0.
689 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19] / aux;
691 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19] / aux;
690 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20] / aux;
692 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20] / aux;
691 }
693 }
692 else
694 else
693 {
695 {
694 cross_re = 0.;
696 cross_re = 0.;
695 cross_im = 0.;
697 cross_im = 0.;
696 }
698 }
697 lfr_bp2[i*NB_BYTES_BP2+18] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
699 lfr_bp2[i*NB_BYTES_BP2+18] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
698 lfr_bp2[i*NB_BYTES_BP2+28] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
700 lfr_bp2[i*NB_BYTES_BP2+28] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
699 #ifdef DEBUG_TCH
701 #ifdef DEBUG_TCH
700 printf("lfr_bp2[i*NB_BYTES_BP2+18] for cross35_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+18]);
702 printf("lfr_bp2[i*NB_BYTES_BP2+18] for cross35_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+18]);
701 printf("lfr_bp2[i*NB_BYTES_BP2+28] for cross35_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+28]);
703 printf("lfr_bp2[i*NB_BYTES_BP2+28] for cross35_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+28]);
702 #endif
704 #endif
703 // S45
705 // S45
704 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
706 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
705 if (aux != 0.) { // no division by 0.
707 if (aux != 0.) { // no division by 0.
706 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+22] / aux;
708 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+22] / aux;
707 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+23] / aux;
709 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+23] / aux;
708 }
710 }
709 else
711 else
710 {
712 {
711 cross_re = 0.;
713 cross_re = 0.;
712 cross_im = 0.;
714 cross_im = 0.;
713 }
715 }
714 lfr_bp2[i*NB_BYTES_BP2+19] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
716 lfr_bp2[i*NB_BYTES_BP2+19] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
715 lfr_bp2[i*NB_BYTES_BP2+29] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
717 lfr_bp2[i*NB_BYTES_BP2+29] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
716 #ifdef DEBUG_TCH
718 #ifdef DEBUG_TCH
717 printf("lfr_bp2[i*NB_BYTES_BP2+19] for cross45_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+19]);
719 printf("lfr_bp2[i*NB_BYTES_BP2+19] for cross45_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+19]);
718 printf("lfr_bp2[i*NB_BYTES_BP2+29] for cross45_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+29]);
720 printf("lfr_bp2[i*NB_BYTES_BP2+29] for cross45_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+29]);
719 #endif
721 #endif
720 //==============================================
722 //==============================================
721 // BP2 auto correlations == PA_LFR_SC_BP2_AUTO_F0 == 5*16 bits = 5*[6 bits (exponent) + 10 bits (significand)]
723 // BP2 auto correlations == PA_LFR_SC_BP2_AUTO_F0 == 5*16 bits = 5*[6 bits (exponent) + 10 bits (significand)]
722 // == PA_LFR_SC_BP2_AUTO_A0_F0 == 16 bits
724 // == PA_LFR_SC_BP2_AUTO_A0_F0 == 16 bits
723 // == PA_LFR_SC_BP2_AUTO_A1_F0 == 16 bits
725 // == PA_LFR_SC_BP2_AUTO_A1_F0 == 16 bits
724 // == PA_LFR_SC_BP2_AUTO_A2_F0 == 16 bits
726 // == PA_LFR_SC_BP2_AUTO_A2_F0 == 16 bits
725 // == PA_LFR_SC_BP2_AUTO_A3_F0 == 16 bits
727 // == PA_LFR_SC_BP2_AUTO_A3_F0 == 16 bits
726 // == PA_LFR_SC_BP2_AUTO_A4_F0 == 16 bits
728 // == PA_LFR_SC_BP2_AUTO_A4_F0 == 16 bits
727 // S11
729 // S11
728 significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX], &exponent); // 0.5 <= significand < 1
730 significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX], &exponent); // 0.5 <= significand < 1
729 // S11 = significand * 2^exponent
731 // S11 = significand * 2^exponent
730 #ifdef DEBUG_TCH
732 #ifdef DEBUG_TCH
731 printf("S11 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]);
733 printf("S11 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]);
732 printf("significand : %16.8e\n",significand);
734 printf("significand : %16.8e\n",significand);
733 printf("exponent : %d\n" ,exponent);
735 printf("exponent : %d\n" ,exponent);
734 #endif
736 #endif
735 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
737 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
736 exponent = expmin;
738 exponent = expmin;
737 significand = 0.5; // min value that can be recorded
739 significand = 0.5; // min value that can be recorded
738 }
740 }
739 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
741 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
740 exponent = expmax;
742 exponent = expmax;
741 significand = 1.0; // max value that can be recorded
743 significand = 1.0; // max value that can be recorded
742 }
744 }
743 if (significand == 0) { // in that case exponent == 0 too
745 if (significand == 0) { // in that case exponent == 0 too
744 exponent = expmin;
746 exponent = expmin;
745 significand = 0.5; // min value that can be recorded
747 significand = 0.5; // min value that can be recorded
746 }
748 }
747
749
748 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
750 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
749 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
751 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
750 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
752 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
751 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
753 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
752 tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
754 tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
753 // left place of the significand bits (nbitsig),
755 // left place of the significand bits (nbitsig),
754 // making the 16-bit word to be recorded
756 // making the 16-bit word to be recorded
755 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
757 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
756 #ifdef MSB_FIRST_TCH
758 #ifdef MSB_FIRST_TCH
757 lfr_bp2[i*NB_BYTES_BP2+0] = pt_uint8[0]; // Record MSB of tmp_uint16
759 lfr_bp2[i*NB_BYTES_BP2+0] = pt_uint8[0]; // Record MSB of tmp_uint16
758 lfr_bp2[i*NB_BYTES_BP2+1] = pt_uint8[1]; // Record LSB of tmp_uint16
760 lfr_bp2[i*NB_BYTES_BP2+1] = pt_uint8[1]; // Record LSB of tmp_uint16
759 #endif
761 #endif
760 #ifdef LSB_FIRST_TCH
762 #ifdef LSB_FIRST_TCH
761 lfr_bp2[i*NB_BYTES_BP2+0] = pt_uint8[1]; // Record MSB of tmp_uint16
763 lfr_bp2[i*NB_BYTES_BP2+0] = pt_uint8[1]; // Record MSB of tmp_uint16
762 lfr_bp2[i*NB_BYTES_BP2+1] = pt_uint8[0]; // Record LSB of tmp_uint16
764 lfr_bp2[i*NB_BYTES_BP2+1] = pt_uint8[0]; // Record LSB of tmp_uint16
763 #endif
765 #endif
764 #ifdef DEBUG_TCH
766 #ifdef DEBUG_TCH
765 printf("autocor for S11 significand : %u\n",autocor);
767 printf("autocor for S11 significand : %u\n",autocor);
766 printf("exp for S11 exponent : %u\n",exp);
768 printf("exp for S11 exponent : %u\n",exp);
767 printf("pt_uint8[1] for S11 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
769 printf("pt_uint8[1] for S11 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
768 printf("pt_uint8[0] for S11 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
770 printf("pt_uint8[0] for S11 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
769 printf("lfr_bp2[i*NB_BYTES_BP2+0] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+0], lfr_bp2[i*NB_BYTES_BP2+0]);
771 printf("lfr_bp2[i*NB_BYTES_BP2+0] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+0], lfr_bp2[i*NB_BYTES_BP2+0]);
770 printf("lfr_bp2[i*NB_BYTES_BP2+1] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+1], lfr_bp2[i*NB_BYTES_BP2+1]);
772 printf("lfr_bp2[i*NB_BYTES_BP2+1] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+1], lfr_bp2[i*NB_BYTES_BP2+1]);
771 #endif
773 #endif
772 // S22
774 // S22
773 significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9], &exponent); // 0.5 <= significand < 1
775 significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9], &exponent); // 0.5 <= significand < 1
774 // S22 = significand * 2^exponent
776 // S22 = significand * 2^exponent
775 #ifdef DEBUG_TCH
777 #ifdef DEBUG_TCH
776 printf("S22 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]);
778 printf("S22 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]);
777 printf("significand : %16.8e\n",significand);
779 printf("significand : %16.8e\n",significand);
778 printf("exponent : %d\n" ,exponent);
780 printf("exponent : %d\n" ,exponent);
779 #endif
781 #endif
780 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
782 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
781 exponent = expmin;
783 exponent = expmin;
782 significand = 0.5; // min value that can be recorded
784 significand = 0.5; // min value that can be recorded
783 }
785 }
784 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
786 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
785 exponent = expmax;
787 exponent = expmax;
786 significand = 1.0; // max value that can be recorded
788 significand = 1.0; // max value that can be recorded
787 }
789 }
788 if (significand == 0) { // in that case exponent == 0 too
790 if (significand == 0) { // in that case exponent == 0 too
789 exponent = expmin;
791 exponent = expmin;
790 significand = 0.5; // min value that can be recorded
792 significand = 0.5; // min value that can be recorded
791 }
793 }
792
794
793 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
795 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
794 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
796 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
795 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
797 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
796 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
798 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
797 tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
799 tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
798 // left place of the significand bits (nbitsig),
800 // left place of the significand bits (nbitsig),
799 // making the 16-bit word to be recorded
801 // making the 16-bit word to be recorded
800 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
802 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
801 #ifdef MSB_FIRST_TCH
803 #ifdef MSB_FIRST_TCH
802 lfr_bp2[i*NB_BYTES_BP2+2] = pt_uint8[0]; // Record MSB of tmp_uint16
804 lfr_bp2[i*NB_BYTES_BP2+2] = pt_uint8[0]; // Record MSB of tmp_uint16
803 lfr_bp2[i*NB_BYTES_BP2+3] = pt_uint8[1]; // Record LSB of tmp_uint16
805 lfr_bp2[i*NB_BYTES_BP2+3] = pt_uint8[1]; // Record LSB of tmp_uint16
804 #endif
806 #endif
805 #ifdef LSB_FIRST_TCH
807 #ifdef LSB_FIRST_TCH
806 lfr_bp2[i*NB_BYTES_BP2+2] = pt_uint8[1]; // Record MSB of tmp_uint16
808 lfr_bp2[i*NB_BYTES_BP2+2] = pt_uint8[1]; // Record MSB of tmp_uint16
807 lfr_bp2[i*NB_BYTES_BP2+3] = pt_uint8[0]; // Record LSB of tmp_uint16
809 lfr_bp2[i*NB_BYTES_BP2+3] = pt_uint8[0]; // Record LSB of tmp_uint16
808 #endif
810 #endif
809 #ifdef DEBUG_TCH
811 #ifdef DEBUG_TCH
810 printf("autocor for S22 significand : %u\n",autocor);
812 printf("autocor for S22 significand : %u\n",autocor);
811 printf("exp for S11 exponent : %u\n",exp);
813 printf("exp for S11 exponent : %u\n",exp);
812 printf("pt_uint8[1] for S22 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
814 printf("pt_uint8[1] for S22 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
813 printf("pt_uint8[0] for S22 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
815 printf("pt_uint8[0] for S22 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
814 printf("lfr_bp2[i*NB_BYTES_BP2+2] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+2], lfr_bp2[i*NB_BYTES_BP2+2]);
816 printf("lfr_bp2[i*NB_BYTES_BP2+2] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+2], lfr_bp2[i*NB_BYTES_BP2+2]);
815 printf("lfr_bp2[i*NB_BYTES_BP2+3] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+3], lfr_bp2[i*NB_BYTES_BP2+3]);
817 printf("lfr_bp2[i*NB_BYTES_BP2+3] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+3], lfr_bp2[i*NB_BYTES_BP2+3]);
816 #endif
818 #endif
817 // S33
819 // S33
818 significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16], &exponent); // 0.5 <= significand < 1
820 significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16], &exponent); // 0.5 <= significand < 1
819 // S33 = significand * 2^exponent
821 // S33 = significand * 2^exponent
820 #ifdef DEBUG_TCH
822 #ifdef DEBUG_TCH
821 printf("S33 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
823 printf("S33 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
822 printf("significand : %16.8e\n",significand);
824 printf("significand : %16.8e\n",significand);
823 printf("exponent : %d\n" ,exponent);
825 printf("exponent : %d\n" ,exponent);
824 #endif
826 #endif
825 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
827 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
826 exponent = expmin;
828 exponent = expmin;
827 significand = 0.5; // min value that can be recorded
829 significand = 0.5; // min value that can be recorded
828 }
830 }
829 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
831 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
830 exponent = expmax;
832 exponent = expmax;
831 significand = 1.0; // max value that can be recorded
833 significand = 1.0; // max value that can be recorded
832 }
834 }
833 if (significand == 0) { // in that case exponent == 0 too
835 if (significand == 0) { // in that case exponent == 0 too
834 exponent = expmin;
836 exponent = expmin;
835 significand = 0.5; // min value that can be recorded
837 significand = 0.5; // min value that can be recorded
836 }
838 }
837
839
838 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
840 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
839 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
841 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
840 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
842 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
841 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
843 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
842 tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
844 tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
843 // left place of the significand bits (nbitsig),
845 // left place of the significand bits (nbitsig),
844 // making the 16-bit word to be recorded
846 // making the 16-bit word to be recorded
845 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
847 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
846 #ifdef MSB_FIRST_TCH
848 #ifdef MSB_FIRST_TCH
847 lfr_bp2[i*NB_BYTES_BP2+4] = pt_uint8[0]; // Record MSB of tmp_uint16
849 lfr_bp2[i*NB_BYTES_BP2+4] = pt_uint8[0]; // Record MSB of tmp_uint16
848 lfr_bp2[i*NB_BYTES_BP2+5] = pt_uint8[1]; // Record LSB of tmp_uint16
850 lfr_bp2[i*NB_BYTES_BP2+5] = pt_uint8[1]; // Record LSB of tmp_uint16
849 #endif
851 #endif
850 #ifdef LSB_FIRST_TCH
852 #ifdef LSB_FIRST_TCH
851 lfr_bp2[i*NB_BYTES_BP2+4] = pt_uint8[1]; // Record MSB of tmp_uint16
853 lfr_bp2[i*NB_BYTES_BP2+4] = pt_uint8[1]; // Record MSB of tmp_uint16
852 lfr_bp2[i*NB_BYTES_BP2+5] = pt_uint8[0]; // Record LSB of tmp_uint16
854 lfr_bp2[i*NB_BYTES_BP2+5] = pt_uint8[0]; // Record LSB of tmp_uint16
853 #endif
855 #endif
854 #ifdef DEBUG_TCH
856 #ifdef DEBUG_TCH
855 printf("autocor for S33 significand : %u\n",autocor);
857 printf("autocor for S33 significand : %u\n",autocor);
856 printf("exp for S33 exponent : %u\n",exp);
858 printf("exp for S33 exponent : %u\n",exp);
857 printf("pt_uint8[1] for S33 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
859 printf("pt_uint8[1] for S33 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
858 printf("pt_uint8[0] for S33 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
860 printf("pt_uint8[0] for S33 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
859 printf("lfr_bp2[i*NB_BYTES_BP2+4] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+4], lfr_bp2[i*NB_BYTES_BP2+4]);
861 printf("lfr_bp2[i*NB_BYTES_BP2+4] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+4], lfr_bp2[i*NB_BYTES_BP2+4]);
860 printf("lfr_bp2[i*NB_BYTES_BP2+5] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+5], lfr_bp2[i*NB_BYTES_BP2+5]);
862 printf("lfr_bp2[i*NB_BYTES_BP2+5] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+5], lfr_bp2[i*NB_BYTES_BP2+5]);
861 #endif
863 #endif
862 // S44
864 // S44
863 significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21], &exponent); // 0.5 <= significand < 1
865 significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21], &exponent); // 0.5 <= significand < 1
864 // S44 = significand * 2^exponent
866 // S44 = significand * 2^exponent
865 #ifdef DEBUG_TCH
867 #ifdef DEBUG_TCH
866 printf("S44 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
868 printf("S44 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
867 printf("significand : %16.8e\n",significand);
869 printf("significand : %16.8e\n",significand);
868 printf("exponent : %d\n" ,exponent);
870 printf("exponent : %d\n" ,exponent);
869 #endif
871 #endif
870
872
871 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
873 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
872 exponent = expmin;
874 exponent = expmin;
873 significand = 0.5; // min value that can be recorded
875 significand = 0.5; // min value that can be recorded
874 }
876 }
875 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
877 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
876 exponent = expmax;
878 exponent = expmax;
877 significand = 1.0; // max value that can be recorded
879 significand = 1.0; // max value that can be recorded
878 }
880 }
879 if (significand == 0) { // in that case exponent == 0 too
881 if (significand == 0) { // in that case exponent == 0 too
880 exponent = expmin;
882 exponent = expmin;
881 significand = 0.5; // min value that can be recorded
883 significand = 0.5; // min value that can be recorded
882 }
884 }
883
885
884 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
886 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
885 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
887 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
886 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
888 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
887 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
889 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
888 tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
890 tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
889 // left place of the significand bits (nbitsig),
891 // left place of the significand bits (nbitsig),
890 // making the 16-bit word to be recorded
892 // making the 16-bit word to be recorded
891 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
893 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
892 #ifdef MSB_FIRST_TCH
894 #ifdef MSB_FIRST_TCH
893 lfr_bp2[i*NB_BYTES_BP2+6] = pt_uint8[0]; // Record MSB of tmp_uint16
895 lfr_bp2[i*NB_BYTES_BP2+6] = pt_uint8[0]; // Record MSB of tmp_uint16
894 lfr_bp2[i*NB_BYTES_BP2+7] = pt_uint8[1]; // Record LSB of tmp_uint16
896 lfr_bp2[i*NB_BYTES_BP2+7] = pt_uint8[1]; // Record LSB of tmp_uint16
895 #endif
897 #endif
896 #ifdef LSB_FIRST_TCH
898 #ifdef LSB_FIRST_TCH
897 lfr_bp2[i*NB_BYTES_BP2+6] = pt_uint8[1]; // Record MSB of tmp_uint16
899 lfr_bp2[i*NB_BYTES_BP2+6] = pt_uint8[1]; // Record MSB of tmp_uint16
898 lfr_bp2[i*NB_BYTES_BP2+7] = pt_uint8[0]; // Record LSB of tmp_uint16
900 lfr_bp2[i*NB_BYTES_BP2+7] = pt_uint8[0]; // Record LSB of tmp_uint16
899 #endif
901 #endif
900 #ifdef DEBUG_TCH
902 #ifdef DEBUG_TCH
901 printf("autocor for S44 significand : %u\n",autocor);
903 printf("autocor for S44 significand : %u\n",autocor);
902 printf("exp for S44 exponent : %u\n",exp);
904 printf("exp for S44 exponent : %u\n",exp);
903 printf("pt_uint8[1] for S44 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
905 printf("pt_uint8[1] for S44 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
904 printf("pt_uint8[0] for S44 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
906 printf("pt_uint8[0] for S44 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
905 printf("lfr_bp2[i*NB_BYTES_BP2+6] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+6], lfr_bp2[i*NB_BYTES_BP2+6]);
907 printf("lfr_bp2[i*NB_BYTES_BP2+6] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+6], lfr_bp2[i*NB_BYTES_BP2+6]);
906 printf("lfr_bp2[i*NB_BYTES_BP2+7] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+7], lfr_bp2[i*NB_BYTES_BP2+7]);
908 printf("lfr_bp2[i*NB_BYTES_BP2+7] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+7], lfr_bp2[i*NB_BYTES_BP2+7]);
907 #endif
909 #endif
908 // S55
910 // S55
909 significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24], &exponent); // 0.5 <= significand < 1
911 significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24], &exponent); // 0.5 <= significand < 1
910 // S55 = significand * 2^exponent
912 // S55 = significand * 2^exponent
911 #ifdef DEBUG_TCH
913 #ifdef DEBUG_TCH
912 printf("S55 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
914 printf("S55 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
913 printf("significand : %16.8e\n",significand);
915 printf("significand : %16.8e\n",significand);
914 printf("exponent : %d\n" ,exponent);
916 printf("exponent : %d\n" ,exponent);
915 #endif
917 #endif
916 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
918 if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
917 exponent = expmin;
919 exponent = expmin;
918 significand = 0.5; // min value that can be recorded
920 significand = 0.5; // min value that can be recorded
919 }
921 }
920 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
922 if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
921 exponent = expmax;
923 exponent = expmax;
922 significand = 1.0; // max value that can be recorded
924 significand = 1.0; // max value that can be recorded
923 }
925 }
924 if (significand == 0) { // in that case exponent == 0 too
926 if (significand == 0) { // in that case exponent == 0 too
925 exponent = expmin;
927 exponent = expmin;
926 significand = 0.5; // min value that can be recorded
928 significand = 0.5; // min value that can be recorded
927 }
929 }
928
930
929 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
931 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
930 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
932 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
931 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
933 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
932 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
934 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
933 tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
935 tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
934 // left place of the significand bits (nbitsig),
936 // left place of the significand bits (nbitsig),
935 // making the 16-bit word to be recorded
937 // making the 16-bit word to be recorded
936 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
938 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
937 #ifdef MSB_FIRST_TCH
939 #ifdef MSB_FIRST_TCH
938 lfr_bp2[i*NB_BYTES_BP2+8] = pt_uint8[0]; // Record MSB of tmp_uint16
940 lfr_bp2[i*NB_BYTES_BP2+8] = pt_uint8[0]; // Record MSB of tmp_uint16
939 lfr_bp2[i*NB_BYTES_BP2+9] = pt_uint8[1]; // Record LSB of tmp_uint16
941 lfr_bp2[i*NB_BYTES_BP2+9] = pt_uint8[1]; // Record LSB of tmp_uint16
940 //printf("MSB:\n");
942 //printf("MSB:\n");
941 #endif
943 #endif
942 #ifdef LSB_FIRST_TCH
944 #ifdef LSB_FIRST_TCH
943 lfr_bp2[i*NB_BYTES_BP2+8] = pt_uint8[1]; // Record MSB of tmp_uint16
945 lfr_bp2[i*NB_BYTES_BP2+8] = pt_uint8[1]; // Record MSB of tmp_uint16
944 lfr_bp2[i*NB_BYTES_BP2+9] = pt_uint8[0]; // Record LSB of tmp_uint16
946 lfr_bp2[i*NB_BYTES_BP2+9] = pt_uint8[0]; // Record LSB of tmp_uint16
945 //printf("LSB:\n");
947 //printf("LSB:\n");
946 #endif
948 #endif
947 #ifdef DEBUG_TCH
949 #ifdef DEBUG_TCH
948 printf("autocor for S55 significand : %u\n",autocor);
950 printf("autocor for S55 significand : %u\n",autocor);
949 printf("exp for S55 exponent : %u\n",exp);
951 printf("exp for S55 exponent : %u\n",exp);
950 printf("pt_uint8[1] for S55 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
952 printf("pt_uint8[1] for S55 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
951 printf("pt_uint8[0] for S55 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
953 printf("pt_uint8[0] for S55 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
952 printf("lfr_bp2[i*NB_BYTES_BP2+8] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+8], lfr_bp2[i*NB_BYTES_BP2+8]);
954 printf("lfr_bp2[i*NB_BYTES_BP2+8] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+8], lfr_bp2[i*NB_BYTES_BP2+8]);
953 printf("lfr_bp2[i*NB_BYTES_BP2+9] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+9], lfr_bp2[i*NB_BYTES_BP2+9]);
955 printf("lfr_bp2[i*NB_BYTES_BP2+9] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+9], lfr_bp2[i*NB_BYTES_BP2+9]);
954 #endif
956 #endif
955 }
957 }
956 }
958 }
957
959
958
960
959 #endif // BASIC_PARAMETERS_H_INCLUDED
961 #endif // BASIC_PARAMETERS_H_INCLUDED
@@ -1,65 +1,66
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
2 // version 1.4: 16/05/2014
2 // version 1.4: 16/05/2014
3 // version 1.5: 20/05/2014
3 // version 1.5: 20/05/2014
4 // version 1.6: 19/12/2014
4 // version 1.6: 19/12/2014
5 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
5 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
6 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
6 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
7 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
7 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
8 // version 2.0: 19/06/2015
8 // version 2.0: 19/06/2015
9 // version 2.1: 22/06/2015 (modifs de Paul)
9 // version 2.1: 22/06/2015 (modifs de Paul)
10 // 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)
10 // 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)
11 // version 2.3: 01/07/2015 (affectation initiale des octets 7 et 9 dans les BP1 corrigée ...)
11
12
12 #ifndef BASIC_PARAMETERS_PARAMS_H
13 #ifndef BASIC_PARAMETERS_PARAMS_H
13 #define BASIC_PARAMETERS_PARAMS_H
14 #define BASIC_PARAMETERS_PARAMS_H
14
15
15 #define NB_VALUES_PER_SPECTRAL_MATRIX 25
16 #define NB_VALUES_PER_SPECTRAL_MATRIX 25
16
17
17 #define NB_BINS_COMPRESSED_MATRIX_f0 11
18 #define NB_BINS_COMPRESSED_MATRIX_f0 11
18 #define NB_BINS_COMPRESSED_MATRIX_f1 13
19 #define NB_BINS_COMPRESSED_MATRIX_f1 13
19 #define NB_BINS_COMPRESSED_MATRIX_f2 12
20 #define NB_BINS_COMPRESSED_MATRIX_f2 12
20
21
21 #define NB_BYTES_BP1 11
22 #define NB_BYTES_BP1 11
22 #define NB_BYTES_BP2 30
23 #define NB_BYTES_BP2 30
23
24
24 //********************************************
25 //********************************************
25 // K-COEFFICIENTS FOR ONBOARD INTERCALIBRATION
26 // K-COEFFICIENTS FOR ONBOARD INTERCALIBRATION
26
27
27 #define NB_K_COEFF_PER_BIN 32
28 #define NB_K_COEFF_PER_BIN 32
28
29
29 #define K44_PE 0
30 #define K44_PE 0
30 #define K55_PE 1
31 #define K55_PE 1
31 #define K45_PE_RE 2
32 #define K45_PE_RE 2
32 #define K45_PE_IM 3
33 #define K45_PE_IM 3
33
34
34 #define K14_SX_RE 4
35 #define K14_SX_RE 4
35 #define K14_SX_IM 5
36 #define K14_SX_IM 5
36 #define K15_SX_RE 6
37 #define K15_SX_RE 6
37 #define K15_SX_IM 7
38 #define K15_SX_IM 7
38 #define K24_SX_RE 8
39 #define K24_SX_RE 8
39 #define K24_SX_IM 9
40 #define K24_SX_IM 9
40 #define K25_SX_RE 10
41 #define K25_SX_RE 10
41 #define K25_SX_IM 11
42 #define K25_SX_IM 11
42 #define K34_SX_RE 12
43 #define K34_SX_RE 12
43 #define K34_SX_IM 13
44 #define K34_SX_IM 13
44 #define K35_SX_RE 14
45 #define K35_SX_RE 14
45 #define K35_SX_IM 15
46 #define K35_SX_IM 15
46
47
47 #define K24_NY_RE 16
48 #define K24_NY_RE 16
48 #define K24_NY_IM 17
49 #define K24_NY_IM 17
49 #define K25_NY_RE 18
50 #define K25_NY_RE 18
50 #define K25_NY_IM 19
51 #define K25_NY_IM 19
51 #define K34_NY_RE 20
52 #define K34_NY_RE 20
52 #define K34_NY_IM 21
53 #define K34_NY_IM 21
53 #define K35_NY_RE 22
54 #define K35_NY_RE 22
54 #define K35_NY_IM 23
55 #define K35_NY_IM 23
55
56
56 #define K24_NZ_RE 24
57 #define K24_NZ_RE 24
57 #define K24_NZ_IM 25
58 #define K24_NZ_IM 25
58 #define K25_NZ_RE 26
59 #define K25_NZ_RE 26
59 #define K25_NZ_IM 27
60 #define K25_NZ_IM 27
60 #define K34_NZ_RE 28
61 #define K34_NZ_RE 28
61 #define K34_NZ_IM 29
62 #define K34_NZ_IM 29
62 #define K35_NZ_RE 30
63 #define K35_NZ_RE 30
63 #define K35_NZ_IM 31
64 #define K35_NZ_IM 31
64
65
65 #endif // BASIC_PARAMETERS_PARAMS_H
66 #endif // BASIC_PARAMETERS_PARAMS_H
@@ -1,27 +1,27
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
2 // version 1.6: 19/12/2014
2 // version 1.6: 19/12/2014
3 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
3 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
4 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
4 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
5 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
5 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
6 // version 2.0: 19/06/2015
6 // version 2.0: 19/06/2015
7 // version 2.1: 22/06/2015 (modifs de Paul)
7 // version 2.1: 22/06/2015 (modifs de Paul)
8 // 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)
8 // 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)
9
9 // version 2.3: 01/07/2015 (affectation initiale des octets 7 et 9 dans les BP1 corrigée ...)
10
10
11 #ifndef BASIC_PARAMETERS_UTILITIES_H
11 #ifndef BASIC_PARAMETERS_UTILITIES_H
12 #define BASIC_PARAMETERS_UTILITIES_H
12 #define BASIC_PARAMETERS_UTILITIES_H
13
13
14 #include <stdio.h>
14 #include <stdio.h>
15 #include <malloc.h>
15 #include <malloc.h>
16
16
17 #include "basic_parameters_params.h"
17 #include "basic_parameters_params.h"
18
18
19 float compressed_spectral_matrix_f0[NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_SPECTRAL_MATRIX];
19 float compressed_spectral_matrix_f0[NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_SPECTRAL_MATRIX];
20 float k_coefficients_f0[NB_BINS_COMPRESSED_MATRIX_f0 * NB_K_COEFF_PER_BIN];
20 float k_coefficients_f0[NB_BINS_COMPRESSED_MATRIX_f0 * NB_K_COEFF_PER_BIN];
21 float k_coefficients_f1[NB_BINS_COMPRESSED_MATRIX_f1 * NB_K_COEFF_PER_BIN];
21 float k_coefficients_f1[NB_BINS_COMPRESSED_MATRIX_f1 * NB_K_COEFF_PER_BIN];
22 float k_coefficients_f2[NB_BINS_COMPRESSED_MATRIX_f2 * NB_K_COEFF_PER_BIN];
22 float k_coefficients_f2[NB_BINS_COMPRESSED_MATRIX_f2 * NB_K_COEFF_PER_BIN];
23
23
24 unsigned char LFR_BP1_f0[NB_BINS_COMPRESSED_MATRIX_f0*NB_BYTES_BP1];
24 unsigned char LFR_BP1_f0[NB_BINS_COMPRESSED_MATRIX_f0*NB_BYTES_BP1];
25 unsigned char LFR_BP2_f0[NB_BINS_COMPRESSED_MATRIX_f0*NB_BYTES_BP2];
25 unsigned char LFR_BP2_f0[NB_BINS_COMPRESSED_MATRIX_f0*NB_BYTES_BP2];
26
26
27 #endif // BASIC_PARAMETERS_UTILITIES_H
27 #endif // BASIC_PARAMETERS_UTILITIES_H
@@ -1,77 +1,77
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
2 // version 1.0: 31/07/2013
2 // version 1.0: 31/07/2013
3 // version 1.1: 02/04/2014
3 // version 1.1: 02/04/2014
4 // version 1.2: 30/04/2014
4 // version 1.2: 30/04/2014
5 // version 1.3: 02/05/2014
5 // version 1.3: 02/05/2014
6 // version 1.4: 16/05/2014
6 // version 1.4: 16/05/2014
7 // version 1.5: 20/05/2014
7 // version 1.5: 20/05/2014
8 // version 1.6: 19/12/2014
8 // version 1.6: 19/12/2014
9 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
9 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
10 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
10 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
11 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
11 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
12 // version 2.0: 19/06/2015
12 // version 2.0: 19/06/2015
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
15 // version 2.3: 01/07/2015 (affectation initiale des octets 7 et 9 dans les BP1 corrigée ...)
16
16
17 #include "basic_parameters_utilities.h"
17 #include "basic_parameters_utilities.h"
18
18
19 int lecture_file_sm(const char *fileName)
19 int lecture_file_sm(const char *fileName)
20 {
20 {
21 int i;
21 int i;
22
22
23 FILE *infile;
23 FILE *infile;
24 infile = fopen(fileName, "rb"); // open explicitely a binary file !!! ...
24 infile = fopen(fileName, "rb"); // open explicitely a binary file !!! ...
25 if(infile == NULL) {
25 if(infile == NULL) {
26 printf("Hello I cannot open the file! \n");
26 printf("Hello I cannot open the file! \n");
27 return 0;
27 return 0;
28 }
28 }
29 (void) fread(compressed_spectral_matrix_f0, sizeof(compressed_spectral_matrix_f0), 1, infile);
29 (void) fread(compressed_spectral_matrix_f0, sizeof(compressed_spectral_matrix_f0), 1, infile);
30 (void) fclose(infile);
30 (void) fclose(infile);
31
31
32 printf("Compressed_spectral_matrix_f0 : \n");
32 printf("Compressed_spectral_matrix_f0 : \n");
33 printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0);
33 printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0);
34 printf("Number of values per spectral matrix: %d\n", NB_VALUES_PER_SPECTRAL_MATRIX);
34 printf("Number of values per spectral matrix: %d\n", NB_VALUES_PER_SPECTRAL_MATRIX);
35 printf("Size of compressed_spectral_matrix_f0 : %lu\n", sizeof(compressed_spectral_matrix_f0));
35 printf("Size of compressed_spectral_matrix_f0 : %lu\n", sizeof(compressed_spectral_matrix_f0));
36
36
37 for(i=0; i<NB_BINS_COMPRESSED_MATRIX_f0; i++){
37 for(i=0; i<NB_BINS_COMPRESSED_MATRIX_f0; i++){
38
38
39 printf("\nBin number: %d\n", i);
39 printf("\nBin number: %d\n", i);
40
40
41 printf("Element %.2d (S11) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 1, 0,
41 printf("Element %.2d (S11) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 1, 0,
42 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+0], 0.);
42 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+0], 0.);
43 printf("Element %.2d (S12) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 2, 1, 2,
43 printf("Element %.2d (S12) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 2, 1, 2,
44 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+1], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+2]);
44 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+1], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+2]);
45 printf("Element %.2d (S13) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 3, 3, 4,
45 printf("Element %.2d (S13) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 3, 3, 4,
46 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+3], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+4]);
46 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+3], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+4]);
47 printf("Element %.2d (S14) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 4, 5, 6,
47 printf("Element %.2d (S14) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 4, 5, 6,
48 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+5], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+6]);
48 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+5], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+6]);
49 printf("Element %.2d (S15) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 5, 7, 8,
49 printf("Element %.2d (S15) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 5, 7, 8,
50 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+7], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+8]);
50 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+7], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+8]);
51 printf("Element %.2d (S22) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 6, 9,
51 printf("Element %.2d (S22) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 6, 9,
52 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+9], 0.);
52 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+9], 0.);
53 printf("Element %.2d (S23) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 7, 10, 11,
53 printf("Element %.2d (S23) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 7, 10, 11,
54 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+10], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]);
54 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+10], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]);
55 printf("Element %.2d (S24) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 8, 12, 13,
55 printf("Element %.2d (S24) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 8, 12, 13,
56 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+12], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]);
56 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+12], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]);
57 printf("Element %.2d (S25) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 9, 14, 15,
57 printf("Element %.2d (S25) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 9, 14, 15,
58 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+14], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]);
58 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+14], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]);
59 printf("Element %.2d (S33) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 10, 16,
59 printf("Element %.2d (S33) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 10, 16,
60 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+16], 0.);
60 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+16], 0.);
61 printf("Element %.2d (S34) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 11, 17, 18,
61 printf("Element %.2d (S34) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 11, 17, 18,
62 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+17], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]);
62 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+17], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]);
63 printf("Element %.2d (S35) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 12, 19, 20,
63 printf("Element %.2d (S35) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 12, 19, 20,
64 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+19], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]);
64 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+19], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]);
65 printf("Element %.2d (S44) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 13, 21,
65 printf("Element %.2d (S44) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 13, 21,
66 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+21], 0.);
66 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+21], 0.);
67 printf("Element %.2d (S45) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 14, 22, 23,
67 printf("Element %.2d (S45) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 14, 22, 23,
68 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+22], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+23]);
68 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+22], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+23]);
69 printf("Element %.2d (S55) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 15, 24,
69 printf("Element %.2d (S55) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 15, 24,
70 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+24], 0.);
70 compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+24], 0.);
71
71
72 }
72 }
73 return 0;
73 return 0;
74 }
74 }
75
75
76
76
77
77
@@ -1,22 +1,22
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
2 // version 1.0: 31/07/2013
2 // version 1.0: 31/07/2013
3 // version 1.1: 02/04/2014
3 // version 1.1: 02/04/2014
4 // version 1.2: 30/04/2014
4 // version 1.2: 30/04/2014
5 // version 1.3: 02/05/2014
5 // version 1.3: 02/05/2014
6 // version 1.4: 16/05/2014
6 // version 1.4: 16/05/2014
7 // version 1.5: 20/05/2014
7 // version 1.5: 20/05/2014
8 // version 1.6: 19/12/2014
8 // version 1.6: 19/12/2014
9 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
9 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
10 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
10 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
11 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
11 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
12 // version 2.0: 19/06/2015
12 // version 2.0: 19/06/2015
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
15 // version 2.3: 01/07/2015 (affectation initiale des octets 7 et 9 dans les BP1 corrigée ...)
16
16
17 #ifndef FILE_UTILITIES_H
17 #ifndef FILE_UTILITIES_H
18 #define FILE_UTILITIES_H
18 #define FILE_UTILITIES_H
19
19
20 int lecture_file_sm(const char *fileName);
20 int lecture_file_sm(const char *fileName);
21
21
22 #endif // FILE_UTILITIES_H
22 #endif // FILE_UTILITIES_H
@@ -1,73 +1,76
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
1 // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
2 // version 1.O: 31/07/2013
2 // version 1.O: 31/07/2013
3 // version 1.1: 02/04/2014
3 // version 1.1: 02/04/2014
4 // version 1.2: 30/04/2014
4 // version 1.2: 30/04/2014
5 // version 1.3: 02/05/2014
5 // version 1.3: 02/05/2014
6 // version 1.4: 16/05/2014
6 // version 1.4: 16/05/2014
7 // version 1.5: 20/05/2014
7 // version 1.5: 20/05/2014
8 // version 1.6: 19/12/2014
8 // version 1.6: 19/12/2014
9 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
9 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
10 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
10 // version 1.8: 02/02/2015 (gestion des divisions par zéro)
11 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
11 // In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
12 // version 2.0: 19/06/2015
12 // version 2.0: 19/06/2015
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
16
16 #include <stdio.h>
17 #include <stdio.h>
17
18
18 #include "file_utilities.h"
19 #include "file_utilities.h"
19 #include "basic_parameters_utilities.h"
20 #include "basic_parameters_utilities.h"
20 #include "basic_parameters.h"
21 #include "basic_parameters.h"
21
22
22 int main(void)
23 int main(void)
23 {
24 {
24 const char *filename;
25 const char *filename;
25 printf("Hello World!\n\n");
26 printf("Hello World!\n\n");
26
27
27 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
28 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
28 //LSB FIRST
29 //LSB FIRST
29 printf("The multi-byte quantities are laid out in a LSB FIRST (little endian) fashion \n\n");
30 printf("The multi-byte quantities are laid out in a LSB FIRST (little endian) fashion \n\n");
30 #endif
31 #endif
31
32
32 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
33 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
33 //MSB FIRST
34 //MSB FIRST
34 printf("The multi-byte quantities are laid out in a MSB FIRST (big endian) fashion\n\n");
35 printf("The multi-byte quantities are laid out in a MSB FIRST (big endian) fashion\n\n");
35 #endif
36 #endif
36
37
37 filename="/WIN/Users/chust/DD CHUST/Missions/Solar Orbiter/LFR/Prog C/tests bp Paul/tests7/sm_test2_R3.dat";
38 filename="/WIN/Users/chust/DD CHUST/Missions/Solar Orbiter/LFR/Prog C/tests bp Paul/tests7/sm_test2_R3.dat";
39 //filename="/home/chust/DD pc-p-chust/Missions/Solar Orbiter/LFR/Prog C/tests bp Paul/tests7/sm_test2_R3.dat";
40
38 lecture_file_sm(filename);
41 lecture_file_sm(filename);
39
42
40 printf("\n");
43 printf("\n");
41
44
42 init_k_coefficients(k_coefficients_f0, NB_BINS_COMPRESSED_MATRIX_f0);
45 init_k_coefficients(k_coefficients_f0, NB_BINS_COMPRESSED_MATRIX_f0);
43 init_k_coefficients(k_coefficients_f1, NB_BINS_COMPRESSED_MATRIX_f1);
46 init_k_coefficients(k_coefficients_f1, NB_BINS_COMPRESSED_MATRIX_f1);
44 init_k_coefficients(k_coefficients_f2, NB_BINS_COMPRESSED_MATRIX_f2);
47 init_k_coefficients(k_coefficients_f2, NB_BINS_COMPRESSED_MATRIX_f2);
45
48
46 printf("\n\n");
49 printf("\n\n");
47
50
48 BP1_set(compressed_spectral_matrix_f0, k_coefficients_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_f0);
51 BP1_set(compressed_spectral_matrix_f0, k_coefficients_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_f0);
49
52
50 printf("\n");
53 printf("\n");
51
54
52 BP2_set(compressed_spectral_matrix_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP2_f0);
55 BP2_set(compressed_spectral_matrix_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP2_f0);
53
56
54 return 0;
57 return 0;
55 }
58 }
56
59
57
60
58
61
59
62
60
63
61
64
62
65
63
66
64
67
65
68
66
69
67
70
68
71
69
72
70
73
71
74
72
75
73
76
General Comments 0
You need to be logged in to leave comments. Login now