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