Пример #1
0
def main():
    pm = PixelMasks()
    dead = np.where(np.logical_or(pm.dead, np.repeat(pm.bad_hv, 4)))[0]

    bright_path = get_astri_2019("d2019-04-23_nudges/bright_50pe/charge.h5")
    with HDF5Reader(bright_path) as reader:
        df = reader.read("data").groupby(['nudge',
                                          'pixel']).mean().reset_index()
        mapping = reader.get_mapping()

    df_0 = df.loc[df['nudge'] == 0]
    isin_dead = df_0['pixel'].isin(dead)
    avg = df_0.loc[~isin_dead].mean()
    ff = avg['onsky_calib'] / df_0['onsky_calib'].values
    ff[dead] = 1

    np.testing.assert_allclose(ff.mean(), 1, rtol=1e-2)

    df = pd.DataFrame(dict(
        pixel=np.arange(ff.size),
        ff=ff,
    ))

    output_dir = get_astri_2019("d2019-04-23_nudges/results/extract_ff")
    cm = CameraImage.from_mapping(mapping)
    cm.image = ff
    cm.add_colorbar()
    cm.highlight_pixels(pm.dead, 'red')
    cm.highlight_pixels(np.repeat(pm.bad_hv, 4), 'black')
    cm.highlight_pixels(pm.low, 'blue')
    cm.save(join(output_dir, "ff_camera.pdf"))

    outpath = get_calib_data("ff_coeff.dat")
    df.to_csv(outpath, sep='\t', index=False)
    print(f"Created ff_coeff file: {outpath}")
Пример #2
0
def main():
    r1_paths = dict(
        off=get_astri_2019("d2019-05-08_ledflashers_dynrange/Run13268_r1.tio"),
        on_50=get_astri_2019("d2019-05-08_ledflashers_dynrange/Run13272_r1.tio"),
        on_3=get_astri_2019("d2019-05-08_ledflashers_dynrange/Run13267_r1.tio")
    )
    output = get_data("d190520_charge_extraction/data/charge.h5")
    poi = 2004

    reader = ReaderR1(list(r1_paths.values())[0])
    kw = dict(
        n_pixels=reader.n_pixels,
        n_samples=reader.n_samples,
        mapping=reader.mapping,
        reference_pulse_path=reader.reference_pulse_path,
    )
    extractors = dict(
        cc_nn=(CrossCorrelationNeighbour(**kw), 'charge_cc_nn'),
    )
    for width in range(1, 15):
        extractors[f'sliding_{width}'] = (
            SlidingWindowNeighbour(**kw, window_size=width),
            "charge_sliding_nn"
        )

        for shift in range(-3, 8):
            extractors[f'peak_{width}_{shift}'] = (
                CtapipeNeighbourPeakIntegrator(
                    **kw, window_size=width, window_shift=shift
                ), "charge_nn"
            )

    with HDF5Writer(output) as writer:
        for key, path in r1_paths.items():
            reader = ReaderR1(path, max_events=500)
            baseline_subtractor = BaselineSubtractor(reader)
            time_calibrator = TimeCalibrator()

            desc = "Looping over file"
            for wfs in tqdm(reader, total=reader.n_events, desc=desc):
                iev = wfs.iev
                if reader.stale.any():
                    continue

                wfs = time_calibrator(wfs)
                wfs = baseline_subtractor.subtract(wfs)

                global_params = dict(
                    key=key,
                    iev=iev,
                    pixel=poi,
                )

                for name, (extractor, column) in extractors.items():
                    params = global_params.copy()
                    params['extractor'] = name
                    params['charge'] = extractor.process(wfs)[column][poi]
                    df = pd.DataFrame(params, index=[0])
                    writer.append(df, key='data')
