Data format » History » Version 14
Anonymous, 03/05/2020 03:34 PM
1 | 1 | Anonymous | h1. Data format |
---|---|---|---|
2 | |||
3 | 14 | Anonymous | La fonction de lecture d'un fichier de données est la suivante: |
4 | 3 | Anonymous | |
5 | 1 | Anonymous | <pre><code class="python"> |
6 | def readFileADLINKCh0( filename, samplesPerFile, timeSerie_A ): |
||
7 | fd = open(filename,'rb') |
||
8 | |||
9 | dum = np.fromfile(fd, dtype = np.uint16) |
||
10 | |||
11 | timeSerie_A[:] = dum[:] |
||
12 | |||
13 | fd.close() |
||
14 | </code></pre> |
||
15 | 3 | Anonymous | |
16 | 11 | Anonymous | On fait une boucle pour lire tous les fichiers et créer une matrice contenant une ligne par fichier: |
17 | 1 | Anonymous | |
18 | <pre><code class="python"> |
||
19 | 9 | Anonymous | firstFile = 0 |
20 | nbFiles = 59 |
||
21 | lastFile = firstFile + nbFiles - 1 |
||
22 | 1 | Anonymous | firstBuffer = firstFile * buffersPerFile |
23 | 11 | Anonymous | lastBuffer = (nbFiles-1) * buffersPerFile + firstBuffer |
24 | 9 | Anonymous | |
25 | 8 | Anonymous | scalingFactor = 2 / 65535 |
26 | 1 | Anonymous | offset = -32768 |
27 | 10 | Anonymous | |
28 | 1 | Anonymous | timeSerie_A = np.zeros( samplesPerFile ) |
29 | 4 | Anonymous | adc_A = np.zeros( (nbFiles, samplesPerFile) ) |
30 | 11 | Anonymous | |
31 | 1 | Anonymous | for k in range( nbFiles ): |
32 | |||
33 | # read the data |
||
34 | nb = str( int( k * buffersPerFile + firstBuffer) ) |
||
35 | filename = data_dir + "/record" + nb + ".bin" |
||
36 | readFileADLINKCh0( filename, samplesPerFile, timeSerie_A ) |
||
37 | |||
38 | print("k = {}, block = {} / {}".format(k, nb, lastBuffer)) |
||
39 | |||
40 | adc_A[ k, : ] = (timeSerie_A + offset) * scalingFactor |
||
41 | </code></pre> |
||
42 | 2 | Anonymous | |
43 | 11 | Anonymous | Les données étant lues, on remet en forme la matrice, une ligne par période de signal et on ne garde que le signal correspondant aux rampes montantes: |
44 | 1 | Anonymous | |
45 | 2 | Anonymous | <pre><code class="python"> |
46 | A_reshaped = adc_A.reshape(nbFiles * rampsPerFile, samplesPerRamp) |
||
47 | 12 | Anonymous | |
48 | samplesPerDownRamp = int(samplesPerRamp/2) |
||
49 | 11 | Anonymous | A_rampUp = A_reshaped[:, 0:samplesPerDownRamp] |
50 | 2 | Anonymous | </code></pre> |
51 | 5 | Anonymous | |
52 | 13 | Anonymous | On obtient ainsi une matrice contenant toutes les rampes montantes. |
53 | |||
54 | 7 | Anonymous | *Note:* dans l'exemple *2019_07_12_14_12_21*, les paramètres sont les suivants: |
55 | 5 | Anonymous | |
56 | <pre><code class="xml"> |
||
57 | <?xml version="1.0" encoding="UTF-8"?> |
||
58 | <posarmc version="2.0"> |
||
59 | <posarV2> |
||
60 | <rampsPerBuffer value="500" units="-"/> |
||
61 | <bufferSize value="20000000" units="byte"/> |
||
62 | <buffersPerFile value="2" units="byte"/> |
||
63 | <rampsPerFile value="1000" units="-"/> |
||
64 | <fileSize value="4e+7" units="byte"/> |
||
65 | <samplingFrequency value="2e+7" units="Hz"/> |
||
66 | <samplesPerRamp value="20000" units="-"/> |
||
67 | <skipNSamples value="0" units="-"/> |
||
68 | <rampPeriod value="1000" units="-"/> |
||
69 | <startFrequency value="9800" units="-"/> |
||
70 | <stopFrequency value="10100" units="-"/> |
||
71 | </posarV2> |
||
72 | </posarmc> |
||
73 | </code></pre> |