Ejemplo n.º 1
0
def test_read_gbm_save(grb):

    path = "test_grb.h5"

    grb = GRBSave.from_file(path)

    print(grb)
    grb.info()

    for k, v in grb.items():

        print(k, v)
        
        
    lightcurve = grb["n1"]["lightcurve"]

    print(lightcurve)
    lightcurve.info()

    grbsave_to_gbm_fits(path)

    files_to_remove = glob("*SynthGRB*.rsp")

    for f in files_to_remove:
        os.remove(f)

    files_to_remove = glob("*SynthGRB*.fits")

    for f in files_to_remove:
        os.remove(f)
Ejemplo n.º 2
0
def grbsave_to_gbm_fits(file_name, destination="."):

    grb = GRBSave.from_file(file_name)

    for key, det in grb.items():

        tstart = det["lightcurve"].tstart + det["lightcurve"].time_adjustment
        tstop = det["lightcurve"].tstop + det["lightcurve"].time_adjustment

        tte_file = TTEFile(
            det_name=key,
            tstart=tstart,
            tstop=tstop,
            trigger_time=grb.T0 + det["lightcurve"].time_adjustment,
            ra=grb.ra,
            dec=grb.dec,
            channel=np.arange(0, 128, dtype=np.int16),
            emin=det["response"].channel_edges[:-1],
            emax=det["response"].channel_edges[1:],
            pha=det["lightcurve"].pha.astype(np.int16),
            time=det["lightcurve"].times + det["lightcurve"].time_adjustment,
        )

        tte_file.writeto(f"tte_{grb.name}_{key}.fits", overwrite=True)

        rsp = det["response"]

        file_name = f"rsp_{grb.name}_{key}.rsp"

        rsp.to_fits(file_name,
                    telescope_name="fermi",
                    instrument_name=key,
                    overwrite=True)
Ejemplo n.º 3
0
    def __init__(self, *grb_saves):

        self._internal_storage = collections.OrderedDict()

        for grb in grb_saves:

            reloaded_grb = GRBSave.from_file(grb)

            self._internal_storage[reloaded_grb.name] = reloaded_grb
Ejemplo n.º 4
0
def test_lightcurve_plotting(grb):

    grb = GRBSave.from_file("test_grb.h5")

    for key, get in grb.items():

        lc = grb[key]["lightcurve"]

        lc.display_lightcurve()
        lc.display_background()
        lc.display_source()

        lc.display_lightcurve(emin=100)
        lc.display_background(emin=100)
        lc.display_source(emin=100)

        lc.display_lightcurve(emax=100)
        lc.display_background(emax=100)
        lc.display_source(emax=100)

        lc.display_lightcurve(emin=100, emax=1000)
        lc.display_background(emin=100, emax=1000)
        lc.display_source(emin=100, emax=1000)

        lc.display_count_spectrum()
        lc.display_count_spectrum_background()
        lc.display_count_spectrum_source()

        lc.display_count_spectrum(tmin=0)
        lc.display_count_spectrum_background(tmin=0)
        lc.display_count_spectrum_source(tmin=0)

        lc.display_count_spectrum(tmax=10)
        lc.display_count_spectrum_background(tmax=10)
        lc.display_count_spectrum_source(tmax=10)

        lc.display_count_spectrum(tmin=0, tmax=10)
        lc.display_count_spectrum_background(tmin=0, tmax=10)
        lc.display_count_spectrum_source(tmin=0, tmax=10)
Ejemplo n.º 5
0
 def grb(self):
     return GRBSave.from_file(self._grb)