Пример #3
0
def main():
    runlist_path = get_astri_2019("d2019-05-01_mrk501/runlist.txt")
    directory = dirname(runlist_path)
    df = pd.read_csv(runlist_path, sep='\t')
    paths = [join(directory, f"Run{run:05d}_r1.tio") for run in df['run']]
    output_path = get_data("d190505_dtack/d2019-05-01_mrk501.h5")
    process(paths, output_path)
Пример #4
0
def process(name, file_lists):
    script = "/Users/Jason/Software/CHECOnsky/CHECOnsky/scripts_analysis/add_pointing_to_hillas.py"
    db_path = get_astri_2019("astri_db.h5")
    paths = " ".join([item for sublist in file_lists for item in sublist])
    cmd = f"python {script} -f {paths} -d {db_path} -s {name}"
    if name is None:
        cmd = f"python {script} -f {paths} -d {db_path}"
    call(cmd, shell=True)
Пример #5
0
def main():
    path_gamma = get_astri_2019("d2019-05-15_simulations/gamma_1deg.h5")
    path_proton = get_astri_2019("d2019-05-15_simulations/proton.h5")
    base_output = get_data(
        "d190918_alpha/extract_alpha_mc/d2019-05-15_simulations_gamma1deg")
    n_off = 1
    process(path_gamma, path_proton, base_output, n_off)

    path_gamma = get_astri_2019("d2019-05-15_simulations/gamma_1deg.h5")
    path_proton = get_astri_2019("d2019-05-15_simulations/proton.h5")
    base_output = get_data(
        "d190918_alpha/extract_alpha_mc/d2019-05-15_simulations_gamma1deg_5off"
    )
    n_off = 5
    process(path_gamma, path_proton, base_output, n_off)

    path_gamma = get_astri_2019("d2019-05-15_simulations/gamma_0deg.h5")
    path_proton = get_astri_2019("d2019-05-15_simulations/proton.h5")
    base_output = get_data(
        "d190918_alpha/extract_alpha_mc/d2019-05-15_simulations_gamma0deg")
    n_off = 1
    process(path_gamma, path_proton, base_output, n_off)

    path_gamma = get_astri_2019("d2019-05-15_simulations/gamma_1deg.h5")
    path_proton = path_gamma
    base_output = get_data(
        "d190918_alpha/extract_alpha_mc/d2019-05-15_simulations_gammaonly")
    n_off = 1
    process_gamma_only(path_gamma, base_output, n_off)
Пример #6
0
def main():
    # sql = ASTRISQLQuerier()
    # start = pd.Timestamp("2019-04-29 00:00")
    # end = pd.Timestamp("2019-05-13 00:00")
    # ra = sql.get_table_between_datetimes("TCU_ACTUAL_RA", start, end)
    # dec = sql.get_table_between_datetimes("TCU_ACTUAL_DEC", start, end)
    # alt = sql.get_table_between_datetimes("TCU_ELACTPOS", start, end)
    # az = sql.get_table_between_datetimes("TCU_AZACTPOS", start, end)

    path = get_astri_2019("astri_db.h5")
    with HDF5Reader(path) as reader:
        ra = reader.read("TCU_ACTUAL_RA")
        dec = reader.read("TCU_ACTUAL_DEC")
        alt = reader.read("TCU_ELACTPOS")
        az = reader.read("TCU_AZACTPOS")

    df = pd.merge(pd.merge(
        ra, dec,
        on='timestamp').rename(columns=dict(value_x="ra", value_y="dec")),
                  pd.merge(alt, az, on='timestamp').rename(
                      columns=dict(value_x="alt", value_y="az")),
                  on='timestamp')

    location = EarthLocation.from_geodetic(lon=14.974609,
                                           lat=37.693267,
                                           height=1750)
    altaz_frame = AltAz(location=location, obstime=df['timestamp'])
    telescope_pointing = SkyCoord(
        alt=df['alt'].values,
        az=df['az'].values,
        unit='deg',
        frame=altaz_frame,
    )
    telescope_pointing_icrs = telescope_pointing.icrs
    df['ra_calc'] = telescope_pointing_icrs.ra.deg
    df['dec_calc'] = telescope_pointing_icrs.dec.deg

    d_ra = np.arctan2(np.sin(df['ra'] - df['ra_calc']),
                      np.cos(df['ra'] - df['ra_calc']))
    d_dec = np.arctan2(np.sin(df['dec'] - df['dec_calc']),
                       np.cos(df['dec'] - df['dec_calc']))

    p = Plotter()
    p.ax.plot(df['timestamp'], d_ra)
    p.ax.set_xlabel("Timestamp")
    p.ax.set_ylabel("RA_database - RA_calculated (deg)")
    p.fig.autofmt_xdate()
    p.save(get_plot("d190527_astri_sql/ra.pdf"))

    p = Plotter()
    p.ax.plot(df['timestamp'], d_dec)
    p.ax.set_xlabel("Timestamp")
    p.ax.set_ylabel("DEC_database - DEC_calculated (deg)")
    p.fig.autofmt_xdate()
    p.save(get_plot("d190527_astri_sql/dec.pdf"))
