source: mire/moyenne_ring.py @ 33

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
4import math
5import string
6import glob
7import scipy
8
9# Une valeur moyenne par image
10for 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
23data = []
24for 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°
35collect = []
36for i in range(36):
37    collect.append([])
38
39for d in data:
40    collect[int(math.floor(d[0]/10.))].append(d[1])
41
42moy = []
43for c in collect:
44    moy.append(scipy.mean(c))
45
46sig = []
47for c in collect:
48    sig.append(scipy.std(c))
49
50
51# Filtrage à 3sig
52result = []
53for 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
60of = open("couronne",'w')
61for i in range(36):
62    outs = "%3d %10.7f\n" % (i*10,result[i])
63    of.write(outs)
64
65of.close()
66   
Note: See TracBrowser for help on using the repository browser.