#!/usr/bin/python
import spidev
#import RPi.GPIO as GPIO
import time
import numpy as np
import matplotlib 
from scipy import signal
import matplotlib.pyplot as plt
import json
import time
from pyUn0 import *
from scipy import fftpack
for FILE in ["data/20180813a-17.json"]:
    x = us_json()
    x.JSONprocessing(FILE)
    # row and column sharing
    f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2,figsize=(20,10))
    Duration = (x.parameters['LengthAcq']-x.parameters['DeltaAcq'])/1000.0
    Title = "Duration: "+str(Duration)+"us ("+str(x.parameters['LengthAcq'])+" - "
    Title+= str(x.parameters['DeltaAcq'])+"), for "+str(x.Nacq)
    Title += " repeats\n"
    Title += "Fech = "+str(x.f)+"Msps, total of "+str(float(x.f)*Duration)+" pts per line\n" 
    Title += "Nacq = "+str(x.Nacq)
    plt.suptitle(Title)
    #plt.figure()
    A = 4000
    B = 6000
    ax1.plot(x.tmp)
    ax1.plot(x.IDLine)
    ax1.set_title('signal / IDLine for '+str(x.N))
    A =34000
    ax2.plot(x.t[A:A+1400],x.tmp[A:A+1400])
    ax2.plot(x.t[A:A+1400],x.IDLine[A:A+1400])
    ax2.set_title('signal / IDLine - total')
    ax3.plot(x.t,x.tmp)
    ax3.plot(x.t,x.IDLine)
    ax3.set_title('signal / IDLine - total')
    ax4.plot(x.t[1500:1600],x.TT1[1500:1600])
    ax4.plot(x.t[1500:1600],x.TT2[1500:1600])
    ax4.set_title('TT1 / TT2')
    plt.show()
    #plt.tight_layout()
    FileName = "images/"+x.iD+"-"+str(x.N)+"-all.jpg"
    f.savefig(FileName)
Data acquired

png

for k in range(255):
    n = 0
    A = (n-1+k)*640+13500
    B = (n+k)*640+13500
    plt.plot(x.tmp[A:B])
plt.show()

png

x.f
8.0
x.timings
{u'Fech': 8.0,
 u'LAcq': 80,
 u'NAcq': 384000,
 u'NLines': 600,
 u't1': 200,
 u't2': 100,
 u't3': 2000,
 u't4': 25000,
 u't5': 105000}
ID = []
Counter = 0
ps = 0
PS = []
L = []
for i in range(len(x.tmp)-2):
    if i < len(x.tmp) - 50:
        if (x.IDLine[i] ==  x.IDLine[i+1]) and  (x.IDLine[i] <> x.IDLine[i+2]):
            if (i - ps) > 100:
                L.append(i-ps)
                print Counter,i,L[-1],x.t[i]*1.0/(1+Counter)
                Counter = Counter + 1
                ps = i
                PS.append(i)
        else:
            ID.append(Counter)
    else:
        ID.append(-1)