Пример #7
0
def main():
    base = get_astri_2019("")
    runlist_paths = [
        join(base, "d2019-04-30_cosmicray/runlist.txt"),
        join(base, "d2019-05-01_cosmicray/runlist.txt"),
        join(base, "d2019-05-01_mrk501/runlist.txt"),
        join(base, "d2019-05-02_PG1553+113/runlist.txt"),
        join(base, "d2019-05-02_mrk421/runlist.txt"),
        join(base, "d2019-05-02_mrk501/runlist.txt"),
        join(base, "d2019-05-06_mrk501/runlist.txt"),
        join(base, "d2019-05-07_cosmicray/runlist.txt"),
        join(base, "d2019-05-08_cosmicray/runlist.txt"),
        join(base, "d2019-05-09_mrk421/runlist.txt"),
    ]
    output_path = get_data("d190522_hillas_over_campaign/hillas.h5")

    with HDF5Writer(output_path) as writer:

        n_investigations = len(runlist_paths)
        mapping = None

        for iinv, path in enumerate(runlist_paths):
            print(f"PROGRESS: Processing inv {iinv+1}/{n_investigations}")

            if not exists(path):
                raise ValueError(f"Missing runlist file: {path}")

            directory = abspath(dirname(path))
            investigation = directory.split('/')[-1]
            df_runlist = pd.read_csv(path, sep='\t')

            for _, row in df_runlist.iterrows():
                run = int(row['run'])
                hillas_path = join(directory, f"Run{run:05d}_hillas.h5")

                with HDF5Reader(hillas_path) as reader:
                    if mapping is None:
                        mapping = reader.get_mapping()

                    keys = ['data', 'pointing', 'mc', 'mcheader']
                    for key in keys:
                        if key not in reader.dataframe_keys:
                            continue

                        it = enumerate(reader.iterate_over_chunks(key, 1000))
                        for ientry, df in it:
                            df['iinv'] = iinv
                            df['investigation'] = investigation
                            writer.append(df, key=key)

        writer.add_mapping(mapping)
