from icecube.load_pybindings import load_pybindings import icecube.icetray, icecube.dataclasses, icecube.simclasses, icecube.phys_services # be nice and pull in our dependencies load_pybindings(__name__, __path__) import inspect def monkeypatch(cls): def monkeypatch(f): name = f.__name__ if inspect.getargspec(f).args[0] == 'cls': f = classmethod(f) setattr(cls, name, f) return None return monkeypatch @monkeypatch(ExtrudedPolygon) def from_I3Geometry(cls, i3geo, padding=0): from collections import defaultdict import numpy strings = defaultdict(list) for omkey, omgeo in i3geo.omgeo: if omgeo.omtype != omgeo.IceTop: strings[omkey.string].append(list(omgeo.position)) mean_xy = [ numpy.mean(positions, axis=0)[0:2] for positions in strings.values() ] zmax = max(max(p[2] for p in positions) for positions in strings.values()) zmin = min(min(p[2] for p in positions) for positions in strings.values())
from icecube import icetray, dataclasses from icecube.load_pybindings import load_pybindings load_pybindings(__name__, __path__) import sys if sys.version_info[:2] >= (2,6): from icecube.dataio.I3FileStagerFile import AbstractFileStager set_local_scratch_dir = AbstractFileStager.set_local_scratch_dir def get_stagers(staging_directory=None, extra_stagers=[]): """ Set up file stagers for all supported URL schemes. :param staging_directory: use this directory for temporary files. If not\ specified, the staging directory will be guessed. :param extra_stagers: a list of stager classes to instatiate in addition to\ the those included with the base distribution """ if staging_directory is not None: set_local_scratch_dir(staging_directory) impls = set(extra_stagers) for stager in AbstractFileStager.get_subclasses(): impls.add(stager) return I3FileStagerCollection([stager() for stager in impls]) @icetray.traysegment_inherit('I3Reader') def I3Reader(tray, name, **kwargs): """Read an .i3 file. This supports remote files by specifying URLs and will stage them in an auto-configured