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