Пример #8
0
def main():
    # paths = glob(get_astri_2019("d2019-04-23_nudges/mc/*.simtel.gz"))
    # output = get_astri_2019("d2019-04-23_nudges/mc/charge.h5")
    paths = glob(get_astri_2019("d2019-04-23_nudges/mc_191011/*.simtel.gz"))
    output = get_astri_2019("d2019-04-23_nudges/mc_191011/charge.h5")

    with HDF5Writer(output) as writer:
        for path in paths:
            reader = SimtelReader(path)

            kw = dict(
                n_pixels=reader.n_pixels,
                n_samples=reader.n_samples,
                mapping=reader.mapping,
                reference_pulse_path=reader.reference_pulse_path,
            )
            baseline_subtractor = BaselineSubtractor(reader)
            extractor_onsky = OnskyExtractor(**kw)
            common = Common(**kw, _disable_by_default=True, waveform_max=True)

            pixel_array = np.arange(reader.n_pixels)

            desc = "Looping over file"
            for wfs in tqdm(reader, total=reader.n_events, desc=desc):
                iev = wfs.iev
                wfs = baseline_subtractor.subtract(wfs)

                params = dict(
                    iev=iev,
                    pixel=pixel_array,
                    onsky=extractor_onsky.process(wfs)['charge_onsky'],
                    waveform_max=common.process(wfs)['waveform_max'],
                    mc_true=wfs.mc_true,
                )

                df = pd.DataFrame(params)
                writer.append(df, key='data')
def main():
    path = get_astri_2019("astri_db.h5")
    with HDF5Reader(path) as reader:
        ra = reader.read("TCU_ACTUAL_RA")
        dec = reader.read("TCU_ACTUAL_DEC")
        alt = reader.read("TCU_ELACTPOS")
        az = reader.read("TCU_AZACTPOS")

    df = pd.merge(pd.merge(
        ra, dec,
        on='timestamp').rename(columns=dict(value_x="ra", value_y="dec")),
                  pd.merge(alt, az, on='timestamp').rename(
                      columns=dict(value_x="alt", value_y="az")),
                  on='timestamp')

    df = df.query(" (timestamp > '2019-06-12 18:00')"
                  "&(timestamp < '2019-06-13 05:00')")

    embed()

    altaz_frame = AltAz(location=LOCATION, obstime=df['timestamp'].values)
    telescope_pointing = SkyCoord(
        alt=df['alt'].values,
        az=df['az'].values,
        unit='deg',
        frame=altaz_frame,
    )
    telescope_pointing_icrs = telescope_pointing.icrs
    df['ra_calc'] = telescope_pointing_icrs.ra.deg
    df['dec_calc'] = telescope_pointing_icrs.dec.deg

    d_ra = np.arctan2(np.sin(df['ra'] - df['ra_calc']),
                      np.cos(df['ra'] - df['ra_calc']))
    d_dec = np.arctan2(np.sin(df['dec'] - df['dec_calc']),
                       np.cos(df['dec'] - df['dec_calc']))

    p = Plotter()
    p.ax.plot(df['timestamp'], d_ra)
    p.ax.set_xlabel("Timestamp")
    p.ax.set_ylabel("RA_database - RA_calculated (deg)")
    p.fig.autofmt_xdate()
    p.save(get_plot("d190918_alpha/pointing/ra.pdf"))

    p = Plotter()
    p.ax.plot(df['timestamp'], d_dec)
    p.ax.set_xlabel("Timestamp")
    p.ax.set_ylabel("DEC_database - DEC_calculated (deg)")
    p.fig.autofmt_xdate()
    p.save(get_plot("d190918_alpha/pointing/dec.pdf"))
def main():
    pixel_mask_path = get_astri_2019(
        # "d2019-04-23_nudges/mc/mc_chec_pixel_mask_190521.dat"
        "d2019-04-23_nudges/mc_191011/mc_chec_pixel_mask.dat")
    pm = PixelMasks(pixel_mask_path)
    dead = np.where(pm.all_mask)[0]

    path = get_astri_2019("d2019-04-23_nudges/mc/charge.h5")
    output_path = get_calib_data("charge2photons_simtel.yml")
    pde = 0.25

    with HDF5Reader(path) as reader:
        df = reader.read("data")
        df = df.loc[df['mc_true'] > 5]
        isin_dead = df['pixel'].isin(dead)
        df = df.loc[~isin_dead]

    measured = df['onsky'].values
    true = df['mc_true'].values / pde

    coeff = polyfit(true, measured, [1])
    _, charge2photons = coeff

    print(f"charge2photons = {charge2photons}")

    results_dir = get_astri_2019(
        "d2019-04-23_nudges/results/extract_charge2photons_mc")

    p_calib = CalibPlotter()
    p_calib.plot(true, measured, coeff)
    p_calib.save(join(results_dir, "calib.pdf"))

    output = dict(charge2photons=float(charge2photons), )
    with open(output_path, 'w') as outfile:
        yaml.dump(output, outfile, default_flow_style=False)
    print(f"Created charge2photons file: {output_path}")
