@@ -56,6 +56,7 @@ def doCompareTraces_SINGLE(tn1):
56
56
TRACE_FILES = []
57
57
CONFIG_OFFSET = None
58
58
CONFIG_SAMPLES = None
59
+ CONFIG_SAMPSZ = None
59
60
60
61
import random
61
62
# group 1 is random, group2 is fixed.
@@ -108,10 +109,13 @@ def onclick(event):
108
109
lastX = localX
109
110
110
111
def doCompareTraces (tn1 ,tn2 ):
111
- global CONFIG_OFFSET ,CONFIG_SAMPLES
112
+ global CONFIG_OFFSET ,CONFIG_SAMPLES , CONFIG_SAMPSZ
112
113
tm_in1 = sparkgap .filemanager .TraceManager (tn1 )
113
- trace_avg1 = tm_in1 .getMeant ()
114
114
tm_in2 = sparkgap .filemanager .TraceManager (tn2 )
115
+ if CONFIG_SAMPSZ is not None :
116
+ tm_in1 .randomSelect (CONFIG_SAMPSZ )
117
+ tm_in2 .randomSelect (CONFIG_SAMPSZ )
118
+ trace_avg1 = tm_in1 .getMeant ()
115
119
trace_avg2 = tm_in2 .getMeant ()
116
120
if len (trace_avg1 ) != len (trace_avg2 ):
117
121
print ("The traces do not have equal lengths, I can't use this" )
@@ -132,16 +136,23 @@ def doCompareTraces(tn1,tn2):
132
136
a3 .set_title ("Avg Standard Deviation (Noise)" )
133
137
# (nn0,nn1,points) = doTLVA(tm_in1,tm_in2)
134
138
group1_traces = []
139
+ group2_traces = []
135
140
for f in range (0 ,tm_in1 .getTraceCount ()):
136
141
group1_traces .append (tm_in1 .getSingleTrace (f )[CONFIG_OFFSET :CONFIG_OFFSET + CONFIG_SAMPLES ])
137
- a3 .plot (np .std (group1_traces ,axis = 0 ,keepdims = True )[0 ])
142
+ for f in range (0 ,tm_in2 .getTraceCount ()):
143
+ group2_traces .append (tm_in2 .getSingleTrace (f )[CONFIG_OFFSET :CONFIG_OFFSET + CONFIG_SAMPLES ])
144
+ a3 .plot (np .std (group1_traces ,axis = 0 ,keepdims = True )[0 ],label = os .path .basename (tn1 ))
145
+ a3 .plot (np .std (group2_traces ,axis = 0 ,keepdims = True )[0 ], label = os .path .basename (tn2 ))
146
+ a3 .legend ()
138
147
plt .show ()
139
148
140
149
if __name__ == "__main__" :
141
- opts ,remainder = getopt .getopt (sys .argv [1 :],"f:o:n:" ,["file=" ,"offset=" ,"samples=" ])
150
+ opts ,remainder = getopt .getopt (sys .argv [1 :],"f:o:n:" ,["file=" ,"offset=" ,"samples=" , "samplesize=" ])
142
151
for opt , arg in opts :
143
152
if opt in ("-f" ,"--file" ):
144
153
TRACE_FILES .append (arg )
154
+ elif opt == "--samplesize" :
155
+ CONFIG_SAMPSZ = int (arg )
145
156
elif opt in ("-o" ,"--offset" ):
146
157
CONFIG_OFFSET = int (arg )
147
158
elif opt in ("-n" ,"--samples" ):
0 commit comments