source: fact/tools/pyscripts/tools/cleaning/area_vs_size.py@ 13104

Last change on this file since 13104 was 13104, checked in by neise, 13 years ago
added a comment
  • Property svn:executable set to *
File size: 2.7 KB
Line 
1#!/usr/bin/python -i
2#
3# Dominik Neise
4#
5# cleaning a small step towards the truth
6from pyfact_rename import *
7import os.path
8import matplotlib.pyplot as plt
9import numpy as np
10from fir_filter import *
11from extractor import *
12from drs_spikes import *
13from plotters import *
14import time as t
15from cleaners import AmplitudeCleaner
16confirm_next_step = False# this is for user interaction
17
18data_file_name = '/media/daten_platte/FACT/data/20120229_144.fits.gz'
19calib_file_name = '/media/daten_platte/FACT/data/20120229_132.drs.fits.gz'
20if not os.path.isfile(data_file_name):
21 print 'not able to find file:', data_file_name
22 sys.exit(-1)
23if not os.path.isfile(calib_file_name ):
24 print 'not able to find file:', calib_file_name
25 sys.exit(-1)
26
27run = RawData(data_file_name, calib_file_name)
28despike = DRSSpikes()
29smooth = SlidingAverage(8)
30extract = GlobalMaxFinder(40,200)
31cleaner = AmplitudeCleaner(45,18)
32
33#plotA = CamPlotter('amplitudes')
34#plotT = CamPlotter('times')
35#plotCA = CamPlotter('cleaned amplitudes')
36
37#plotArea = HistPlotter('area', 1440, (0,1440) )
38#plotSize = HistPlotter('size', 1000, (0,10000) )
39
40
41areas = []
42sizes = []
43for data,startcell,tt in run:
44 # trigger type 4 means 'physics event'
45 if tt==4:
46 data = despike(data)
47 data = smooth(data)
48 amplitude, time_of_max = extract(data)
49 clean_mask = cleaner(amplitude)
50 #plotA.name='amplitudes EvtID:' + str(run.event_id.value) + ' TT:' + str(tt)
51 #plotA(amplitude)
52 #plotT(time_of_max)
53 #plotCA(data=amplitude, mask=clean_mask)
54
55 survivors = np.where( clean_mask)[0]
56 size = 0
57 for pixel in survivors:
58 size += amplitude[pixel]
59
60 if len(survivors) > 0:
61 areas.append( len(survivors) )
62 sizes.append( size )
63
64
65 #plotArea(areas, 'areas of ' + str(run.event_id.value) + 'events')
66 #plotSize(sizes, 'sizes of ' + str(run.event_id.value) + 'events')
67
68 if confirm_next_step:
69 user_input = raw_input("'q'-quit, 'r'-run, anything else goes one step")
70 number=None
71 try:
72 number=int(user_input)
73 except:
74 number=None
75 if user_input.find('q') != -1:
76 sys.exit(0)
77 elif user_input.find('r') != -1:
78 confirm_next_step = False
79 elif number!=None:
80 run += number
81
82
83plt.ion()
84myfig = plt.figure()
85myn = myfig.number
86logsize = np.log10(np.array(sizes))
87areas = np.array(areas)
88
89plt.figure(myn)
90plt.title('area vs. log10(size) of '+ str(run.event_id.value) + 'events')
91plt.xlabel('log10(size/1mV)')
92plt.ylabel('area [#pixel]')
93plt.plot( logsize,areas, '.')
Note: See TracBrowser for help on using the repository browser.