Пример #11
0
def main():
    output_path = get_data(f"d190918_alpha/onsky_hillas.h5")
    path_list = [
        glob(get_astri_2019("d2019-05-01_mrk501/*_hillas.h5")),
        glob(get_astri_2019("d2019-05-02_PG1553+113/*_hillas.h5")),
        glob(get_astri_2019("d2019-05-02_mrk421/*_hillas.h5")),
        glob(get_astri_2019("d2019-05-02_mrk501/*_hillas.h5")),
        glob(get_astri_2019("d2019-05-06_mrk501/*_hillas.h5")),
        glob(get_astri_2019("d2019-05-09_mrk421/*_hillas.h5")),
        glob(get_astri_2019("d2019-06-12_mrk421_moonlight/*_hillas.h5")),
        glob(get_astri_2019("d2019-06-12_mrk501/*_hillas.h5")),
        glob(get_astri_2019("d2019-06-12_mrk501_moonlight/*_hillas.h5")),
    ]

    with HDF5Writer(output_path) as writer:
        for iinv, hillas_paths in enumerate(path_list):
            hillas_paths = sort_file_list(hillas_paths)

            for ifile, input_path in enumerate(hillas_paths):
                with HDF5Reader(input_path) as reader:
                    if ifile == 0:
                        writer.add_mapping(reader.get_mapping())
                        writer.add_metadata(**reader.get_metadata())

                    df = reader.read("data")
                    df_pointing = reader.read("pointing")
                    df_source = reader.read("source")
                    source_name = reader.get_metadata("source")['source_name']

                    df['iinv'] = iinv
                    df['ifile'] = ifile
                    df['source_ra'] = df_source['source_ra'].values
                    df['source_dec'] = df_source['source_dec'].values
                    df['altitude_raw'] = df_pointing['altitude_raw'].values
                    df['altitude_cor'] = df_pointing['altitude_cor'].values
                    df['azimuth_raw'] = df_pointing['azimuth_raw'].values
                    df['azimuth_cor'] = df_pointing['azimuth_cor'].values
                    df['source_name'] = source_name

                    writer.append(df, 'data')
Пример #12
0
def main():
    # path = get_astri_2019("d2019-06-10_ledflashers/flasher_comparison_May-June/unit0pattern-low_r1.tio")
    # path = get_astri_2019("d2019-06-10_ledflashers/flasher_comparison_May-June/Run13270_r1.tio")
    path = get_astri_2019(
        "d2019-06-10_ledflashers/flasher_comparison_May-June/Run13401_r1.tio")

    output_dir = path.replace("_r1.tio", "")
    reader = TIOReader(path, max_events=100)
    waveforms = reader[:].mean(0)
    mapping = get_superpixel_mapping(reader.mapping)
    n_pixels, n_samples = waveforms.shape
    n_sp = n_pixels // 4

    correction = pd.read_csv(join(DIR, "sp_illumination_profile.dat"),
                             sep='\t')['correction'].values

    sp_waveforms = waveforms.reshape((n_sp, 4, n_samples)).sum(1)
    sp_waveforms_corrected = sp_waveforms * correction[:, None]

    amplitude = sp_waveforms_corrected.max(1)
    median = np.median(amplitude)
    threshold = median * 1.10
    trigger_off = amplitude > threshold
    # trigger_off[[  # TODO: Remove?
    #     355, 356, 357, 358, 359, 382, 375, 460, 459, 457, 458, 465, 289, 489,
    #     502, 254, 247, 154, 144, 56, 46, 39, 24, 25, 76
    # ]] = True
    hv_off = np.zeros(n_sp, dtype=bool)
    hv_off[[24, 453]] = True
    print(f"SP Trigger OFF: {np.where(trigger_off)[0].tolist()}")
    print(f"SP HV OFF: {np.where(hv_off)[0].tolist()}")

    plot = CameraPlotter(mapping)
    plot.highlight_pixels(trigger_off, 'yellow')
    plot.highlight_pixels(hv_off, 'red')
    plot.plot_waveforms(sp_waveforms)
    plot.save(join(output_dir, "led.pdf"))
    plot.plot_waveforms(sp_waveforms_corrected)
    plot.save(join(output_dir, "uniform.pdf"))

    df = pd.DataFrame(
        dict(
            superpixel=np.arange(n_sp),
            hv_on=(~hv_off).astype(int),
            trigger_off=trigger_off.astype(int),
        ))
    df.to_csv(join(output_dir, "sp_settings.txt"), sep='\t', index=False)
def main():
    path = get_astri_2019("d2019-06-10_ledflashers/flasher_comparison_May-June/unit0pattern-low_r1.tio")
    reader = TIOReader(path, max_events=100)
    waveforms = reader[:].mean(0)

    # Calculate coeff
    n_pixels, n_samples = waveforms.shape
    n_sp = n_pixels // 4
    waveforms_sp = waveforms.reshape(
        (n_sp, 4, n_samples)
    ).sum(1)
    correction = (waveforms_sp.max(1).mean() / waveforms_sp.max(1))

    df = pd.DataFrame(dict(
        superpixel=np.arange(n_sp),
        correction=correction,
    ))
    df.to_csv(join(DIR, "sp_illumination_profile.dat"), sep='\t', index=False)
Пример #14
0
def main():
    pm = PixelMasks()
    dead = np.where(np.logical_or(pm.dead, np.repeat(pm.bad_hv, 4)))[0]

    ref_path = CameraConfiguration("1.1.0").GetReferencePulsePath()
    cc = CrossCorrelation(1, 96, reference_pulse_path=ref_path)

    spe_path = get_astri_2019('d2019-04-23_nudges/spe_+0.h5')
    with pd.HDFStore(spe_path) as store:
        coeff = store['coeff_pixel']
        coeff = coeff.loc[~coeff['pixel'].isin(dead)]

    spe = cc.get_pulse_height(np.median(coeff['spe']))
    spe_sigma = cc.get_pulse_height(np.median(coeff['spe_sigma']))
    opct = np.median(coeff['opct'])

    output_dir = get_plot("d190716_simtel_cfg")
    generate_spectrum.call(output_dir, spe, spe_sigma, opct, 0, 0)
Пример #15
0
def main():
    name = "mrk501"
    file_lists = [
        glob(get_astri_2019("d2019-05-01_mrk501/*_hillas.h5")),
        glob(get_astri_2019("d2019-05-02_mrk501/*_hillas.h5")),
        glob(get_astri_2019("d2019-05-06_mrk501/*_hillas.h5")),
        glob(get_astri_2019("d2019-06-12_mrk501/*_hillas.h5")),
        glob(get_astri_2019("d2019-06-12_mrk501_moonlight/*_hillas.h5")),
    ]
    process(name, file_lists)

    name = "mrk421"
    file_lists = [
        glob(get_astri_2019("d2019-05-02_mrk421/*_hillas.h5")),
        glob(get_astri_2019("d2019-05-09_mrk421/*_hillas.h5")),
        glob(get_astri_2019("d2019-06-12_mrk421_moonlight/*_hillas.h5")),
    ]
    process(name, file_lists)

    name = "PG1553+113"
    file_lists = [
        glob(get_astri_2019("d2019-05-02_PG1553+113/*_hillas.h5")),
    ]
    process(name, file_lists)
