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