Data format » History » Version 8
Anonymous, 03/05/2020 03:28 PM
1 | 1 | Anonymous | h1. Data format |
---|---|---|---|
2 | |||
3 | 3 | Anonymous | La fonction de lecture des données est la suivantes, pour un fichier: |
4 | |||
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 | On fait une boucle pour lire tous les fichiers et créer un grand vecteur: |
||
17 | 1 | Anonymous | |
18 | <pre><code class="python"> |
||
19 | 8 | Anonymous | scalingFactor = 2 / 65535 |
20 | offset = -32768 |
||
21 | 4 | Anonymous | timeSerie_A = np.zeros( samplesPerFile ) |
22 | adc_A = np.zeros( (nbFiles, samplesPerFile) ) |
||
23 | 1 | Anonymous | lastBuffer = (nbFiles-1) * buffersPerFile + firstBuffer |
24 | for k in range( nbFiles ): |
||
25 | |||
26 | # read the data |
||
27 | nb = str( int( k * buffersPerFile + firstBuffer) ) |
||
28 | filename = data_dir + "/record" + nb + ".bin" |
||
29 | readFileADLINKCh0( filename, samplesPerFile, timeSerie_A ) |
||
30 | |||
31 | print("k = {}, block = {} / {}".format(k, nb, lastBuffer)) |
||
32 | |||
33 | adc_A[ k, : ] = (timeSerie_A + offset) * scalingFactor |
||
34 | </code></pre> |
||
35 | 2 | Anonymous | |
36 | Les données étant lues, on remet en forme le vecteur pour ne garder que le signal correspondant aux rampes montantes: |
||
37 | |||
38 | <pre><code class="python"> |
||
39 | A_reshaped = adc_A.reshape(nbFiles * rampsPerFile, samplesPerRamp) |
||
40 | </code></pre> |
||
41 | 5 | Anonymous | |
42 | 7 | Anonymous | *Note:* dans l'exemple *2019_07_12_14_12_21*, les paramètres sont les suivants: |
43 | 5 | Anonymous | |
44 | <pre><code class="xml"> |
||
45 | <?xml version="1.0" encoding="UTF-8"?> |
||
46 | <posarmc version="2.0"> |
||
47 | <posarV2> |
||
48 | <rampsPerBuffer value="500" units="-"/> |
||
49 | <bufferSize value="20000000" units="byte"/> |
||
50 | <buffersPerFile value="2" units="byte"/> |
||
51 | <rampsPerFile value="1000" units="-"/> |
||
52 | <fileSize value="4e+7" units="byte"/> |
||
53 | <samplingFrequency value="2e+7" units="Hz"/> |
||
54 | <samplesPerRamp value="20000" units="-"/> |
||
55 | <skipNSamples value="0" units="-"/> |
||
56 | <rampPeriod value="1000" units="-"/> |
||
57 | <startFrequency value="9800" units="-"/> |
||
58 | <stopFrequency value="10100" units="-"/> |
||
59 | </posarV2> |
||
60 | </posarmc> |
||
61 | </code></pre> |