Commit 87cea8f7e8957a54760d84946e55bbcb7f7cf6b9

Authored by bmarechal
1 parent b2e5864fc4
Exists in master

replace 4 spaces by tabs

Showing 1 changed file with 87 additions and 87 deletions Side-by-side Diff

... ... @@ -13,99 +13,99 @@
13 13 #==============================================================================
14 14  
15 15 def parse():
16   - """
17   - Specific parsing procedure for Allan Deviation plotting tool.
18   - :returns: populated namespace (parser)
19   - """
20   - parser = argparse.ArgumentParser(description = 'Plot Allan Deviation from timeseries file',
21   - epilog = 'Example: \'./allanplot.py -f \'toto.dat\' -c 2 3\' compute and plot Allan Deviation form columns 2 and 3 of toto.dat')
  16 + """
  17 + Specific parsing procedure for Allan Deviation plotting tool.
  18 + :returns: populated namespace (parser)
  19 + """
  20 + parser = argparse.ArgumentParser(description = 'Plot Allan Deviation from timeseries file',
  21 + epilog = 'Example: \'./allanplot.py -f \'toto.dat\' -c 2 3\' compute and plot Allan Deviation form columns 2 and 3 of toto.dat')
22 22  
23   - parser.add_argument('-f',
24   - action='store',
25   - dest='filename',
26   - default=FILENAME,
27   - help='File(s) to import (default '+FILENAME+')')
  23 + parser.add_argument('-f',
  24 + action='store',
  25 + dest='filename',
  26 + default=FILENAME,
  27 + help='File(s) to import (default '+FILENAME+')')
28 28  
29   - parser.add_argument('-c',
30   - nargs = '+',
31   - action='store',
32   - dest='columns',
33   - default=COLUMNS,
34   - help='Columns to import (default '+str(COLUMNS)+')')
  29 + parser.add_argument('-c',
  30 + nargs = '+',
  31 + action='store',
  32 + dest='columns',
  33 + default=COLUMNS,
  34 + help='Columns to import (default '+str(COLUMNS)+')')
35 35  
36   - parser.add_argument('-r',
37   - action='store',
38   - dest='rate',
39   - default=RATE,
40   - help='Time rate in seconds (default '+str(RATE)+')')
  36 + parser.add_argument('-r',
  37 + action='store',
  38 + dest='rate',
  39 + default=RATE,
  40 + help='Time rate in seconds (default '+str(RATE)+')')
41 41  
42   - parser.add_argument('-R',
43   - action='store_true',
44   - dest='rel',
45   - default=False,
46   - help='Relative ADev')
  42 + parser.add_argument('-R',
  43 + action='store_true',
  44 + dest='rel',
  45 + default=False,
  46 + help='Relative ADev')
47 47  
48   - args = parser.parse_args()
49   - return args
  48 + args = parser.parse_args()
  49 + return args
50 50  
51 51 #==============================================================================
52 52  
53 53 def main():
54   - """
55   - Main script
56   - """
57   - # Parse command line
58   - args = parse()
59   - # filename
60   - filename = args.filename
61   - # columns
62   - columns = map(int, args.columns)
63   - # rate
64   - rate = int(args.rate)
65   - # rel
66   - rel = bool(args.rel)
  54 + """
  55 + Main script
  56 + """
  57 + # Parse command line
  58 + args = parse()
  59 + # filename
  60 + filename = args.filename
  61 + # columns
  62 + columns = map(int, args.columns)
  63 + # rate
  64 + rate = int(args.rate)
  65 + # rel
  66 + rel = bool(args.rel)
67 67  
68   - try:
69   - list_files = []
70   - filename = filename.split()
71   - for name in filename:
72   - list_files.extend(sorted(glob.glob(name)))
  68 + try:
  69 + list_files = []
  70 + filename = filename.split()
  71 + for name in filename:
  72 + list_files.extend(sorted(glob.glob(name)))
73 73  
74   - for name in list_files:
75   - print(name)
76   - data = []
  74 + for name in list_files:
  75 + print(name)
  76 + data = []
77 77  
78   - for f in list_files:
79   - with open(f, 'r') as dest_f:
80   - data_iter = csv.reader(dest_f, delimiter = '\t', quotechar = '"')
81   - temp_data = [value for value in data_iter]
82   - data.extend(temp_data)
  78 + for f in list_files:
  79 + with open(f, 'r') as dest_f:
  80 + data_iter = csv.reader(dest_f, delimiter = '\t', quotechar = '"')
  81 + temp_data = [value for value in data_iter]
  82 + data.extend(temp_data)
83 83  
84   - data = numpy.asarray(data, dtype = float)
  84 + data = numpy.asarray(data, dtype = float)
85 85  
86   - del(temp_data, list_files, value, f)
  86 + del(temp_data, list_files, value, f)
87 87  
88   - g = Gnuplot.Gnuplot(persist = 1)
89   - g('set logscale x')
90   - g('set logscale y')
91   - g('set grid')
92   - g('set format y "%0.1e"')
93   - g.xlabel('Tau (s)')
94   - g.ylabel('Adev')
  88 + g = Gnuplot.Gnuplot(persist = 1)
  89 + g('set logscale x')
  90 + g('set logscale y')
  91 + g('set grid')
  92 + g('set format y "%0.1e"')
  93 + g.xlabel('Tau (s)')
  94 + g.ylabel('Adev')
95 95  
96   - for i in columns:
97   - if rel:
98   - (tau2, ad, ade, adn) = allantools.adev(data[:,i]/data[:,i].mean(), rate=rate, data_type="freq", taus='decade')
99   - else:
100   - (tau2, ad, ade, adn) = allantools.adev(data[:,i], rate=rate, data_type="freq", taus='decade')
101   - g.replot(Gnuplot.Data(tau2, ad, ade, with_='yerrorbars', title='%s : %s'%(name, str(i))))
  96 + for i in columns:
  97 + if rel:
  98 + (tau2, ad, ade, adn) = allantools.adev(data[:,i]/data[:,i].mean(), rate=rate, data_type="freq", taus='decade')
  99 + else:
  100 + (tau2, ad, ade, adn) = allantools.adev(data[:,i], rate=rate, data_type="freq", taus='decade')
  101 + g.replot(Gnuplot.Data(tau2, ad, ade, with_='yerrorbars', title='%s : %s'%(name, str(i))))
102 102  
103   - except Exception as ex:
104   - print 'Oups '+str(ex)
105   - print 'Program ending\n'
  103 + except Exception as ex:
  104 + print 'Oups '+str(ex)
  105 + print 'Program ending\n'
106 106  
107 107 #==============================================================================
108 108  
109 109 if __name__ == "__main__":
110   - main()
  110 + main()