def interpolator(): trigdat_h5 = get_path_of_data_file("trigdat.h5") interp_trig_h5 = PositionInterpolator.from_trigdat_hdf5(trigdat_h5) return interp_trig_h5
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)
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]) )