Example #1
0
    def build_catalog(**kwargs):
        """Build a `fermipy.catalog.Catalog` object

        Parameters
        ----------

        catalog_type : str
            Specifies catalog type, options include 2FHL | 3FGL | 4FGLP
        catalog_file : str
            FITS file with catalog tables
        catalog_extdir : str
            Path to directory with extended source templates
        """
        catalog_type = kwargs.get('catalog_type')
        catalog_file = kwargs.get('catalog_file')
        catalog_extdir = kwargs.get('catalog_extdir')
        if catalog_type == '2FHL':
            return catalog.Catalog2FHL(fitsfile=catalog_file,
                                       extdir=catalog_extdir)
        elif catalog_type == '3FGL':
            return catalog.Catalog3FGL(fitsfile=catalog_file,
                                       extdir=catalog_extdir)
        elif catalog_type == '4FGLP':
            return catalog.Catalog4FGLP(fitsfile=catalog_file,
                                        extdir=catalog_extdir)
        elif catalog_type == 'FL8Y':
            return catalog.CatalogFL8Y(fitsfile=catalog_file,
                                       extdir=catalog_extdir)
        else:
            table = Table.read(catalog_file)
        return catalog.Catalog(table, extdir=catalog_extdir)
Example #2
0
    def calc_sep(self, tab, src_list):

        print('calculating separations')

        src_tab = catalog.Catalog3FGL().table
        m = utils.find_rows_by_string(
            src_tab, src_list, ['Source_Name', 'ASSOC1', 'ASSOC2'])
        rows = src_tab[m]
        src_skydir = SkyCoord(rows['RAJ2000'], rows['DEJ2000'], unit='deg')
        evt_skydir = SkyCoord(tab['RA'], tab['DEC'], unit='deg')
        lat_skydir = SkyCoord(tab['PtRaz'], tab['PtDecz'], unit='deg')
        evt_sep = evt_skydir.separation(src_skydir[:, None]).deg
        evt_ebin = utils.val_to_bin(self._energy_bins, tab['ENERGY'])
        evt_xsep = evt_sep / self._psf_scale[evt_ebin][None, :]
        evt_ctheta = np.cos(lat_skydir.separation(src_skydir[:, None]).rad)

        return evt_sep, evt_xsep, evt_ctheta