示例#1
0
def test_interp():

    trigdat = get_path_of_data_file("glg_trigdat_all_bn080916009_v02.fit")

    interp_trig = PositionInterpolator.from_trigdat(trigdat)

    interp_trig.quaternion(0)

    interp_trig.sc_pos(0)

    assert interp_trig.is_fermi_active(1) == True

    trigdat_h5 = get_path_of_data_file("trigdat.h5")

    interp_trig_h5 = PositionInterpolator.from_trigdat_hdf5(trigdat_h5)

    assert np.all(interp_trig_h5.quaternion(0) == interp_trig.quaternion(0))

    assert np.all(interp_trig_h5.sc_pos(0) == interp_trig.sc_pos(0))

    assert interp_trig_h5.is_fermi_active(1) == True

    poshist = get_path_of_data_file("glg_poshist_all_151013_v00.fit")

    interp_pos = PositionInterpolator.from_poshist(poshist)

    tmin, tmax = interp_pos.minmax_time()

    interp_pos.is_fermi_active(tmin)

    interp_pos.is_fermi_active([tmin, tmax])

    interp_pos.quaternion(interp_pos.time[0])

    interp_pos.sc_pos(interp_pos.time[0])

    poshist_h5 = get_path_of_data_file("posthist.h5")

    interp_pos_h5 = PositionInterpolator.from_poshist_hdf5(poshist_h5)

    assert np.all(
        interp_pos_h5.quaternion(interp_pos_h5.time[0])
        == interp_pos.quaternion(interp_pos.time[0])
    )

    assert np.all(
        interp_pos_h5.sc_pos(interp_pos_h5.time[0])
        == interp_pos.sc_pos(interp_pos.time[0])
    )
示例#2
0
def interpolator():

    trigdat_h5 = get_path_of_data_file("trigdat.h5")

    interp_trig_h5 = PositionInterpolator.from_trigdat_hdf5(trigdat_h5)

    return interp_trig_h5
示例#3
0
    def run(self):

        trigdat_file = base_path / self.grb_name / \
            f"trigdat_bn{self.grb_name[3:]}.h5"

        pi: PositionInterpolator = PositionInterpolator.from_trigdat_hdf5(
            trigdat_file)

        gbm: GBM = GBM.from_position_interpolator(pi)

        ra, dec, err = get_official_location(self.grb_name)

        coord = SkyCoord(ra=ra, dec=dec, unit="deg", frame="icrs")

        # get the separation

        separations = gbm.get_separation(coord)

        # get the Nais that are less
        # than 60 deg away

        nai = [f"n{i}" for i in range(10)]
        nai.extend(['na', 'nb'])

        nai = separations[nai]

        idx = nai < 60.

        out = nai[idx].sort_values()

        if len(out) < 2:

            idx = nai < 80.

            out = nai[idx].sort_values()

        dets = list(out.index[:3])

        # now get the closest BGO

        bgo = separations[["b0", "b1"]]

        idx = bgo.argmin()

        dets.append(bgo.index[idx])

        file_name: Path = base_path / self.grb_name / "geometry.yml"

        output = {}
        output["location"] = dict(ra=ra, dec=dec, err=err)
        output["detector"] = dets

        with file_name.open("w") as f:

            yaml.dump(data=output, stream=f, Dumper=yaml.SafeDumper)
示例#4
0
def test_point_space_plotting():

    pi = PositionInterpolator.from_trigdat(
        get_path_of_data_file("balrog_trig.fits"))

    skypoints = balrog_to_skypoints(
        get_path_of_data_file("balrog.fits"),
        new_nside=2**5,
        cmap="viridis",
        as_point=True,
    )
示例#5
0
    def __init__(self):

        self._minimum_met = 576201540.940077
        self._maximum_time = 86519.99999904633
        self._T0 = self._minimum_met
        self._used_times = []

        logger.debug("Setting up the GBM orbit")

        self._interpolator = PositionInterpolator.from_poshist_hdf5(
            get_path_of_data_file("posthist.h5"), T0=self._T0)

        self._tmin, self._tmax = self._interpolator.minmax_time()

        self._delta_time = self._tmax - self._tmin
示例#6
0
def test_ray_space_plotting():

    pi = PositionInterpolator.from_trigdat(
        get_path_of_data_file("balrog_trig.fits"))

    skypoints = balrog_to_skypoints(
        get_path_of_data_file("balrog.fits"),
        new_nside=2**5,
        cmap="viridis",
        as_point=False,
    )

    plot_in_space(
        pi,
        0,
        sky_points=skypoints,
        show_detector_pointing=True,
        show_moon=True,
        earth_time="day",
        show_stars=True,
    )