Пример #16
0
 def __init__(self):
     self.directory = get_astri_2019("d2019-05-02_PG1553+113")
     self.events = dict(
         Run12931=[
             28727,
             63199,
             #     16187,
             #     16403,
             #     17586,
             #     28727,
             #     1025,
             #     1421,
             #     1592,
             #     1892,
             #     1942,
             #     2181,
             #     2602,
             #     3151,
             #     3440,
             #     3921,
             #     5186,
             #     9587,
             #     10381,
             #     10514,
             #     13814,
             #     14366,
             #     15282,
         ],
         # Run12932=[
         #     24203,
         # ],
         # Run12933=[
         #     4284,
         #     7605,
         #     24041,
         #     28891,
         # ],
         # Run12934=[
         #     17390,
         # ],
     )
Пример #17
0
def main():
    paths = glob(get_astri_2019("*/*_r1.tio"))
    pattern = re.compile(r"(?:.+?)/d(.+?)/Run(\d+?)_r1.tio")
    d_list = []
    for path in paths:
        reader = TIOReader(path)
        wfs = reader[0]
        nudge, temperature = get_nudge_and_temperature_from_reader(reader)

        regexp = re.search(pattern, path)
        investigation = regexp.group(1)
        run_id = regexp.group(2)

        d_list.append(
            dict(investigation=investigation,
                 run_id=run_id,
                 t_cpu=wfs.t_cpu,
                 nudge=nudge,
                 temperature=temperature))

    df = pd.DataFrame(d_list)
    with HDF5Writer(get_data("d190507_check_amplitude_calib/data.h5")) as w:
        w.write(data=df)
Пример #18
0
def main():
    path = get_astri_2019("d2019-05-02_mrk421/Run12913_hillas.h5")
    with HDF5Reader(path) as reader:
        t_tack, length = reader.select_columns('data', ['t_tack', 'length'])

    tack = t_tack.values.astype(np.int)
    notzero = tack != 0
    tack = tack[notzero]
    length = length[notzero]
    mask = (length > 2.2) & (length < 2.4)
    tack_noisy = tack[mask]

    dtack = np.diff(tack)
    dtack_noisy = np.diff(tack_noisy)

    # embed()

    output_dir = get_plot("d190522_hillas_over_campaign")

    p_tack = TackPlotter()
    p_tack.add(dtack, label="All")
    # p_tack.add(dtack_noisy, label="Noisy Events")
    p_tack.save(join(output_dir, "dtack.pdf"))
Пример #19
0
class d20190614_pedestal_3(File):
    """Internal BP generator 10k events 0 5 9 14 18 23 27 28"""
    r0 = get_astri_2019("d2019-06-14_pedestal/Run13799_r0.tio")
Пример #20
0
class d20190614_pedestal_1(File):
    """Internal BP generator 1kHz 1 6 10 15 19 20 24 29"""
    r0 = get_astri_2019("d2019-06-14_pedestal/Run13795_r0.tio")
Пример #21
0
class d20190612_muon(File):
    r0 = get_astri_2019("d2019-06-12_muon/Run13695_r0.tio")
Пример #22
0
from CHECLabPy.core.io import TIOReader
from sstcam_sandbox import get_astri_2019
from tqdm import trange
import numpy as np
from matplotlib import pyplot as plt

path = get_astri_2019("d2019-06-14_pedestal/Run13794_r0.tio")
reader = TIOReader(path)
dt = np.zeros(reader.n_events - 1)
for iev in trange(1, reader.n_events):
    dt[iev - 1] = (reader[iev].t_cpu - reader[iev - 1].t_cpu).value

plt.hist(dt, bins=100)
plt.yscale("log")
Пример #23
0
class d20190614_pedestal_2(File):
    """Internal BP generator 5k events 2 7 11 12 16 21 25 30"""
    r0 = get_astri_2019("d2019-06-14_pedestal/Run13798_r0.tio")
