source: fact/tools/pyscripts/examples/result_collection/fake_analysis.py@ 17548

Last change on this file since 17548 was 13228, checked in by neise, 13 years ago
changes as discussed with werner ... not executable anymore
  • Property svn:executable set to *
File size: 3.5 KB
Line 
1#!/usr/bin/python -i
2
3# Please read first:
4# * readme.1st and
5# * area_vs_hist_with_can.py
6#
7# this scipt is just a funny test, how such a can, might be filled during an
8# analysis ...
9# it is possible to execute this script
10#
11# the output can be read in, and will be displayed by
12# canread.py
13import sys
14import pickle
15import random
16confirm_next_step = False
17
18# this little can will hold
19# * all the settings,
20# * all results and intermediate results
21# * as well as this script itself
22# and then it will be written, to an output file
23analysis = {}
24can['input'] = {} #
25can['settings'] = {} # a subspace for holdind all settings
26can['output'] = {} # a subspace for holding all results... or similar stuff
27can['logbook'] = [] # a list of statements ... human readable logbook
28can['src'] = [] # this script and other sources
29
30# store this scipt in the list of sources.
31can['src'].append( open(sys.argv[0], 'r').read() )
32
33# declare filenames to work with:
34can['settings']['data_file_names'] = ['/media/daten_platte/FACT/data/20120229_144.fits.gz']
35can['settings']['calib_file_names'] = ['/media/daten_platte/FACT/data/20120229_132.drs.fits.gz']
36# we even tell the can, where we are going to store it
37can['settings']['outfile_name'] = './can.pkl' # <-- no list ... simple string
38
39
40# put the settings for all the extractors and similar data processors
41# into the settings
42can['settings']['SlidingAverage'] = [8]
43can['settings']['DRSSpikes'] = []
44can['settings']['GlobalMaxFinder'] = [40,200]
45can['settings']['AmplitudeCleaner'] = [45,18,'return_bool_mask=False']
46
47# prepare some space in the can, for the results of this script
48can['results']['areas'] = []
49can['results']['sizes'] = []
50# and make some shortcuts
51areas = can['results']['areas']
52sizes = can['results']['sizes']
53
54# this loop will loop over all events, out of all data files in the can,
55# so the analysis loop doesn't even know, there are more files involved.
56# of course in the logbook the opening and closing will be stored
57for data in range(100):
58 if True:
59
60 size = 0
61 for i in range(data):
62 size += data
63
64 area = random.randint(0,data)
65 if area > 4:
66 areas.append( area )
67 sizes.append( size )
68 # we suddenly realize, that we would like to store
69 # the event IDs of events, which are have no survivors
70 # we should scroll up ... before the loop and declare an empty list
71 # like: can['results']['no_survivor_ids'] = []
72 # but imagine we are writing a function, which is beeing called inside the loop
73 # and this function has no possibility to declare that ...
74 # well then this function can still put new things inside the can!
75 else:
76 if 'no_survivor_ids' not in can['results']:
77 can['results']['no_survivor_ids'] = [data]
78 else:
79 can['results']['no_survivor_ids'].append(data)
80
81 if confirm_next_step:
82 user_input = raw_input("'q'-quit, 'r'-run, anything else goes one step")
83 number=None
84 try:
85 number=int(user_input)
86 except:
87 number=None
88 if user_input.find('q') != -1:
89 sys.exit(0)
90 elif user_input.find('r') != -1:
91 confirm_next_step = False
92 elif number!=None:
93 run += number
94
95# Now our analysis is done and we save the can
96output = open(can['settings']['outfile_name'], 'wb')
97pickle.dump(can, output)
98output.close()
Note: See TracBrowser for help on using the repository browser.