def test_3(): from gammapy.catalog import SourceCatalog3FGL source = SourceCatalog3FGL()['3FGL J0349.9-2102'] lc = source.lightcurve lc.table.info() import matplotlib.pyplot as plt lc.plot() plt.show()
def plot_source_spectra(name): plot_source_spectrum(source=SourceCatalog3FGL()[name], label="3FGL", color="r") plot_source_spectrum(source=SourceCatalog2FHL()[name], label="2FHL", color="g") plot_source_spectrum(source=SourceCatalog3FHL()[name], label="3FHL", color="b") ax = plt.gca() ax.set_ylim(1.0e-12, 7.0e-11) ax.set_xlim(1.0e-4, 2.0) ax.set_xlabel("Energy (TeV)") ax.set_ylabel("E^2 dN/dE (erg cm-2 s-1])") plt.legend(loc=0)
def plot_source_spectra(name): plot_source_spectrum(source=SourceCatalog3FGL()[name], label='Fermi 3FGL', color='r') plot_source_spectrum(source=SourceCatalog2FHL()[name], label='Fermi 2FHL', color='g') plot_source_spectrum(source=SourceCatalog1FHL()[name], label='Fermi 1FHL', color='c') plot_source_spectrum(source=SourceCatalog3FHL()[name], label='Fermi 3FHL', color='b') ax = plt.gca() ax.set_ylim(1.e-12, 7.e-11) ax.set_xlim(1.e-4, 2.) ax.set_xlabel('Energy (TeV)') ax.set_ylabel('E^2 dN/dE (erg cm-2 s-1])') plt.legend(loc=0)
def setup_class(cls): cls.cat = SourceCatalog3FGL()
def setup_class(cls): cls.cat = SourceCatalog3FGL() # Use 3FGL J0534.5+2201 (Crab) as a test source cls.source_name = "3FGL J0534.5+2201" cls.source = cls.cat[cls.source_name]
) from gammapy.spectrum import FluxPointsDataset, FluxPoints from gammapy.catalog import ( SourceCatalog3FGL, SourceCatalogGammaCat, SourceCatalog3FHL, ) from gammapy.utils.fitting import Fit # ## Load spectral points # # For this analysis we choose to work with the source 'HESS J1507-622' and the associated Fermi-LAT sources '3FGL J1506.6-6219' and '3FHL J1507.9-6228e'. We load the source catalogs, and then access source of interest by name: # In[ ]: fermi_3fgl = SourceCatalog3FGL() fermi_3fhl = SourceCatalog3FHL() gammacat = SourceCatalogGammaCat("$GAMMAPY_DATA/gamma-cat/gammacat.fits.gz") # In[ ]: source_gammacat = gammacat["HESS J1507-622"] source_fermi_3fgl = fermi_3fgl["3FGL J1506.6-6219"] source_fermi_3fhl = fermi_3fhl["3FHL J1507.9-6228e"] # The corresponding flux points data can be accessed with `.flux_points` attribute: # In[ ]: flux_points_gammacat = source_gammacat.flux_points flux_points_gammacat.table
# In[ ]: get_ipython().system('ls -1 $GAMMAPY_DATA/catalogs') # In[ ]: # Catalog object - FITS file is loaded catalog = SOURCE_CATALOGS["3fgl"]() catalog # In[ ]: from gammapy.catalog import SourceCatalog3FGL catalog = SourceCatalog3FGL() catalog # In[ ]: # Let's load the source catalogs we will use throughout this tutorial catalog_gammacat = SOURCE_CATALOGS["gamma-cat"] catalog_3fhl = SOURCE_CATALOGS["3fhl"]() catalog_4fgl = SOURCE_CATALOGS["4fgl"]() catalog_hgps = SOURCE_CATALOGS["hgps"]() # ## Select a source # # To create a source object, index into the catalog using `[]`, passing a catalog table row index (zero-based, first row is `[0]`), or a source name. If passing a name, catalog table columns with source names and association names ("ASSOC1" in the example below) are searched top to bottom. There is no name resolution web query. # In[ ]: