Commit eaefdbe47c6aa73aed5c76b1e3d4b11dd4614f78

Authored by Brice COLOMBIER
1 parent 4a466f9a5e
Exists in master

Clean saving part and prints

Showing 3 changed files with 15 additions and 10 deletions

downsample.py View file @ eaefdbe
1 1 import numpy as np
  2 +
2 3 import argparse
  4 +import os
3 5  
4 6 def downsample(traces, factor, offset=0):
5 7 return traces[:,offset::factor]
6 8  
7 9  
8 10  
9 11  
... ... @@ -9,20 +11,20 @@
9 11 # Parsing arguments
10 12 parser = argparse.ArgumentParser(description='Preprocess traces')
11 13 parser.add_argument("traces_name", type=str)
12   - parser.add_argument("factor", type=int)
13   - parser.add_argument("offset", type=int, nargs='?', default=0)
  14 + parser.add_argument("--factor", type=int)
  15 + parser.add_argument("--offset", type=int, nargs='?', default=0)
14 16 args = parser.parse_args()
15 17  
16 18 fake_nb_samples = 10
17 19 fake_nb_traces = 2
18 20  
19 21 test_array = np.random.random_integers(10, size=(fake_nb_traces, fake_nb_samples))
20   - traces = test_array
  22 + # traces = test_array
21 23 # Load traces from file
22   - # traces = np.load(args.traces_name)
  24 + traces = np.load(args.traces_name)
23 25  
24   - print traces
25 26 downsampled_traces = downsample(traces, args.factor, args.offset)
26   - print downsampled_traces
  27 +
  28 + print os.path(args.traces)
27 29 np.save("downsampled_"+str(args.factor)+"_"+args.traces_name, downsampled_traces)
filter_highest_variance.py View file @ eaefdbe
... ... @@ -40,11 +40,11 @@
40 40 # Load traces from file
41 41 # traces = np.load(args.traces_name)
42 42  
43   - print traces
  43 + dirname, filename = os.path.split(args.traces_name)
44 44 if args.ratio:
45 45 filtered_variance_traces = filter_highest_variance(traces, ratio=args.ratio)
  46 + np.save(dirname+"filtered_variance_"+str(args.ratio)+"_"+filename, filtered_variance_traces)
46 47 elif args.nsamples:
47 48 filtered_variance_traces = filter_highest_variance(traces, nsamples=args.nsamples)
48   - print filtered_variance_traces
49   - np.save("filtered_variance_"+str(args.ratio)+"_"+args.traces_name, filtered_variance_traces)
  49 + np.save(dirname+"filtered_variance_"+str(args.nsamples)+"_"+filename, filtered_variance_traces)
pairwise_operation.py View file @ eaefdbe
... ... @@ -157,5 +157,7 @@
157 157 if np.all(preprocessed_traces.sort()==preprocessed_traces_parallel.sort()):
158 158 if np.all(indexes.sort()==indexes_parallel.sort()):
159 159 print "###\nGreat, sequential and\nparallel processing\nreturned the same result\n###"
160   - np.save("preprocessed_"+args.traces_name, preprocessed_traces_parallel)
  160 +
  161 + dirname, filename = os.path.split(args.traces_name)
  162 + np.save(dirname+"pairwise_"+args.operation+"_"+filename, preprocessed_traces_parallel)