del PS[0]
del ID[0]
del L[0]
0 700 700 87.5
1 1340 640 83.75
2 1980 640 82.5
3 2619 639 81.84375
4 3260 641 81.5
5 3900 640 81.25
6 4540 640 81.0714285714
7 5180 640 80.9375
8 5820 640 80.8333333333
9 6460 640 80.75
10 7100 640 80.6818181818
11 7740 640 80.625
12 8380 640 80.5769230769
13 9020 640 80.5357142857
14 9660 640 80.5
15 10300 640 80.46875
16 10940 640 80.4411764706
17 11580 640 80.4166666667
18 12220 640 80.3947368421
19 12860 640 80.375
20 13500 640 80.3571428571
21 14140 640 80.3409090909
22 14780 640 80.3260869565
23 15420 640 80.3125
24 16060 640 80.3
25 16700 640 80.2884615385
26 17340 640 80.2777777778
27 17979 639 80.2633928571
28 18620 641 80.2586206897
29 19260 640 80.25
30 19900 640 80.2419354839
31 20540 640 80.234375
32 21180 640 80.2272727273
33 21820 640 80.2205882353
34 22460 640 80.2142857143
35 23099 639 80.2048611111
36 23740 641 80.2027027027
37 24380 640 80.1973684211
38 25020 640 80.1923076923
39 25660 640 80.1875
40 26300 640 80.1829268293
41 26940 640 80.1785714286
42 27580 640 80.1744186047
43 28219 639 80.1676136364
44 28860 641 80.1666666667
45 29500 640 80.1630434783
46 30140 640 80.1595744681
47 30780 640 80.15625
48 31420 640 80.1530612245
49 32060 640 80.15
50 32700 640 80.1470588235
51 33340 640 80.1442307692
52 33980 640 80.141509434
53 34620 640 80.1388888889
54 35260 640 80.1363636364
55 35900 640 80.1339285714
56 36540 640 80.1315789474
57 37180 640 80.1293103448
58 37820 640 80.1271186441
59 38460 640 80.125
60 39100 640 80.1229508197
61 39740 640 80.1209677419
62 40380 640 80.119047619
63 41020 640 80.1171875
64 41660 640 80.1153846154
65 42300 640 80.1136363636
66 42940 640 80.1119402985
67 43579 639 80.1084558824
68 44220 641 80.1086956522
69 44860 640 80.1071428571
70 45500 640 80.1056338028
71 46140 640 80.1041666667
72 46780 640 80.102739726
73 47420 640 80.1013513514
74 48060 640 80.1
75 48699 639 80.0970394737
76 49340 641 80.0974025974
77 49980 640 80.0961538462
78 50620 640 80.0949367089
79 51260 640 80.09375
80 51900 640 80.0925925926
81 52540 640 80.0914634146
82 53180 640 80.0903614458
83 53819 639 80.087797619
84 54460 641 80.0882352941
85 55100 640 80.0872093023
86 55740 640 80.0862068966
87 56380 640 80.0852272727
88 57020 640 80.0842696629
89 57660 640 80.0833333333
90 58300 640 80.0824175824
91 58940 640 80.0815217391
92 59580 640 80.0806451613
93 60220 640 80.079787234
94 60860 640 80.0789473684
95 61500 640 80.078125
96 62140 640 80.0773195876
97 62780 640 80.0765306122
98 63420 640 80.0757575758
99 64060 640 80.075
100 64700 640 80.0742574257
101 65340 640 80.0735294118
102 65980 640 80.072815534
103 66620 640 80.0721153846
104 67260 640 80.0714285714
105 67900 640 80.070754717
106 68540 640 80.0700934579
107 69179 639 80.068287037
108 69820 641 80.0688073394
109 70460 640 80.0681818182
110 71100 640 80.0675675676
111 71740 640 80.0669642857
112 72380 640 80.0663716814
113 73020 640 80.0657894737
114 73660 640 80.0652173913
115 74299 639 80.0635775862
116 74940 641 80.0641025641
117 75580 640 80.063559322
118 76220 640 80.0630252101
119 76860 640 80.0625
120 77500 640 80.0619834711
121 78140 640 80.0614754098
122 78780 640 80.0609756098
123 79419 639 80.0594758065
124 80060 641 80.06
125 80700 640 80.0595238095
126 81340 640 80.0590551181
127 81980 640 80.05859375
128 82620 640 80.0581395349
129 83260 640 80.0576923077
130 83900 640 80.0572519084
131 84539 639 80.0558712121
132 85180 641 80.0563909774
133 85820 640 80.0559701493
134 86460 640 80.0555555556
135 87100 640 80.0551470588
136 87740 640 80.0547445255
137 88380 640 80.0543478261
138 89020 640 80.0539568345
139 89659 639 80.0526785714
140 90300 641 80.0531914894
141 90940 640 80.0528169014
142 91580 640 80.0524475524
143 92220 640 80.0520833333
144 92860 640 80.0517241379
145 93500 640 80.051369863
146 94140 640 80.0510204082
147 94779 639 80.0498310811
148 95420 641 80.0503355705
149 96060 640 80.05
150 96700 640 80.0496688742
151 97340 640 80.0493421053
152 97980 640 80.0490196078
153 98620 640 80.0487012987
154 99260 640 80.0483870968
155 99899 639 80.047275641
156 100540 641 80.0477707006
157 101180 640 80.0474683544
158 101820 640 80.0471698113
159 102460 640 80.046875
160 103100 640 80.0465838509
161 103740 640 80.0462962963
162 104380 640 80.0460122699
163 105019 639 80.0449695122
164 105660 641 80.0454545455
165 106300 640 80.0451807229
166 106940 640 80.0449101796
167 107580 640 80.0446428571
168 108220 640 80.0443786982
169 108860 640 80.0441176471
170 109500 640 80.0438596491
171 110140 640 80.0436046512
172 110780 640 80.0433526012
173 111420 640 80.0431034483
174 112060 640 80.0428571429
175 112700 640 80.0426136364
176 113340 640 80.0423728814
177 113980 640 80.0421348315
178 114620 640 80.0418994413
179 115260 640 80.0416666667
180 115900 640 80.0414364641
181 116540 640 80.0412087912
182 117180 640 80.0409836066
183 117820 640 80.0407608696
184 118460 640 80.0405405405
185 119100 640 80.0403225806
186 119740 640 80.0401069519
187 120380 640 80.039893617
188 121020 640 80.0396825397
189 121660 640 80.0394736842
190 122300 640 80.0392670157
191 122940 640 80.0390625
192 123580 640 80.0388601036
193 124220 640 80.0386597938
194 124860 640 80.0384615385
195 125499 639 80.037627551
196 126140 641 80.038071066
197 126780 640 80.0378787879
198 127420 640 80.0376884422
199 128060 640 80.0375
200 128700 640 80.0373134328
201 129340 640 80.0371287129
202 129980 640 80.0369458128
203 130619 639 80.0361519608
204 131260 641 80.0365853659
205 131900 640 80.036407767
206 132540 640 80.0362318841
207 133180 640 80.0360576923
208 133820 640 80.0358851675
209 134460 640 80.0357142857
210 135100 640 80.0355450237
211 135739 639 80.0347877358
212 136380 641 80.0352112676
213 137020 640 80.035046729
214 137660 640 80.0348837209
215 138300 640 80.0347222222
216 138940 640 80.034562212
217 139580 640 80.0344036697
218 140220 640 80.0342465753
219 140859 639 80.0335227273
220 141500 641 80.0339366516
221 142140 640 80.0337837838
222 142780 640 80.033632287
223 143420 640 80.0334821429
224 144060 640 80.0333333333
225 144700 640 80.0331858407
226 145340 640 80.0330396476
227 145979 639 80.0323464912
228 146620 641 80.0327510917
229 147260 640 80.0326086957
230 147900 640 80.0324675325
231 148540 640 80.0323275862
232 149180 640 80.0321888412
233 149820 640 80.0320512821
234 150460 640 80.0319148936
235 151099 639 80.03125
236 151740 641 80.0316455696
237 152380 640 80.031512605
238 153020 640 80.0313807531
239 153660 640 80.03125
240 154300 640 80.031120332
241 154940 640 80.0309917355
242 155580 640 80.0308641975
243 156219 639 80.0302254098
244 156860 641 80.0306122449
245 157500 640 80.0304878049
246 158140 640 80.0303643725
247 158780 640 80.0302419355
248 159420 640 80.0301204819
249 160060 640 80.03
250 160700 640 80.0298804781
251 161340 640 80.0297619048
252 161980 640 80.0296442688
253 162620 640 80.0295275591
39*1.28
49.92
479/1.28
374.21875
45*8
360
plt.plot(x.t[2000:6000],x.tmp[2000:6000])
plt.show()

png



results matching ""

    No results matching ""