Last change
on this file since 33 was
33,
checked in by meynadie, 16 years ago
|
filtrage des données couronne
|
-
Property svn:executable set to
*
|
File size:
1.4 KB
|
Line | |
---|
1 | #!/bin/env python |
---|
2 | # coding: utf-8 |
---|
3 | |
---|
4 | import math |
---|
5 | import string |
---|
6 | import glob |
---|
7 | import scipy |
---|
8 | |
---|
9 | # Une valeur moyenne par image |
---|
10 | for filename in glob.glob("*.ring"): |
---|
11 | data = [] |
---|
12 | for line in file(filename): |
---|
13 | if (line[0]=="#"): |
---|
14 | line_s = string.split(line) |
---|
15 | phase = line_s[2] |
---|
16 | date = line_s[4] |
---|
17 | else : |
---|
18 | data.append(float(string.split(line)[2])) |
---|
19 | print filename, phase, date, scipy.mean(data) |
---|
20 | |
---|
21 | # Un fichier contenant la moyenne en fonction du PA |
---|
22 | |
---|
23 | data = [] |
---|
24 | for filename in glob.glob("*.ring"): |
---|
25 | for line in file(filename): |
---|
26 | if (line[0]=="#"): |
---|
27 | line_s = string.split(line) |
---|
28 | phase = line_s[2] |
---|
29 | date = line_s[4] |
---|
30 | else : |
---|
31 | data.append([float(string.split(line)[1]), |
---|
32 | float(string.split(line)[2])]) |
---|
33 | |
---|
34 | # binning par pas de 10° |
---|
35 | collect = [] |
---|
36 | for i in range(36): |
---|
37 | collect.append([]) |
---|
38 | |
---|
39 | for d in data: |
---|
40 | collect[int(math.floor(d[0]/10.))].append(d[1]) |
---|
41 | |
---|
42 | moy = [] |
---|
43 | for c in collect: |
---|
44 | moy.append(scipy.mean(c)) |
---|
45 | |
---|
46 | sig = [] |
---|
47 | for c in collect: |
---|
48 | sig.append(scipy.std(c)) |
---|
49 | |
---|
50 | |
---|
51 | # Filtrage à 3sig |
---|
52 | result = [] |
---|
53 | for i in range(len(collect)): |
---|
54 | def f(x): |
---|
55 | return (math.fabs(x - moy[i]) < 3 * sig[i]) |
---|
56 | collect[i] = filter(f,collect[i]) |
---|
57 | result.append(scipy.mean(collect[i])) |
---|
58 | |
---|
59 | |
---|
60 | of = open("couronne",'w') |
---|
61 | for i in range(36): |
---|
62 | outs = "%3d %10.7f\n" % (i*10,result[i]) |
---|
63 | of.write(outs) |
---|
64 | |
---|
65 | of.close() |
---|
66 | |
---|
Note: See
TracBrowser
for help on using the repository browser.