Esempio n. 1
0
    def read(cls, filename, offset='0.5 deg'):
        """Read from a FITS file.

        Compute RMF at 0.5 deg offset on fly.

        Parameters
        ----------
        filename : `str`
            File containing the IRFs
        """
        filename = str(make_path(filename))

        with fits.open(filename, memmap=False) as hdulist:
            aeff = EffectiveAreaTable.from_hdulist(hdulist=hdulist)
            edisp = EnergyDispersion2D.read(filename, hdu='ENERGY DISPERSION')
            bkg = BgRateTable.from_hdulist(hdulist=hdulist)
            psf = Psf68Table.from_hdulist(hdulist=hdulist)
            sens = SensitivityTable.from_hdulist(hdulist=hdulist)

        # Create rmf with appropriate dimensions (e_reco->bkg, e_true->area)
        e_reco_min = bkg.energy.lo[0]
        e_reco_max = bkg.energy.hi[-1]
        e_reco_bin = bkg.energy.nbins
        e_reco_axis = EnergyBounds.equal_log_spacing(
            e_reco_min,
            e_reco_max,
            e_reco_bin,
            'TeV',
        )

        e_true_min = aeff.energy.lo[0]
        e_true_max = aeff.energy.hi[-1]
        e_true_bin = aeff.energy.nbins
        e_true_axis = EnergyBounds.equal_log_spacing(
            e_true_min,
            e_true_max,
            e_true_bin,
            'TeV',
        )

        rmf = edisp.to_energy_dispersion(
            offset=offset,
            e_reco=e_reco_axis,
            e_true=e_true_axis,
        )

        return cls(aeff=aeff,
                   bkg=bkg,
                   edisp=edisp,
                   psf=psf,
                   sens=sens,
                   rmf=rmf)
Esempio n. 2
0
    def read(cls, filename, offset='0.5 deg'):
        """Read from a FITS file.

        Compute RMF at 0.5 deg offset on fly.

        Parameters
        ----------
        filename : `str`
            File containing the IRFs
        """
        filename = str(make_path(filename))

        with fits.open(filename, memmap=False) as hdulist:
            aeff = EffectiveAreaTable.from_hdulist(hdulist=hdulist)
            edisp = EnergyDispersion2D.read(filename, hdu='ENERGY DISPERSION')
            bkg = BgRateTable.from_hdulist(hdulist=hdulist)
            psf = Psf68Table.from_hdulist(hdulist=hdulist)
            sens = SensitivityTable.from_hdulist(hdulist=hdulist)

        # Create rmf with appropriate dimensions (e_reco->bkg, e_true->area)
        e_reco_min = bkg.energy.lo[0]
        e_reco_max = bkg.energy.hi[-1]
        e_reco_bin = bkg.energy.nbins
        e_reco_axis = EnergyBounds.equal_log_spacing(
            e_reco_min, e_reco_max, e_reco_bin, 'TeV',
        )

        e_true_min = aeff.energy.lo[0]
        e_true_max = aeff.energy.hi[-1]
        e_true_bin = aeff.energy.nbins
        e_true_axis = EnergyBounds.equal_log_spacing(
            e_true_min, e_true_max, e_true_bin, 'TeV',
        )

        rmf = edisp.to_energy_dispersion(
            offset=offset, e_reco=e_reco_axis, e_true=e_true_axis,
        )

        return cls(
            aeff=aeff,
            bkg=bkg,
            edisp=edisp,
            psf=psf,
            sens=sens,
            rmf=rmf
        )
Esempio n. 3
0
    def load_irf(self):
        filename = os.path.join(self.outdir, 'irf.fits.gz')
        with fits.open(filename, memmap=False) as hdulist:
            aeff = EffectiveAreaTable.from_hdulist(hdulist=hdulist)
            edisp = EnergyDispersion2D.read(filename, hdu="ENERGY DISPERSION")

            bkg_fits_table = hdulist["BACKGROUND"]
            bkg_table = Table.read(bkg_fits_table)
            energy_lo = bkg_table["ENERG_LO"].quantity
            energy_hi = bkg_table["ENERG_HI"].quantity
            bkg = bkg_table["BGD"].quantity

            axes = [
                BinnedDataAxis(
                    energy_lo, energy_hi, interpolation_mode="log", name="energy"
                )
            ]
            bkg = BkgData(data=NDDataArray(axes=axes, data=bkg))

        # Create rmf with appropriate dimensions (e_reco->bkg, e_true->area)
        e_reco_min = bkg.energy.lo[0]
        e_reco_max = bkg.energy.hi[-1]
        e_reco_bin = bkg.energy.nbins
        e_reco_axis = EnergyBounds.equal_log_spacing(
            e_reco_min, e_reco_max, e_reco_bin, "TeV"
        )

        e_true_min = aeff.energy.lo[0]
        e_true_max = aeff.energy.hi[-1]
        e_true_bin = aeff.energy.nbins
        e_true_axis = EnergyBounds.equal_log_spacing(
            e_true_min, e_true_max, e_true_bin, "TeV"
        )

        # Fake offset...
        rmf = edisp.to_energy_dispersion(
            offset=0.5 * u.deg, e_reco=e_reco_axis, e_true=e_true_axis
        )

        self.irf = Irf(bkg=bkg, aeff=aeff, rmf=rmf)