file_utilities.c
76 lines
| 4.6 KiB
| text/x-c
|
CLexer
r22 | // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW | |||
r5 | // version 1.0: 31/07/2013 | |||
r6 | // version 1.1: 02/04/2014 | |||
// version 1.2: 30/04/2014 | ||||
r7 | // version 1.3: 02/05/2014 | |||
r12 | // version 1.4: 16/05/2014 | |||
// version 1.5: 20/05/2014 | ||||
r13 | // version 1.6: 19/12/2014 | |||
r16 | // version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3]) | |||
r22 | // 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 | ||||
r24 | // version 2.1: 22/06/2015 (modifs de Paul) | |||
|
r2 | |||
r13 | #include "basic_parameters_utilities.h" | |||
|
r0 | |||
|
r2 | int lecture_file_sm(const char *fileName) | ||
|
r0 | { | ||
r5 | int i; | |||
|
r0 | |||
FILE *infile; | ||||
|
r1 | infile = fopen(fileName, "rb"); // open explicitely a binary file !!! ... | ||
|
r0 | if(infile == NULL) { | ||
|
r2 | printf("Hello I cannot open the file! \n"); | ||
|
r0 | return 0; | ||
} | ||||
(void) fread(compressed_spectral_matrix_f0, sizeof(compressed_spectral_matrix_f0), 1, infile); | ||||
(void) fclose(infile); | ||||
|
r2 | |||
r7 | printf("Compressed_spectral_matrix_f0 : \n"); | |||
printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0); | ||||
printf("Number of values per spectral matrix: %d\n", NB_VALUES_PER_SPECTRAL_MATRIX); | ||||
printf("Size of compressed_spectral_matrix_f0 : %lu\n", sizeof(compressed_spectral_matrix_f0)); | ||||
|
r2 | |||
r5 | for(i=0; i<NB_BINS_COMPRESSED_MATRIX_f0; i++){ | |||
r22 | printf("\nBin number: %d\n", i); | |||
r5 | ||||
|
r2 | printf("Element %.2d (S11) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 1, 0, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+0], 0.); | |||
|
r2 | printf("Element %.2d (S12) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 2, 1, 2, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+1], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+2]); | |||
|
r2 | printf("Element %.2d (S13) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 3, 3, 4, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+3], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+4]); | |||
|
r2 | printf("Element %.2d (S14) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 4, 5, 6, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+5], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+6]); | |||
|
r2 | printf("Element %.2d (S15) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 5, 7, 8, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+7], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+8]); | |||
|
r2 | printf("Element %.2d (S22) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 6, 9, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+9], 0.); | |||
|
r2 | printf("Element %.2d (S23) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 7, 10, 11, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+10], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]); | |||
|
r2 | printf("Element %.2d (S24) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 8, 12, 13, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+12], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]); | |||
|
r2 | printf("Element %.2d (S25) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 9, 14, 15, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+14], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]); | |||
|
r2 | printf("Element %.2d (S33) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 10, 16, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+16], 0.); | |||
|
r2 | printf("Element %.2d (S34) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 11, 17, 18, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+17], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]); | |||
|
r2 | printf("Element %.2d (S35) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 12, 19, 20, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+19], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]); | |||
|
r2 | printf("Element %.2d (S44) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 13, 21, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+21], 0.); | |||
|
r2 | printf("Element %.2d (S45) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 14, 22, 23, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+22], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+23]); | |||
|
r2 | printf("Element %.2d (S55) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 15, 24, | ||
r5 | compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+24], 0.); | |||
|
r0 | |||
r5 | } | |||
|
r0 | return 0; | ||
} | ||||
r12 | ||||