예제 #1
0
    def Calibration(self, frame):
        domcal = frame['I3Calibration'].dom_cal
        n_valid = sum([1 for omkey, i3domcal in domcal.iteritems() \
            if i3domcal.combined_spe_charge_distribution.is_valid])

        n_nan_atwd_charge = 0
        n_nan_fadc_charge = 0
        for omkey, i3domcal in domcal.iteritems():
            if i3domcal.combined_spe_charge_distribution.is_valid:
                # it's not true in general, but for this test file
                # whenever the combined fits are valid, the mean
                # ATWD and FADC charges should be non-NaN as well
                if isnan(i3domcal.mean_atwd_charge):
                    n_nan_atwd_charge += 1
                if isnan(i3domcal.mean_fadc_charge):
                    n_nan_fadc_charge += 1

        ENSURE(n_nan_atwd_charge == 0,
               "All the ATWD mean charges should be non-NaN.")
        ENSURE(n_nan_fadc_charge == 5, "There should be 5 NaN FADC charges.")

        # there are 5050 valid entries out of 5085 in the file 'final-spe-fits-pole-run2015.json'
        if n_valid != 5050:
            print("Expected 5050 valid entries.")
            print("Got N valid = %d" % n_valid)
            print("FAIL")
            sys.exit(1)  # report back to the mothership

        self.PushFrame(frame)
    def Calibration(self, frame):
        domcal = frame['I3Calibration'].dom_cal
        n_valid = sum([1 for omkey, i3domcal in domcal.iteritems() \
            if i3domcal.combined_spe_charge_distribution.is_valid])
        print(n_valid)
        n_nan_atwd_charge = 0
        n_nan_fadc_charge = 0
        n_nan_exp2_amp = 0
        for omkey, i3domcal in domcal.iteritems():
            if i3domcal.combined_spe_charge_distribution.is_valid:
                # it's not true in general, but for this test file
                # whenever the combined fits are valid, the mean
                # ATWD and FADC charges should be non-NaN as well
                if isnan(i3domcal.mean_atwd_charge):
                    n_nan_atwd_charge += 1
                if isnan(i3domcal.mean_fadc_charge):
                    n_nan_fadc_charge += 1
                if isnan(i3domcal.combined_spe_charge_distribution.exp2_amp):
                    n_nan_exp2_amp += 1

            if omkey[0] == 1 and omkey[1] == 1:
                print('\n -- Printing i3DOMCal Structure for DOM(1,1) -- ')
                print(i3domcal)
                print('\n\nOf Note: \n\
                    - CombinedSPEChargeDistribution should have non-NaNs.\n\
                    - MeanATWDCharge should be roughly 0.95 - 1.05. \n\
                    - MeanFADCCharge should be roughly 0.90 - 1.15.')

        spe_fi = SPEFitInjector(args.json_fn)

        if spe_fi.new_style:
            # There are 5085 valid entries out of 5085 in the file IC86.2016_923_NewWaveDeform.json
            # Not sure about other JSON files out there, so 5k seems reasonable.
            if n_valid < 5000:
                print("Expected 5085 valid entries.")
                print("Got N valid = %d" % n_valid)
                print("FAIL")
                sys.exit(1)  # report back to the mothership
        else:
            ENSURE(n_nan_atwd_charge == 0,
                   "All the ATWD mean charges should be non-NaN.")
            ENSURE(n_nan_fadc_charge == 5,
                   "There should be 5 NaN FADC charges.")
            ENSURE(
                n_nan_exp2_amp == 0,
                "All parameters describing the SPE Charge distribution should be non-NaN."
            )

            # there are 5050 valid entries out of 5085 in the file 'final-spe-fits-pole-run2015.json'
            if n_valid != 5050:
                print("Expected 5050 valid entries.")
                print("Got N valid = %d" % n_valid)
                print("FAIL")
                sys.exit(1)  # report back to the mothership

        self.PushFrame(frame)
