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