# HG changeset patch # User chust # Date 2015-06-19 17:25:39 # Node ID a5a60b47035dc30e0bbec019004ee8ca48c2277e # Parent a586fe639ac179e95bdc150ebdbab0312f31dc30 version 2.0 pour la R3 + modif de init_coefficients diff --git a/basic_parameters.c b/basic_parameters.c --- a/basic_parameters.c +++ b/basic_parameters.c @@ -1,4 +1,4 @@ -// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) +// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW // version 1.0: 31/07/2013 // version 1.1: 02/04/2014 // version 1.2: 30/04/2014 @@ -7,15 +7,48 @@ // version 1.5: 20/05/2014 // version 1.6: 19/12/2014 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3]) +// version 1.8: 02/02/2015 (gestion des divisions par zéro) +// In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW +// version 2.0: 19/06/2015 - +#include #include #include "basic_parameters_params.h" +void init_k_coefficients_f0( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix ); +void init_k_coefficients_f1( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix ); +void init_k_coefficients_f2( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix ); + void init_k_coefficients(float *k_coefficients, unsigned char nb_binscompressed_matrix ) { - uint16_t i; // 16 bits unsigned + + switch (nb_binscompressed_matrix) + { + case 11: + puts("F0 data: initialization of the intercalibration k-coefficients"); + init_k_coefficients_f0(k_coefficients, nb_binscompressed_matrix); + break; + case 13: + puts("F1 data: initialization of the intercalibration k-coefficients"); + init_k_coefficients_f1(k_coefficients, nb_binscompressed_matrix); + break; + case 12: + printf("F2 data: initialization of the intercalibration k-coefficients"); + init_k_coefficients_f2(k_coefficients, nb_binscompressed_matrix); + break; + default: + puts("there is a problème !!?"); + break; + } +} + + +void init_k_coefficients_f0(float *k_coefficients, + unsigned char nb_binscompressed_matrix ) +{ + + uint8_t i; // 8 bits unsigned for(i=0; i R2 FSW // version 1.0: 31/07/2013 // version 1.1: 02/04/2014 // version 1.2: 30/04/2014 @@ -8,6 +8,8 @@ // version 1.6: 19/12/2014 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3]) // version 1.8: 02/02/2015 (gestion des divisions par zéro) +// In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW +// version 2.0: 19/06/2015 #ifndef BASIC_PARAMETERS_H_INCLUDED #define BASIC_PARAMETERS_H_INCLUDED @@ -21,7 +23,7 @@ static inline void BP1_set(float * compressed_spec_mat, float * k_coeff_intercalib, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp1); static inline void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp2); -void init_k_coefficients( float *k_coefficients_f0, unsigned char nb_binscompressed_matrix ); +void init_k_coefficients( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix ); //*********************************** // STATIC INLINE FUNCTION DEFINITIONS @@ -67,11 +69,11 @@ void BP1_set( float * compressed_spec_ma #endif // 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 + nbitexp = 6; // number of bits for the exponent + expmax = 32+5; // maximum value of the exponent expmin = expmax - (1 << nbitexp) + 1; // accordingly the minimum exponent value - // for floating point data to be recorded on 12-bit words: - nbitsig = 12 - nbitexp; // number of bits for the significand + // for floating point data to be recorded on 16-bit words: + nbitsig = 16 - nbitexp; // number of bits for the significand rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1 #ifdef DEBUG_TCH @@ -81,14 +83,13 @@ void BP1_set( float * compressed_spec_ma for(i=0; i= 0.5 * 2^expmin exponent = expmin; @@ -121,27 +122,25 @@ void BP1_set( float * compressed_spec_ma #endif #ifdef DEBUG_TCH printf("\nBin number: %d\n", i); - printf("PSDB / 3 : %16.8e\n",PSDB/3); + printf("PSDB : %16.8e\n",PSDB); printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); printf("psd for PSDB significand : %d\n",psd); printf("exp for PSDB exponent : %d\n",exp); printf("pt_uint8[1] for PSDB exponent + significand: %.3d or %.2x\n",pt_uint8[1], pt_uint8[1]); - printf("pt_uint8[0] for PSDB exponent + significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]); + printf("pt_uint8[0] for PSDB significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]); + printf("lfr_bp1[i*NB_BYTES_BP1+2] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+2], lfr_bp1[i*NB_BYTES_BP1+2]); printf("lfr_bp1[i*NB_BYTES_BP1+3] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+3], lfr_bp1[i*NB_BYTES_BP1+3]); - printf("lfr_bp1[i*NB_BYTES_BP1+2] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+2], lfr_bp1[i*NB_BYTES_BP1+2]); #endif //============================================== - // BP1 PSDE == PA_LFR_SC_BP1_PE_F0 == 12 bits = 5 bits (exponent) + 7 bits (significand) + // BP1 PSDE == PA_LFR_SC_BP1_PE_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand) PSDE = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K44_PE] // S44 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K55_PE] // S55 + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+22] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K45_PE_RE] // S45 Re - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+23] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+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 ... + significand = frexpf(PSDE, &exponent); // 0.5 <= significand < 1 + // PSDE = significand * 2^exponent if (exponent < expmin) { // value should be >= 0.5 * 2^expmin exponent = expmin; @@ -173,16 +172,15 @@ void BP1_set( float * compressed_spec_ma lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[0]; // Record LSB of tmp_uint16 #endif #ifdef DEBUG_TCH - printf("Bin number: %d\n", i); - printf("PSDE/2 : %16.8e\n",PSDE/2); + printf("PSDE : %16.8e\n",PSDE); printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); printf("psd for PSDE significand : %d\n",psd); printf("exp for PSDE exponent : %d\n",exp); printf("pt_uint8[1] for PSDE exponent + significand: %.3d or %.2x\n",pt_uint8[1], pt_uint8[1]); - printf("pt_uint8[0] for PSDE exponent + significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]); + printf("pt_uint8[0] for PSDE significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]); + printf("lfr_bp1[i*NB_BYTES_BP1+0] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+0], lfr_bp1[i*NB_BYTES_BP1+0]); printf("lfr_bp1[i*NB_BYTES_BP1+1] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+1], lfr_bp1[i*NB_BYTES_BP1+1]); - printf("lfr_bp1[i*NB_BYTES_BP1+0] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+0], lfr_bp1[i*NB_BYTES_BP1+0]); #endif //============================================================================== // BP1 normal wave vector == PA_LFR_SC_BP1_NVEC_V0_F0 == 8 bits @@ -270,9 +268,9 @@ void BP1_set( float * compressed_spec_ma printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity + DOP : %u\n",lfr_bp1[i*NB_BYTES_BP1+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) + // BP1 X_SO-component of the Poynting flux == PA_LFR_SC_BP1_SX_F0 == 16 bits + // = 1 sign bit + 1 argument bit (two sectors) + // + 6 bits (exponent) + 8 bits (significand) e_cross_b_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_RE] //S34 Re + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_RE] //S35 Re + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_RE] //S14 Re @@ -300,26 +298,23 @@ void BP1_set( float * compressed_spec_ma - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_RE] //S24 Im - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_RE]; //S25 Im #ifdef DEBUG_TCH - printf("ReaSX / 2 : %16.8e\n",e_cross_b_re/2); + printf("ReaSX : %16.8e\n",e_cross_b_re); #endif pt_uint8 = (uint8_t*) &e_cross_b_re; // Affect an uint8_t pointer with the adress of e_cross_b_re #ifdef LSB_FIRST_TCH - lfr_bp1[i*NB_BYTES_BP1+0] = lfr_bp1[i*NB_BYTES_BP1+0] | (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention) + lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention) // Record it at the 8th bit position (from the right to the left) - // of lfr_bp1[i*NB_BYTES_BP1+0] + // of lfr_bp1[i*NB_BYTES_BP1+7] pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX| #endif #ifdef MSB_FIRST_TCH - lfr_bp1[i*NB_BYTES_BP1+0] = lfr_bp1[i*NB_BYTES_BP1+0] | (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention) + lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention) // Record it at the 8th bit position (from the right to the left) - // of lfr_bp1[i*NB_BYTES_BP1+0] + // of lfr_bp1[i*NB_BYTES_BP1+7] pt_uint8[0] = (pt_uint8[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) - // Should be reconsidered by taking into account the k-coefficients ... - + significand = frexpf(e_cross_b_re, &exponent); // 0.5 <= significand < 1 + // ReaSX = significand * 2^exponent if (exponent < expmin) { // value should be >= 0.5 * 2^expmin exponent = expmin; significand = 0.5; // min value that can be recorded @@ -333,23 +328,22 @@ void BP1_set( float * compressed_spec_ma significand = 0.5; // min value that can be recorded } - lfr_bp1[i*NB_BYTES_BP1+7] = (uint8_t) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding - // where just the first 3 bits are used (0, ..., 7) + lfr_bp1[i*NB_BYTES_BP1+8] = (uint8_t) ((significand*2-1)*255 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding + // where all bits are used (0, ..., 255) tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where - // just the first 5 bits are used (0, ..., 2^5-1) + // just the first nbitexp bits are used (0, ..., 2^nbitexp-1) #ifdef DEBUG_TCH - printf("|ReaSX| / 2 : %16.8e\n",e_cross_b_re/2); + printf("|ReaSX| : %16.8e\n",e_cross_b_re); printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); - printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]); printf("tmp_uint8 for ReaSX exponent : %d\n",tmp_uint8); #endif - lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | (tmp_uint8 << 3); // Shift these 5 bits to the left before logical addition - // with lfr_bp1[i*NB_BYTES_BP1+7] + lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | tmp_uint8; // Record these nbitexp bits in the nbitexp first bits + // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+7] #ifdef DEBUG_TCH - printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX exponent + significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]); - printf("lfr_bp1[i*NB_BYTES_BP1+0] for ReaSX sign + PSDE 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+0]); - printf("ImaSX / 2 : %16.8e\n",e_cross_b_im/2); + printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX sign + RealSX exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]); + printf("lfr_bp1[i*NB_BYTES_BP1+8] for ReaSX significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]); + printf("ImaSX : %16.8e\n",e_cross_b_im); #endif pt_uint8 = (uint8_t*) &e_cross_b_im; // Affect an uint8_t pointer with the adress of e_cross_b_im #ifdef LSB_FIRST_TCH @@ -360,17 +354,17 @@ void BP1_set( float * compressed_spec_ma #endif tmp_uint8 = (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[i*NB_BYTES_BP1+0] = lfr_bp1[i*NB_BYTES_BP1+0] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right - // to the left) of lfr_bp1[i*NB_BYTES_BP1+0], by simple logical addition. + lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right + // to the left) of lfr_bp1[i*NB_BYTES_BP1+7], by simple logical addition. #ifdef DEBUG_TCH - printf("|ImaSX| / 2 : %16.8e\n",e_cross_b_im/2); + printf("|ImaSX| : %16.8e\n",e_cross_b_im); printf("ArgSX sign : %u\n",tmp_uint8); - printf("lfr_bp1[i*NB_BYTES_BP1+0] for ReaSX & ArgSX signs + PSDE 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+0]); + printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX & ArgSX signs + ReaSX exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]); #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) + // BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 16 bits + // = 1 sign bit + 1 argument bit (two sectors) + // + 6 bits (exponent) + 8 bits (significand) ny = sin(alpha_M)*NVEC_V1 + cos(alpha_M)*NVEC_V2; nz = NVEC_V0; bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] // S22 Re @@ -418,15 +412,15 @@ void BP1_set( float * compressed_spec_ma // vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re) pt_uint8 = (uint8_t*) &n_cross_e_scal_b_re; // Affect an uint8_t pointer with the adress of n_cross_e_scal_b_re #ifdef LSB_FIRST_TCH - lfr_bp1[i*NB_BYTES_BP1+2] = lfr_bp1[i*NB_BYTES_BP1+2] | (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention) + lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention) // Record it at the 8th bit position (from the right to the left) - // of lfr_bp1[i*NB_BYTES_BP1+2] + // of lfr_bp1[i*NB_BYTES_BP1+9] pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re| #endif #ifdef MSB_FIRST_TCH - lfr_bp1[i*NB_BYTES_BP1+2] = lfr_bp1[i*NB_BYTES_BP1+2] | (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention) + lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention) // Record it at the 8th bit position (from the right to the left) - // of lfr_bp1[i*NB_BYTES_BP1+2] + // of lfr_bp1[i*NB_BYTES_BP1+9] pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re| #endif if (bx_bx_star != 0.) { // no division by 0. @@ -436,11 +430,8 @@ void BP1_set( float * compressed_spec_ma { vphi = 1.e+20; // Put a huge value } - 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 ... - + significand = frexpf(vphi, &exponent); // 0.5 <= significand < 1 + // vphi = significand * 2^exponent if (exponent < expmin) { // value should be >= 0.5 * 2^expmin exponent = expmin; significand = 0.5; // min value that can be recorded @@ -453,41 +444,39 @@ void BP1_set( float * compressed_spec_ma exponent = expmin; significand = 0.5; // min value that can be recorded } + + lfr_bp1[i*NB_BYTES_BP1+10] = (uint8_t) ((significand*2-1)*255 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding + // where all the bits are used (0, ..., 255) + tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where + // just the first nbitexp bits are used (0, ..., 2^nbitexp-1) #ifdef DEBUG_TCH - printf("|VPHI| / 2 : %16.8e\n",vphi/2); + printf("|VPHI| : %16.8e\n",vphi); printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); -#endif - lfr_bp1[i*NB_BYTES_BP1+8] = (uint8_t) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding - // where just the first 3 bits are used (0, ..., 7) - tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where - // just the first 5 bits are used (0, ..., 2^5-1) -#ifdef DEBUG_TCH - printf("lfr_bp1[i*NB_BYTES_BP1+8] for VPHI significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]); printf("tmp_uint8 for VPHI exponent : %d\n",tmp_uint8); #endif - lfr_bp1[i*NB_BYTES_BP1+8] = lfr_bp1[i*NB_BYTES_BP1+8] | (tmp_uint8 << 3); // shift these 5 bits to the left before logical addition - // with lfr_bp1[i*NB_BYTES_BP1+8] + lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | tmp_uint8; // Record these nbitexp bits in the nbitexp first bits + // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+9] #ifdef DEBUG_TCH - printf("lfr_bp1[i*NB_BYTES_BP1+8] for VPHI exponent + significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]); - printf("lfr_bp1[i*NB_BYTES_BP1+2] for VPHI sign + PSDB 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+2]); + printf("lfr_bp1[i*NB_BYTES_BP1+9] for VPHI sign + VPHI exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+9]); + printf("lfr_bp1[i*NB_BYTES_BP1+10] for VPHI significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+10]); #endif pt_uint8 = (uint8_t*) &n_cross_e_scal_b_im; // Affect an uint8_t pointer with the adress of n_cross_e_scal_b_im #ifdef LSB_FIRST_TCH - pt_uint8[3] = pt_uint8[3] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaSX| (32-bit float, sign bit in the 4th octet:PC convention) + pt_uint8[3] = pt_uint8[3] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaNEBX| (32-bit float, sign bit in the 4th octet:PC convention) #endif #ifdef MSB_FIRST_TCH - pt_uint8[0] = pt_uint8[0] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaSX| (32-bit float, sign bit in the 1th octet:SPARC convention) + pt_uint8[0] = pt_uint8[0] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaNEBX| (32-bit float, sign bit in the 1th octet:SPARC convention) #endif - tmp_uint8 = (n_cross_e_scal_b_im > n_cross_e_scal_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect + tmp_uint8 = (n_cross_e_scal_b_im > n_cross_e_scal_b_re) ? 0x40 : 0x00; // Determine the sector argument of NEBX. If |Im| > |Re| affect // an unsigned 8-bit char with 01000000; otherwise with null. - lfr_bp1[i*NB_BYTES_BP1+2] = lfr_bp1[i*NB_BYTES_BP1+2] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right - // to the left) of lfr_bp1[i*NB_BYTES_BP1+3], by simple logical addition. + lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right + // to the left) of lfr_bp1[i*NB_BYTES_BP1+9], 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_uint8); - printf("lfr_bp1[i*NB_BYTES_BP1+2] for VPHI & ArgNEBX signs + PSDB 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+2]); + printf("|n_cross_e_scal_b_im|/bx_bx_star : %16.8e\n",n_cross_e_scal_b_im/bx_bx_star); + printf("ArgNEBX sign : %u\n",tmp_uint8); + printf("lfr_bp1[i*NB_BYTES_BP1+9] for VPHI & ArgNEBX signs + VPHI exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+9]); #endif } } @@ -519,12 +508,13 @@ void BP2_set( float * compressed_spec_ma nbitexp = 6; // number of bits for the exponent nbitsig = 16 - nbitexp; // number of bits for the significand rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1 - expmax = 32; + expmax = 32 + 5; expmin = expmax - (1 << nbitexp) + 1; #ifdef DEBUG_TCH - printf("nbitexp : %d, nbitsig : %d, rangesig : %d\n", nbitexp, nbitsig, rangesig); - printf("expmin : %d, expmax : %d\n", expmin, expmax); + + printf("nbitexp : %d, expmax : %d, expmin : %d\n", nbitexp, expmax, expmin); + printf("nbitsig : %d, rangesig : %d\n", nbitsig, rangesig); #endif for(i = 0; i R2 FSW // version 1.4: 16/05/2014 // version 1.5: 20/05/2014 // version 1.6: 19/12/2014 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3]) - +// version 1.8: 02/02/2015 (gestion des divisions par zéro) +// In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW +// version 2.0: 19/06/2015 #ifndef BASIC_PARAMETERS_PARAMS_H #define BASIC_PARAMETERS_PARAMS_H #define NB_VALUES_PER_SPECTRAL_MATRIX 25 -#define NB_BYTES_BP1 9 +#define NB_BYTES_BP1 11 #define NB_BYTES_BP2 30 //******************************************** diff --git a/basic_parameters_utilities.h b/basic_parameters_utilities.h --- a/basic_parameters_utilities.h +++ b/basic_parameters_utilities.h @@ -1,7 +1,9 @@ -// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) +// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW // version 1.6: 19/12/2014 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3]) - +// version 1.8: 02/02/2015 (gestion des divisions par zéro) +// In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW +// version 2.0: 19/06/2015 #ifndef BASIC_PARAMETERS_UTILITIES_H #define BASIC_PARAMETERS_UTILITIES_H @@ -11,7 +13,7 @@ #include "basic_parameters_params.h" -#define NB_BINS_COMPRESSED_MATRIX_f0 1 +#define NB_BINS_COMPRESSED_MATRIX_f0 11 #define NB_BINS_COMPRESSED_MATRIX_f1 13 #define NB_BINS_COMPRESSED_MATRIX_f2 12 diff --git a/file_utilities.c b/file_utilities.c --- a/file_utilities.c +++ b/file_utilities.c @@ -1,4 +1,4 @@ -// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) +// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW // version 1.0: 31/07/2013 // version 1.1: 02/04/2014 // version 1.2: 30/04/2014 @@ -7,7 +7,9 @@ // version 1.5: 20/05/2014 // version 1.6: 19/12/2014 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3]) - +// version 1.8: 02/02/2015 (gestion des divisions par zéro) +// In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW +// version 2.0: 19/06/2015 #include "basic_parameters_utilities.h" @@ -31,7 +33,7 @@ int lecture_file_sm(const char *fileName for(i=0; i Re:%16.8e Im:%16.8e\n", 1, 0, compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+0], 0.); diff --git a/file_utilities.h b/file_utilities.h --- a/file_utilities.h +++ b/file_utilities.h @@ -1,4 +1,4 @@ -// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) +// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW // version 1.0: 31/07/2013 // version 1.1: 02/04/2014 // version 1.2: 30/04/2014 @@ -7,7 +7,9 @@ // version 1.5: 20/05/2014 // version 1.6: 19/12/2014 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3]) - +// version 1.8: 02/02/2015 (gestion des divisions par zéro) +// In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW +// version 2.0: 19/06/2015 #ifndef FILE_UTILITIES_H #define FILE_UTILITIES_H diff --git a/main.c b/main.c --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) +// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW // version 1.O: 31/07/2013 // version 1.1: 02/04/2014 // version 1.2: 30/04/2014 @@ -7,7 +7,9 @@ // version 1.5: 20/05/2014 // version 1.6: 19/12/2014 // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3]) - +// version 1.8: 02/02/2015 (gestion des divisions par zéro) +// In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW +// version 2.0: 19/06/2015 #include @@ -30,14 +32,16 @@ int main(void) printf("The multi-byte quantities are laid out in a MSB FIRST (big endian) fashion\n\n"); #endif - filename="/WIN/Users/chust/DD CHUST/Missions/Solar Orbiter/LFR/Prog C/tests bp Paul/tests2/sm_test2.dat"; + filename="/WIN/Users/chust/DD CHUST/Missions/Solar Orbiter/LFR/Prog C/tests bp Paul/tests7/sm_test2_R3.dat"; lecture_file_sm(filename); + printf("\n"); + init_k_coefficients(k_coefficients_f0, NB_BINS_COMPRESSED_MATRIX_f0); init_k_coefficients(k_coefficients_f1, NB_BINS_COMPRESSED_MATRIX_f1); init_k_coefficients(k_coefficients_f2, NB_BINS_COMPRESSED_MATRIX_f2); - printf("\n"); + printf("\n\n"); BP1_set(compressed_spectral_matrix_f0, k_coefficients_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_f0); diff --git a/sm_test2_R3.dat b/sm_test2_R3.dat new file mode 100755 --- /dev/null +++ b/sm_test2_R3.dat @@ -0,0 +1,1 @@ +5tJ�n ��j�I�!�D%t�d�D˙�K]&��j�č/8I,F���jC�K�AO�'�)E��dKFKwHU����t5E����.ˑ��LB68ŭ.%M� �M \ No newline at end of file diff --git a/sm_test2_R3.txt b/sm_test2_R3.txt new file mode 100755 --- /dev/null +++ b/sm_test2_R3.txt @@ -0,0 +1,12 @@ +# -------------------------------------------------------- +# MISSION NAME : LFR/RPW/SO +# DATA NAME : test matrix +# NB_TOTAL_VALUES : 25 +# NB_COMPONENTS : 25 +# FORMAT : (25(e16.8)) +# UNIT : floating +# COMMENT : +# -------------------------------------------------------- +# BEGIN DATA + 4.00109575e+06 -2.19891187e+03 1.73193325e+06 1.88106079e+03 -1.00001638e+06 6.23724854e+02 2.00016860e+07 -3.46422920e+07 -1.44333826e+03 7.54424812e+05 -4.36785375e+05 2.34538879e+02 8.65882200e+06 -3.31611108e+03 2.71719702e+03 1.50027590e+07 2.53229094e+05 -4.99895450e+06 2.90329712e+03 -2.17048022e+03 -8.66275100e+06 1.00002952e+08 -2.94739111e+03 1.73206224e+08 3.00003392e+08 +# END DATA diff --git a/tests7.pro b/tests7.pro new file mode 100755 --- /dev/null +++ b/tests7.pro @@ -0,0 +1,20 @@ +TEMPLATE = app +CONFIG += console +CONFIG -= app_bundle +CONFIG -= qt + +DEFINES += DEBUG_TCH +DEFINES += LSB_FIRST_TCH # PC convention +#DEFINES += MSB_FIRST_TCH # SPARC convention + +SOURCES += main.c \ + basic_parameters.c \ + file_utilities.c + +HEADERS += \ + basic_parameters.h \ + basic_parameters_params.h \ + basic_parameters_utilities.h \ + file_utilities.h + +