Ejemplo n.º 1
0
def load_pwn(filename, savedir=None, **kwargs):
    """ By default, pwn roi's are not loadable. """
    d=cPickle.load(open(expandvars(filename),'r'))

    extra=d['extra']

    ft1=extra['unphased_ft1']
    ltcube=extra['unphased_ltcube']
    phase=PhaseRange(extra['phase'])

    if exists(ft1) and exists(ltcube) and exists(phase):
        return load(filename, **kwargs)

    if savedir is None:
        save_data = False
        savedir=mkdtemp(prefix='/scratch/')
    else:
        if not os.path.exists(savedir):
            os.makedirs(savedir)
        save_data = True

    print 'new savedir is',savedir

    phased_ft1=PWNRegion.phase_ft1(ft1,phase,savedir)
    phased_ltcube=PWNRegion.phase_ltcube(ltcube,phase,savedir)
    binfile=join(savedir,'binned_phased.fits')

    roi = load(filename, ft1files=phased_ft1, ltcube=phased_ltcube, binfile=binfile, **kwargs)

    if not save_data:
        roi.__del__ = lambda x: shutil.rmtree(savedir)

    return roi
Ejemplo n.º 2
0
def load_pwn(filename, savedir=None, **kwargs):
    """ By default, pwn roi's are not loadable. """
    d = cPickle.load(open(expandvars(filename), 'r'))

    extra = d['extra']

    ft1 = extra['unphased_ft1']
    ltcube = extra['unphased_ltcube']
    phase = PhaseRange(extra['phase'])

    if exists(ft1) and exists(ltcube) and exists(phase):
        return load(filename, **kwargs)

    if savedir is None:
        save_data = False
        savedir = mkdtemp(prefix='/scratch/')
    else:
        if not os.path.exists(savedir):
            os.makedirs(savedir)
        save_data = True

    print 'new savedir is', savedir

    phased_ft1 = PWNRegion.phase_ft1(ft1, phase, savedir)
    phased_ltcube = PWNRegion.phase_ltcube(ltcube, phase, savedir)
    binfile = join(savedir, 'binned_phased.fits')

    roi = load(filename,
               ft1files=phased_ft1,
               ltcube=phased_ltcube,
               binfile=binfile,
               **kwargs)

    if not save_data:
        roi.__del__ = lambda x: shutil.rmtree(savedir)

    return roi
Ejemplo n.º 3
0
 def reload_roi(self, hypothesis, *args, **kwargs):
     roi = load('roi_%s_%s.dat' % (hypothesis, self.name), *args, **kwargs)
     roi.print_summary(galactic=True, maxdist=10)
     return roi
Ejemplo n.º 4
0
 def reload_roi(self,hypothesis, *args, **kwargs):
     roi = load('roi_%s_%s.dat' % (hypothesis,self.name), *args, **kwargs)
     roi.print_summary(galactic=True, maxdist=10)
     return roi