from I3Tray import I3Units
from icecube import icetray, dataclasses
from icecube.icetray.I3Test import ENSURE

#
#  This file is not a hard test per-say, but just exercises some of the
#        python bindings for dataclasses.  Might be useful for example usage.
#  Is there an interface you see missing?  Add it, and if it doesn't work
#   properly, report it via Trac:  http://code.icecube.wisc.edu/projects/icecube
#
#    No attempt to use all interfaces for each class has been made

print('Testing TriggerKey pybindings')
tk = dataclasses.TriggerKey(dataclasses.IN_ICE,
                            dataclasses.SIMPLE_MULTIPLICITY, 1002)
ENSURE(tk.check_config_id() == True, "CheckConfigID fail")
ENSURE(tk.config_id == 1002, "Wrong ConfigID")

ENSURE(tk.source == dataclasses.IN_ICE, "Wrong Trigger Source")

ENSURE(tk.type == dataclasses.SIMPLE_MULTIPLICITY, "Wrong Trigger Type")
print(tk)
tk.reset_config_id()
ENSURE(tk.check_config_id() == False, "CheckConfigID fail")

mytrig = dataclasses.I3Trigger()
mytrig.fired = True
mytrig.time = 5.0 * icetray.I3Units.microsecond
mytrig.length = 1.0 * icetray.I3Units.microsecond

print(mytrig)
예제 #4
0
tray = I3Tray()

class ComputeSomething(icetray.I3Module) :
    def __init__(self, context):
        icetray.I3Module.__init__(self, context)
        self.AddParameter("N", "Number of times to compute something.", 0)
    def Configure(self):
        self.n = self.GetParameter("N")
    def Physics(self, frame):
        for i in range(self.n) :
            x = cos(random.uniform(0,2 * pi))
        self.PushFrame(frame)

# generate empty frames
tray.AddModule("BottomlessSource")

tray.AddModule(ComputeSomething, n = 100000)
tray.AddModule(ComputeSomething, n = 10000)
tray.AddModule(ComputeSomething, n = 1000)
tray.AddModule(ComputeSomething, n = 100)
tray.AddModule(ComputeSomething, n = 10)
tray.AddModule(ComputeSomething, n = 1)

# do it 5 times.
tray.Execute(5)

printed_keys = tray.PrintUsage(fraction = 0.99999999)
ENSURE(len(printed_keys) > 1, "Not enough modules printed.")

    pos_list = []
    size_list = []
    for cls in (raw.File, raw.FileGroup):
        f = cls(filename)
        pos = []
        while 1:
            pos.append(f.current_stream_pos)
            try:
                frame = f.next(True)
            except StopIteration:
                pos.pop()
                break
        pos_list.append(pos)
        size_list.append(f.size)

    ENSURE(pos_list[1] == pos_list[0], "positions differ from raw::File")
    ENSURE(size_list[1] == size_list[0], "size differs from raw::File")

    f = raw.File(filename)
    f2 = raw.FileGroup(filename)

    for p in pos:
        frame = f.at_stream_pos(p)
        frame2 = f2.at_stream_pos(p)
        ENSURE(
            str(frame) == str(frame2),
            "frames differ at position {}".format(p))

    # check that raw.FileGroup with two files behaves properly

    pos1 = pos[:]
예제 #6
0
#!/usr/bin/env python
from icecube.icetray.I3Test import ENSURE
from icecube import dataclasses, trigger_sim

sets = trigger_sim.GetDefaultDOMSets()

max_len_set = list()
for k, v in sets:
    if len(v) > len(max_len_set):
        max_len_set = v

ENSURE( len(max_len_set) == 4 ,"There should be 4 DOM sets in this list not %d." \
        % len(max_len_set))

for domset in [2, 4, 5, 6]:
    ENSURE(domset in max_len_set,
           "DOM set %d not found in default lists." % domset)