source: fact/tools/pyscripts/sandbox/dneise/cleaning/area_vs_size.py@ 14473

Last change on this file since 14473 was 13147, checked in by neise, 13 years ago
enabled tab checking and excahnged python_rename with python
  • Property svn:executable set to *
File size: 2.2 KB
Line 
1#!/usr/bin/python -itt
2#
3# Dominik Neise
4#
5# cleaning a small step towards the truth
6from pyfact import RawData
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
16from image_extractors import SimpleArea, SimpleSize
17confirm_next_step = False# this is for user interaction
18
19data_file_name = 'data/20120223_212.fits.gz'
20calib_file_name = 'data/20120223_206.drs.fits.gz'
21if not os.path.isfile(data_file_name):
22 print 'not able to find file:', data_file_name
23 sys.exit(-1)
24if not os.path.isfile(calib_file_name ):
25 print 'not able to find file:', calib_file_name
26 sys.exit(-1)
27
28run = RawData(data_file_name, calib_file_name)
29despike = DRSSpikes()
30smooth = SlidingAverage(8)
31extract = GlobalMaxFinder(40,200)
32cleaner = AmplitudeCleaner(45,18)
33area = SimpleArea()
34size = SimpleSize()
35
36#plotA = CamPlotter('amplitudes')
37#plotT = CamPlotter('times')
38#plotCA = CamPlotter('cleaned amplitudes')
39
40#plotArea = HistPlotter('area', 1440, (0,1440) )
41#plotSize = HistPlotter('size', 1000, (0,10000) )
42
43
44areas = []
45sizes = []
46for data,startcell,tt in run:
47 # trigger type 4 means 'physics event'
48 if tt==4:
49 data = despike(data)
50 data = smooth(data)
51 amplitude, time_of_max = extract(data)
52 survivors = cleaner(amplitude, return_bool_mask=False )
53 areas.append( area(survivors) )
54 sizes.append( size(survivors, amplitude) )
55
56 if confirm_next_step:
57 user_input = raw_input("'q'-quit, 'r'-run, anything else goes one step")
58 number=None
59 try:
60 number=int(user_input)
61 except:
62 number=None
63 if user_input.find('q') != -1:
64 sys.exit(0)
65 elif user_input.find('r') != -1:
66 confirm_next_step = False
67 elif number!=None:
68 run += number
69
70
71plt.ion()
72myfig = plt.figure()
73myn = myfig.number
74logsize = np.log10(np.array(sizes))
75areas = np.array(areas)
76
77plt.figure(myn)
78plt.title('area vs. log10(size) of '+ str(run.event_id.value) + 'events')
79plt.xlabel('log10(size/1mV)')
80plt.ylabel('area [#pixel]')
81plt.plot( logsize,areas, '.')
Note: See TracBrowser for help on using the repository browser.