# HG changeset patch # User thomas # Date 2013-07-31 09:18:23 # Node ID e3b32f3d7c4c448d6c0299096cebe8916a13f9d8 # Parent 323f9b4b5db0848a9fb754fa8c843f50d2583c95 Basic parameters - LFR software ICD 1.8 - Version 1 diff --git a/basic_parameters_1_ICD_issue1rev6.c b/basic_parameters.c rename from basic_parameters_1_ICD_issue1rev6.c rename to basic_parameters.c --- a/basic_parameters_1_ICD_issue1rev6.c +++ b/basic_parameters.c @@ -1,48 +1,94 @@ -#include "basic_parameters_1_ICD_issue1rev6.h" +// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) +// version 1: 31/07/2013 + +#include "basic_parameters.h" #include #include -float k44_pe = 1; -float k55_pe = 1; -float k45_pe_re = 1; -float k45_pe_im = 1; +#define K44_PE 0 +#define K55_PE 1 +#define K45_PE_RE 2 +#define K45_PE_IM 3 + +#define K14_SX_RE 4 +#define K14_SX_IM 5 +#define K15_SX_RE 6 +#define K15_SX_IM 7 +#define K24_SX_RE 8 +#define K24_SX_IM 9 +#define K25_SX_RE 10 +#define K25_SX_IM 11 +#define K34_SX_RE 12 +#define K34_SX_IM 13 +#define K35_SX_RE 14 +#define K35_SX_IM 15 -float k14_sx_re = 1; -float k14_sx_im = 1; -float k15_sx_re = 1; -float k15_sx_im = 1; -float k24_sx_re = 1; -float k24_sx_im = 1; -float k25_sx_re = 1; -float k25_sx_im = 1; -float k34_sx_re = 1; -float k34_sx_im = 1; -float k35_sx_re = 1; -float k35_sx_im = 1; +#define K24_NY_RE 16 +#define K24_NY_IM 17 +#define K25_NY_RE 18 +#define K25_NY_IM 19 +#define K34_NY_RE 20 +#define K34_NY_IM 21 +#define K35_NY_RE 22 +#define K35_NY_IM 23 + +#define K24_NZ_RE 24 +#define K24_NZ_IM 25 +#define K25_NZ_RE 26 +#define K25_NZ_IM 27 +#define K34_NZ_RE 28 +#define K34_NZ_IM 29 +#define K35_NZ_RE 30 +#define K35_NZ_IM 31 + +float k_f0[NB_BINS_COMPRESSED_MATRIX_f0][32]; -float k24_ny_re = 1; -float k24_ny_im = 1; -float k25_ny_re = 1; -float k25_ny_im = 1; -float k34_ny_re = 1; -float k34_ny_im = 1; -float k35_ny_re = 1; -float k35_ny_im = 1; +void init_k_f0(){ + unsigned char i; + + for(i=0; i= 0.5 * 2^expmin exponent = expmin; significand = 0.5; // min value that can be recorded @@ -101,46 +145,37 @@ void BP1_set(){ significand = 0.5; // min value that can be recorded } - psd = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding + psd = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int + tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP1_F0[i*9+7]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = psd | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the + pt_u_short_int = (unsigned short int*) &LFR_BP1_F0[i*9+2]; // Affect an unsigned short int pointer with the + // adress where the 16-bit word result will be stored + *pt_u_short_int = psd | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the // left place of the significand bits (nbitsig), making // the 16-bit word to be recorded, and record it using the pointer #ifdef DEBUG_TCH + printf("PSDB / 3 : %16.8e\n",PSDB/3); + printf("significand : %16.8e\n",significand); + printf("exponent : %d\n" ,exponent); printf("psd for PSDB significand : %d\n",psd); printf("tmp_u_short_int for PSDB exponent : %d\n",tmp_u_short_int); - printf("*pt_u_short_int for PSDB significand + exponent: %.3d or %.4x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP1_F0[i*9+8] : %.3d or %.2x\n",LFR_BP1_F0[i*9+8], LFR_BP1_F0[i*9+8]); - printf("LFR_BP1_F0[i*9+7] : %.3d or %.2x\n",LFR_BP1_F0[i*9+7], LFR_BP1_F0[i*9+7]); + printf("*pt_u_short_int for PSDB exponent + significand: %.3d or %.4x\n",*pt_u_short_int, *pt_u_short_int); + printf("LFR_BP1_F0[i*9+3] : %.3d or %.2x\n",LFR_BP1_F0[i*9+3], LFR_BP1_F0[i*9+3]); + printf("LFR_BP1_F0[i*9+2] : %.3d or %.2x\n",LFR_BP1_F0[i*9+2], LFR_BP1_F0[i*9+2]); #endif - - //toto_f = 32768*32768; // max value ? - //toto_f = 1./3; // min value ? - //significand = frexp(toto_f, &exponent); - //printf("toto_f : %16.8e\n",toto_f); - //printf("significand : %16.8e\n",significand); - //printf("exponent : %d\n" ,exponent); - //============================================== // BP1 PSDE == PA_LFR_SC_BP1_PE_F0 == 12 bits = 5 bits (exponent) + 7 bits (significand) - PSDE = compressed_spectral_matrix_f0[i*30+24] * k44_pe // S44 - + compressed_spectral_matrix_f0[i*30+28] * k55_pe // S55 - + compressed_spectral_matrix_f0[i*30+26] * k45_pe_re // S45 Re - - compressed_spectral_matrix_f0[i*30+27] * k45_pe_im; // S45 Im + PSDE = compressed_spectral_matrix_f0[i*30+21] * k_f0[i][K44_PE] // S44 + + compressed_spectral_matrix_f0[i*30+24] * k_f0[i][K55_PE] // S55 + + compressed_spectral_matrix_f0[i*30+22] * k_f0[i][K45_PE_RE] // S45 Re + - compressed_spectral_matrix_f0[i*30+23] * k_f0[i][K45_PE_IM]; // S45 Im significand = frexpf(PSDE/2, &exponent); // 0.5 <= significand < 1 // PSDE/2 = significand * 2^exponent // the division by 2 is to ensure that max value <= 2^30 // should be reconsidered by taking into account the k-coefficients ... - printf("PSDE / 2 : %16.8e\n",PSDE/2); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin exponent = expmin; significand = 0.5; // min value that can be recorded @@ -154,137 +189,139 @@ void BP1_set(){ significand = 0.5; // min value that can be recorded } - psd = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding + psd = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int + tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP1_F0[i*9+5]; // affect an unsigned short int pointer with the + pt_u_short_int = (unsigned short int*) &LFR_BP1_F0[i*9+0]; // Affect an unsigned short int pointer with the // adress where the 16-bit word result will be stored - *pt_u_short_int = psd | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the + *pt_u_short_int = psd | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the // left place of the significand bits (nbitsig), making // the 16-bit word to be recorded, and record it using the pointer +#ifdef DEBUG_TCH + printf("PSDE / 2 : %16.8e\n",PSDE/2); + printf("significand : %16.8e\n",significand); + printf("exponent : %d\n" ,exponent); printf("psd for PSDE significand : %d\n",psd); printf("tmp_u_short_int for PSDE exponent : %d\n",tmp_u_short_int); - printf("*pt_u_short_int for PSDE significand + exponent: %.3d or %.4x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP1_F0[i*9+6] : %.3d or %.2x\n",LFR_BP1_F0[i*9+6], LFR_BP1_F0[i*9+6]); - printf("LFR_BP1_F0[i*9+5] : %.3d or %.2x\n",LFR_BP1_F0[i*9+5], LFR_BP1_F0[i*9+5]); - + printf("*pt_u_short_int for PSDE exponent + significand: %.3d or %.4x\n",*pt_u_short_int, *pt_u_short_int); + printf("LFR_BP1_F0[i*9+1] : %.3d or %.2x\n",LFR_BP1_F0[i*9+1], LFR_BP1_F0[i*9+1]); + printf("LFR_BP1_F0[i*9+0] : %.3d or %.2x\n",LFR_BP1_F0[i*9+0], LFR_BP1_F0[i*9+0]); +#endif //============================================================================== // BP1 normal wave vector == PA_LFR_SC_BP1_NVEC_V0_F0 == 8 bits // == PA_LFR_SC_BP1_NVEC_V1_F0 == 8 bits // == PA_LFR_SC_BP1_NVEC_V2_F0 == 1 sign bit - tmp = sqrt( compressed_spectral_matrix_f0[i*30+3] *compressed_spectral_matrix_f0[i*30+3] //Im S12 - +compressed_spectral_matrix_f0[i*30+5] *compressed_spectral_matrix_f0[i*30+5] //Im S13 - +compressed_spectral_matrix_f0[i*30+13]*compressed_spectral_matrix_f0[i*30+13] //Im S23 + tmp = sqrt( compressed_spectral_matrix_f0[i*30+2] *compressed_spectral_matrix_f0[i*30+2] //Im S12 + +compressed_spectral_matrix_f0[i*30+4] *compressed_spectral_matrix_f0[i*30+4] //Im S13 + +compressed_spectral_matrix_f0[i*30+11]*compressed_spectral_matrix_f0[i*30+11] //Im S23 ); - NVEC_V0 = compressed_spectral_matrix_f0[i*30+13]/ tmp; // S23 Im => n1 - NVEC_V1 = -compressed_spectral_matrix_f0[i*30+5] / tmp; // S13 Im => n2 - NVEC_V2 = compressed_spectral_matrix_f0[i*30+3] / tmp; // S12 Im => n3 + NVEC_V0 = compressed_spectral_matrix_f0[i*30+11]/ tmp; // S23 Im => n1 + NVEC_V1 = -compressed_spectral_matrix_f0[i*30+4] / tmp; // S13 Im => n2 + NVEC_V2 = compressed_spectral_matrix_f0[i*30+2] / tmp; // S12 Im => n3 + LFR_BP1_F0[i*9+4] = (unsigned char) (NVEC_V0*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding + LFR_BP1_F0[i*9+5] = (unsigned char) (NVEC_V1*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding + pt_u_char = (unsigned char*) &NVEC_V2; // affect an unsigned char pointer with the adress of NVEC_V2 +#ifdef LSB_FIRST_TCH + LFR_BP1_F0[i*9+6] = pt_u_char[3] & 0x80; // extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 4th octet:PC convention) + // record it at the 8th bit position (from the right to the left) of LFR_BP1_F0[i*9+6] +#endif +#ifdef MSB_FIRST_TCH + LFR_BP1_F0[i*9+6] = pt_u_char[0] & 0x80; // extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 0th octet:SPARC convention) + // record it at the 8th bit position (from the right to the left) of LFR_BP1_F0[i*9+6] +#endif +#ifdef DEBUG_TCH printf("NVEC_V0 : %16.8e\n",NVEC_V0); printf("NVEC_V1 : %16.8e\n",NVEC_V1); printf("NVEC_V2 : %16.8e\n",NVEC_V2); - - LFR_BP1_F0[i*9+4] = (unsigned char) (NVEC_V0*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP1_F0[i*9+3] = (unsigned char) (NVEC_V1*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - pt_u_char = (unsigned char*) &NVEC_V2; // affect an unsigned char pointer with the adress of NVEC_V2 - LFR_BP1_F0[i*9+2] = pt_u_char[3] & 0x80; // extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 4th octet) - // record it at the 8th bit position (from the right to the left) of LFR_BP1_F0[i*9+2] - printf("LFR_BP1_F0[i*9+4] for NVEC_V0 : %u\n",LFR_BP1_F0[i*9+4]); - printf("LFR_BP1_F0[i*9+3] for NVEC_V1 : %u\n",LFR_BP1_F0[i*9+3]); - printf("LFR_BP1_F0[i*9+2] for NVEC_V2 : %u\n",LFR_BP1_F0[i*9+2]); - - //toto_f = 128.9999 ; - //toto_s_char = (signed char) toto_f; - //printf("toto_s_char : %d\n",toto_s_char); - - //toto_f = 255.999 ; - //toto_u_char = (unsigned char) (toto_f); - //printf("toto_u_char : %d\n",toto_u_char); - - //toto_f = -1110.999 ; - //pt_toto_u_char = (unsigned char*) &toto_f; - //printf("pt_toto_u_char : %u\n", pt_toto_u_char[3] & 0x80); - + printf("LFR_BP1_F0[i*9+5] for NVEC_V1 : %u\n",LFR_BP1_F0[i*9+5]); + printf("LFR_BP1_F0[i*9+6] for NVEC_V2 : %u\n",LFR_BP1_F0[i*9+6]); +#endif //======================================================= // BP1 ellipticity == PA_LFR_SC_BP1_ELLIP_F0 == 4 bits aux = 2*tmp / PSDB; // compute the ellipticity - printf("ellipticity : %16.8e\n",aux); - tmp_u_char = (unsigned char) (aux*15 + 0.5); // shift and cast into a 8-bit unsigned char with rounding // where just the first 4 bits are used (0, ..., 15) - LFR_BP1_F0[i*9+2] = LFR_BP1_F0[i*9+2] | (tmp_u_char << 3); // put these 4 bits next to the right place + LFR_BP1_F0[i*9+6] = LFR_BP1_F0[i*9+6] | (tmp_u_char << 3); // put these 4 bits next to the right place // of the sign bit of NVEC_V2 (recorded - // previously in LFR_BP1_F0[i*9+2]) - + // previously in LFR_BP1_F0[i*9+6]) +#ifdef DEBUG_TCH + printf("ellipticity : %16.8e\n",aux); printf("tmp_u_char for ellipticity : %u\n",tmp_u_char); - printf("LFR_BP1_F0[i*9+2] for NVEC_V2 + ellipticity : %u\n",LFR_BP1_F0[i*9+2]); - + printf("LFR_BP1_F0[i*9+6] for NVEC_V2 + ellipticity : %u\n",LFR_BP1_F0[i*9+6]); +#endif //============================================================== // BP1 degree of polarization == PA_LFR_SC_BP1_DOP_F0 == 3 bits - tr_SB_SB = compressed_spectral_matrix_f0[i*30] *compressed_spectral_matrix_f0[i*30] - + compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+10] - + compressed_spectral_matrix_f0[i*30+18]*compressed_spectral_matrix_f0[i*30+18] + tr_SB_SB = compressed_spectral_matrix_f0[i*30] *compressed_spectral_matrix_f0[i*30] + + compressed_spectral_matrix_f0[i*30+9] *compressed_spectral_matrix_f0[i*30+9] + + compressed_spectral_matrix_f0[i*30+16] *compressed_spectral_matrix_f0[i*30+16] + + 2 * compressed_spectral_matrix_f0[i*30+1] *compressed_spectral_matrix_f0[i*30+1] + 2 * compressed_spectral_matrix_f0[i*30+2] *compressed_spectral_matrix_f0[i*30+2] + 2 * compressed_spectral_matrix_f0[i*30+3] *compressed_spectral_matrix_f0[i*30+3] + 2 * compressed_spectral_matrix_f0[i*30+4] *compressed_spectral_matrix_f0[i*30+4] - + 2 * compressed_spectral_matrix_f0[i*30+5] *compressed_spectral_matrix_f0[i*30+5] - + 2 * compressed_spectral_matrix_f0[i*30+12]*compressed_spectral_matrix_f0[i*30+12] - + 2 * compressed_spectral_matrix_f0[i*30+13]*compressed_spectral_matrix_f0[i*30+13]; + + 2 * compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+10] + + 2 * compressed_spectral_matrix_f0[i*30+11]*compressed_spectral_matrix_f0[i*30+11]; aux = PSDB*PSDB; tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); // compute the degree of polarisation - printf("DOP : %16.8e\n",tmp); - tmp_u_char = (unsigned char) (tmp*7 + 0.5);// shift and cast into a 8-bit unsigned char with rounding // where just the first 3 bits are used (0, ..., 7) - LFR_BP1_F0[i*9+2] = LFR_BP1_F0[i*9+2] | tmp_u_char; // record these 3 bits at the 3 first bit positions - // (from the right to the left) of LFR_BP1_F0[i*9+2] - + LFR_BP1_F0[i*9+6] = LFR_BP1_F0[i*9+6] | tmp_u_char; // record these 3 bits at the 3 first bit positions + // (from the right to the left) of LFR_BP1_F0[i*9+6] +#ifdef DEBUG_TCH + printf("DOP : %16.8e\n",tmp); printf("tmp_u_char for DOP : %u\n",tmp_u_char); - printf("LFR_BP1_F0[i*9+2] for NVEC_V2 + ellipticity + DOP : %u\n",LFR_BP1_F0[i*9+2]); - + printf("LFR_BP1_F0[i*9+6] for NVEC_V2 + ellipticity + DOP : %u\n",LFR_BP1_F0[i*9+6]); +#endif //======================================================================================= // BP1 X_SO-component of the Poynting flux == PA_LFR_SC_BP1_SX_F0 == 8 (+ 2) bits // = 5 bits (exponent) + 3 bits (significand) // + 1 sign bit + 1 argument bit (two sectors) - e_cross_b_re = compressed_spectral_matrix_f0[i*30+20]*k34_sx_re //S34 Re - + compressed_spectral_matrix_f0[i*30+22]*k35_sx_re //S35 Re - + compressed_spectral_matrix_f0[i*30+6] *k14_sx_re //S14 Re - + compressed_spectral_matrix_f0[i*30+8] *k15_sx_re //S15 Re - + compressed_spectral_matrix_f0[i*30+14]*k24_sx_re //S24 Re - + compressed_spectral_matrix_f0[i*30+16]*k25_sx_re //S25 Re - + compressed_spectral_matrix_f0[i*30+21]*k34_sx_im //S34 Im - + compressed_spectral_matrix_f0[i*30+23]*k35_sx_im //S35 Im - + compressed_spectral_matrix_f0[i*30+7] *k14_sx_im //S14 Im - + compressed_spectral_matrix_f0[i*30+9] *k15_sx_im //S15 Im - + compressed_spectral_matrix_f0[i*30+15]*k24_sx_im //S24 Im - + compressed_spectral_matrix_f0[i*30+17]*k25_sx_im; //S25 Im + e_cross_b_re = compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_SX_RE] //S34 Re + + compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_SX_RE] //S35 Re + + compressed_spectral_matrix_f0[i*30+5] *k_f0[i][K14_SX_RE] //S14 Re + + compressed_spectral_matrix_f0[i*30+7] *k_f0[i][K15_SX_RE] //S15 Re + + compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_SX_RE] //S24 Re + + compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_SX_RE] //S25 Re + + compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_SX_IM] //S34 Im + + compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_SX_IM] //S35 Im + + compressed_spectral_matrix_f0[i*30+6] *k_f0[i][K14_SX_IM] //S14 Im + + compressed_spectral_matrix_f0[i*30+8] *k_f0[i][K15_SX_IM] //S15 Im + + compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_SX_IM] //S24 Im + + compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_SX_IM]; //S25 Im // Im(S_ji) = -Im(S_ij) // k_ji = k_ij - e_cross_b_im = compressed_spectral_matrix_f0[i*30+20]*k34_sx_im //S34 Re - + compressed_spectral_matrix_f0[i*30+22]*k35_sx_im //S35 Re - + compressed_spectral_matrix_f0[i*30+6] *k14_sx_im //S14 Re - + compressed_spectral_matrix_f0[i*30+8] *k15_sx_im //S15 Re - + compressed_spectral_matrix_f0[i*30+14]*k24_sx_im //S24 Re - + compressed_spectral_matrix_f0[i*30+16]*k25_sx_im //S25 Re - - compressed_spectral_matrix_f0[i*30+21]*k34_sx_re //S34 Im - - compressed_spectral_matrix_f0[i*30+23]*k35_sx_re //S35 Im - - compressed_spectral_matrix_f0[i*30+7] *k14_sx_re //S14 Im - - compressed_spectral_matrix_f0[i*30+9] *k15_sx_re //S15 Im - - compressed_spectral_matrix_f0[i*30+15]*k24_sx_re //S24 Im - - compressed_spectral_matrix_f0[i*30+17]*k25_sx_re; //S25 Im - + e_cross_b_im = compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_SX_IM] //S34 Re + + compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_SX_IM] //S35 Re + + compressed_spectral_matrix_f0[i*30+5] *k_f0[i][K14_SX_IM] //S14 Re + + compressed_spectral_matrix_f0[i*30+7] *k_f0[i][K15_SX_IM] //S15 Re + + compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_SX_IM] //S24 Re + + compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_SX_IM] //S25 Re + - compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_SX_RE] //S34 Im + - compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_SX_RE] //S35 Im + - compressed_spectral_matrix_f0[i*30+6] *k_f0[i][K14_SX_RE] //S14 Im + - compressed_spectral_matrix_f0[i*30+8] *k_f0[i][K15_SX_RE] //S15 Im + - compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_SX_RE] //S24 Im + - compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_SX_RE]; //S25 Im +#ifdef DEBUG_TCH printf("ReaSX / 2 : %16.8e\n",e_cross_b_re/2); - +#endif pt_u_char = (unsigned char*) &e_cross_b_re; // Affect an unsigned char pointer with the adress of e_cross_b_re - LFR_BP1_F0[i*9+8] = LFR_BP1_F0[i*9+8] | (pt_u_char[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet) +#ifdef LSB_FIRST_TCH + LFR_BP1_F0[i*9+1] = LFR_BP1_F0[i*9+1] | (pt_u_char[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention) // Record it at the 8th bit position (from the right to the left) - // of LFR_BP1_F0[i*9+8] + // of LFR_BP1_F0[i*9+1] pt_u_char[3] = (pt_u_char[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX| - +#endif +#ifdef MSB_FIRST_TCH + LFR_BP1_F0[i*9+1] = LFR_BP1_F0[i*9+1] | (pt_u_char[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 0th octet:SPARC convention) + // Record it at the 8th bit position (from the right to the left) + // of LFR_BP1_F0[i*9+1] + pt_u_char[0] = (pt_u_char[0] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX| +#endif significand = frexpf(e_cross_b_re/2, &exponent);// 0.5 <= significand < 1 // ReaSX/2 = significand * 2^exponent // The division by 2 is to ensure that max value <= 2^30 (rough estimate) @@ -302,87 +339,103 @@ void BP1_set(){ exponent = expmin; significand = 0.5; // min value that can be recorded } - printf("|ReaSX| / 2 : %16.8e\n",e_cross_b_re/2); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - LFR_BP1_F0[i*9+1] = (unsigned char) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit unsigned char with rounding + LFR_BP1_F0[i*9+7] = (unsigned char) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit unsigned char with rounding // where just the first 3 bits are used (0, ..., 7) tmp_u_char = (unsigned char) (exponent-expmin); // Shift and cast into a 8-bit unsigned char where // just the first 5 bits are used (0, ..., 2^5-1) - printf("LFR_BP1_F0[i*9+1] for ReaSX significand : %u\n",LFR_BP1_F0[i*9+1]); +#ifdef DEBUG_TCH + printf("|ReaSX| / 2 : %16.8e\n",e_cross_b_re/2); + printf("significand : %16.8e\n",significand); + printf("exponent : %d\n" ,exponent); + printf("LFR_BP1_F0[i*9+7] for ReaSX significand : %u\n",LFR_BP1_F0[i*9+7]); printf("tmp_u_char for ReaSX exponent : %d\n",tmp_u_char); - LFR_BP1_F0[i*9+1] = LFR_BP1_F0[i*9+1] | (tmp_u_char << 3); // shift these 5 bits to the left before logical addition - // with LFR_BP1_F0[i*9+1] - printf("LFR_BP1_F0[i*9+1] for ReaSX exponent + significand : %u\n",LFR_BP1_F0[i*9+1]); - printf("LFR_BP1_F0[i*9+8] for ReaSX sign + PSDB 'exponent' : %u\n",LFR_BP1_F0[i*9+8]); - +#endif + LFR_BP1_F0[i*9+7] = LFR_BP1_F0[i*9+7] | (tmp_u_char << 3); // shift these 5 bits to the left before logical addition + // with LFR_BP1_F0[i*9+7] +#ifdef DEBUG_TCH + printf("LFR_BP1_F0[i*9+7] for ReaSX exponent + significand : %u\n",LFR_BP1_F0[i*9+7]); + printf("LFR_BP1_F0[i*9+1] for ReaSX sign + PSDE 'exponent' : %u\n",LFR_BP1_F0[i*9+1]); printf("ImaSX / 2 : %16.8e\n",e_cross_b_im/2); - +#endif pt_u_char = (unsigned char*) &e_cross_b_im; // Affect an unsigned char pointer with the adress of e_cross_b_im +#ifdef LSB_FIRST_TCH pt_u_char[3] = pt_u_char[3] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX| +#endif +#ifdef MSB_FIRST_TCH + pt_u_char[0] = pt_u_char[0] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX| +#endif tmp_u_char = (e_cross_b_im > e_cross_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect // an unsigned 8-bit char with 01000000; otherwise with null. - LFR_BP1_F0[i*9+8] = LFR_BP1_F0[i*9+8] | tmp_u_char; // Record it as a sign bit at the 7th bit position (from the right - // to the left) of LFR_BP1_F0[i*9+7], by simple logical addition. - + LFR_BP1_F0[i*9+1] = LFR_BP1_F0[i*9+1] | tmp_u_char; // Record it as a sign bit at the 7th bit position (from the right + // to the left) of LFR_BP1_F0[i*9+1], by simple logical addition. +#ifdef DEBUG_TCH printf("|ImaSX| / 2 : %16.8e\n",e_cross_b_im/2); printf("ArgSX sign : %u\n",tmp_u_char); - printf("LFR_BP1_F0[i*9+8] for ReaSX & ArgSX signs + PSDB 'exponent' : %u\n",LFR_BP1_F0[i*9+8]); - + printf("LFR_BP1_F0[i*9+1] for ReaSX & ArgSX signs + PSDE 'exponent' : %u\n",LFR_BP1_F0[i*9+1]); +#endif //====================================================================== // BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 8 (+ 2) bits // = 5 bits (exponent) + 3 bits (significand) // + 1 sign bit + 1 argument bit (two sectors) ny = sin(alpha_M)*NVEC_V1 + cos(alpha_M)*NVEC_V2; nz = NVEC_V0; - bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spectral_matrix_f0[i*30+10] // S22 Re - + sin(alpha_M)*sin(alpha_M)*compressed_spectral_matrix_f0[i*30+18] // S33 Re - - 2*sin(alpha_M)*cos(alpha_M)*compressed_spectral_matrix_f0[i*30+12]; // S23 Re + bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spectral_matrix_f0[i*30+9] // S22 Re + + sin(alpha_M)*sin(alpha_M)*compressed_spectral_matrix_f0[i*30+16] // S33 Re + - 2*sin(alpha_M)*cos(alpha_M)*compressed_spectral_matrix_f0[i*30+10]; // S23 Re - n_cross_e_scal_b_re = ny * (compressed_spectral_matrix_f0[i*30+14]*k24_ny_re //S24 Re - +compressed_spectral_matrix_f0[i*30+16]*k25_ny_re //S25 Re - +compressed_spectral_matrix_f0[i*30+20]*k34_ny_re //S34 Re - +compressed_spectral_matrix_f0[i*30+22]*k35_ny_re //S35 Re - +compressed_spectral_matrix_f0[i*30+15]*k24_ny_im //S24 Im - +compressed_spectral_matrix_f0[i*30+17]*k25_ny_im //S25 Im - +compressed_spectral_matrix_f0[i*30+21]*k34_ny_im //S34 Im - +compressed_spectral_matrix_f0[i*30+23]*k35_ny_im) //S35 Im - + nz * (compressed_spectral_matrix_f0[i*30+14]*k24_nz_re //S24 Re - +compressed_spectral_matrix_f0[i*30+16]*k25_nz_re //S25 Re - +compressed_spectral_matrix_f0[i*30+20]*k34_nz_re //S34 Re - +compressed_spectral_matrix_f0[i*30+22]*k35_nz_re //S35 Re - +compressed_spectral_matrix_f0[i*30+15]*k24_nz_im //S24 Im - +compressed_spectral_matrix_f0[i*30+17]*k25_nz_im //S25 Im - +compressed_spectral_matrix_f0[i*30+21]*k34_nz_im //S34 Im - +compressed_spectral_matrix_f0[i*30+23]*k35_nz_im);//S35 Im + n_cross_e_scal_b_re = ny * (compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_NY_RE] //S24 Re + +compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_NY_RE] //S25 Re + +compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_NY_RE] //S34 Re + +compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_NY_RE] //S35 Re + +compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_NY_IM] //S24 Im + +compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_NY_IM] //S25 Im + +compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_NY_IM] //S34 Im + +compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_NY_IM]) //S35 Im + + nz * (compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_NZ_RE] //S24 Re + +compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_NZ_RE] //S25 Re + +compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_NZ_RE] //S34 Re + +compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_NZ_RE] //S35 Re + +compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_NZ_IM] //S24 Im + +compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_NZ_IM] //S25 Im + +compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_NZ_IM] //S34 Im + +compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_NZ_IM]);//S35 Im // Im(S_ji) = -Im(S_ij) // k_ji = k_ij - n_cross_e_scal_b_im = ny * (compressed_spectral_matrix_f0[i*30+14]*k24_ny_im //S24 Re - +compressed_spectral_matrix_f0[i*30+16]*k25_ny_im //S25 Re - +compressed_spectral_matrix_f0[i*30+20]*k34_ny_im //S34 Re - +compressed_spectral_matrix_f0[i*30+22]*k35_ny_im //S35 Re - -compressed_spectral_matrix_f0[i*30+15]*k24_ny_re //S24 Im - -compressed_spectral_matrix_f0[i*30+17]*k25_ny_re //S25 Im - -compressed_spectral_matrix_f0[i*30+21]*k34_ny_re //S34 Im - -compressed_spectral_matrix_f0[i*30+23]*k35_ny_re) //S35 Im - + nz * (compressed_spectral_matrix_f0[i*30+14]*k24_nz_im //S24 Re - +compressed_spectral_matrix_f0[i*30+16]*k25_nz_im //S25 Re - +compressed_spectral_matrix_f0[i*30+20]*k34_nz_im //S34 Re - +compressed_spectral_matrix_f0[i*30+22]*k35_nz_im //S35 Re - -compressed_spectral_matrix_f0[i*30+15]*k24_nz_re //S24 Im - -compressed_spectral_matrix_f0[i*30+17]*k25_nz_re //S25 Im - -compressed_spectral_matrix_f0[i*30+21]*k34_nz_re //S34 Im - -compressed_spectral_matrix_f0[i*30+23]*k35_nz_re);//S35 Im - + n_cross_e_scal_b_im = ny * (compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_NY_IM] //S24 Re + +compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_NY_IM] //S25 Re + +compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_NY_IM] //S34 Re + +compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_NY_IM] //S35 Re + -compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_NY_RE] //S24 Im + -compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_NY_RE] //S25 Im + -compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_NY_RE] //S34 Im + -compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_NY_RE]) //S35 Im + + nz * (compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_NZ_IM] //S24 Re + +compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_NZ_IM] //S25 Re + +compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_NZ_IM] //S34 Re + +compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_NZ_IM] //S35 Re + -compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_NZ_RE] //S24 Im + -compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_NZ_RE] //S25 Im + -compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_NZ_RE] //S34 Im + -compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_NZ_RE]);//S35 Im +#ifdef DEBUG_TCH printf("n_cross_e_scal_b_re : %16.8e\n",n_cross_e_scal_b_re); printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im); +#endif // vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re) pt_u_char = (unsigned char*) &n_cross_e_scal_b_re; // Affect an unsigned char pointer with the adress of n_cross_e_scal_b_re - LFR_BP1_F0[i*9+7] = LFR_BP1_F0[i*9+7] | (pt_u_char[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet) +#ifdef LSB_FIRST_TCH + LFR_BP1_F0[i*9+3] = LFR_BP1_F0[i*9+3] | (pt_u_char[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention) // Record it at the 8th bit position (from the right to the left) - // of LFR_BP1_F0[i*9+7] + // of LFR_BP1_F0[i*9+3] pt_u_char[3] = (pt_u_char[3] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re| +#endif +#ifdef MSB_FIRST_TCH + LFR_BP1_F0[i*9+3] = LFR_BP1_F0[i*9+3] | (pt_u_char[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 0th octet:SPARC convention) + // Record it at the 8th bit position (from the right to the left) + // of LFR_BP1_F0[i*9+3] + pt_u_char[0] = (pt_u_char[0] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re| +#endif vphi = n_cross_e_scal_b_re / bx_bx_star; // Compute |VPHI| significand = frexpf(vphi/2, &exponent); // 0.5 <= significand < 1 @@ -402,33 +455,42 @@ void BP1_set(){ exponent = expmin; significand = 0.5; // min value that can be recorded } +#ifdef DEBUG_TCH printf("|VPHI| / 2 : %16.8e\n",vphi/2); printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); - - LFR_BP1_F0[i*9+0] = (unsigned char) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit unsigned char with rounding +#endif + LFR_BP1_F0[i*9+8] = (unsigned char) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit unsigned char with rounding // where just the first 3 bits are used (0, ..., 7) tmp_u_char = (unsigned char) (exponent-expmin); // Shift and cast into a 8-bit unsigned char where // just the first 5 bits are used (0, ..., 2^5-1) - printf("LFR_BP1_F0[i*9+0] for VPHI significand : %u\n",LFR_BP1_F0[i*9+0]); +#ifdef DEBUG_TCH + printf("LFR_BP1_F0[i*9+8] for VPHI significand : %u\n",LFR_BP1_F0[i*9+8]); printf("tmp_u_char for VPHI exponent : %d\n",tmp_u_char); - LFR_BP1_F0[i*9+0] = LFR_BP1_F0[i*9+0] | (tmp_u_char << 3); // shift these 5 bits to the left before logical addition - // with LFR_BP1_F0[i*9+0] - printf("LFR_BP1_F0[i*9+0] for VPHI exponent + significand : %u\n",LFR_BP1_F0[i*9+0]); - printf("LFR_BP1_F0[i*9+6] for VPHI sign + PSDE 'exponent' : %u\n",LFR_BP1_F0[i*9+6]); - +#endif + LFR_BP1_F0[i*9+8] = LFR_BP1_F0[i*9+8] | (tmp_u_char << 3); // shift these 5 bits to the left before logical addition + // with LFR_BP1_F0[i*9+8] +#ifdef DEBUG_TCH + printf("LFR_BP1_F0[i*9+8] for VPHI exponent + significand : %u\n",LFR_BP1_F0[i*9+8]); + printf("LFR_BP1_F0[i*9+3] for VPHI sign + PSDB 'exponent' : %u\n",LFR_BP1_F0[i*9+3]); +#endif pt_u_char = (unsigned char*) &n_cross_e_scal_b_im; // Affect an unsigned char pointer with the adress of n_cross_e_scal_b_im +#ifdef LSB_FIRST_TCH pt_u_char[3] = pt_u_char[3] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaSX| +#endif +#ifdef MSB_FIRST_TCH + pt_u_char[0] = pt_u_char[0] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaSX| +#endif tmp_u_char = (n_cross_e_scal_b_im > n_cross_e_scal_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect // an unsigned 8-bit char with 01000000; otherwise with null. - LFR_BP1_F0[i*9+6] = LFR_BP1_F0[i*9+6] | tmp_u_char; // Record it as a sign bit at the 7th bit position (from the right - // to the left) of LFR_BP1_F0[i*9+6], by simple logical addition. - + LFR_BP1_F0[i*9+3] = LFR_BP1_F0[i*9+3] | tmp_u_char; // Record it as a sign bit at the 7th bit position (from the right + // to the left) of LFR_BP1_F0[i*9+3], by simple logical addition. +#ifdef DEBUG_TCH printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im); printf("|n_cross_e_scal_b_im|/bx_bx_star/2: %16.8e\n",n_cross_e_scal_b_im/bx_bx_star/2); printf("ArgNEBX sign : %u\n",tmp_u_char); - printf("LFR_BP1_F0[i*9+6] for VPHI & ArgNEBX signs + PSDE 'exponent' : %u\n",LFR_BP1_F0[i*9+6]); - + printf("LFR_BP1_F0[i*9+3] for VPHI & ArgNEBX signs + PSDB 'exponent' : %u\n",LFR_BP1_F0[i*9+3]); +#endif } } @@ -440,19 +502,24 @@ void BP2_set(){ unsigned short int autocor, tmp_u_short_int; // 16 bits unsigned short int *pt_u_short_int; // pointer on unsigned 16-bit words +#ifdef DEBUG_TCH printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0); printf("BP2 : \n"); +#endif // For floating point data to be recorded on 16-bit words : nbitexp = 6; // number of bits for the exponent nbitsig = 16 - nbitexp; // number of bits for the significand rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1 - printf("nbitexp : %d, nbitsig : %d, rangesig : %d\n", nbitexp, nbitsig, rangesig); expmax = 32; expmin = expmax - (1 << nbitexp) + 1; - printf("expmin : %d, expmax : %d\n", expmin, expmax); - for(i = 0; i<1; i++){ +#ifdef DEBUG_TCH + printf("nbitexp : %d, nbitsig : %d, rangesig : %d\n", nbitexp, nbitsig, rangesig); + printf("expmin : %d, expmax : %d\n", expmin, expmax); +#endif + + for(i = 0; i= 0.5 * 2^expmin + exponent = expmin; + significand = 0.5; // min value that can be recorded + } + if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) + exponent = expmax; + significand = 1.0; // max value that can be recorded + } + if (significand == 0) {// in that case exponent == 0 too + exponent = expmin; + significand = 0.5; // min value that can be recorded + } + + autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding + // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) + tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int + // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) + pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+0]; // Affect an unsigned short int pointer with the + // adress where the 16-bit word result will be stored + *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the + // left place of the significand bits (nbitsig), making + // the 16-bit word to be recorded, and record it using the pointer +#ifdef DEBUG_TCH + printf("autocor for S11 significand : %u\n",autocor ); + printf("tmp_u_char for S11 exponent : %u\n",tmp_u_short_int ); + printf("*pt_u_short_int for S11 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); + printf("LFR_BP2_F0[i*30+1] : %u or %x\n",LFR_BP2_F0[i*30+1], LFR_BP2_F0[i*30+1]); + printf("LFR_BP2_F0[i*30+0] : %u or %x\n",LFR_BP2_F0[i*30+0], LFR_BP2_F0[i*30+0]); +#endif + // S22 + significand = frexpf(compressed_spectral_matrix_f0[i*30+9], &exponent); // 0.5 <= significand < 1 + // S22 = significand * 2^exponent +#ifdef DEBUG_TCH + printf("S22 : %16.8e\n",compressed_spectral_matrix_f0[i*30+9]); + printf("significand : %16.8e\n",significand); + printf("exponent : %d\n" ,exponent); +#endif + if (exponent < expmin) { // value should be >= 0.5 * 2^expmin + exponent = expmin; + significand = 0.5; // min value that can be recorded + } + if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) + exponent = expmax; + significand = 1.0; // max value that can be recorded + } + if (significand == 0) {// in that case exponent == 0 too + exponent = expmin; + significand = 0.5; // min value that can be recorded + } + + autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding + // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) + tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int + // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) + pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+2]; // Affect an unsigned short int pointer with the + // adress where the 16-bit word result will be stored + *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the + // left place of the significand bits (nbitsig), making + // the 16-bit word to be recorded, and record it using the pointer +#ifdef DEBUG_TCH + printf("autocor for S22 significand : %d\n",autocor ); + printf("tmp_u_char for S22 exponent : %d\n",tmp_u_short_int ); + printf("*pt_u_short_int for S22 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); + printf("LFR_BP2_F0[i*30+3] : %.3d or %x\n",LFR_BP2_F0[i*30+3], LFR_BP2_F0[i*30+3]); + printf("LFR_BP2_F0[i*30+2] : %.3d or %x\n",LFR_BP2_F0[i*30+2], LFR_BP2_F0[i*30+2]); +#endif + // S33 + significand = frexpf(compressed_spectral_matrix_f0[i*30+16], &exponent); // 0.5 <= significand < 1 + // S33 = significand * 2^exponent +#ifdef DEBUG_TCH + printf("S33 : %16.8e\n",compressed_spectral_matrix_f0[i*30+16]); + printf("significand : %16.8e\n",significand); + printf("exponent : %d\n" ,exponent); +#endif + if (exponent < expmin) { // value should be >= 0.5 * 2^expmin + exponent = expmin; + significand = 0.5; // min value that can be recorded + } + if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) + exponent = expmax; + significand = 1.0; // max value that can be recorded + } + if (significand == 0) {// in that case exponent == 0 too + exponent = expmin; + significand = 0.5; // min value that can be recorded + } + + autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding + // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) + tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int + // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) + pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+4]; // Affect an unsigned short int pointer with the + // adress where the 16-bit word result will be stored + *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the + // left place of the significand bits (nbitsig), making + // the 16-bit word to be recorded, and record it using the pointer +#ifdef DEBUG_TCH + printf("autocor for S33 significand : %d\n",autocor ); + printf("tmp_u_char for S33 exponent : %d\n",tmp_u_short_int ); + printf("*pt_u_short_int for S33 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); + printf("LFR_BP2_F0[i*30+5] : %.3d or %x\n",LFR_BP2_F0[i*30+5], LFR_BP2_F0[i*30+5]); + printf("LFR_BP2_F0[i*30+4] : %.3d or %x\n",LFR_BP2_F0[i*30+4], LFR_BP2_F0[i*30+4]); +#endif + // S44 + significand = frexpf(compressed_spectral_matrix_f0[i*30+21], &exponent); // 0.5 <= significand < 1 + // S44 = significand * 2^exponent +#ifdef DEBUG_TCH + printf("S44 : %16.8e\n",compressed_spectral_matrix_f0[i*30+21]); + printf("significand : %16.8e\n",significand); + printf("exponent : %d\n" ,exponent); +#endif if (exponent < expmin) { // value should be >= 0.5 * 2^expmin exponent = expmin; @@ -585,63 +782,30 @@ void BP2_set(){ significand = 0.5; // min value that can be recorded } - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding + autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int + tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+28]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the + pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+6]; // Affect an unsigned short int pointer with the + // adress where the 16-bit word result will be stored + *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the // left place of the significand bits (nbitsig), making // the 16-bit word to be recorded, and record it using the pointer - //printf("size of autocor : %d\n",sizeof(autocor) ); - //printf("size of tmp_u_short_int : %d\n",sizeof(tmp_u_short_int) ); - printf("autocor for S11 significand : %u\n",autocor ); - printf("tmp_u_char for S11 exponent : %u\n",tmp_u_short_int ); - printf("*pt_u_short_int for S11 significand + exponent: %u or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+29] : %u or %x\n",LFR_BP2_F0[i*30+29], LFR_BP2_F0[i*30+29]); - printf("LFR_BP2_F0[i*30+28] : %u or %x\n",LFR_BP2_F0[i*30+28], LFR_BP2_F0[i*30+28]); - // S22 - significand = frexpf(compressed_spectral_matrix_f0[i*30+10], &exponent); // 0.5 <= significand < 1 - // S22 = significand * 2^exponent - printf("S22 : %16.8e\n",compressed_spectral_matrix_f0[i*30+10]); +#ifdef DEBUG_TCH + printf("autocor for S44 significand : %d\n",autocor ); + printf("tmp_u_char for S44 exponent : %d\n",tmp_u_short_int ); + printf("*pt_u_short_int for S44 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); + printf("LFR_BP2_F0[i*30+7] : %.3d or %x\n",LFR_BP2_F0[i*30+7], LFR_BP2_F0[i*30+7]); + printf("LFR_BP2_F0[i*30+6] : %.3d or %x\n",LFR_BP2_F0[i*30+6], LFR_BP2_F0[i*30+6]); +#endif + // S55 + significand = frexpf(compressed_spectral_matrix_f0[i*30+24], &exponent); // 0.5 <= significand < 1 + // S55 = significand * 2^exponent +#ifdef DEBUG_TCH + printf("S55 : %16.8e\n",compressed_spectral_matrix_f0[i*30+24]); printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+26]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - printf("autocor for S22 significand : %d\n",autocor ); - printf("tmp_u_char for S22 exponent : %d\n",tmp_u_short_int ); - printf("*pt_u_short_int for S22 significand + exponent: %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+27] : %.3d or %x\n",LFR_BP2_F0[i*30+27], LFR_BP2_F0[i*30+27]); - printf("LFR_BP2_F0[i*30+26] : %.3d or %x\n",LFR_BP2_F0[i*30+26], LFR_BP2_F0[i*30+26]); - // S33 - significand = frexpf(compressed_spectral_matrix_f0[i*30+18], &exponent); // 0.5 <= significand < 1 - // S33 = significand * 2^exponent - printf("S33 : %16.8e\n",compressed_spectral_matrix_f0[i*30+18]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - +#endif if (exponent < expmin) { // value should be >= 0.5 * 2^expmin exponent = expmin; significand = 0.5; // min value that can be recorded @@ -655,89 +819,22 @@ void BP2_set(){ significand = 0.5; // min value that can be recorded } - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int + autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding + // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) + tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+24]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the + pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+8]; // Affect an unsigned short int pointer with the + // adress where the 16-bit word result will be stored + *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the // left place of the significand bits (nbitsig), making // the 16-bit word to be recorded, and record it using the pointer - printf("autocor for S33 significand : %d\n",autocor ); - printf("tmp_u_char for S33 exponent : %d\n",tmp_u_short_int ); - printf("*pt_u_short_int for S33 significand + exponent: %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+25] : %.3d or %x\n",LFR_BP2_F0[i*30+25], LFR_BP2_F0[i*30+25]); - printf("LFR_BP2_F0[i*30+24] : %.3d or %x\n",LFR_BP2_F0[i*30+24], LFR_BP2_F0[i*30+24]); - // S44 - significand = frexpf(compressed_spectral_matrix_f0[i*30+24], &exponent); // 0.5 <= significand < 1 - // S44 = significand * 2^exponent - printf("S44 : %16.8e\n",compressed_spectral_matrix_f0[i*30+24]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+22]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - printf("autocor for S44 significand : %d\n",autocor ); - printf("tmp_u_char for S44 exponent : %d\n",tmp_u_short_int ); - printf("*pt_u_short_int for S44 significand + exponent: %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+23] : %.3d or %x\n",LFR_BP2_F0[i*30+23], LFR_BP2_F0[i*30+23]); - printf("LFR_BP2_F0[i*30+22] : %.3d or %x\n",LFR_BP2_F0[i*30+22], LFR_BP2_F0[i*30+22]); - // S55 - significand = frexpf(compressed_spectral_matrix_f0[i*30+28], &exponent); // 0.5 <= significand < 1 - // S55 = significand * 2^exponent - printf("S55 : %16.8e\n",compressed_spectral_matrix_f0[i*30+28]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+20]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer +#ifdef DEBUG_TCH printf("autocor for S55 significand : %d\n",autocor ); printf("tmp_u_char for S55 exponent : %d\n",tmp_u_short_int ); - printf("*pt_u_short_int for S55 significand + exponent: %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+21] : %.3d or %x\n",LFR_BP2_F0[i*30+21], LFR_BP2_F0[i*30+21]); - printf("LFR_BP2_F0[i*30+20] : %.3d or %x\n",LFR_BP2_F0[i*30+20], LFR_BP2_F0[i*30+20]); - + printf("*pt_u_short_int for S55 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); + printf("LFR_BP2_F0[i*30+9] : %.3d or %x\n",LFR_BP2_F0[i*30+9], LFR_BP2_F0[i*30+9]); + printf("LFR_BP2_F0[i*30+8] : %.3d or %x\n",LFR_BP2_F0[i*30+8], LFR_BP2_F0[i*30+8]); +#endif } } diff --git a/basic_parameters_1_ICD_issue1rev6.h b/basic_parameters.h rename from basic_parameters_1_ICD_issue1rev6.h rename to basic_parameters.h --- a/basic_parameters_1_ICD_issue1rev6.h +++ b/basic_parameters.h @@ -1,3 +1,6 @@ +// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) +// version 1: 31/07/2013 + #ifndef BASIC_PARAMETERS_H_INCLUDED #define BASIC_PARAMETERS_H_INCLUDED @@ -6,9 +9,9 @@ #define LPP_SPECTRAL_MATRIX_2 0x80000708 #define NB_BINS_SPECTRAL_MATRIX 128 -#define NB_VALUES_PER_SPECTRAL_MATRIX 30 +#define NB_VALUES_PER_SPECTRAL_MATRIX 25 #define TOTAL_SIZE_SPECTRAL_MATRIX NB_BINS_SPECTRAL_MATRIX * NB_VALUES_PER_SPECTRAL_MATRIX -#define NB_BINS_COMPRESSED_MATRIX_f0 2 +#define NB_BINS_COMPRESSED_MATRIX_f0 1 #define SIZE_COMPRESSED_SPECTRAL_MATRIX_f1 13 #define SIZE_COMPRESSED_SPECTRAL_MATRIX_f2 12 #define TOTAL_SIZE_COMPRESSED_MATRIX_f0 NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_SPECTRAL_MATRIX @@ -18,10 +21,10 @@ volatile int spectral_matrix_f0_a[TOTAL_ volatile int spectral_matrix_f0_b[TOTAL_SIZE_SPECTRAL_MATRIX]; int averaged_spectral_matrix_f0[TOTAL_SIZE_SPECTRAL_MATRIX]; -extern float compressed_spectral_matrix_f0[ ]; +extern float compressed_spectral_matrix_f0[]; -extern unsigned char LFR_BP1_F0[ ]; -extern unsigned char LFR_BP2_F0[ ]; +extern unsigned char LFR_BP1_F0[]; +extern unsigned char LFR_BP2_F0[]; void BP1_set(); void BP2_set(); diff --git a/basic_parameters_1_ICD_issue1rev6_V1.c b/basic_parameters_1_ICD_issue1rev6_V1.c deleted file mode 100644 --- a/basic_parameters_1_ICD_issue1rev6_V1.c +++ /dev/null @@ -1,625 +0,0 @@ -#include "basic_parameters_1_ICD_issue1rev6.h" -#include -#include - -float k44_pe = 1; -float k55_pe = 1; -float k45_pe_re = 1; -float k45_pe_im = 1; - -float k14_sx_re = 1; -float k14_sx_im = 1; -float k15_sx_re = 1; -float k15_sx_im = 1; -float k24_sx_re = 1; -float k24_sx_im = 1; -float k25_sx_re = 1; -float k25_sx_im = 1; -float k34_sx_re = 1; -float k34_sx_im = 1; -float k35_sx_re = 1; -float k35_sx_im = 1; - -float k24_ny_re = 1; -float k24_ny_im = 1; -float k25_ny_re = 1; -float k25_ny_im = 1; -float k34_ny_re = 1; -float k34_ny_im = 1; -float k35_ny_re = 1; -float k35_ny_im = 1; - -float k24_nz_re = 1; -float k24_nz_im = 1; -float k25_nz_re = 1; -float k25_nz_im = 1; -float k34_nz_re = 1; -float k34_nz_im = 1; -float k35_nz_re = 1; -float k35_nz_im = 1; - -float alpha_M = 45; - -void BP1_set(){ - int i, j; - unsigned char tmp_u_char; - unsigned char *pt_u_char; - float significand; - int exponent; - float PSDB, PSDE; - float NVEC_V0, NVEC_V1, NVEC_V2; - float aux, tr_SB_SB, tmp; - float e_cross_b_re, e_cross_b_im; - float n_cross_e_scal_b_re = 0, n_cross_e_scal_b_im = 0; - float nx = 0, ny = 0; - float bz_bz_star = 0; - - unsigned char toto_u_char; - unsigned char *pt_toto_u_char; - signed char toto_s_char; - float toto_f; - - FILE *infile; - infile = fopen("sm_test1.dat", "rb"); // open explicitely a binary file !!! ... - if(infile == NULL) { - printf("Hello I cannot open the file!\n"); - return 0; - } - (void) fread(compressed_spectral_matrix_f0, sizeof(compressed_spectral_matrix_f0), 1, infile); - (void) fclose(infile); - //printf("size of compressed_spectral_matrix_f0 : %d\n", sizeof(compressed_spectral_matrix_f0)); - printf("compressed_spectral_matrix_f0 : \n"); - for (i = 0; i < 15; i++) { - printf("Element number %.2d (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", i+1, 2*i, 2*i+1, - compressed_spectral_matrix_f0[2*i], - compressed_spectral_matrix_f0[2*i+1]); - } - - printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0); - printf("BP1 : \n"); - for(i=0; i<1; i++){ - //============================================== - // BP1 PSD == B PAR_LFR_SC_BP1_PB_F0 == 12 bits = 5 bits (exponent) + 7 bits (significand) - PSDB = compressed_spectral_matrix_f0[i*30] // S11 - + compressed_spectral_matrix_f0[i*30+10] // S22 - + compressed_spectral_matrix_f0[i*30+18]; // S33 - - significand = frexpf(PSDB/3, &exponent); // 0.5 <= significand < 1 - // PSDB = significand * 2^exponent - // the division by 3 is to ensure that max value <= 2^30 - - printf("PSDB : %16.8e\n",PSDB); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < 0) { // value is >= 0.5 * 2^0 (min value included) - exponent = 0; - significand = 0.5; // min value that can be recorded - } - - if (exponent > 31) { // value is < 1.0 * 2^31 (max value excluded) - exponent = 31; - significand = 0.999; // max value that can be recorded - // (a minimum of 3 decimal is important !...) - } - - if (significand == 0) {// in that case exponent == 0 too - significand = 0.5; // min value that can be recorded - } - - LFR_BP1_F0[i*9+8] = (unsigned char) (significand*256 -128); // shift and cast into a 8-bit unsigned char - // where just the first 7 bits are used (0, ..., 127) - LFR_BP1_F0[i*9+7] = (unsigned char) exponent; // shift and cast into a 8-bit unsigned char - // where just the first 5 bits are used (0, ..., 31) - - printf("LFR_BP1_F0[i*9+8] for PSDB significand : %u\n",LFR_BP1_F0[i*9+8]); - printf("LFR_BP1_F0[i*9+7] for PSDB exponent : %u\n",LFR_BP1_F0[i*9+7]); - - //toto_f = 32768*32768; // max value ? - //significand = frexp(toto_f, &exponent); - //printf("toto_f : %16.8e\n",toto_f); - //printf("significand : %16.8e\n",significand); - //printf("exponent : %d\n" ,exponent); - - //============================================== - // BP1 PSD == E PAR_LFR_SC_BP1_PE_F0 == 12 bits = 5 bits (exponent) + 7 bits (significand) - PSDE = compressed_spectral_matrix_f0[i*30+24] * k44_pe // S44 - + compressed_spectral_matrix_f0[i*30+28] * k55_pe // S55 - + compressed_spectral_matrix_f0[i*30+26] * k45_pe_re // S45 Re - - compressed_spectral_matrix_f0[i*30+27] * k45_pe_im; // S45 Im - - significand = frexpf(PSDE/2, &exponent); // 0.5 <= significand < 1 - // PSDE = significand * 2^exponent - // the division by 2 is to ensure that max value < 2^31 - - printf("PSDE : %16.8e\n",PSDE); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < 0) { // value is >= 0.5 * 2^0 (min value included) - exponent = 0; - significand = 0.5; // min value that can be recorded - } - - if (exponent > 31) { // value is < 1.0 * 2^31 (max value excluded) - exponent = 31; - significand = 0.999; // max value that can be recorded - // (a minimum of 3 decimal is important !...) - } - - if (significand == 0) {// in that case exponent == 0 too - significand = 0.5; // min value that can be recorded - } - - LFR_BP1_F0[i*9+6] = (unsigned char) (significand*256 -128); // shift and cast into a 8-bit unsigned char - // where just the first 7 bits are used (0, ..., 127) - LFR_BP1_F0[i*9+5] = (unsigned char) exponent; // shift and cast into a 8-bit unsigned char - // where just the first 5 bits are used (0, ..., 31) - - printf("LFR_BP1_F0[i*9+6] for PSDE significand : %u\n",LFR_BP1_F0[i*9+6]); - printf("LFR_BP1_F0[i*9+5] for PSDE exponent : %u\n",LFR_BP1_F0[i*9+5]); - - //toto_f = 1./3; // min value ? - //significand = frexp(toto_f, &exponent); - //printf("toto_f : %16.8e\n",toto_f); - //printf("significand : %16.8e\n",significand); - //printf("exponent : %d\n" ,exponent); - - //============================================================================== - // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits - // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits - // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 sign bit - tmp = sqrt( compressed_spectral_matrix_f0[i*30+3] *compressed_spectral_matrix_f0[i*30+3] //Im S12 - +compressed_spectral_matrix_f0[i*30+5] *compressed_spectral_matrix_f0[i*30+5] //Im S13 - +compressed_spectral_matrix_f0[i*30+13]*compressed_spectral_matrix_f0[i*30+13] //Im S23 - ); - NVEC_V0 = compressed_spectral_matrix_f0[i*30+13]/ tmp; // Im S23 - NVEC_V1 = -compressed_spectral_matrix_f0[i*30+5] / tmp; // Im S13 - NVEC_V2 = compressed_spectral_matrix_f0[i*30+3] / tmp; // Im S12 - - printf("NVEC_V0 : %16.8e\n",NVEC_V0); - printf("NVEC_V1 : %16.8e\n",NVEC_V1); - printf("NVEC_V2 : %16.8e\n",NVEC_V2); - - LFR_BP1_F0[i*9+4] = (unsigned char) (NVEC_V0*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP1_F0[i*9+3] = (unsigned char) (NVEC_V1*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - pt_u_char = (unsigned char*) &NVEC_V2; // affect an unsigned char pointer with the adress of NVEC_V2 - LFR_BP1_F0[i*9+2] = pt_u_char[3] & 0x80; // extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 4th octet) - // record it at the 8th bit position of LFR_BP1_F0[i*9+2] - - printf("LFR_BP1_F0[i*9+4] for NVEC_V0 : %u\n",LFR_BP1_F0[i*9+4]); - printf("LFR_BP1_F0[i*9+3] for NVEC_V1 : %u\n",LFR_BP1_F0[i*9+3]); - printf("LFR_BP1_F0[i*9+2] for NVEC_V2 : %u\n",LFR_BP1_F0[i*9+2]); - - //toto_f = 128.9999 ; - //toto_s_char = (signed char) toto_f; - //printf("toto_s_char : %d\n",toto_s_char); - - //toto_f = 255.999 ; - //toto_u_char = (unsigned char) (toto_f); - //printf("toto_u_char : %d\n",toto_u_char); - - //toto_f = -1110.999 ; - //pt_toto_u_char = (unsigned char*) &toto_f; - //printf("pt_toto_u_char : %u\n", pt_toto_u_char[3] & 0x80); - - //======================================================= - // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits - aux = 2*tmp / PSDB; // compute the ellipticity - - printf("ellipticity : %16.8e\n",aux); - - tmp_u_char = (unsigned char) (aux*15.999);// shift and cast into a 8-bit unsigned char - // where just the first 4 bits are used (0, ..., 15) - LFR_BP1_F0[i*9+2] = LFR_BP1_F0[i*9+2] | (tmp_u_char << 3); // put these 4 bits next to the right place - // of the sign bit of NVEC_V2 (recorded - // previously in LFR_BP1_F0[i*9+2]) - - printf("tmp_u_char for ellipticity : %u\n",tmp_u_char); - printf("LFR_BP1_F0[i*9+2] for NVEC_V2 + ellipticity : %u\n",LFR_BP1_F0[i*9+2]); - - //============================================================== - // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits - tr_SB_SB = compressed_spectral_matrix_f0[i*30] *compressed_spectral_matrix_f0[i*30] - + compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+10] - + compressed_spectral_matrix_f0[i*30+18]*compressed_spectral_matrix_f0[i*30+18] - + 2 * compressed_spectral_matrix_f0[i*30+2] *compressed_spectral_matrix_f0[i*30+2] - + 2 * compressed_spectral_matrix_f0[i*30+3] *compressed_spectral_matrix_f0[i*30+3] - + 2 * compressed_spectral_matrix_f0[i*30+4] *compressed_spectral_matrix_f0[i*30+4] - + 2 * compressed_spectral_matrix_f0[i*30+5] *compressed_spectral_matrix_f0[i*30+5] - + 2 * compressed_spectral_matrix_f0[i*30+12]*compressed_spectral_matrix_f0[i*30+12] - + 2 * compressed_spectral_matrix_f0[i*30+13]*compressed_spectral_matrix_f0[i*30+13]; - - aux = PSDB*PSDB; // compute the degree of polarisation - tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); - - printf("DOP : %16.8e\n",tmp); - - tmp_u_char = (unsigned char) (tmp*7.999);// shift and cast into a 8-bit unsigned char - // where just the first 3 bits are used (0, ..., 7) - LFR_BP1_F0[i*9+2] = LFR_BP1_F0[i*9+2] | tmp_u_char; // record these 3 bits at the 3 first - // bit positions of LFR_BP1_F0[i*9+2] - - printf("tmp_u_char for DOP : %u\n",tmp_u_char); - printf("LFR_BP1_F0[i*9+2] for NVEC_V2 + ellipticity + DOP : %u\n",LFR_BP1_F0[i*9+2]); - - //======================================================================================= - // BP1 X_SO-component of the Poynting flux == PAR_LFR_SC_BP1_SX_F0 == 12 bits - // = 5 bits (exponent) + 5 bits (significand) - // + 1 sign bit + 1 argument bit (two sectors) - e_cross_b_re = compressed_spectral_matrix_f0[i*30+20]*k34_sx_re - + compressed_spectral_matrix_f0[i*30+22]*k35_sx_re - + compressed_spectral_matrix_f0[i*30+6] *k14_sx_re - + compressed_spectral_matrix_f0[i*30+8] *k15_sx_re - + compressed_spectral_matrix_f0[i*30+14]*k24_sx_re - + compressed_spectral_matrix_f0[i*30+16]*k25_sx_re - + compressed_spectral_matrix_f0[i*30+21]*k34_sx_im - + compressed_spectral_matrix_f0[i*30+23]*k35_sx_im - + compressed_spectral_matrix_f0[i*30+7] *k14_sx_im - + compressed_spectral_matrix_f0[i*30+9] *k15_sx_im - + compressed_spectral_matrix_f0[i*30+15]*k24_sx_im - + compressed_spectral_matrix_f0[i*30+17]*k25_sx_im; - // Im(S_ji) = -Im(S_ij) - // k_ji = k_ij - e_cross_b_im = compressed_spectral_matrix_f0[i*30+20]*k34_sx_im - + compressed_spectral_matrix_f0[i*30+22]*k35_sx_im - + compressed_spectral_matrix_f0[i*30+6] *k14_sx_im - + compressed_spectral_matrix_f0[i*30+8] *k15_sx_im - + compressed_spectral_matrix_f0[i*30+14]*k24_sx_im - + compressed_spectral_matrix_f0[i*30+16]*k25_sx_im - - compressed_spectral_matrix_f0[i*30+21]*k34_sx_re - - compressed_spectral_matrix_f0[i*30+23]*k35_sx_re - - compressed_spectral_matrix_f0[i*30+7] *k14_sx_re - - compressed_spectral_matrix_f0[i*30+9] *k15_sx_re - - compressed_spectral_matrix_f0[i*30+15]*k24_sx_re - - compressed_spectral_matrix_f0[i*30+17]*k25_sx_re; - - printf("ReaSX : %16.8e\n",e_cross_b_re); - - pt_u_char = (unsigned char*) &e_cross_b_re; // affect an unsigned char pointer with the adress of e_cross_b_re - //LFR_BP1_F0[i*9+7] = LFR_BP1_F0[i*9+7] | (pt_u_char[3] & 0x80); // extract the sign bit of e_cross_b_re (32-bit float, sign bit in the 4th octet) - // record it at the 8th bit position of LFR_BP1_F0[i*9+7] - pt_u_char[3] = pt_u_char[3] & 0x7f; // make e_cross_b_re be positive in any case: |ReaSX| - - significand = frexpf(e_cross_b_re, &exponent); - - printf("|ReaSX| : %16.8e\n",e_cross_b_re); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - //printf("LFR_BP1_F0[i*9+7] for PSDB exponent + ReaSX sign : %u\n",LFR_BP1_F0[i*9+7]); - - LFR_BP1_F0[i*9+1] = (unsigned char) (significand*64 -32); // shift and cast into a 8-bit unsigned char - // where just the first 5 bits are used (0, ..., 31) - LFR_BP1_F0[i*9+1] = (unsigned char) exponent+28; // shift and cast into a 8-bit unsigned char - // where just the first 6 bits are used (0, ..., 63) - // à réfléchir ... - - // tmp = e_cross_b_re * e_cross_b_im; - // pt_char = (unsigned char*) &tmp; - // LFR_BP1_F0[i*9+1] = LFR_BP1_F0[i*9+1] | (pt_char[0] & 0x80); // extract the sign of ArgSz - - printf("ImaSX : %16.8e\n",e_cross_b_im); - - pt_u_char = (unsigned char*) &e_cross_b_im; // affect an unsigned char pointer with the adress of e_cross_b_im - pt_u_char[3] = pt_u_char[3] & 0x7f; // make e_cross_b_im be positive in any case: |ImaSX| - tmp_u_char = (e_cross_b_im > e_cross_b_re) ? 0x40 : 0x00; // determine the sector argument of SX - //LFR_BP1_F0[i*9+7] = LFR_BP1_F0[i*9+7] | tmp_u_char; // record it as a sign bit at the 7th bit position of LFR_BP1_F0[i*9+7] - - printf("|ImaSX| : %16.8e\n",e_cross_b_im); - printf("argSX sign : %d\n",tmp_u_char); - //printf("LFR_BP1_F0[i*9+7] for PSDB exponent + ReaSX sign + argSX sign: %u\n",LFR_BP1_F0[i*9+7]); - - //====================================================================== - //====================================================================== - } -} - -void BP2_set(){ - int i, exponent; - float aux, significand, cross_re, cross_im; - signed char nbitexp, nbitsig, expmin, expmax; // 8 bits - short int rangesig; // 16 bits - unsigned short int autocor, tmp_u_short_int; // 16 bits - unsigned short int *pt_u_short_int; // pointer on unsigned 16-bit words - - printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0); - printf("BP2 : \n"); - - // For floating point data to be recorded on 16-bit words : - nbitexp = 6; // number of bits for the exponent - nbitsig = 16 - nbitexp; // number of bits for the significand - rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1 - printf("nbitexp : %d, nbitsig : %d, rangesig : %d\n", nbitexp, nbitsig, rangesig); - expmax = 32; - expmin = expmax - (1 << nbitexp) + 1; - printf("expmin : %d, expmax : %d\n", expmin, expmax); - - for(i = 0; i<1; i++){ - //============================================== - // BP2 normalized cross correlations == PA_LFR_SC_BP2_CROSS_F0 == 10 * (8+8) bits - // == PA_LFR_SC_BP2_CROSS_RE_0_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_0_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_1_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_1_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_2_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_2_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_3_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_3_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_4_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_4_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_5_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_5_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_6_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_6_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_7_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_7_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_8_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_8_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_9_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_9_F0 == 8 bits - // S12 - aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+10]); - cross_re = compressed_spectral_matrix_f0[i*30+2] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+3] / aux; - LFR_BP2_F0[i*30+19] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+9] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+19] for cross12_re (%16.8e) : %u\n",cross_re, LFR_BP2_F0[i*30+19]); - printf("LFR_BP2_F0[i*30+9] for cross12_im (%16.8e) : %u\n",cross_im, LFR_BP2_F0[i*30+9]); - - // S13 - aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+18]); - cross_re = compressed_spectral_matrix_f0[i*30+4] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+5] / aux; - LFR_BP2_F0[i*30+18] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+8] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+18] for cross13_re (%16.8e) : %u\n",cross_re, LFR_BP2_F0[i*30+18]); - printf("LFR_BP2_F0[i*30+8] for cross13_im (%16.8e) : %u\n",cross_im, LFR_BP2_F0[i*30+8]); - - // S14 - aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+24]); - cross_re = compressed_spectral_matrix_f0[i*30+6] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+7] / aux; - LFR_BP2_F0[i*30+17] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+7] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+17] for cross14_re (%16.8e) : %u\n",cross_re, LFR_BP2_F0[i*30+17]); - printf("LFR_BP2_F0[i*30+7] for cross14_im (%16.8e) : %u\n",cross_im, LFR_BP2_F0[i*30+7]); - // S15 - aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+28]); - cross_re = compressed_spectral_matrix_f0[i*30+8] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+9] / aux; - LFR_BP2_F0[i*30+16] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+6] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+16] for cross15_re (%16.8e) : %u\n",cross_re, LFR_BP2_F0[i*30+16]); - printf("LFR_BP2_F0[i*30+6] for cross15_im (%16.8e) : %u\n",cross_im, LFR_BP2_F0[i*30+6]); - // S23 - aux = sqrt(compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+18]); - cross_re = compressed_spectral_matrix_f0[i*30+12] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+13] / aux; - LFR_BP2_F0[i*30+15] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+5] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+15] for cross23_re (%16.8e) : %u\n",cross_re, LFR_BP2_F0[i*30+15]); - printf("LFR_BP2_F0[i*30+5] for cross23_im (%16.8e) : %u\n",cross_im, LFR_BP2_F0[i*30+5]); - // S24 - aux = sqrt(compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+24]); - cross_re = compressed_spectral_matrix_f0[i*30+14] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+15] / aux; - LFR_BP2_F0[i*30+14] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+4] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+14] for cross24_re (%16.8e) : %u\n",cross_re, LFR_BP2_F0[i*30+14]); - printf("LFR_BP2_F0[i*30+4] for cross24_im (%16.8e) : %u\n",cross_im, LFR_BP2_F0[i*30+4]); - // S25 - aux = sqrt(compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+28]); - cross_re = compressed_spectral_matrix_f0[i*30+16] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+17] / aux; - LFR_BP2_F0[i*30+13] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+3] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+13] for cross25_re (%16.8e) : %u\n",cross_re, LFR_BP2_F0[i*30+13]); - printf("LFR_BP2_F0[i*30+3] for cross25_im (%16.8e) : %u\n",cross_im, LFR_BP2_F0[i*30+3]); - // S34 - aux = sqrt(compressed_spectral_matrix_f0[i*30+18]*compressed_spectral_matrix_f0[i*30+24]); - cross_re = compressed_spectral_matrix_f0[i*30+20] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+21] / aux; - LFR_BP2_F0[i*30+12] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+2] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+12] for cross34_re (%16.8e) : %u\n",cross_re, LFR_BP2_F0[i*30+12]); - printf("LFR_BP2_F0[i*30+2] for cross34_im (%16.8e) : %u\n",cross_im, LFR_BP2_F0[i*30+2]); - // S35 - aux = sqrt(compressed_spectral_matrix_f0[i*30+18]*compressed_spectral_matrix_f0[i*30+28]); - cross_re = compressed_spectral_matrix_f0[i*30+22] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+23] / aux; - LFR_BP2_F0[i*30+11] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+1] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+11] for cross35_re (%16.8e) : %u\n",cross_re, LFR_BP2_F0[i*30+11]); - printf("LFR_BP2_F0[i*30+1] for cross35_im (%16.8e) : %u\n",cross_im, LFR_BP2_F0[i*30+1]); - // S45 - aux = sqrt(compressed_spectral_matrix_f0[i*30+24]*compressed_spectral_matrix_f0[i*30+28]); - cross_re = compressed_spectral_matrix_f0[i*30+26] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+27] / aux; - LFR_BP2_F0[i*30+10] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+0] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+10] for cross45_re (%16.8e) : %u\n",cross_re, LFR_BP2_F0[i*30+10]); - printf("LFR_BP2_F0[i*30+0] for cross45_im (%16.8e) : %u\n",cross_im, LFR_BP2_F0[i*30+0]); - - //============================================== - // BP2 auto correlations == PA_LFR_SC_BP2_AUTO_F0 == 5*16 bits = 5*[6 bits (exponent) + 10 bits (significand)] - // == PA_LFR_SC_BP2_AUTO_A0_F0 == 16 bits - // == PA_LFR_SC_BP2_AUTO_A1_F0 == 16 bits - // == PA_LFR_SC_BP2_AUTO_A2_F0 == 16 bits - // == PA_LFR_SC_BP2_AUTO_A3_F0 == 16 bits - // == PA_LFR_SC_BP2_AUTO_A4_F0 == 16 bits - // S11 - significand = frexpf(compressed_spectral_matrix_f0[i*30], &exponent); // 0.5 <= significand < 1 - // S11 = significand * 2^exponent - printf("S11 : %16.8e\n",compressed_spectral_matrix_f0[i*30]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+28]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - //printf("size of autocor : %d\n",sizeof(autocor) ); - //printf("size of tmp_u_short_int : %d\n",sizeof(tmp_u_short_int) ); - printf("autocor for S11 significand : %u\n",autocor ); - printf("tmp_u_char for S11 exponent : %u\n",tmp_u_short_int ); - printf("*pt_u_short_int for S11 significand + exponent: %u or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+29] : %u or %x\n",LFR_BP2_F0[i*30+29], LFR_BP2_F0[i*30+29]); - printf("LFR_BP2_F0[i*30+28] : %u or %x\n",LFR_BP2_F0[i*30+28], LFR_BP2_F0[i*30+28]); - // S22 - significand = frexpf(compressed_spectral_matrix_f0[i*30+10], &exponent); // 0.5 <= significand < 1 - // S22 = significand * 2^exponent - printf("S22 : %16.8e\n",compressed_spectral_matrix_f0[i*30+10]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+26]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - printf("autocor for S22 significand : %d\n",autocor ); - printf("tmp_u_char for S22 exponent : %d\n",tmp_u_short_int ); - printf("*pt_u_short_int for S22 significand + exponent: %d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+27] : %d or %x\n",LFR_BP2_F0[i*30+27], LFR_BP2_F0[i*30+27]); - printf("LFR_BP2_F0[i*30+26] : %d or %x\n",LFR_BP2_F0[i*30+26], LFR_BP2_F0[i*30+26]); - // S33 - significand = frexpf(compressed_spectral_matrix_f0[i*30+18], &exponent); // 0.5 <= significand < 1 - // S33 = significand * 2^exponent - printf("S33 : %16.8e\n",compressed_spectral_matrix_f0[i*30+18]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+24]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - printf("autocor for S33 significand : %d\n",autocor ); - printf("tmp_u_char for S33 exponent : %d\n",tmp_u_short_int ); - printf("*pt_u_short_int for S33 significand + exponent: %d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+25] : %d or %x\n",LFR_BP2_F0[i*30+25], LFR_BP2_F0[i*30+25]); - printf("LFR_BP2_F0[i*30+24] : %d or %x\n",LFR_BP2_F0[i*30+24], LFR_BP2_F0[i*30+24]); - // S44 - significand = frexpf(compressed_spectral_matrix_f0[i*30+24], &exponent); // 0.5 <= significand < 1 - // S44 = significand * 2^exponent - printf("S44 : %16.8e\n",compressed_spectral_matrix_f0[i*30+24]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+22]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - printf("autocor for S44 significand : %d\n",autocor ); - printf("tmp_u_char for S44 exponent : %d\n",tmp_u_short_int ); - printf("*pt_u_short_int for S44 significand + exponent: %d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+23] : %d or %x\n",LFR_BP2_F0[i*30+23], LFR_BP2_F0[i*30+23]); - printf("LFR_BP2_F0[i*30+22] : %d or %x\n",LFR_BP2_F0[i*30+22], LFR_BP2_F0[i*30+22]); - // S55 - significand = frexpf(compressed_spectral_matrix_f0[i*30+28], &exponent); // 0.5 <= significand < 1 - // S55 = significand * 2^exponent - printf("S55 : %16.8e\n",compressed_spectral_matrix_f0[i*30+28]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+20]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - printf("autocor for S55 significand : %d\n",autocor ); - printf("tmp_u_char for S55 exponent : %d\n",tmp_u_short_int ); - printf("*pt_u_short_int for S55 significand + exponent: %d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+21] : %d or %x\n",LFR_BP2_F0[i*30+21], LFR_BP2_F0[i*30+21]); - printf("LFR_BP2_F0[i*30+20] : %d or %x\n",LFR_BP2_F0[i*30+20], LFR_BP2_F0[i*30+20]); - - } -} - diff --git a/basic_parameters_1_ICD_issue1rev6_V1.h b/basic_parameters_1_ICD_issue1rev6_V1.h deleted file mode 100644 --- a/basic_parameters_1_ICD_issue1rev6_V1.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef BASIC_PARAMETERS_H_INCLUDED -#define BASIC_PARAMETERS_H_INCLUDED - -#define LPP_SPECTRAL_MATRIX_CTRL 0x80000700 -#define LPP_SPECTRAL_MATRIX_1 0x80000704 -#define LPP_SPECTRAL_MATRIX_2 0x80000708 - -#define NB_BINS_SPECTRAL_MATRIX 128 -#define NB_VALUES_PER_SPECTRAL_MATRIX 30 -#define TOTAL_SIZE_SPECTRAL_MATRIX NB_BINS_SPECTRAL_MATRIX * NB_VALUES_PER_SPECTRAL_MATRIX -#define NB_BINS_COMPRESSED_MATRIX_f0 2 -#define SIZE_COMPRESSED_SPECTRAL_MATRIX_f1 13 -#define SIZE_COMPRESSED_SPECTRAL_MATRIX_f2 12 -#define TOTAL_SIZE_COMPRESSED_MATRIX_f0 NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_SPECTRAL_MATRIX -#define NB_AVERAGE_NORMAL_f0 4 - -volatile int spectral_matrix_f0_a[TOTAL_SIZE_SPECTRAL_MATRIX]; -volatile int spectral_matrix_f0_b[TOTAL_SIZE_SPECTRAL_MATRIX]; -int averaged_spectral_matrix_f0[TOTAL_SIZE_SPECTRAL_MATRIX]; - -float compressed_spectral_matrix_f0[TOTAL_SIZE_COMPRESSED_MATRIX_f0]; - -unsigned char LFR_BP1_F0[NB_BINS_COMPRESSED_MATRIX_f0*9]; -unsigned char LFR_BP2_F0[NB_BINS_COMPRESSED_MATRIX_f0*30]; - -void BP1_set(); -void BP2_set(); - -#endif // BASIC_PARAMETERS_H_INCLUDED diff --git a/basic_parameters_1_ICD_issue1rev6_V2.c b/basic_parameters_1_ICD_issue1rev6_V2.c deleted file mode 100644 --- a/basic_parameters_1_ICD_issue1rev6_V2.c +++ /dev/null @@ -1,756 +0,0 @@ -#include "basic_parameters_1_ICD_issue1rev6.h" -#include -#include - -float k44_pe = 1; -float k55_pe = 1; -float k45_pe_re = 1; -float k45_pe_im = 1; - -float k14_sx_re = 1; -float k14_sx_im = 1; -float k15_sx_re = 1; -float k15_sx_im = 1; -float k24_sx_re = 1; -float k24_sx_im = 1; -float k25_sx_re = 1; -float k25_sx_im = 1; -float k34_sx_re = 1; -float k34_sx_im = 1; -float k35_sx_re = 1; -float k35_sx_im = 1; - -float k24_ny_re = 1; -float k24_ny_im = 1; -float k25_ny_re = 1; -float k25_ny_im = 1; -float k34_ny_re = 1; -float k34_ny_im = 1; -float k35_ny_re = 1; -float k35_ny_im = 1; - -float k24_nz_re = 1; -float k24_nz_im = 1; -float k25_nz_re = 1; -float k25_nz_im = 1; -float k34_nz_re = 1; -float k34_nz_im = 1; -float k35_nz_re = 1; -float k35_nz_im = 1; - -float alpha_M = 45 * (3.1415927/180); - -void BP1_set(){ - int i, j, exponent; - float PSDB, PSDE, tmp, NVEC_V0, NVEC_V1, NVEC_V2, aux, tr_SB_SB, - e_cross_b_re, e_cross_b_im, - n_cross_e_scal_b_re, n_cross_e_scal_b_im, - ny, nz, bx_bx_star, vphi, - significand; - signed char nbitexp, nbitsig, expmin, expmax; // 8 bits - short int rangesig; // 16 bits - unsigned short int psd, tmp_u_short_int; // 16 bits - unsigned short int *pt_u_short_int; // pointer on unsigned 16-bit words - unsigned char tmp_u_char; // 8 bits - unsigned char *pt_u_char; // pointer on unsigned 8-bit bytes - - unsigned char toto_u_char; - unsigned char *pt_toto_u_char; - signed char toto_s_char; - float toto_f; - - FILE *infile; - infile = fopen("sm_test1.dat", "rb"); // open explicitely a binary file !!! ... - if(infile == NULL) { - printf("Hello I cannot open the file!\n"); - return 0; - } - (void) fread(compressed_spectral_matrix_f0, sizeof(compressed_spectral_matrix_f0), 1, infile); - (void) fclose(infile); - //printf("size of compressed_spectral_matrix_f0 : %d\n", sizeof(compressed_spectral_matrix_f0)); - printf("compressed_spectral_matrix_f0 : \n"); - for (i = 0; i < 15; i++) { - printf("Element number %.2d (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", i+1, 2*i, 2*i+1, - compressed_spectral_matrix_f0[2*i], - compressed_spectral_matrix_f0[2*i+1]); - } - - printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0); - printf("BP1 : \n"); - - // initialization for managing the exponents of the floating point data: - nbitexp = 5; // number of bits for the exponent - expmax = 30; // maximum value of the exponent - expmin = expmax - (1 << nbitexp) + 1; // accordingly the minimum exponent value - printf("nbitexp : %d, expmax : %d, expmin : %d\n", nbitexp, expmax, expmin); - // for floating point data to be recorded on 12-bit words: - nbitsig = 12 - nbitexp; // number of bits for the significand - rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1 - printf("nbitsig : %d, rangesig : %d\n", nbitsig, rangesig); - - for(i=0; i<1; i++){ - //============================================== - // BP1 PSDB == PA_LFR_SC_BP1_PB_F0 == 12 bits = 5 bits (exponent) + 7 bits (significand) - PSDB = compressed_spectral_matrix_f0[i*30] // S11 - + compressed_spectral_matrix_f0[i*30+10] // S22 - + compressed_spectral_matrix_f0[i*30+18]; // S33 - - significand = frexpf(PSDB/3, &exponent); // 0.5 <= significand < 1 - // PSDB/3 = significand * 2^exponent - // the division by 3 is to ensure that max value <= 2^30 - - printf("PSDB / 3 : %16.8e\n",PSDB/3); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - psd = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP1_F0[i*9+7]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = psd | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - printf("psd for PSDB significand : %d\n",psd); - printf("tmp_u_short_int for PSDB exponent : %d\n",tmp_u_short_int); - printf("*pt_u_short_int for PSDB significand + exponent: %.3d or %.4x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP1_F0[i*9+8] : %.3d or %.2x\n",LFR_BP1_F0[i*9+8], LFR_BP1_F0[i*9+8]); - printf("LFR_BP1_F0[i*9+7] : %.3d or %.2x\n",LFR_BP1_F0[i*9+7], LFR_BP1_F0[i*9+7]); - - //toto_f = 32768*32768; // max value ? - //toto_f = 1./3; // min value ? - //significand = frexp(toto_f, &exponent); - //printf("toto_f : %16.8e\n",toto_f); - //printf("significand : %16.8e\n",significand); - //printf("exponent : %d\n" ,exponent); - - //============================================== - // BP1 PSDE == PA_LFR_SC_BP1_PE_F0 == 12 bits = 5 bits (exponent) + 7 bits (significand) - PSDE = compressed_spectral_matrix_f0[i*30+24] * k44_pe // S44 - + compressed_spectral_matrix_f0[i*30+28] * k55_pe // S55 - + compressed_spectral_matrix_f0[i*30+26] * k45_pe_re // S45 Re - - compressed_spectral_matrix_f0[i*30+27] * k45_pe_im; // S45 Im - - significand = frexpf(PSDE/2, &exponent); // 0.5 <= significand < 1 - // PSDE/2 = significand * 2^exponent - // the division by 2 is to ensure that max value <= 2^30 - // should be reconsidered by taking into account the k-coefficients ... - - printf("PSDE / 2 : %16.8e\n",PSDE/2); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - psd = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP1_F0[i*9+5]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = psd | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - printf("psd for PSDE significand : %d\n",psd); - printf("tmp_u_short_int for PSDE exponent : %d\n",tmp_u_short_int); - printf("*pt_u_short_int for PSDE significand + exponent: %.3d or %.4x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP1_F0[i*9+6] : %.3d or %.2x\n",LFR_BP1_F0[i*9+6], LFR_BP1_F0[i*9+6]); - printf("LFR_BP1_F0[i*9+5] : %.3d or %.2x\n",LFR_BP1_F0[i*9+5], LFR_BP1_F0[i*9+5]); - - //============================================================================== - // BP1 normal wave vector == PA_LFR_SC_BP1_NVEC_V0_F0 == 8 bits - // == PA_LFR_SC_BP1_NVEC_V1_F0 == 8 bits - // == PA_LFR_SC_BP1_NVEC_V2_F0 == 1 sign bit - tmp = sqrt( compressed_spectral_matrix_f0[i*30+3] *compressed_spectral_matrix_f0[i*30+3] //Im S12 - +compressed_spectral_matrix_f0[i*30+5] *compressed_spectral_matrix_f0[i*30+5] //Im S13 - +compressed_spectral_matrix_f0[i*30+13]*compressed_spectral_matrix_f0[i*30+13] //Im S23 - ); - NVEC_V0 = compressed_spectral_matrix_f0[i*30+13]/ tmp; // S23 Im => n1 - NVEC_V1 = -compressed_spectral_matrix_f0[i*30+5] / tmp; // S13 Im => n2 - NVEC_V2 = compressed_spectral_matrix_f0[i*30+3] / tmp; // S12 Im => n3 - - printf("NVEC_V0 : %16.8e\n",NVEC_V0); - printf("NVEC_V1 : %16.8e\n",NVEC_V1); - printf("NVEC_V2 : %16.8e\n",NVEC_V2); - - LFR_BP1_F0[i*9+4] = (unsigned char) (NVEC_V0*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP1_F0[i*9+3] = (unsigned char) (NVEC_V1*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - pt_u_char = (unsigned char*) &NVEC_V2; // affect an unsigned char pointer with the adress of NVEC_V2 - LFR_BP1_F0[i*9+2] = pt_u_char[3] & 0x80; // extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 4th octet) - // record it at the 8th bit position (from the right to the left) of LFR_BP1_F0[i*9+2] - - printf("LFR_BP1_F0[i*9+4] for NVEC_V0 : %u\n",LFR_BP1_F0[i*9+4]); - printf("LFR_BP1_F0[i*9+3] for NVEC_V1 : %u\n",LFR_BP1_F0[i*9+3]); - printf("LFR_BP1_F0[i*9+2] for NVEC_V2 : %u\n",LFR_BP1_F0[i*9+2]); - - //toto_f = 128.9999 ; - //toto_s_char = (signed char) toto_f; - //printf("toto_s_char : %d\n",toto_s_char); - - //toto_f = 255.999 ; - //toto_u_char = (unsigned char) (toto_f); - //printf("toto_u_char : %d\n",toto_u_char); - - //toto_f = -1110.999 ; - //pt_toto_u_char = (unsigned char*) &toto_f; - //printf("pt_toto_u_char : %u\n", pt_toto_u_char[3] & 0x80); - - //======================================================= - // BP1 ellipticity == PA_LFR_SC_BP1_ELLIP_F0 == 4 bits - aux = 2*tmp / PSDB; // compute the ellipticity - - printf("ellipticity : %16.8e\n",aux); - - tmp_u_char = (unsigned char) (aux*15 + 0.5); // shift and cast into a 8-bit unsigned char with rounding - // where just the first 4 bits are used (0, ..., 15) - LFR_BP1_F0[i*9+2] = LFR_BP1_F0[i*9+2] | (tmp_u_char << 3); // put these 4 bits next to the right place - // of the sign bit of NVEC_V2 (recorded - // previously in LFR_BP1_F0[i*9+2]) - - printf("tmp_u_char for ellipticity : %u\n",tmp_u_char); - printf("LFR_BP1_F0[i*9+2] for NVEC_V2 + ellipticity : %u\n",LFR_BP1_F0[i*9+2]); - - //============================================================== - // BP1 degree of polarization == PA_LFR_SC_BP1_DOP_F0 == 3 bits - tr_SB_SB = compressed_spectral_matrix_f0[i*30] *compressed_spectral_matrix_f0[i*30] - + compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+10] - + compressed_spectral_matrix_f0[i*30+18]*compressed_spectral_matrix_f0[i*30+18] - + 2 * compressed_spectral_matrix_f0[i*30+2] *compressed_spectral_matrix_f0[i*30+2] - + 2 * compressed_spectral_matrix_f0[i*30+3] *compressed_spectral_matrix_f0[i*30+3] - + 2 * compressed_spectral_matrix_f0[i*30+4] *compressed_spectral_matrix_f0[i*30+4] - + 2 * compressed_spectral_matrix_f0[i*30+5] *compressed_spectral_matrix_f0[i*30+5] - + 2 * compressed_spectral_matrix_f0[i*30+12]*compressed_spectral_matrix_f0[i*30+12] - + 2 * compressed_spectral_matrix_f0[i*30+13]*compressed_spectral_matrix_f0[i*30+13]; - aux = PSDB*PSDB; - tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); // compute the degree of polarisation - - printf("DOP : %16.8e\n",tmp); - - tmp_u_char = (unsigned char) (tmp*7 + 0.5);// shift and cast into a 8-bit unsigned char with rounding - // where just the first 3 bits are used (0, ..., 7) - LFR_BP1_F0[i*9+2] = LFR_BP1_F0[i*9+2] | tmp_u_char; // record these 3 bits at the 3 first bit positions - // (from the right to the left) of LFR_BP1_F0[i*9+2] - - printf("tmp_u_char for DOP : %u\n",tmp_u_char); - printf("LFR_BP1_F0[i*9+2] for NVEC_V2 + ellipticity + DOP : %u\n",LFR_BP1_F0[i*9+2]); - - //======================================================================================= - // BP1 X_SO-component of the Poynting flux == PA_LFR_SC_BP1_SX_F0 == 8 (+ 2) bits - // = 5 bits (exponent) + 3 bits (significand) - // + 1 sign bit + 1 argument bit (two sectors) - e_cross_b_re = compressed_spectral_matrix_f0[i*30+20]*k34_sx_re //S34 Re - + compressed_spectral_matrix_f0[i*30+22]*k35_sx_re //S35 Re - + compressed_spectral_matrix_f0[i*30+6] *k14_sx_re //S14 Re - + compressed_spectral_matrix_f0[i*30+8] *k15_sx_re //S15 Re - + compressed_spectral_matrix_f0[i*30+14]*k24_sx_re //S24 Re - + compressed_spectral_matrix_f0[i*30+16]*k25_sx_re //S25 Re - + compressed_spectral_matrix_f0[i*30+21]*k34_sx_im //S34 Im - + compressed_spectral_matrix_f0[i*30+23]*k35_sx_im //S35 Im - + compressed_spectral_matrix_f0[i*30+7] *k14_sx_im //S14 Im - + compressed_spectral_matrix_f0[i*30+9] *k15_sx_im //S15 Im - + compressed_spectral_matrix_f0[i*30+15]*k24_sx_im //S24 Im - + compressed_spectral_matrix_f0[i*30+17]*k25_sx_im; //S25 Im - // Im(S_ji) = -Im(S_ij) - // k_ji = k_ij - e_cross_b_im = compressed_spectral_matrix_f0[i*30+20]*k34_sx_im //S34 Re - + compressed_spectral_matrix_f0[i*30+22]*k35_sx_im //S35 Re - + compressed_spectral_matrix_f0[i*30+6] *k14_sx_im //S14 Re - + compressed_spectral_matrix_f0[i*30+8] *k15_sx_im //S15 Re - + compressed_spectral_matrix_f0[i*30+14]*k24_sx_im //S24 Re - + compressed_spectral_matrix_f0[i*30+16]*k25_sx_im //S25 Re - - compressed_spectral_matrix_f0[i*30+21]*k34_sx_re //S34 Im - - compressed_spectral_matrix_f0[i*30+23]*k35_sx_re //S35 Im - - compressed_spectral_matrix_f0[i*30+7] *k14_sx_re //S14 Im - - compressed_spectral_matrix_f0[i*30+9] *k15_sx_re //S15 Im - - compressed_spectral_matrix_f0[i*30+15]*k24_sx_re //S24 Im - - compressed_spectral_matrix_f0[i*30+17]*k25_sx_re; //S25 Im - - printf("ReaSX / 2 : %16.8e\n",e_cross_b_re/2); - - pt_u_char = (unsigned char*) &e_cross_b_re; // Affect an unsigned char pointer with the adress of e_cross_b_re - LFR_BP1_F0[i*9+8] = LFR_BP1_F0[i*9+8] | (pt_u_char[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet) - // Record it at the 8th bit position (from the right to the left) - // of LFR_BP1_F0[i*9+8] - pt_u_char[3] = (pt_u_char[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX| - - significand = frexpf(e_cross_b_re/2, &exponent);// 0.5 <= significand < 1 - // ReaSX/2 = significand * 2^exponent - // The division by 2 is to ensure that max value <= 2^30 (rough estimate) - // Should be reconsidered by taking into account the k-coefficients ... - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - printf("|ReaSX| / 2 : %16.8e\n",e_cross_b_re/2); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - LFR_BP1_F0[i*9+1] = (unsigned char) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit unsigned char with rounding - // where just the first 3 bits are used (0, ..., 7) - tmp_u_char = (unsigned char) (exponent-expmin); // Shift and cast into a 8-bit unsigned char where - // just the first 5 bits are used (0, ..., 2^5-1) - printf("LFR_BP1_F0[i*9+1] for ReaSX significand : %u\n",LFR_BP1_F0[i*9+1]); - printf("tmp_u_char for ReaSX exponent : %d\n",tmp_u_char); - LFR_BP1_F0[i*9+1] = LFR_BP1_F0[i*9+1] | (tmp_u_char << 3); // shift these 5 bits to the left before logical addition - // with LFR_BP1_F0[i*9+1] - printf("LFR_BP1_F0[i*9+1] for ReaSX exponent + significand : %u\n",LFR_BP1_F0[i*9+1]); - printf("LFR_BP1_F0[i*9+8] for ReaSX sign + PSDB 'exponent' : %u\n",LFR_BP1_F0[i*9+8]); - - printf("ImaSX / 2 : %16.8e\n",e_cross_b_im/2); - - pt_u_char = (unsigned char*) &e_cross_b_im; // Affect an unsigned char pointer with the adress of e_cross_b_im - pt_u_char[3] = pt_u_char[3] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX| - tmp_u_char = (e_cross_b_im > e_cross_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect - // an unsigned 8-bit char with 01000000; otherwise with null. - LFR_BP1_F0[i*9+8] = LFR_BP1_F0[i*9+8] | tmp_u_char; // Record it as a sign bit at the 7th bit position (from the right - // to the left) of LFR_BP1_F0[i*9+7], by simple logical addition. - - printf("|ImaSX| / 2 : %16.8e\n",e_cross_b_im/2); - printf("ArgSX sign : %u\n",tmp_u_char); - printf("LFR_BP1_F0[i*9+8] for ReaSX & ArgSX signs + PSDB 'exponent' : %u\n",LFR_BP1_F0[i*9+8]); - - //====================================================================== - // BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 8 (+ 2) bits - // = 5 bits (exponent) + 3 bits (significand) - // + 1 sign bit + 1 argument bit (two sectors) - ny = sin(alpha_M)*NVEC_V1 + cos(alpha_M)*NVEC_V2; - nz = NVEC_V0; - bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spectral_matrix_f0[i*30+10] // S22 Re - + sin(alpha_M)*sin(alpha_M)*compressed_spectral_matrix_f0[i*30+18] // S33 Re - - 2*sin(alpha_M)*cos(alpha_M)*compressed_spectral_matrix_f0[i*30+12]; // S23 Re - - n_cross_e_scal_b_re = ny * (compressed_spectral_matrix_f0[i*30+14]*k24_ny_re //S24 Re - +compressed_spectral_matrix_f0[i*30+16]*k25_ny_re //S25 Re - +compressed_spectral_matrix_f0[i*30+20]*k34_ny_re //S34 Re - +compressed_spectral_matrix_f0[i*30+22]*k35_ny_re //S35 Re - +compressed_spectral_matrix_f0[i*30+15]*k24_ny_im //S24 Im - +compressed_spectral_matrix_f0[i*30+17]*k25_ny_im //S25 Im - +compressed_spectral_matrix_f0[i*30+21]*k34_ny_im //S34 Im - +compressed_spectral_matrix_f0[i*30+23]*k35_ny_im) //S35 Im - + nz * (compressed_spectral_matrix_f0[i*30+14]*k24_nz_re //S24 Re - +compressed_spectral_matrix_f0[i*30+16]*k25_nz_re //S25 Re - +compressed_spectral_matrix_f0[i*30+20]*k34_nz_re //S34 Re - +compressed_spectral_matrix_f0[i*30+22]*k35_nz_re //S35 Re - +compressed_spectral_matrix_f0[i*30+15]*k24_nz_im //S24 Im - +compressed_spectral_matrix_f0[i*30+17]*k25_nz_im //S25 Im - +compressed_spectral_matrix_f0[i*30+21]*k34_nz_im //S34 Im - +compressed_spectral_matrix_f0[i*30+23]*k35_nz_im);//S35 Im - // Im(S_ji) = -Im(S_ij) - // k_ji = k_ij - n_cross_e_scal_b_im = ny * (compressed_spectral_matrix_f0[i*30+14]*k24_ny_im //S24 Re - +compressed_spectral_matrix_f0[i*30+16]*k25_ny_im //S25 Re - +compressed_spectral_matrix_f0[i*30+20]*k34_ny_im //S34 Re - +compressed_spectral_matrix_f0[i*30+22]*k35_ny_im //S35 Re - -compressed_spectral_matrix_f0[i*30+15]*k24_ny_re //S24 Im - -compressed_spectral_matrix_f0[i*30+17]*k25_ny_re //S25 Im - -compressed_spectral_matrix_f0[i*30+21]*k34_ny_re //S34 Im - -compressed_spectral_matrix_f0[i*30+23]*k35_ny_re) //S35 Im - + nz * (compressed_spectral_matrix_f0[i*30+14]*k24_nz_im //S24 Re - +compressed_spectral_matrix_f0[i*30+16]*k25_nz_im //S25 Re - +compressed_spectral_matrix_f0[i*30+20]*k34_nz_im //S34 Re - +compressed_spectral_matrix_f0[i*30+22]*k35_nz_im //S35 Re - -compressed_spectral_matrix_f0[i*30+15]*k24_nz_re //S24 Im - -compressed_spectral_matrix_f0[i*30+17]*k25_nz_re //S25 Im - -compressed_spectral_matrix_f0[i*30+21]*k34_nz_re //S34 Im - -compressed_spectral_matrix_f0[i*30+23]*k35_nz_re);//S35 Im - - printf("n_cross_e_scal_b_re : %16.8e\n",n_cross_e_scal_b_re); - printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im); - // vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re) - pt_u_char = (unsigned char*) &n_cross_e_scal_b_re; // Affect an unsigned char pointer with the adress of n_cross_e_scal_b_re - LFR_BP1_F0[i*9+7] = LFR_BP1_F0[i*9+7] | (pt_u_char[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet) - // Record it at the 8th bit position (from the right to the left) - // of LFR_BP1_F0[i*9+7] - pt_u_char[3] = (pt_u_char[3] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re| - vphi = n_cross_e_scal_b_re / bx_bx_star; // Compute |VPHI| - - significand = frexpf(vphi/2, &exponent); // 0.5 <= significand < 1 - // vphi/2 = significand * 2^exponent - // The division by 2 is to ensure that max value <= 2^30 (rough estimate) - // Should be reconsidered by taking into account the k-coefficients ... - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - printf("|VPHI| / 2 : %16.8e\n",vphi/2); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - LFR_BP1_F0[i*9+0] = (unsigned char) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit unsigned char with rounding - // where just the first 3 bits are used (0, ..., 7) - tmp_u_char = (unsigned char) (exponent-expmin); // Shift and cast into a 8-bit unsigned char where - // just the first 5 bits are used (0, ..., 2^5-1) - printf("LFR_BP1_F0[i*9+0] for VPHI significand : %u\n",LFR_BP1_F0[i*9+0]); - printf("tmp_u_char for VPHI exponent : %d\n",tmp_u_char); - LFR_BP1_F0[i*9+0] = LFR_BP1_F0[i*9+0] | (tmp_u_char << 3); // shift these 5 bits to the left before logical addition - // with LFR_BP1_F0[i*9+0] - printf("LFR_BP1_F0[i*9+0] for VPHI exponent + significand : %u\n",LFR_BP1_F0[i*9+0]); - printf("LFR_BP1_F0[i*9+6] for VPHI sign + PSDE 'exponent' : %u\n",LFR_BP1_F0[i*9+6]); - - pt_u_char = (unsigned char*) &n_cross_e_scal_b_im; // Affect an unsigned char pointer with the adress of n_cross_e_scal_b_im - pt_u_char[3] = pt_u_char[3] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaSX| - tmp_u_char = (n_cross_e_scal_b_im > n_cross_e_scal_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect - // an unsigned 8-bit char with 01000000; otherwise with null. - LFR_BP1_F0[i*9+6] = LFR_BP1_F0[i*9+6] | tmp_u_char; // Record it as a sign bit at the 7th bit position (from the right - // to the left) of LFR_BP1_F0[i*9+6], by simple logical addition. - - printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im); - printf("|n_cross_e_scal_b_im|/bx_bx_star/2: %16.8e\n",n_cross_e_scal_b_im/bx_bx_star/2); - printf("ArgNEBX sign : %u\n",tmp_u_char); - printf("LFR_BP1_F0[i*9+6] for VPHI & ArgNEBX signs + PSDE 'exponent' : %u\n",LFR_BP1_F0[i*9+6]); - - } -} - -void BP2_set(){ - int i, exponent; - float aux, significand, cross_re, cross_im; - signed char nbitexp, nbitsig, expmin, expmax; // 8 bits - short int rangesig; // 16 bits - unsigned short int autocor, tmp_u_short_int; // 16 bits - unsigned short int *pt_u_short_int; // pointer on unsigned 16-bit words - - printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0); - printf("BP2 : \n"); - - // For floating point data to be recorded on 16-bit words : - nbitexp = 6; // number of bits for the exponent - nbitsig = 16 - nbitexp; // number of bits for the significand - rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1 - printf("nbitexp : %d, nbitsig : %d, rangesig : %d\n", nbitexp, nbitsig, rangesig); - expmax = 32; - expmin = expmax - (1 << nbitexp) + 1; - printf("expmin : %d, expmax : %d\n", expmin, expmax); - - for(i = 0; i<1; i++){ - //============================================== - // BP2 normalized cross correlations == PA_LFR_SC_BP2_CROSS_F0 == 10 * (8+8) bits - // == PA_LFR_SC_BP2_CROSS_RE_0_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_0_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_1_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_1_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_2_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_2_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_3_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_3_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_4_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_4_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_5_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_5_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_6_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_6_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_7_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_7_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_8_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_8_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_RE_9_F0 == 8 bits - // == PA_LFR_SC_BP2_CROSS_IM_9_F0 == 8 bits - // S12 - aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+10]); - cross_re = compressed_spectral_matrix_f0[i*30+2] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+3] / aux; - LFR_BP2_F0[i*30+19] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+9] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+19] for cross12_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+19]); - printf("LFR_BP2_F0[i*30+9] for cross12_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+9]); - - // S13 - aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+18]); - cross_re = compressed_spectral_matrix_f0[i*30+4] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+5] / aux; - LFR_BP2_F0[i*30+18] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+8] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+18] for cross13_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+18]); - printf("LFR_BP2_F0[i*30+8] for cross13_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+8]); - - // S14 - aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+24]); - cross_re = compressed_spectral_matrix_f0[i*30+6] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+7] / aux; - LFR_BP2_F0[i*30+17] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+7] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+17] for cross14_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+17]); - printf("LFR_BP2_F0[i*30+7] for cross14_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+7]); - // S15 - aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+28]); - cross_re = compressed_spectral_matrix_f0[i*30+8] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+9] / aux; - LFR_BP2_F0[i*30+16] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+6] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+16] for cross15_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+16]); - printf("LFR_BP2_F0[i*30+6] for cross15_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+6]); - // S23 - aux = sqrt(compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+18]); - cross_re = compressed_spectral_matrix_f0[i*30+12] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+13] / aux; - LFR_BP2_F0[i*30+15] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+5] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+15] for cross23_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+15]); - printf("LFR_BP2_F0[i*30+5] for cross23_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+5]); - // S24 - aux = sqrt(compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+24]); - cross_re = compressed_spectral_matrix_f0[i*30+14] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+15] / aux; - LFR_BP2_F0[i*30+14] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+4] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+14] for cross24_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+14]); - printf("LFR_BP2_F0[i*30+4] for cross24_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+4]); - // S25 - aux = sqrt(compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+28]); - cross_re = compressed_spectral_matrix_f0[i*30+16] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+17] / aux; - LFR_BP2_F0[i*30+13] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+3] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+13] for cross25_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+13]); - printf("LFR_BP2_F0[i*30+3] for cross25_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+3]); - // S34 - aux = sqrt(compressed_spectral_matrix_f0[i*30+18]*compressed_spectral_matrix_f0[i*30+24]); - cross_re = compressed_spectral_matrix_f0[i*30+20] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+21] / aux; - LFR_BP2_F0[i*30+12] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+2] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+12] for cross34_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+12]); - printf("LFR_BP2_F0[i*30+2] for cross34_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+2]); - // S35 - aux = sqrt(compressed_spectral_matrix_f0[i*30+18]*compressed_spectral_matrix_f0[i*30+28]); - cross_re = compressed_spectral_matrix_f0[i*30+22] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+23] / aux; - LFR_BP2_F0[i*30+11] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+1] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+11] for cross35_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+11]); - printf("LFR_BP2_F0[i*30+1] for cross35_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+1]); - // S45 - aux = sqrt(compressed_spectral_matrix_f0[i*30+24]*compressed_spectral_matrix_f0[i*30+28]); - cross_re = compressed_spectral_matrix_f0[i*30+26] / aux; - cross_im = compressed_spectral_matrix_f0[i*30+27] / aux; - LFR_BP2_F0[i*30+10] = (unsigned char) (cross_re*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP2_F0[i*30+0] = (unsigned char) (cross_im*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - printf("LFR_BP2_F0[i*30+10] for cross45_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+10]); - printf("LFR_BP2_F0[i*30+0] for cross45_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+0]); - - //============================================== - // BP2 auto correlations == PA_LFR_SC_BP2_AUTO_F0 == 5*16 bits = 5*[6 bits (exponent) + 10 bits (significand)] - // == PA_LFR_SC_BP2_AUTO_A0_F0 == 16 bits - // == PA_LFR_SC_BP2_AUTO_A1_F0 == 16 bits - // == PA_LFR_SC_BP2_AUTO_A2_F0 == 16 bits - // == PA_LFR_SC_BP2_AUTO_A3_F0 == 16 bits - // == PA_LFR_SC_BP2_AUTO_A4_F0 == 16 bits - // S11 - significand = frexpf(compressed_spectral_matrix_f0[i*30], &exponent); // 0.5 <= significand < 1 - // S11 = significand * 2^exponent - printf("S11 : %16.8e\n",compressed_spectral_matrix_f0[i*30]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+28]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - //printf("size of autocor : %d\n",sizeof(autocor) ); - //printf("size of tmp_u_short_int : %d\n",sizeof(tmp_u_short_int) ); - printf("autocor for S11 significand : %u\n",autocor ); - printf("tmp_u_char for S11 exponent : %u\n",tmp_u_short_int ); - printf("*pt_u_short_int for S11 significand + exponent: %u or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+29] : %u or %x\n",LFR_BP2_F0[i*30+29], LFR_BP2_F0[i*30+29]); - printf("LFR_BP2_F0[i*30+28] : %u or %x\n",LFR_BP2_F0[i*30+28], LFR_BP2_F0[i*30+28]); - // S22 - significand = frexpf(compressed_spectral_matrix_f0[i*30+10], &exponent); // 0.5 <= significand < 1 - // S22 = significand * 2^exponent - printf("S22 : %16.8e\n",compressed_spectral_matrix_f0[i*30+10]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+26]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - printf("autocor for S22 significand : %d\n",autocor ); - printf("tmp_u_char for S22 exponent : %d\n",tmp_u_short_int ); - printf("*pt_u_short_int for S22 significand + exponent: %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+27] : %.3d or %x\n",LFR_BP2_F0[i*30+27], LFR_BP2_F0[i*30+27]); - printf("LFR_BP2_F0[i*30+26] : %.3d or %x\n",LFR_BP2_F0[i*30+26], LFR_BP2_F0[i*30+26]); - // S33 - significand = frexpf(compressed_spectral_matrix_f0[i*30+18], &exponent); // 0.5 <= significand < 1 - // S33 = significand * 2^exponent - printf("S33 : %16.8e\n",compressed_spectral_matrix_f0[i*30+18]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+24]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - printf("autocor for S33 significand : %d\n",autocor ); - printf("tmp_u_char for S33 exponent : %d\n",tmp_u_short_int ); - printf("*pt_u_short_int for S33 significand + exponent: %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+25] : %.3d or %x\n",LFR_BP2_F0[i*30+25], LFR_BP2_F0[i*30+25]); - printf("LFR_BP2_F0[i*30+24] : %.3d or %x\n",LFR_BP2_F0[i*30+24], LFR_BP2_F0[i*30+24]); - // S44 - significand = frexpf(compressed_spectral_matrix_f0[i*30+24], &exponent); // 0.5 <= significand < 1 - // S44 = significand * 2^exponent - printf("S44 : %16.8e\n",compressed_spectral_matrix_f0[i*30+24]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+22]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - printf("autocor for S44 significand : %d\n",autocor ); - printf("tmp_u_char for S44 exponent : %d\n",tmp_u_short_int ); - printf("*pt_u_short_int for S44 significand + exponent: %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+23] : %.3d or %x\n",LFR_BP2_F0[i*30+23], LFR_BP2_F0[i*30+23]); - printf("LFR_BP2_F0[i*30+22] : %.3d or %x\n",LFR_BP2_F0[i*30+22], LFR_BP2_F0[i*30+22]); - // S55 - significand = frexpf(compressed_spectral_matrix_f0[i*30+28], &exponent); // 0.5 <= significand < 1 - // S55 = significand * 2^exponent - printf("S55 : %16.8e\n",compressed_spectral_matrix_f0[i*30+28]); - printf("significand : %16.8e\n",significand); - printf("exponent : %d\n" ,exponent); - - if (exponent < expmin) { // value should be >= 0.5 * 2^expmin - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1) - exponent = expmax; - significand = 1.0; // max value that can be recorded - } - if (significand == 0) {// in that case exponent == 0 too - exponent = expmin; - significand = 0.5; // min value that can be recorded - } - - autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // shift and cast into a 16-bit unsigned int with rounding - // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) - tmp_u_short_int = (unsigned short int) (exponent-expmin); // shift and cast into a 16-bit unsigned int - // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+20]; // affect an unsigned short int pointer with the - // adress where the 16-bit word result will be stored - *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // put the exponent bits (nbitexp) next to the - // left place of the significand bits (nbitsig), making - // the 16-bit word to be recorded, and record it using the pointer - printf("autocor for S55 significand : %d\n",autocor ); - printf("tmp_u_char for S55 exponent : %d\n",tmp_u_short_int ); - printf("*pt_u_short_int for S55 significand + exponent: %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2_F0[i*30+21] : %.3d or %x\n",LFR_BP2_F0[i*30+21], LFR_BP2_F0[i*30+21]); - printf("LFR_BP2_F0[i*30+20] : %.3d or %x\n",LFR_BP2_F0[i*30+20], LFR_BP2_F0[i*30+20]); - - } -} - diff --git a/basic_parameters_1_ICD_issue1rev6_V2.h b/basic_parameters_1_ICD_issue1rev6_V2.h deleted file mode 100644 --- a/basic_parameters_1_ICD_issue1rev6_V2.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef BASIC_PARAMETERS_H_INCLUDED -#define BASIC_PARAMETERS_H_INCLUDED - -#define LPP_SPECTRAL_MATRIX_CTRL 0x80000700 -#define LPP_SPECTRAL_MATRIX_1 0x80000704 -#define LPP_SPECTRAL_MATRIX_2 0x80000708 - -#define NB_BINS_SPECTRAL_MATRIX 128 -#define NB_VALUES_PER_SPECTRAL_MATRIX 30 -#define TOTAL_SIZE_SPECTRAL_MATRIX NB_BINS_SPECTRAL_MATRIX * NB_VALUES_PER_SPECTRAL_MATRIX -#define NB_BINS_COMPRESSED_MATRIX_f0 2 -#define SIZE_COMPRESSED_SPECTRAL_MATRIX_f1 13 -#define SIZE_COMPRESSED_SPECTRAL_MATRIX_f2 12 -#define TOTAL_SIZE_COMPRESSED_MATRIX_f0 NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_SPECTRAL_MATRIX -#define NB_AVERAGE_NORMAL_f0 4 - -volatile int spectral_matrix_f0_a[TOTAL_SIZE_SPECTRAL_MATRIX]; -volatile int spectral_matrix_f0_b[TOTAL_SIZE_SPECTRAL_MATRIX]; -int averaged_spectral_matrix_f0[TOTAL_SIZE_SPECTRAL_MATRIX]; - -float compressed_spectral_matrix_f0[TOTAL_SIZE_COMPRESSED_MATRIX_f0]; - -unsigned char LFR_BP1_F0[NB_BINS_COMPRESSED_MATRIX_f0*9]; -unsigned char LFR_BP2_F0[NB_BINS_COMPRESSED_MATRIX_f0*30]; - -void BP1_set(); -void BP2_set(); - -#endif // BASIC_PARAMETERS_H_INCLUDED diff --git a/file_utilities.c b/file_utilities.c --- a/file_utilities.c +++ b/file_utilities.c @@ -1,24 +1,54 @@ +// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) +// version 1: 31/07/2013 + #include -int lecture_file_sm(const char * fileName) +int lecture_file_sm(const char *fileName) { - unsigned int i; + // unsigned int i; FILE *infile; infile = fopen(fileName, "rb"); // open explicitely a binary file !!! ... if(infile == NULL) { - printf("Hello I cannot open the file!\n"); + printf("Hello I cannot open the file! \n"); return 0; } (void) fread(compressed_spectral_matrix_f0, sizeof(compressed_spectral_matrix_f0), 1, infile); (void) fclose(infile); - //printf("size of compressed_spectral_matrix_f0 : %d\n", sizeof(compressed_spectral_matrix_f0)); + printf("size of compressed_spectral_matrix_f0 : %d\n", sizeof(compressed_spectral_matrix_f0)); + printf("compressed_spectral_matrix_f0 : \n"); - for (i = 0; i < 15; i++) { - printf("Element number %.2d (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", i+1, 2*i, 2*i+1, - compressed_spectral_matrix_f0[2*i], - compressed_spectral_matrix_f0[2*i+1]); - } + + printf("Element %.2d (S11) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 1, 0, + compressed_spectral_matrix_f0[0], 0.); + printf("Element %.2d (S12) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 2, 1, 2, + compressed_spectral_matrix_f0[1], compressed_spectral_matrix_f0[2]); + printf("Element %.2d (S13) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 3, 3, 4, + compressed_spectral_matrix_f0[3], compressed_spectral_matrix_f0[4]); + printf("Element %.2d (S14) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 4, 5, 6, + compressed_spectral_matrix_f0[5], compressed_spectral_matrix_f0[6]); + printf("Element %.2d (S15) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 5, 7, 8, + compressed_spectral_matrix_f0[7], compressed_spectral_matrix_f0[8]); + printf("Element %.2d (S22) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 6, 9, + compressed_spectral_matrix_f0[9], 0.); + printf("Element %.2d (S23) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 7, 10, 11, + compressed_spectral_matrix_f0[10], compressed_spectral_matrix_f0[11]); + printf("Element %.2d (S24) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 8, 12, 13, + compressed_spectral_matrix_f0[12], compressed_spectral_matrix_f0[13]); + printf("Element %.2d (S25) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 9, 14, 15, + compressed_spectral_matrix_f0[14], compressed_spectral_matrix_f0[15]); + printf("Element %.2d (S33) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 10, 16, + compressed_spectral_matrix_f0[16], 0.); + printf("Element %.2d (S34) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 11, 17, 18, + compressed_spectral_matrix_f0[17], compressed_spectral_matrix_f0[18]); + printf("Element %.2d (S35) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 12, 19, 20, + compressed_spectral_matrix_f0[19], compressed_spectral_matrix_f0[20]); + printf("Element %.2d (S44) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 13, 21, + compressed_spectral_matrix_f0[21], 0.); + printf("Element %.2d (S45) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 14, 22, 23, + compressed_spectral_matrix_f0[22], compressed_spectral_matrix_f0[23]); + printf("Element %.2d (S55) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 15, 24, + compressed_spectral_matrix_f0[24], 0.); return 0; } diff --git a/file_utilities.h b/file_utilities.h --- a/file_utilities.h +++ b/file_utilities.h @@ -1,12 +1,14 @@ +// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) +// version 1: 31/07/2013 + #ifndef FILE_UTILITIES_H #define FILE_UTILITIES_H #include -#include +#include +#include -extern float compressed_spectral_matrix_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ]; -extern unsigned char LFR_BP1_F0[ ]; -extern unsigned char LFR_BP2_F0[ ]; +extern float compressed_spectral_matrix_f0[TOTAL_SIZE_COMPRESSED_MATRIX_f0]; int lecture_file_sm(const char *fileName); diff --git a/main.c b/main.c --- a/main.c +++ b/main.c @@ -1,6 +1,8 @@ +// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) +// version 1: 31/07/2013 + #include -#include -#include +#include #include float compressed_spectral_matrix_f0[TOTAL_SIZE_COMPRESSED_MATRIX_f0]; diff --git a/sm_test1.dat b/sm_test1.dat index d56995e64586ba75d298913bb5cc573965ab6006..b8a1cd53128f9b49427a8fddb810c3bbaa256d75 GIT binary patch literal 100 zc$@)b0Gt0>FM~-@WQxb6rK3j5^QT9`MKekG&A>;*D>TVYb>v8@XvxQbVsuBUEvd(J zff~q2C*?;tDLqG$eoe=KrsG6rUQ|gX;W5eOJpV@swfx0lp0&u97f(q(zkx@rXPro6 Gf>%h?VKDgs diff --git a/sm_test1.txt b/sm_test1.txt --- a/sm_test1.txt +++ b/sm_test1.txt @@ -1,11 +1,11 @@ # -------------------------------------------------------- # MISSION NAME : LFR/RPW/SO # DATA NAME : test matrix -# NB_TOTAL_VALUES : 60 -# NB_COMPONENTS : 30 -# FORMAT : (60(e16.8)) +# NB_TOTAL_VALUES : 25 +# NB_COMPONENTS : 25 +# FORMAT : (25(e16.8)) # UNIT : floating # -------------------------------------------------------- # BEGIN DATA - 1.00200234e+004 0.00000000e+000-8.89210144e+002 1.14001392e+003-5.19522591e+001 4.09957178e+003 5.89932617e+002-8.61112012e+003 8.60225684e+003-7.61522522e+002 3.59796326e+002 0.00000000e+000 4.94544861e+002-4.77043762e+002-1.08253699e+003 5.83120300e+002-8.45693970e+002-1.06855054e+003 1.77511353e+003 0.00000000e+000-3.44424780e+003-2.54208740e+002-2.31431686e+002-3.53662280e+003 7.53777246e+003 0.00000000e+000 1.27810120e+003 7.40368945e+003 7.60701318e+003 0.00000000e+000 1.00200234e+004 0.00000000e+000-8.89210144e+002 1.14001392e+003-5.19522591e+001 4.09957178e+003 5.89932617e+002-8.61112012e+003 8.60225684e+003-7.61522522e+002 3.59796326e+002 0.00000000e+000 4.94544861e+002-4.77043762e+002-1.08253699e+003 5.83120300e+002-8.45693970e+002-1.06855054e+003 1.77511353e+003 0.00000000e+000-3.44424780e+003-2.54208740e+002-2.31431686e+002-3.53662280e+003 7.53777246e+003 0.00000000e+000 1.27810120e+003 7.40368945e+003 7.60701318e+003 0.00000000e+000 + 1.07466725e+006-7.08566328e+004 2.09468203e+004 8.59915781e+004 7.34300125e+005 9.87159375e+004-7.37980250e+005 4.67882438e+005-1.03121328e+005 6.25625000e+004-8.66193281e+004-1.58213813e+005 1.17326563e+005 4.84252188e+004-5.26065703e+004 1.82120313e+003 8.69862375e+005-7.28594313e+005 1.30681789e+005-8.08662891e+003-3.71955031e+005 8.48249375e+005 6.64304844e+004 3.22365375e+005 2.20681547e+005 # END DATA diff --git a/tests1.pro b/tests1.pro --- a/tests1.pro +++ b/tests1.pro @@ -3,15 +3,16 @@ CONFIG += console CONFIG -= app_bundle CONFIG -= qt -# DEFINES += DEBUG_TCH +#DEFINES += MSB_FIRST_TCH # SPARC convention +DEFINES += LSB_FIRST_TCH # PC convention SOURCES += main.c \ - basic_parameters_1_ICD_issue1rev6.c \ + basic_parameters.c \ file_utilities.c HEADERS += \ - file_utilities.h \ - basic_parameters_1_ICD_issue1rev6.h + basic_parameters.h \ + file_utilities.h diff --git a/tests1.pro.autosave b/tests1.pro.autosave deleted file mode 100644 --- a/tests1.pro.autosave +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -CONFIG += console -CONFIG -= app_bundle -CONFIG -= qt - -# -DEFINES += DEBUG_TCH - -SOURCES += main.c \ - basic_parameters_1_ICD_issue1rev6.c \ - file_utilities.c - -HEADERS += \ - file_utilities.h \ - basic_parameters_1_ICD_issue1rev6.h - - diff --git a/tests1.pro.user b/tests1.pro.user --- a/tests1.pro.user +++ b/tests1.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget