source: fact/tools/pyscripts/pyfact/image_extractors.py@ 13148

Last change on this file since 13148 was 13143, checked in by neise, 13 years ago
included python -tt option. thus checking for tabs/spaces
  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#!/usr/bin/python -tt
2#
3# Dominik Neise
4# TU Dortmund
5#
6from coor import Coordinator
7from euclid import Vector2
8
9class SimpleArea(object):
10 """ Calculate Hillas Area in simple way.
11 Sum up the number of pixels, which survived the cleaning.
12 The unit is [Number of Pixel]
13 """
14 def __init__(self):
15 # I don't know, if classes, which need no initialization
16 # do still need an empty __init__ func....
17 pass
18
19 def __call__(self, survivors):
20 return len(survivors)
21
22class SimpleSize(object):
23 """ Calculate Hillas Size in a very simple way
24 Sum up the 'amplitude'-like value, for each survivor
25 """
26 def __init__(self):
27 # I don't know, if classes, which need no initialization
28 # do still need an empty __init__ func....
29 pass
30
31 def __call__(self, survivors, amplitude):
32 size = 0
33 for pixel in survivors:
34 size += amplitude[pixel]
35 return size
36
37class HillasParameter(object):
38 """ Calculate Hillas Parameters
39 http://magic.mppmu.mpg.de/publications/theses/TBretz.pdf p.42
40
41 """
42 def __init__(self):
43 self.coordinator = Coordinator()
44 self.chid2coor = self.coordinator.chid2vec
45 pass
46
47 def __call__(self, survivors, amplitude):
48 self.survivors = survivors
49 self.amplitude = amplitude
50
51 self._CalculateSize()
52 self._CalculateCOG()
53
54
55 def _CalculateSize(self):
56 # shortcuts
57 survivors = self.survivors
58 amplitude = self.amplitude
59 size = 0
60 for pixel in survivors:
61 size += amplitude[pixel]
62
63 self.size = size
64 return size
65
66 def _CalculateCOG(self):
67 # shortcuts
68 survivors = self.survivors
69 amplitude = self.amplitude
70 chid2coor = self.chid2coor
71
72
73 cog = Vector2( 0, 0)
74 for chid in survivors:
75 cog += chid2coor[chid] * amplitude[chid]
76 cog /= self.size
77 self.cog = cog
78 return cog
79 def _CaluculateM(self):
80 """ M is a matrix I didn't understand yet.
81 Maybe some kind of covariance matrix...
82 """
83
84if __name__ == '__main__':
85 """ no tests yet """
86 print 'no test implemented yet'
Note: See TracBrowser for help on using the repository browser.