Package: gPCS
gPCS: Gamma-ray Photon-Counts StatisticsThis repository contains the code for the paperDeepening gamma-ray point-source catalogues with sub-threshold information.We provide our results in the form of aprecomputed FITS, as well as python package which can be used to read the data asnumpyarrays, as well as export a similar FITS table.InstallationThis package can easily be installed through pip:pipinstallgPCSExample usageThis package can be used to obtain the firing pixels, either given a chosen TS_star or by fixing a quality factor (QF) and significance level (alpha).importnumpyasnpfromgPCSimportgPCS# specify manually a TS_starTS_star=36pixel_firing=gPCS.get_firing_pixels(TS_star,filter=False)print(len(pixel_firing))# Compute the TS_star from a chosen QF and alphaQF=0.5alpha=0.05TS_star=gPCS.get_TS_from_QF(QF,alpha=alpha)pixel_firing=gPCS.get_firing_pixels(TS_star,filter=False)print(len(pixel_firing))We can get the TS of the firing pixels:TS_star=36firing_pixels=gPCS.get_firing_pixels(TS_star,filter=False)TS_ranking=gPCS.TS_map_Fermi[firing_pixels]It is easy to obtain the galactic coordinates of the firing pixels using healpy:importhealpyashplon,lat=hp.pix2ang(NSIDE,firing_pixels,lonlat=True)# lon lat in degreesAnd we can compute the QF and QF range of the firing pixels, given alpha:# obtain the QF using all the simulationsQF=gPCS.get_QF_from_TS(TS_ranking,alpha=alpha)# compute the mean and std of the QF using batches of simulationsmean_QF,std_QF=gPCS.get_QF_ranges_from_TS(TS_ranking,alpha=alpha,batches=100,batch_size=3000)# we can obtain the QF range for the firing pixels using the mean and stdQF_min=mean_QF-std_QFQF_max=mean_QF+std_QFIf desired, we provide some simple functions to filter the firing pixels, for example by removing pixels that are firing for the simulated 4FGL $\mathcal{K}$ map (see paper):# filter out the firing pixels for the 4FGL K mappixel_firing=gPCS.get_firing_pixels(TS_star,filter=True)# If conservative is True, after filtering the pixels in K,# the routine will also filter the pixels in the 1 pixel neighborhood of the pixels in K.pixel_firing=gPCS.get_firing_pixels(TS_star,filter=True,conservative=True)# If deg is specified, the routine will also filter the pixels# in the disc of radius deg centered on the centroid of the 4FGL catalog sources.pixel_firing=gPCS.get_firing_pixels(TS_star,filter=True,conservative=True,deg=0.5)For ease of use, we provide the TS maps both for Fermi and the simualted 4FGL map ($\mathcal{K}$) asnumpyattays. The maps are computed atnside=512and are stored in the following variables:gPCS.TS_map_FermigPCS.TS_map_4FGLIn order to compute the 4FGL $\mathcal{K}$ map, we use employ thegll_psc_v30catalog, available from the Fermi LAT colalborationwebsite.Exporting the resultsWe provide a simple function to export the results in the form of a FITS table, which can be used to reproduce the results of the paper.export_fits_table(filename,QF,alpha,overwrite=False,**kwargs)export_fits_tableaccepts the following arguments:filename : name of the output FITS fileQF : quality factoralpha : significance level (can be an array, and the supported values are 0.01, 0.05, 0.1)overwrite : if True, the routine will overwrite the output file if it already exists**kwargs : additional arguments to be passed toget_firing_pixels.export_fits_tablewill create a FITS table with the following columns:pixel : pixel indexTS : TS valueQF_best : QF value obtained by considering all the simulationsQF_min : lower bound of the QF rangeQF_max : upper bound of the QF rangeIn order to export the FITS table available in the examples folder, we can run the command:gPCS.export_fits_table(filename="firing_pixels.fits",QF=0.50,alpha=[0.01,0.05,0.1])List of functionsget_QF_from_TS(TS, alpha): computes the quality factor from a given TS and alphaget_QF_ranges_from_TS(TS, alpha, batches=100, batch_size=3000): computes the mean and std of the QF from a given TS and alpha, using batches of simulationsget_TS_from_QF(QF, alpha): computes the TS from a given QF and alphaget_firing_pixels(TS_lim, filter=False, conservative=False, deg=None): computes the firing pixels for a given TS_lim.export_fits_table(filename, QF, alpha, overwrite=False, **kwargs): exports the results in the form of a FITS table.For more information about what each function does, please refer to thedocstringsand help of each function.LicenseThis code is released under the Zlib license. See theLICENSEfile for more information.