Beispiel #1
0
    def _make_source_object(self, index):
        """Make one source object.

        Parameters
        ----------
        index : int
            Row index

        Returns
        -------
        source : `SourceCatalogObject`
            Source object
        """
        data = table_row_to_dict(self.table[index])
        data[SourceCatalogObject._row_index_key] = index

        fp_energy_edges = getattr(self, "flux_points_energy_edges", None)

        if fp_energy_edges:
            data["fp_energy_edges"] = fp_energy_edges

        hist_table = getattr(self, "hist_table", None)
        hist2_table = getattr(self, "hist2_table", None)

        if hist_table:
            try:
                data["time_axis"] = TimeMapAxis.from_table(hist_table,
                                                           format="fermi-fgl")
            except KeyError:
                pass

        if hist2_table:
            try:
                data["time_axis_2"] = TimeMapAxis.from_table(
                    hist2_table, format="fermi-fgl")
            except KeyError:
                pass
        if "Extended_Source_Name" in data:
            name_extended = data["Extended_Source_Name"].strip()
        elif "Source_Name" in data:
            name_extended = data["Source_Name"].strip()
        else:
            name_extended = None
        try:
            idx = self._lookup_extended_source_idx[name_extended]
            data_extended = table_row_to_dict(self.extended_sources_table[idx])
        except (KeyError, AttributeError):
            data_extended = None

        source = self.source_object_class(data, data_extended)
        return source
Beispiel #2
0
def test_from_table_time_axis():
    t0 = Time("2006-02-12", scale="utc")
    t_min = np.linspace(0, 10, 10) * u.d
    t_max = t_min + 12 * u.h

    table = Table()
    table["TIME_MIN"] = t_min
    table["TIME_MAX"] = t_max
    table.meta.update(time_ref_to_dict(t0))
    table.meta["AXCOLS1"] = "TIME_MIN,TIME_MAX"

    axis = TimeMapAxis.from_table(table, format="gadf")

    assert axis.nbin == 10
    assert_allclose(axis.time_mid[0].mjd, 53778.25)