Пример #24
0
class d20190614_pedestal_4(File):
    """Flasher input 4 12 20 28"""
    r0 = get_astri_2019("d2019-06-14_pedestal/Run13800_r0.tio")
Пример #25
0
def main():
    pm = PixelMasks()
    dead = np.where(np.logical_or(pm.dead, np.repeat(pm.bad_hv, 4)))[0]

    bright_path = get_astri_2019("d2019-04-23_nudges/bright_50pe/charge.h5")
    with HDF5Reader(bright_path) as reader:
        df_bright = reader.read("data")
        isin_dead = df_bright['pixel'].isin(dead)
        df_bright = df_bright.loc[~isin_dead]

    spe_path = get_astri_2019("d2019-04-23_nudges/results/process_spe/spe.csv")
    df_spe = pd.read_csv(spe_path)

    illumination = calculate_illumination(df_bright, df_spe)

    d_list = []

    for nudge, group in df_bright.groupby("nudge"):
        temperatures = group['temperature'].values
        assert (temperatures == temperatures[0]).all()
        temperature = temperatures[0]

        calibrator = OnskyAmplitudeCalibrator(nudge, temperature)

        pixel = group['pixel'].values
        charge = group['onsky_calib'].values
        charge_cal = calibrator(charge, pixel)

        group_avg = group.groupby('pixel').mean()
        pixel_avg = group_avg.index.values
        charge_avg = group_avg['onsky_calib'].values
        charge_avg_cal = calibrator(charge_avg, pixel_avg)

        rmse = np.sqrt(
            np.sum((illumination - charge_cal)**2) / charge_cal.size)

        d_list.append(
            dict(
                nudge=nudge,
                mean=charge_cal.mean(),
                std=charge_cal.std(),
                mean_avg=charge_avg_cal.mean(),
                std_avg=charge_avg_cal.std(),
                rmse=rmse,
            ))

    df = pd.DataFrame(d_list)

    output_dir = get_astri_2019("d2019-04-23_nudges/results/plot_residuals")

    p_cal = CalibratedvsNudge("DAC Nudge", "Calibrated Charge (photons)")
    p_cal.plot(df['nudge'], df['mean'], df['std'])
    p_cal.ax.axhline(illumination, color='red', alpha=0.2, lw=0.2)
    p_cal.save(join(output_dir, "calibrated_vs_nudge.pdf"))

    p_avg = CalibratedvsNudge("DAC Nudge", "Average Charge (photons)")
    p_avg.plot(df['nudge'], df['mean_avg'], df['std_avg'])
    p_avg.ax.axhline(illumination, color='red', alpha=0.2, lw=0.2)
    p_avg.save(join(output_dir, "calibrated_vs_nudge_avg.pdf"))

    p_rmse = CalibratedvsNudge("DAC Nudge", f"RMSE {illumination:.2f} photons")
    p_rmse.plot(df['nudge'], df['rmse'], None)
    p_rmse.save(join(output_dir, "rmse_vs_nudge.pdf"))
Пример #26
0
class InternalTrigger_0(File):
    r0 = get_astri_2019("d2019-05-02_mrk421/Run12913_r0.tio")
Пример #27
0
class Lab_spe1p1(File):
    r0 = get_astri_2019("d2019-04-23_nudges/spe_1.1pe/pedestal_r0.tio")
Пример #28
0
class Lab_spe0p8(File):
    r0 = get_astri_2019("d2019-04-23_nudges/spe_0.8pe/pedestal_r0.tio")
Пример #29
0
class Lab_bright(File):
    r0 = get_astri_2019("d2019-04-23_nudges/bright_50pe/pedestal_r0.tio")
Пример #30
0
class InternalTrigger_1(File):
    r0 = get_astri_2019("d2019-06-12_mrk501/Run13681_r0.tio")