def test_lightcurve_to_time_series(): from gammapy.catalog import SourceCatalog4FGL catalog_4fgl = SourceCatalog4FGL( "$GAMMAPY_DATA/catalogs/fermi/gll_psc_v20.fit.gz") lightcurve = catalog_4fgl["FGES J1553.8-5325"].lightcurve() table = lightcurve.to_table(sed_type="flux", format="binned-time-series") timeseries = BinnedTimeSeries(data=table) assert_allclose(timeseries.time_bin_center.mjd[0], 54863.97885336907) assert_allclose(timeseries.time_bin_end.mjd[0], 55045.301668796295) time_axis = lightcurve.geom.axes["time"] assert_allclose(timeseries.time_bin_end.mjd[0], time_axis.time_max.mjd[0]) # assert that it interfaces with periodograms p = BoxLeastSquares.from_timeseries(timeseries=timeseries, signal_column_name="flux", uncertainty="flux_errp") result = p.power(1 * u.year, 0.5 * u.year) assert_allclose(result.duration, 182.625 * u.d)
def test_4FGL_DR3(): cat = SourceCatalog4FGL("$GAMMAPY_DATA/catalogs/fermi/gll_psc_v28.fit.gz") source = cat["4FGL J0534.5+2200"] model = source.spectral_model() fp = source.flux_points not_ul = ~fp.is_ul.data.squeeze() fp_dnde = fp.dnde.quantity.squeeze()[not_ul] model_dnde = model(fp.energy_ref[not_ul]) assert_quantity_allclose(model_dnde, fp_dnde, rtol=0.07)
def test_fermi_to_dnde(): from gammapy.catalog import SourceCatalog4FGL catalog_4fgl = SourceCatalog4FGL("$GAMMAPY_DATA/catalogs/fermi/gll_psc_v20.fit.gz") src = catalog_4fgl["FGES J1553.8-5325"] fp = src.flux_points assert_allclose( fp.dnde.quantity[1, 0, 0], 4.567393e-10 * u.Unit("cm-2 s-1 MeV-1"), rtol=1e-5, )
def test_fermi_to_dnde(): from gammapy.catalog import SourceCatalog4FGL catalog_4fgl = SourceCatalog4FGL( "$GAMMAPY_DATA/catalogs/fermi/gll_psc_v20.fit.gz") src = catalog_4fgl["FGES J1553.8-5325"] fp_dnde = src.flux_points.to_sed_type("dnde", model=src.spectral_model()) assert_allclose( fp_dnde.table["dnde"].quantity[1], 4.567393e-10 * u.Unit("cm-2 s-1 MeV-1"), rtol=1e-5, )
def test_lightcurve_dr2(self): dr2 = SourceCatalog4FGL("$GAMMAPY_DATA/catalogs/fermi/gll_psc_v27.fit.gz") source_dr2 = dr2[self.source_name] table = source_dr2.lightcurve(interval="1-year").table assert table["flux"].unit == "cm-2 s-1" assert_allclose(table["flux"][0], 2.196788e-6, rtol=1e-3) assert table["flux_errp"].unit == "cm-2 s-1" assert_allclose(table["flux_errp"][0], 2.312938e-8, rtol=1e-3) assert table["flux_errn"].unit == "cm-2 s-1" assert_allclose(table["flux_errn"][0], 2.312938e-8, rtol=1e-3) with pytest.raises(ValueError): source_dr2.lightcurve(interval="2-month")
def setup_class(cls): cls.cat = SourceCatalog4FGL() cls.source_name = "4FGL J0534.5+2200" cls.source = cls.cat[cls.source_name]
def setup_class(cls): cls.cat = SourceCatalog4FGL()
def setup_class(cls): cls.cat = SourceCatalog4FGL("$GAMMAPY_DATA/catalogs/fermi/gll_psc_v20.fit.gz") cls.source_name = "4FGL J0534.5+2200" cls.source = cls.cat[cls.source_name]