-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeoSkimmer.py
More file actions
51 lines (37 loc) · 1.62 KB
/
GeoSkimmer.py
File metadata and controls
51 lines (37 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from icecube import icetray, dataio
from icecube.icetray import I3LogLevel
from FilterFrame import FilterFrame
from argparse import ArgumentParser
import csv
icetray.I3Logger.global_logger.set_level(I3LogLevel.LOG_INFO)
usage = "usage: %prog [options]"
parser = ArgumentParser(usage)
parser.add_argument("-i","--infile",default=None, help="read from infile (.i3{.gz} format)")
parser.add_argument("-o","--outfile",default=None,help="Write output to outfile (.i3{.gz} format)")
parser.add_argument("-s","--selectionfile",default="strings.csv",help="csv file with list of strings to keep in selection")
parser.add_argument("-g","--gcdfile", default=None,help="read in gcdfile (.i3{.gz} format)")
parser.add_argument("-t","--outgcd", default=None,help="filtered gcdfile (.i3{.gz} format)")
options = parser.parse_args()
outfile = options.outfile
outgcd = options.outgcd
infile = options.infile
ingcd = options.gcdfile
allowed_strings = []
with open(options.selectionfile, 'r') as file:
reader = csv.reader(file)
for row in reader:
allowed_strings=list(map(int,row))
icetray.logging.log_info(f"selected strings: {allowed_strings}")
tray = icetray.I3Tray()
infiles = []
if infile: infiles.append(infile)
if ingcd: infiles.append(ingcd)
if not infiles:
print("No input")
sys.exit(1)
tray.Add("I3Reader", FilenameList=infiles)
tray.Add(FilterFrame, AllowedStrings=allowed_strings)
if outfile: tray.Add("I3Writer", Filename=outfile, Streams=[icetray.I3Frame.DAQ])
if outgcd: tray.Add("I3Writer", Filename=outgcd, Streams=[icetray.I3Frame.Geometry, icetray.I3Frame.Calibration, icetray.I3Frame.DetectorStatus])
tray.Execute()
tray.Finish()