def get_files_metadata(self): """ Same as `get_files()` but with additional metadata. Returns a list of dictionaries, sorted by file number aka sub run. """ from icecube import dataclasses files = self.get_files() metadata = { int(f['file_number']): f for f in self._get_file_metadata() } data = [] for f in files: file_number = self._find_file_number(f) if file_number not in metadata: raise RuntimeError( 'No metadata avilable for run {run_id}, file #{file_number} ({path})' .format(run_id=self['run_id'], file_number=file_number, path=f)) entry = { 'path': f, 'file_number': file_number, 'livetime': float(metadata[file_number]['livetime']), 'first_event': int(metadata[file_number]['first_event']), 'last_event': int(metadata[file_number]['last_event']), 'first_event_time': dataclasses.I3Time( int(metadata[file_number]['first_event_year']), int(metadata[file_number]['first_event_frac'])), 'last_event_time': dataclasses.I3Time( int(metadata[file_number]['last_event_year']), int(metadata[file_number]['last_event_frac'])) } data.append(entry) return sorted(data, key=lambda f: f['file_number'])
def test_I3Calibration_equality(self): cal1 = dataclasses.I3Calibration() cal1.dom_cal = dataclasses.I3DOMCalibrationMap() cal1.vem_cal = dataclasses.I3VEMCalibrationMap() cal1.start_time = dataclasses.I3Time() cal1.end_time = dataclasses.I3Time() cal2 = dataclasses.I3Calibration() cal2.dom_cal = dataclasses.I3DOMCalibrationMap() cal2.vem_cal = dataclasses.I3VEMCalibrationMap() cal2.start_time = dataclasses.I3Time() cal2.end_time = dataclasses.I3Time() self.assertEqual(cal1, cal2, "these should be the same.")
def test_I3DetectorStatus_equality(self): stat1 = dataclasses.I3DetectorStatus() stat1.dom_status = dataclasses.I3DOMStatusMap() stat1.trigger_status = dataclasses.I3TriggerStatusMap() stat1.start_time = dataclasses.I3Time() stat1.end_time = dataclasses.I3Time() stat2 = dataclasses.I3DetectorStatus() stat2.dom_status = dataclasses.I3DOMStatusMap() stat2.trigger_status = dataclasses.I3TriggerStatusMap() stat2.start_time = dataclasses.I3Time() stat2.end_time = dataclasses.I3Time() self.assertEqual(stat1, stat2, "these should be the same.")
def test_I3Geometry_equality(self): geo1 = dataclasses.I3Geometry() geo1.omgeo = dataclasses.I3OMGeoMap() geo1.stationgeo = dataclasses.I3StationGeoMap() geo1.start_time = dataclasses.I3Time() geo1.end_time = dataclasses.I3Time() geo2 = dataclasses.I3Geometry() geo2.omgeo = dataclasses.I3OMGeoMap() geo2.stationgeo = dataclasses.I3StationGeoMap() geo2.start_time = dataclasses.I3Time() geo2.end_time = dataclasses.I3Time() self.assertEqual(geo1, geo2, "these should be the same.")
def equa_to_dir(ra, dec, mjd): """ Get the IceCube `zenith` and `azimuth` of an equatorial coordinate (Right Ascension and Declination) at a given time `mjd`. Warnings -------- This function is significantly slower than :py:func:`dir_to_equa`, it is highly recommended that if you need to perfrom a significant number of calculations that you go from local to equatorial coordinates and perform the analyses in equatorial coordinates, rather than the reverse. Parameters ---------- ra : array_like Right Ascension (J2000) of the event dec : array_like Declination (J2000) of the event mjd: array_like float Modified julian date of the event as a floating point Returns ------- zenith : array_like IceCube zenith direction azimuth : array_like IceCube azimuthal direction """ eq = I3Equatorial(ra, dec) i3time = dataclasses.I3Time() i3time.set_mod_julian_time_double(mjd) i3dir = I3GetDirectionFromEquatorial(eq, i3time) return i3dir.zenith, i3dir.azimuth
def test_dir_from_equa(self): random.seed(0) t1 = dataclasses.I3Time() t1.set_utc_cal_date(2000, 1, 1, 0, 0, 0, 0.0) mjd1 = t1.mod_julian_day_double t1.set_utc_cal_date(2030, 1, 1, 0, 0, 0, 0.0) mjd2 = t1.mod_julian_day_double for n in range(1000): t1.set_mod_julian_time_double(random.uniform(mjd1, mjd2)) eq = astro.I3Equatorial(random.uniform(0, 2 * math.pi), random.uniform(-math.pi / 2, math.pi / 2)) d = astro.I3GetDirectionFromEquatorial(eq, t1) eqprime = astro.I3GetEquatorialFromDirection(d, t1) self.assert_almost_equal(eq.ra * math.cos(eq.dec), eqprime.ra * math.cos(eqprime.dec), 4e-6) self.assert_almost_equal(eq.dec, eqprime.dec, 4e-6) self.assert_less( astro.angular_distance(eq.ra, eq.dec, eqprime.ra, eqprime.dec), 5e-6)
def inject_header(frame): time = dc.I3Time() time.set_mod_julian_time(options.MJD, 0, 0.0) eh = dc.I3EventHeader() eh.start_time = time eh.end_time = time frame["I3EventHeader"] = eh
def Process(self): try: c = next(self.lines) except StopIteration: self.RequestSuspension() return eq = astro.I3Equatorial(c[0] * I3Units.degree, c[1] * I3Units.degree) time = dataclasses.I3Time(2015, 0) direction = astro.I3GetDirectionFromEquatorial(eq, time) eqq = astro.I3GetEquatorialFromDirection(direction, time) particle = dataclasses.I3Particle() particle.dir = direction header = dataclasses.I3EventHeader() header.start_time = time frame = icetray.I3Frame("P") if self.evthdr: frame["I3EventHeader"] = header frame["Particle"] = particle self.PushFrame(frame)
def dir_to_equa(zenith, azimuth, mjd): """ Get the equatorial coordinates (right ascension and declination) of an IceCube event (`zenith` and `azimuth`) at a given time (`mjd`). Parameters ---------- zenith : array_like IceCube zenith of the direction azimuth: array_like IceCube azimuth of the direction mjd: array_like Modified julian date of the event as as floating point Returns ------- ra : array_like Right Ascension in J2000 dec : array_like Declination in J2000 """ i3dir = dataclasses.I3Direction(zenith, azimuth) i3time = dataclasses.I3Time() i3time.set_mod_julian_time_double(mjd) eq = I3GetEquatorialFromDirection(i3dir, i3time) return eq.ra, eq.dec
def equa_to_dir(ra, dec, mjd): """ Get the IceCube `zenith` and `azimuth` of an equatorial coordinate (Right Ascension and Declination) at a given time `mjd`. Parameters ---------- ra : array_like Right Ascension (J2000) of the event dec : array_like Declination (J2000) of the event mjd: array_like float Modified julian date of the event as a floating point Returns ------- zenith : array_like IceCube zenith direction azimuth : array_like IceCube azimuthal direction """ eq = I3Equatorial(ra, dec) i3time = dataclasses.I3Time() i3time.set_mod_julian_time_double(mjd) i3dir = I3GetDirectionFromEquatorial(eq, i3time) return i3dir.zenith, i3dir.azimuth
def test_equa_from_dir(self): random.seed(0) t1 = dataclasses.I3Time() t1.set_utc_cal_date(2000, 1, 1, 0, 0, 0, 0.0) mjd1 = t1.mod_julian_day_double t1.set_utc_cal_date(2030, 1, 1, 0, 0, 0, 0.0) mjd2 = t1.mod_julian_day_double for n in range(1000): t1.set_mod_julian_time_double(random.uniform(mjd1, mjd2)) d = dataclasses.I3Direction( random.uniform(0, math.pi), random.uniform(0, 2 * math.pi), ) eq = astro.I3GetEquatorialFromDirection(d, t1) dprime = astro.I3GetDirectionFromEquatorial(eq, t1) self.assert_almost_equal(d.zenith, dprime.zenith, 5e-6) self.assert_almost_equal(d.azimuth * math.sin(d.zenith), dprime.azimuth * math.sin(d.zenith), 6e-6) self.assert_less( astro.angular_distance(d.azimuth, math.pi / 2 - d.zenith, dprime.azimuth, math.pi / 2 - dprime.zenith), 6e-6)
def Configure(self): mjd = self.GetParameter("MJD") sec = self.GetParameter("MJDSeconds") nanosec = self.GetParameter("MJDNanoSeconds") self.rand = self.GetParameter("Randomize") self.rng = self.GetParameter("RNG") self.time = dataclasses.I3Time() self.time.set_mod_julian_time(mjd,sec,nanosec)
def run_booker(self, horizons_filename, body): ephem = test_horizons.read_horizons(horizons_filename) csv_dir_name = "tableout" csv_filename = os.path.join(csv_dir_name, "I3EventHeader.csv") tray = I3Tray() tray.Add(generator, times=ephem['date']) tray.Add(tableio.I3TableWriter, tableservice=[tableio.I3CSVTableService(csv_dir_name)], keys={ 'I3EventHeader': [ astro.converters.I3SunAndMoonConverter(), dataclasses.converters.I3EventHeaderConverter() ], }) tray.Execute() tray.Finish() del tray with open(csv_filename, 'r') as csvfile: reader = csv.reader(csvfile) header = reader.next() keys = [ 'time_start_mjd_day [days]', 'time_start_mjd_sec [seconds]', 'time_start_mjd_ns [ns]', body + '_zenith [radian]', body + '_azimuth [radian]' ] indices = {} for k in keys: indices[k] = header.index(k) #skip info row reader.next() for line_number, row in enumerate(reader): #row_values = [row[indices[k]] for k in keys] t = dataclasses.I3Time() t.set_mod_julian_time( int(row[indices['time_start_mjd_day [days]']]), int(row[indices['time_start_mjd_sec [seconds]']]), float(row[indices['time_start_mjd_ns [ns]']])) self.assertEqual( t, dataclasses.make_I3Time(ephem['date'][line_number])) assert ( abs(90 - float(row[indices[body + '_zenith [radian]']]) / I3Units.degree - ephem['el'][line_number]) < 0.003) assert (test_horizons.azimuth_distance( 90 - (float(row[indices[body + '_azimuth [radian]']]) + astro.ICECUBE_LONGITUDE) / I3Units.degree, ephem['az'][line_number]) < 1.)
def GenerateBundles(tray, name, Generator=None, RunNumber=1, NEvents=100, GCDFile='/data/sim/sim-new/downloads/GCD_31_08_11/GeoCalibDetectorStatus_IC79.55380_L2a.i3.gz', FromTime=dataclasses.I3Time(55380), ToTime=dataclasses.I3Time(55380)): """ Generate muon bundles from a parametrization. :param Generator: an instance of I3MuonGun.Generator """ from icecube import icetray, dataclasses from icecube import sim_services, MuonGun RandomService = tray.context['I3RandomService'] tray.AddModule("I3InfiniteSource",name+"_streams", Prefix=GCDFile, Stream=icetray.I3Frame.DAQ) # modify the header if necessary by generating a random time # between StartTime and EndTime def GenRandomTime(frame, StartTime, EndTime, RandomService): header = dataclasses.I3EventHeader() mjdStart = StartTime.mod_julian_day_double mjdEnd = EndTime.mod_julian_day_double mjd = mjdStart + (RandomService.uniform(0.,1.)*(mjdEnd-mjdStart)) eventTime = dataclasses.I3Time() eventTime.set_mod_julian_time_double(mjd) header.start_time = eventTime frame["I3EventHeader"] = header if FromTime != ToTime: if RandomService is None: raise ValueError("You must specify a random service!") tray.AddModule(GenRandomTime, name+"_GenRandomTime", StartTime=FromTime, EndTime=ToTime, RandomService=RandomService, Streams=[icetray.I3Frame.DAQ]) tray.AddModule('I3MuonGun::GeneratorModule',name, Generator=NEvents*Generator)
def sun_dir(mjd): """ Get the location of the Sun in IceCube local coordinates `zenith` and `azimuth` for a given time in `mjd` """ i3time = dataclasses.I3Time() i3time.set_mod_julian_time_double(mjd) i3dir = I3GetSunDirection(i3time) return i3dir.zenith, i3dir.azimuth
def GenRandomTime(frame, StartTime, EndTime, RandomService): header = dataclasses.I3EventHeader() mjdStart = StartTime.mod_julian_day_double mjdEnd = EndTime.mod_julian_day_double mjd = mjdStart + (RandomService.uniform(0.,1.)*(mjdEnd-mjdStart)) eventTime = dataclasses.I3Time() eventTime.set_mod_julian_time_double(mjd) header.start_time = eventTime frame["I3EventHeader"] = header
def dir_to_equa(zenith, azimuth, mjd_list): ra = [] dec = [] for mjd in mjd_list: i3dir = dataclasses.I3Direction(zenith, azimuth) i3time = dataclasses.I3Time() i3time.set_mod_julian_time_double(mjd) eq = astro.I3GetEquatorialFromDirection(i3dir, i3time) ra.append(eq.ra) dec.append(eq.dec) # results.append((eq.ra,eq.dec)) return ra, dec
def Process(self): """ deliver frames QP with only a bit of rudamentary information """ #make a Q-frame Qframe = icetray.I3Frame(icetray.I3Frame.DAQ) Qeh = dataclasses.I3EventHeader() Qeh.start_time = (dataclasses.I3Time(2011, 0)) Qeh.end_time = (dataclasses.I3Time(2011, 2)) Qeh.run_id = 1 Qeh.event_id = 1 Qframe.Put("I3EventHeader", Qeh) Qrecomap = dataclasses.I3RecoPulseSeriesMap() recopulse1 = dataclasses.I3RecoPulse() recopulse1.time = 0 recopulse1.charge = 1 recopulse2 = dataclasses.I3RecoPulse() recopulse2.time = 1 recopulse2.charge = 2 Qrecomap[icetray.OMKey(1,1)] = [recopulse1] Qrecomap[icetray.OMKey(2,2)] = [recopulse2] Qframe.Put(OrgPulses, Qrecomap) Qframe.Put(SplitName+"SplitCount", icetray.I3Int(1)) self.PushFrame(Qframe) #now make the first p-frame containing one I3RecoPulse P1frame = icetray.I3Frame(icetray.I3Frame.Physics) P1eh = dataclasses.I3EventHeader() P1eh.start_time = (dataclasses.I3Time(2011, 0)) P1eh.end_time = (dataclasses.I3Time(2011, 1)) P1eh.run_id = 1 P1eh.event_id = 1 P1eh.sub_event_stream = "split" P1eh.sub_event_id = 0 P1frame.Put("I3EventHeader", P1eh) P1recomap = dataclasses.I3RecoPulseSeriesMap() P1recomap[icetray.OMKey(1,1)] = [recopulse1] P1recomask = dataclasses.I3RecoPulseSeriesMapMask(Qframe, OrgPulses, Qrecomap) P1frame.Put(SplitPulses, P1recomask) self.PushFrame(P1frame) self.RequestSuspension()
def test_gmst(self): i3t0 = dataclasses.I3Time() i3t0.set_utc_cal_date(2000, 1, 1, 0, 0, 0, 0) for day in np.linspace(0, 365 * 100, 1): # run over a century for hour in np.linspace(0, 24, 1): for minute in np.linspace(0, 60, 1): i3time = i3t0 + day * minute * 60 * I3Units.s i3gmst_a = astro.I3GetGMST(i3time) i3gmst_b = self.caclulate_gmst( i3time.mod_julian_day_double) assert (abs(i3gmst_a - i3gmst_b) < 0.000002)
def WimpSimReaderEarth(tray, name, GCDFileName=None, Infile=None, StartMJD=None, EndMJD=None): """ run this traysegement for earth files :param Infile: infile to read :param GCDFileName: specify either this to take the detector start_time as event-time -or- use a random time-stamp in [startMJD, endMJD] :param StartMJD: pick a random MJD starting from this time :param EndMJD: pick a random MJD ending at this time """ def get_time(gcdfile): frame = gcdfile.pop_frame() while not frame.Has("I3DetectorStatus"): frame = gcdfile.pop_frame() return frame.Get("I3DetectorStatus").start_time time = dataclasses.I3Time() if GCDFileName != None: print("Will use (GCDFile)DetectorStatus.start_time for timing") if not GCD == "": #if -g was specified used the runstartttime of that GCD file time = get_time(dataio.I3File(options.GCD)) if (Infile == None): print('choose an infile') tray.AddModule("I3WimpSimReader", name+"WimpSimReader", FileNameList = [Infile], #default "" StartMJD = StartMJD, #default 0 EndMJD = EndMJD, #default 0 NEvents = 0, #default 0 Oversampling = 0, #default 0 PositionLimits = [-800.,800.,-800.,800.,-800.,800.], #default [-800*I3Units.meter,800*I3Units.meter,-800*I3Units.meter,800*I3Units.meter,-800*I3Units.meter,800*I3Units.meter] InjectionRadius = 0*I3Units.meter , #default 0*I3Units.meter LowerZenCut = 0*I3Units.degree , #default 0*I3Units.degree UpperZenCut = 180*I3Units.degree , #default 180*I3Units.degree UseElectrons = False, #default False UseMuons = True, #default True UseTaus = False, #default False UseNC = False, #default False SensitiveHeight = 700*I3Units.meter, #default 0*I3Units.meter SensitiveRadius = 1800*I3Units.meter, #default 0*I3Units.meter )
def test_radec(self): src_dec = 22.01450 for src_ra in np.linspace(0, 360, 1): i3src = astro.I3Equatorial(src_ra * I3Units.degree, src_dec * I3Units.degree) i3t0 = dataclasses.I3Time() i3t0.set_utc_cal_date(2000, 1, 1, 0, 0, 0, 0) for day in np.linspace(0, 10000, 100): i3time = i3t0 + day * 86400 * I3Units.s i3dir = astro.I3GetDirectionFromEquatorial(i3src, i3time) i3az = i3dir.azimuth / I3Units.degree i3zen = i3dir.zenith / I3Units.degree #this equation from inspecting the output of ephempy paz = (189.9640733918 - src_ra + day * 360.985606808) % 360 pzen = 90 + src_dec assert (azimuth_distance(i3az, paz) < 0.2) assert (abs(i3zen - pzen) < 0.2)
def set_time(fr): fr['DrivingTime'] = dataclasses.I3Time(2006, 0)
#!/usr/bin/env python # # @copyright (C) 2015 The IceCube Collaboration # # @author Kevin Meagher # @date August 2015 """ Simple example demonstraing all the functions in astro """ from icecube.icetray import I3Units from icecube import dataclasses, astro time = dataclasses.I3Time() time.set_mod_julian_time_double(56819.20444852863) #calculate the position of the moon moon_direction = astro.I3GetMoonDirection(time) print( "At {} the moon will be at zenith={:8.4f} deg, azimuth={:7.4f} deg".format( str(time), moon_direction.zenith / I3Units.degree, moon_direction.azimuth / I3Units.degree, )) print #calculate the position of the sun sun_direction = astro.I3GetSunDirection(time)
def testTypes(self): #try to access all keys of the params WimpParams = self.frame[self.WimpParamsName] self.assert_( isinstance(WimpParams, simclasses.I3WimpParams) and WimpParams != simclasses.I3WimpParams(), "WimpParams exists and not the default constructor") self.assert_( isinstance(WimpParams.mass, float) and WimpParams.mass != 0., "WimpParams.mass exists and is set") self.assert_( isinstance(WimpParams.channel, simclasses.I3WimpParams.DecayChannel) and WimpParams.channel != simclasses.I3WimpParams.DecayChannel.unknown, "WimpParams.channel exists and is set") self.assert_( isinstance(WimpParams.source, simclasses.I3WimpParams.SourceType) and WimpParams.source != simclasses.I3WimpParams.SourceType.UNKNOWN, "WimpParams.time exists and is set") self.assert_( isinstance(WimpParams.nu_weight, float) and WimpParams.nu_weight != 0., "WimpParams.nu_weight exists and is set") self.assert_( isinstance(WimpParams.lep_weight, float) and WimpParams.lep_weight != 0., "WimpParams.lep_weight exists and is set") self.assert_( isinstance(WimpParams.had_weight, float) and WimpParams.had_weight != 0., "WimpParams.had_weight exists and is set") self.assert_( isinstance(WimpParams.vgen, float) and WimpParams.vgen != 0., "WimpParams.vgen exists and is set") self.assert_(isinstance(WimpParams.time, dataclasses.I3Time), "WimpParams.time exists") #try to access all the particles in the mctree WimpMCTree = self.frame[self.WimpMCTreeName] self.assert_( isinstance(WimpMCTree, dataclasses.I3MCTree) and WimpMCTree != dataclasses.I3MCTree(), "WimpMCTree exists and is not the default constructor") #try to access all set parameters in the I3EventHeader EventHeader = self.frame[self.EventHeaderName] self.assert_( isinstance(EventHeader, dataclasses.I3EventHeader) and EventHeader != dataclasses.I3EventHeader(), "EventHeader exists and is not the default constructor") #try to access all set parameters in the I3EventHeader #test values self.assert_(WimpParams.mass == 1000, "The wimpMass is correctly 1000") self.assert_(WimpParams.channel == 5, "WIMPs have corectly annihilated trough the 5(w) channel" ) #simclasses.I3WimpParams.w self.assert_(WimpParams.source == simclasses.I3WimpParams.EARTH, "it is the EARTH") #test the values: MCTree self.assert_( len(WimpMCTree.primaries) == 1, "found exactly one primary") self.assert_( len(WimpMCTree.get_daughters(WimpMCTree.primaries[0])) == 2, "found my two daughter particles and they are asserted") #test the values EentHeader: self.assert_(EventHeader.start_time != dataclasses.I3Time(), "EventHeader.start_time is set") self.assert_(EventHeader.run_id == 0, "EventHeader.run_id is correctly set") self.assert_(EventHeader.event_id == self.count_up, "EventHeader.event_id is correctly set") self.count_up += 1
print(" %s" % str(event_header.start_time)) print(" %s" % str(self.event_header.start_time)) self.assertNotEqual(time_difference, 0, "TimeRange is not working correctly.") self.event_header = event_header tray = I3Tray() tray.context["I3RandomService"] = phys_services.I3GSLRandomService(1618); gcd_file = expandvars("$I3_TESTDATA/sim/GeoCalibDetectorStatus_2013.56429_V1.i3.gz") tray.AddModule("I3InfiniteSource", prefix=gcd_file, stream=icetray.I3Frame.DAQ) tray.AddModule(frame_setup, Streams = [icetray.I3Frame.DAQ]) tray.AddModule("I3GlobalTriggerSim", I3DOMLaunchSeriesMapNames = ["InIceRawData"], FromTime = dataclasses.I3Time(53005), ToTime = dataclasses.I3Time(53006), FilterMode = False, RunID = 0) tray.AddModule(icetray.I3TestModuleFactory(TestGlobalTriggerSim), Streams = [icetray.I3Frame.DAQ]) tray.Execute(10000) tray.Finish()
exit(-1) import os import sys import shutil print os.uname() from icecube import icetray, dataclasses, dataio, phys_services if options.DETECTOR not in ("IC79", "IC86"): raise RuntimeError("unknown detector %s. use IC79 or IC86" % options.DETECTOR) eventGenerationTimes = { 'IC86': dataclasses.I3Time( 2011, 158100000000000000), # 2011-07-02 23:40:00.000,000,000,0 UTC 'IC79': dataclasses.I3Time(2010, 158100000000000000) } # 2010-07-02 23:40:00.000,000,000,0 UTC eventGenerationTime = eventGenerationTimes[options.DETECTOR] if options.GCDFILE == "auto": gcdFilesDefault = { 'IC86': expandvars( "$I3_TESTDATA/sim/GeoCalibDetectorStatus_IC86.55697_corrected_V2.i3.gz" ), 'IC79': expandvars( "$I3_TESTDATA/sim/GeoCalibDetectorStatus_IC79.55380_L2a.i3.gz"), } gcdFile = gcdFilesDefault[options.DETECTOR]
print("Working out CutValues") ## This is just a dumb container. cv = phys_services.I3CutValues() cog_pos = dataclasses.I3Position(0.0, 0.0, 0.0) cv.cog = cog_pos cv.ldir = 500.5 * icetray.I3Units.m cv.ndir = 5 cv.nchan = 55 print("your I3CutValues: %s %.2f %d %d" % (cv.cog, cv.ldir, cv.ndir, cv.nchan)) print("Working out GCDFileService") mytime = dataclasses.I3Time(2010, 158082172000000000) infile = os.path.expandvars( "$I3_TESTDATA/GCD/GeoCalibDetectorStatus_IC86.55697_corrected_V2.i3.gz") my_fs = phys_services.I3GCDFileCalibrationService(infile) my_cal = my_fs.get_calibration(mytime) print("I found calibrations for %d DOMs" % len(my_cal.dom_cal)) print("Working out randoms") rng = phys_services.I3GSLRandomService(31334) print("Please take these 100 rands") print([rng.gaus(0, 1) for x in range(100)])
def Process(self): gcd = dataio.I3File(self.gcdfile, 'R') while (gcd.more()): frame = gcd.pop_frame() self.PushFrame(frame) gcd.close() #now deliver artificial testcase #make a Q-frame#make a Q-frame Qframe = icetray.I3Frame(icetray.I3Frame.DAQ) Qeh = dataclasses.I3EventHeader() Qeh.start_time = (dataclasses.I3Time(2011, 0)) Qeh.end_time = (dataclasses.I3Time(2011, 2)) Qeh.run_id = 1 Qeh.event_id = 1 Qframe.Put("I3EventHeader", Qeh) Qrecomap = dataclasses.I3RecoPulseSeriesMap() recopulse1 = dataclasses.I3RecoPulse() recopulse1.time = 0 recopulse1.charge = 1 recopulse2 = dataclasses.I3RecoPulse() recopulse2.time = 1 recopulse2.charge = 2 Qrecomap[icetray.OMKey(1, 1)] = [recopulse1] Qrecomap[icetray.OMKey(2, 2)] = [recopulse2] Qframe.Put(OrgPulses, Qrecomap) Qframe.Put(SplitName + "SplitCount", icetray.I3Int(2)) Qframe.Put(SplitName + "ReducedCount", icetray.I3Int(0)) self.PushFrame(Qframe) #now make the first p-frame containing one I3RecoPulse P1frame = icetray.I3Frame(icetray.I3Frame.Physics) P1eh = dataclasses.I3EventHeader() P1eh.start_time = (dataclasses.I3Time(2011, 0)) P1eh.end_time = (dataclasses.I3Time(2011, 1)) P1eh.run_id = 1 P1eh.event_id = 1 P1eh.sub_event_stream = SplitName P1eh.sub_event_id = 0 P1frame.Put("I3EventHeader", P1eh) P1recomap = dataclasses.I3RecoPulseSeriesMap() P1recomap[icetray.OMKey(1, 1)] = [recopulse1] P1recomask = dataclasses.I3RecoPulseSeriesMapMask( Qframe, OrgPulses, Qrecomap) P1frame.Put(SplitPulses, P1recomask) self.PushFrame(P1frame) #now make the second p-frame containing one I3RecoPulse P2frame = icetray.I3Frame(icetray.I3Frame.Physics) P2eh = dataclasses.I3EventHeader() P2eh.start_time = (dataclasses.I3Time(2011, 1)) P2eh.end_time = (dataclasses.I3Time(2011, 2)) P2eh.run_id = 1 P2eh.event_id = 1 P2eh.sub_event_stream = SplitName P2eh.sub_event_id = 1 P2frame.Put("I3EventHeader", P2eh) P2recomap = dataclasses.I3RecoPulseSeriesMap() P2recomap[icetray.OMKey(2, 2)] = [recopulse2] P2recomask = dataclasses.I3RecoPulseSeriesMapMask( Qframe, OrgPulses, P2recomap) P2frame.Put(SplitPulses, P2recomask) self.PushFrame(P2frame) self.RequestSuspension()
def Process(self): gcd = dataio.I3File(self.gcdfile, 'R') while (gcd.more()): frame = gcd.pop_frame() self.PushFrame(frame) gcd.close() #now deliver artificial testcase #make a Q-frame Qframe = icetray.I3Frame(icetray.I3Frame.DAQ) Qeh = dataclasses.I3EventHeader() Qeh.start_time = (dataclasses.I3Time(2011, 0)) Qeh.end_time = (dataclasses.I3Time(2011, 2)) Qeh.run_id = 1 Qeh.event_id = 1 Qframe.Put("I3EventHeader", Qeh) Qrecomap = dataclasses.I3RecoPulseSeriesMap() recopulse1 = dataclasses.I3RecoPulse() recopulse1.time = 0 recopulse1.charge = 1 recopulse2 = dataclasses.I3RecoPulse() recopulse2.time = 1 recopulse2.charge = 2 Qrecomap[icetray.OMKey(1,1)] = [recopulse1] Qrecomap[icetray.OMKey(2,2)] = [recopulse2] Qframe.Put(OrgPulses, Qrecomap) Qframe.Put(SplitName+"SplitCount", icetray.I3Int(2)) Qframe.Put(SplitName+"ReducedCount", icetray.I3Int(0)) self.PushFrame(Qframe) #now make the first p-frame containing one I3RecoPulse P1frame = icetray.I3Frame(icetray.I3Frame.Physics) P1eh = dataclasses.I3EventHeader() P1eh.start_time = (dataclasses.I3Time(2011, 0)) P1eh.end_time = (dataclasses.I3Time(2011, 1)) P1eh.run_id = 1 P1eh.event_id = 1 P1eh.sub_event_stream = "split" P1eh.sub_event_id = 0 P1frame.Put("I3EventHeader", P1eh) P1recomap = dataclasses.I3RecoPulseSeriesMap() P1recomap[icetray.OMKey(1,1)] = [recopulse1] P1recomask = dataclasses.I3RecoPulseSeriesMapMask(Qframe, OrgPulses, Qrecomap) P1frame.Put(SplitPulses, P1recomask) P1fit = dataclasses.I3Particle() P1fit.pos= dataclasses.I3Position(0.,0., CriticalDistance) P1fit.dir= dataclasses.I3Direction(0., CriticalAngle) P1fit.fit_status = dataclasses.I3Particle.OK P1frame.Put("Fit", P1fit) self.PushFrame(P1frame) #now make the second p-frame containing one I3RecoPulse P2frame = icetray.I3Frame(icetray.I3Frame.Physics) P2eh = dataclasses.I3EventHeader() P2eh.start_time = (dataclasses.I3Time(2011, 1)) P2eh.end_time = (dataclasses.I3Time(2011, 2)) P2eh.run_id = 1 P2eh.event_id = 1 P2eh.sub_event_stream = "split" P2eh.sub_event_id = 1 P2frame.Put("I3EventHeader", P2eh) P2recomap = dataclasses.I3RecoPulseSeriesMap() P2recomap[icetray.OMKey(2,2)] = [recopulse2] P2recomask = dataclasses.I3RecoPulseSeriesMapMask(Qframe, OrgPulses, P2recomap) P2frame.Put(SplitPulses, P2recomask) P2fit = dataclasses.I3Particle() P2fit.pos= dataclasses.I3Position(0.,0., CriticalDistance) P2fit.dir= dataclasses.I3Direction(0., -CriticalAngle) P2fit.fit_status = dataclasses.I3Particle.OK P2frame.Put("Fit", P2fit) self.PushFrame(P2frame) Hframe = icetray.I3Frame(icetray.I3Frame.Physics) Heh = dataclasses.I3EventHeader() Heh.start_time = (dataclasses.I3Time(2011, 0)) Heh.end_time = (dataclasses.I3Time(2011, 2)) Heh.run_id = 1 Heh.event_id = 1 Heh.sub_event_stream = HypoName Heh.sub_event_id = 0 Hframe.Put("I3EventHeader", Heh) Hrecomap = dataclasses.I3RecoPulseSeriesMap() Hrecomap[icetray.OMKey(1,1)] = [recopulse1] Hrecomap[icetray.OMKey(2,2)] = [recopulse2] Hrecomask = dataclasses.I3RecoPulseSeriesMapMask(Qframe, OrgPulses, Hrecomap) Hframe.Put(SplitPulses, Hrecomask) Hcf = dataclasses.I3MapStringVectorDouble() Hcf["split"]=[0,1] Hframe.Put("CS_CreatedFrom", Hcf) Hfit = dataclasses.I3Particle() Hfit.time= 0 Hfit.pos= dataclasses.I3Position(0.,0.,0.) Hfit.dir= dataclasses.I3Direction(0., 0.) Hfit.fit_status = dataclasses.I3Particle.OK Hframe.Put("HFit", Hfit) self.PushFrame(Hframe) self.RequestSuspension()
self.frame["TriggerID"].value) self.assertEquals(self.frame["I3EventHeader"].event_id, frame["I3EventHeader"].event_id) self.assertEquals(self.frame["I3EventHeader"].run_id, frame["I3EventHeader"].run_id) phys_frames += 1 def Finish(self): self.assertEquals(phys_frames, max_phys_frames) # Manufacture a file. fname = os.environ["I3_BUILD"] + "/daq_frame_test.i3.gz" if os.path.exists(fname): os.unlink(fname) the_time = dataclasses.I3Time() the_time.set_utc_cal_date(1919, 1, 15, 0, 0, 0, 0) f = dataio.I3File(fname, "w") geo = dataclasses.I3Geometry() geo.start_time = the_time - 100 geo.end_time = the_time + 100 calib = dataclasses.I3Calibration() calib.start_time = the_time - 100 calib.end_time = the_time + 100 status = dataclasses.I3DetectorStatus() status.start_time = the_time - 100 status.end_time = the_time + 100 frame = icetray.I3Frame(icetray.I3Frame.Geometry) frame['I3Geometry'] = geo f.push(frame) frame = icetray.I3Frame(icetray.I3Frame.Calibration)