예제 #1
0
    def __init__(self, mapping, **kwargs):
        super().__init__(sidebyside=True, **kwargs)

        figsize = self.get_figsize()

        self.fig_image = plt.figure(figsize=figsize)
        self.ax_image = self.fig_image.add_subplot(1, 1, 1)
        self.ci_image = CameraImage.from_mapping(mapping, ax=self.ax_image)
        self.ci_image.add_colorbar("Pixel Amplitude (p.e.)", pad=-0.2)

        self.fig_gf = plt.figure(figsize=figsize)
        self.ax_gf = self.fig_gf.add_subplot(1, 1, 1)
        self.ci_gf = CameraImage.from_mapping(mapping, ax=self.ax_gf)
        self.ci_gf.add_colorbar("Pixel Amplitude (mV)", pad=-0.2)

        figsize_combined = figsize
        figsize_combined[0] *= 1.5
        self.fig_combined = plt.figure(figsize=figsize_combined)
        self.ax_cgf = self.fig_combined.add_subplot(1, 2, 1)
        self.ax_cimage = self.fig_combined.add_subplot(1, 2, 2)
        self.ci_cgf = CameraImage.from_mapping(mapping, ax=self.ax_cgf)
        # self.ci_cgf.add_colorbar("Pixel Amplitude (mV)", pad=0)
        self.ci_cimage = CameraImage.from_mapping(mapping, ax=self.ax_cimage)
        self.ci_cimage.add_colorbar("Pixel Amplitude (p.e.)", pad=0)
        self.fig_combined.subplots_adjust(left=0.01,
                                          right=0.95,
                                          top=0.90,
                                          bottom=0.05,
                                          wspace=0,
                                          hspace=0)

        self.meta = None
        self.image = None
        self.waveforms = None
예제 #2
0
    def __init__(self, mapping):
        super().__init__()

        self.fig = plt.figure(figsize=(8, 3))
        self.ax_values = self.fig.add_subplot(1, 2, 1)
        self.ax_errors = self.fig.add_subplot(1, 2, 2)
        self.ci_values = CameraImage.from_mapping(mapping, ax=self.ax_values)
        self.ci_errors = CameraImage.from_mapping(mapping, ax=self.ax_errors)
        self.ci_values.add_colorbar("Fit Values", pad=0.1)
        self.ci_errors.add_colorbar("Fit Errors", pad=0.1)
    def __init__(self, mapping):
        super().__init__()

        self.fig = plt.figure(figsize=(8, 3))
        self.ax_mean = self.fig.add_subplot(1, 2, 1)
        self.ax_std = self.fig.add_subplot(1, 2, 2)
        self.ci_mean = CameraImage.from_mapping(mapping, ax=self.ax_mean)
        self.ci_std = CameraImage.from_mapping(mapping, ax=self.ax_std)
        self.ci_mean.add_colorbar("Residuals Mean (ADC)", pad=0.1)
        self.ci_std.add_colorbar("Residuals StdDev (ADC)", pad=0.1)
예제 #4
0
def plot_from_coordinates():
    """
    Plot directly with coordinates
    """
    from target_calib import CameraConfiguration
    c = CameraConfiguration("1.1.0")
    m = c.GetMapping()
    xpix = np.array(m.GetXPixVector())
    ypix = np.array(m.GetYPixVector())
    size = m.GetSize()
    camera = CameraImage(xpix, ypix, size)
    image = np.zeros(xpix.size)
    image[::2] = 1
    camera.image = image
    plt.show()
예제 #5
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}")
예제 #6
0
def process(name, tcal_path):
    ped_reader = PedestalArrayReader(tcal_path)
    hits_tcal = np.array(ped_reader.GetHits())
    std_tcal = np.array(ped_reader.GetStdDev())

    mask = (hits_tcal < 6) | np.isnan(std_tcal)
    std_tcal = np.ma.masked_array(std_tcal, mask=mask)

    embed()

    # std_values = std_tcal.compressed()
    # std_pix = std_tcal.mean((2, 3)).ravel()
    std_max_pix = std_tcal.max((2, 3)).ravel()

    # p_hist = Hist()
    # p_hist.plot(std_values)
    # p_hist.save(get_plot(f"d190730_pedestal/plot_from_tcals/hist/{name}.png"))
    #
    # p_ci = CameraImage.from_camera_version("1.1.0")
    # p_ci.image = std_pix
    # p_ci.add_colorbar()
    # p_ci.save(get_plot(f"d190730_pedestal/plot_from_tcals/camera/{name}.png"))

    p_ci = CameraImage.from_camera_version("1.1.0")
    p_ci.image = std_max_pix
    p_ci.add_colorbar()
    p_ci.save(
        get_plot(f"d190730_pedestal/plot_from_tcals/camera_max/{name}.png"))
예제 #7
0
def main():
    file = np.load("cherenkov.npz")
    cherenkov = file['frames']
    min_array = file['min']
    max_array = file['max']
    n_pixels, n_frames = cherenkov.shape

    message = np.load("happy_birthday_rich.npy")

    ci = CameraImage.from_camera_version("1.1.0")
    mapping = get_clp_mapping_from_version("1.1.0")
    rows = mapping.metadata['n_rows'] - mapping.row
    # embed()

    for iframe in range(n_frames):
        frame = cherenkov[:, iframe]
        min_ = min_array[iframe]
        max_ = max_array[iframe]
        max_row = iframe // 2

        frame_message = message.copy()
        frame_message[rows > max_row] = False
        frame[frame_message] += (max_ + min_) / 2

        ci.image = frame
        ci.set_limits_minmax(min_, max_)
        ci.save(f"frames/{iframe:03d}.png", dpi=115)
예제 #8
0
def plot_pixel_positions():
    """
    Plot pixel positions onto the camera
    """
    camera_version = "1.0.1"
    camera = CameraImage.from_camera_version(camera_version)
    pixels = np.arange(camera.n_pixels)
    camera.add_pixel_text(pixels)
    plt.show()
예제 #9
0
def plot_tm_edge_labels():
    """
    Annotate plot with the TM numbers on the edges
    """
    camera_version = "1.1.0"
    camera = CameraImage.from_camera_version(camera_version)
    pixels = np.arange(camera.n_pixels)
    camera.annotate_tm_edge_label()
    plt.show()
예제 #10
0
def main():
    path = "/Volumes/gct-jason/astri_onsky_archive/d2019-10-03_simulations/gamma_1deg/run1_dl1.h5"
    # path = "/Volumes/gct-jason/astri_onsky_archive/d2019-05-15_simulations/gamma_1deg/run1_dl1_old.h5"
    reader = DL1Reader(path)
    df = reader.load_entire_table()
    image = df.groupby(['pixel']).sum()['photons']

    ci = CameraImage.from_mapping(reader.mapping)
    ci.image = image
    ci.save(get_plot("d190717_alpha/true_images.pdf"))
예제 #11
0
def plot_from_camera_version_single_module():
    """
    Plot a single module by specifying a camera version (requires TargetCalib)
    """
    camera_version = "1.1.0"
    camera = CameraImage.from_camera_version(camera_version, True)
    image = np.zeros(64)
    image[::2] = 1
    camera.image = image
    plt.show()
예제 #12
0
def plot_from_camera_version():
    """
    Plot by specifying a camera version (requires TargetCalib)
    """
    camera_version = "1.1.0"
    camera = CameraImage.from_camera_version(camera_version)
    image = np.zeros(2048)
    image[::2] = 1
    camera.image = image
    plt.show()
예제 #13
0
def plot_with_limits():
    """
    Set the z-axis limits
    """
    camera_version = "1.1.0"
    camera = CameraImage.from_camera_version(camera_version)
    image = np.arange(2048)
    camera.add_colorbar()
    camera.set_limits_minmax(0, 1000)
    camera.image = image
    plt.show()
예제 #14
0
def plot_from_tc_mapping():
    """
    Plot using the TargetCalib Mapping class
    """
    from target_calib import CameraConfiguration
    c = CameraConfiguration("1.1.0")
    m = c.GetMapping()
    camera = CameraImage.from_tc_mapping(m)
    image = np.zeros(m.GetNPixels())
    image[::2] = 1
    camera.image = image
    plt.show()
예제 #15
0
def r0r1cameraplotter(input_path):
    reader = TIOReader(input_path)  # Load the file
    wfs = reader[1]
    for m in range (0,13):
        camera = plt.figure(figsize=(10, 10))
        # Generate a CameraImage object using the classmethod "from_mapping" which accepts the
        # mapping object contained in the reader, which converts from pixel ID to pixel
        # coordinates (using the Mapping class in TargetCalib)
        camera = CameraImage.from_mapping(reader.mapping)
        camera.add_colorbar()
        camera.image = wfs[:, m*10]  # Plot value of the sample at m x 10ns for each pixel
        plt.show()
        '''
예제 #16
0
def plot_from_tio():
    """
    Use the CHECLabPy mapping dataframe to plot an image
    """
    path = "/Users/Jason/Software/CHECLabPy/refdata/Run17473_r1.tio"
    r = TIOReader(path, max_events=10)
    camera = CameraImage.from_mapping(r.mapping)
    camera.add_colorbar("Amplitude (mV)")
    camera.annotate_on_telescope_up()
    for wf in r:
        image = wf[:, 60]
        camera.image = image
        plt.pause(0.5)
예제 #17
0
def plot_tm():
    """
    Make a camera image plot for values that are per superpixel
    """
    from target_calib import CameraConfiguration
    c = CameraConfiguration("1.1.0")
    m = c.GetMapping()
    df = get_tm_mapping(get_clp_mapping_from_tc_mapping(m))
    camera = CameraImage.from_mapping(df)
    image = np.zeros(m.GetNModules())
    image[::2] = 1
    camera.image = image
    plt.show()
예제 #18
0
def plot_from_dl1():
    """
    Use the CHECLabPy mapping dataframe to plot an image
    """
    path = "/Users/Jason/Software/CHECLabPy/refdata/Run17473_dl1.h5"
    r = DL1Reader(path)
    camera = CameraImage.from_mapping(r.mapping)
    camera.add_colorbar("Charge (mV ns)")
    for i, df in enumerate(r.iterate_over_events()):
        if i > 10:
            break
        charge = df['charge'].values
        camera.image = charge
        plt.pause(0.1)
    def __init__(self, mapping, output_path):
        super().__init__()

        self.fig = plt.figure(figsize=(8, 3))
        self.ax_goldfish = self.fig.add_axes([0, 0, 0.4, 1])
        self.ax_image = self.fig.add_axes([0.4, 0, 0.4, 1])
        self.ax_cb = self.fig.add_axes([0.68, 0, 0.15, 1])
        self.ax_image.patch.set_alpha(0)
        self.ax_cb.patch.set_alpha(0)
        self.ax_cb.axis('off')
        self.ci_image = CameraImage.from_mapping(mapping, ax=self.ax_image)
        self.ci_image.add_colorbar(
            "Pixel Amplitude (p.e.)", ax=self.ax_cb, pad=-0.5
        )
        self.ci_goldfish = CameraImage.from_mapping(mapping, ax=self.ax_goldfish)

        self.output_path = output_path
        self.source_point_image = None
        self.source_point_goldfish = None
        self.source_label_image = None
        self.source_label_goldfish = None
        self.alpha_line = None
        self.timestamp = None
        self.iframe = 0
    def __init__(self, mapping, output_dir):
        super().__init__()

        self.fig = plt.figure(figsize=(8, 6))
        self.ax = self.fig.add_subplot(1, 1, 1)

        self.ci = CameraImage.from_mapping(mapping, ax=self.ax)
        self.ci.add_colorbar("Pixel Amplitude (p.e.)", pad=-0.15)
        # self.ci.colorbar.set_label("Pixel Amplitude (p.e.)", labelpad=20)
        self.output_dir = output_dir
        self.source_point = None
        self.source_label = None
        self.alpha_line = None
        self.iframe = 0

        create_directory(output_dir)
예제 #21
0
xpix = m['xpix']
ypix = m['ypix']
dist = np.sqrt(xpix**2 + ypix**2)

measured_p = measured.values.reshape((1000, 2048)).mean(0)
true_p = true.values.reshape((1000, 2048)).mean(0)

p_mvt = PixelScatter("Measured", "True", "Distance from camera center")
p_dvt = PixelScatter("Distance from camera center", "True", "Measured")
p_dvm = PixelScatter("Distance from camera center", "Measured", "True")

# p_mvt.plot(measured_p, true_p, dist)
calib_params = p_dvt.plot(dist, true_p, measured_p)
# p_dvm.plot(dist, measured_p, true_p)

p_mvt.save("mvt.pdf")
p_dvt.save("dvt.pdf")
p_dvm.save("dvm.pdf")

xpix = m['xpix'].values
ypix = m['ypix'].values
dist = np.sqrt(xpix**2 + ypix**2)
f = polyval(dist, calib_params)
print(calib_params)

p_f = CameraImage.from_mapping(m)
p_f.image = f
p_f.add_colorbar()
p_f.save("f.pdf")

np.savetxt("illumination_correction_mc.txt", f)
예제 #22
0
 def __init__(self, mapping, output_dir):
     self.camera = CameraImage.from_mapping(mapping)
     self.camera.add_colorbar()
     self.output_dir = output_dir
예제 #23
0
 def create_image(mapping, ax, clabel):
     ci = CameraImage.from_mapping(mapping, ax=ax)
     ci.add_colorbar(clabel, pad=0)
     # ci.pixels.set_linewidth(0.2)
     # ci.pixels.set_edgecolor('black')
     return ci
예제 #24
0
plt.ylabel("Amplitude / (mV)")
plt.title("Interval of offset")
for i in [1,23,600,900,1200]:
    plt.plot(dt,calibrated_data[:,i])   
plt.savefig(os.path.join(current_path+'/'+ runfile, runfile+"_std_interval"))


#A time series plot
plt.figure()
plt.plot(data.time-data.time[0],int_space_averaged)
plt.xlabel('Time since run start (s)')
plt.ylabel("Average amplitude (mV)")
plt.savefig(os.path.join(current_path+'/'+ runfile, runfile+"_space_averaged_over_time"))

#Different average camera images
camera = CameraImage(data.xpix, data.ypix, data.size)
camera.image = int_time_averaged
zmin_intspace = min(int_space_averaged) - 0.05*min(int_space_averaged)
zmax_intspace = max(int_space_averaged) + 0.05*max(int_space_averaged)
camera.set_limits_minmax(zmin=zmin_intspace,zmax = zmax_intspace)
camera.add_colorbar('Amplitdue (mV)')
camera.ax.set_title('Time averaged data')
plt.savefig(os.path.join(current_path+'/'+ runfile, runfile+"_camera_time_averaged"))

camera = CameraImage(data.xpix, data.ypix, data.size)
camera.image = calibrated_data[0,:]
camera.add_colorbar('Amplitdue (mV)')
zmin_calbdat = min(int_space_averaged) - 0.01*min(int_space_averaged) 
#zmin_calbdat = 380
zmax_calbdat = max(int_space_averaged) + 0.01*max(int_space_averaged) 
camera.set_limits_minmax(zmin=zmin_calbdat,zmax = zmax_calbdat)
예제 #25
0
def main():
    path = get_data("d190522_hillas_over_campaign/hillas.h5")
    # path = get_data("d190522_hillas_over_campaign/hillas_old.h5")
    path_mc = get_astri_2019("d2019-05-15_simulations/proton.h5")

    with HDF5Reader(path) as reader:
        df = reader.read("data")
        mapping = reader.get_mapping()

        df = df.loc[(df['width'] * df['length'] / df['concentration_1']) < 20]
        # df = df.loc[df['intensity'] > 1000*4]
        print(f"N_EVENTS={df.index.size}")

    with HDF5Reader(path_mc) as reader:
        df_mc = reader.read("data")
        mapping_mc = reader.get_mapping()

    output_dir = get_plot("d190522_hillas_over_campaign/cog")

    for _, group in df.groupby("iinv"):
        investigation = group.iloc[0]['investigation']
        x = group['x'].values
        y = group['y'].values

        p_cog = COGPlotter()
        p_cog.plot(x, y, mapping)
        p_cog.save(join(output_dir, f"{investigation}.png"), dpi=1000)

    x = df['x'].values
    y = df['y'].values
    p_cog = COGPlotter()
    p_cog.plot(x, y, mapping)
    p_cog.save(join(output_dir, f"all.png"), dpi=1000)
    image = bin_cog(x, y, mapping)
    ci = CameraImage.from_mapping(mapping)
    ci.image = image
    ci.add_colorbar()
    ci.save(join(output_dir, f"all_image.png"), dpi=1000)

    df_week1 = df.loc[df['iinv'] < 6]
    x = df_week1['x'].values
    y = df_week1['y'].values
    p_cog = COGPlotter()
    p_cog.plot(x, y, mapping)
    p_cog.save(join(output_dir, "week1.png"), dpi=1000)
    camera = bin_cog(x, y, mapping)
    centre = camera.reshape((32, 64))[[12, 13, 18, 19]].ravel()
    ci = CameraImage.from_mapping(mapping)
    ci.image = camera
    ci.add_colorbar()
    ci.save(join(output_dir, f"week1_image.png"), dpi=1000)
    p_hist = Hist()
    p_hist.plot(camera, "Camera")
    p_hist.plot(centre, "Centre")
    p_hist.save(join(output_dir, f"week1_hist.png"), dpi=1000)
    mean_camera = np.mean(camera)
    mean_centre = np.mean(centre)
    std_camera = np.std(camera)
    std_centre = np.std(centre)
    print(f"Week1: camera_mean={mean_camera}, camera={std_camera/mean_camera}, centre={std_centre/mean_centre}")

    df_week2 = df.loc[df['iinv'] >= 6]
    x = df_week2['x'].values
    y = df_week2['y'].values
    p_cog = COGPlotter()
    p_cog.plot(x, y, mapping)
    p_cog.save(join(output_dir, "week2.png"), dpi=1000)

    x = df_mc['x'].values
    y = df_mc['y'].values
    p_cog = COGPlotter()
    p_cog.plot(x, y, mapping_mc)
    p_cog.save(join(output_dir, f"mc.png"), dpi=1000)
    camera = bin_cog(x, y, mapping)
    centre = camera.reshape((32, 64))[[12, 13, 18, 19]].ravel()
    ci = CameraImage.from_mapping(mapping)
    ci.image = camera
    ci.add_colorbar()
    ci.save(join(output_dir, f"mc_image.png"), dpi=1000)
    p_hist = Hist()
    p_hist.plot(camera, "Camera")
    p_hist.plot(centre, "Centre")
    p_hist.save(join(output_dir, f"mc_hist.png"), dpi=1000)
    mean_camera = np.mean(camera)
    mean_centre = np.mean(centre)
    std_camera = np.std(camera)
    std_centre = np.std(centre)
    print(f"MC: camera_mean={mean_camera}, camera={std_camera/mean_camera}, centre={std_centre/mean_centre}")
예제 #26
0
def main():
    path = "/Users/Jason/Data/d2019-04-23_nudges/bright_50pe/Run09095_r1.tio"
    reader = TIOReader(path)
    n_events = reader.n_events
    n_pixels = reader.n_pixels
    n_samples = reader.n_samples
    pixel_array = np.arange(n_pixels)
    time_calibrator = TimeCalibrator()
    extractor = Timing(n_pixels, n_samples)
    df_list = []
    for wfs in tqdm(reader, total=n_events):
        iev = wfs.iev
        shifted = time_calibrator(wfs)

        params = extractor.process(wfs)
        params_shifted = extractor.process(shifted)

        df_list.append(
            pd.DataFrame(
                dict(
                    iev=iev,
                    pixel=pixel_array,
                    t_pulse=params['t_pulse'],
                    t_pulse_corrected=params_shifted['t_pulse'],
                )))

    df = pd.concat(df_list, ignore_index=True)

    pm = PixelMasks()
    dead = np.where(pm.all_mask)
    mask = ~np.isin(df['pixel'].values, dead)
    df = df.iloc[mask]
    df_ev = df.groupby('iev').mean()
    mean_timing = np.repeat(df_ev['t_pulse'], n_pixels - pm.all_mask.sum())
    mean_timing_c = np.repeat(df_ev['t_pulse'], n_pixels - pm.all_mask.sum())
    df['t_pulse'] -= mean_timing.values
    df['t_pulse_corrected'] -= mean_timing_c.values
    df_pix = df.groupby('pixel').mean()
    pixel = df_pix.index.values
    t_pulse = df_pix['t_pulse'].values
    t_pulse_corrected = df_pix['t_pulse_corrected'].values

    image = np.full(n_pixels, np.nan)
    image[pixel] = t_pulse
    mean = np.nanmean(image)
    std = np.nanstd(image)
    ci = CameraImage.from_mapping(reader.mapping)
    ci.image = image
    ci.add_colorbar()
    ci.ax.set_title(f"MEAN = {mean:.2f}, STDDEV = {std:.2f}")
    ci.save(join(DIR, "before.pdf"))

    image = np.full(n_pixels, np.nan)
    image[pixel] = t_pulse_corrected
    mean = np.nanmean(image)
    std = np.nanstd(image)
    ci = CameraImage.from_mapping(reader.mapping)
    ci.image = image
    ci.add_colorbar()
    ci.ax.set_title(f"MEAN = {mean:.2f}, STDDEV = {std:.2f}")
    ci.save(join(DIR, "after.pdf"))
def cal_report(cal):
    hist_a = dashi.histogram.hist1d(
        np.linspace(np.nanmin(cal.a), np.nanmax(cal.a), 100))
    hist_a.fill(cal.a)
    hist_b = dashi.histogram.hist1d(
        np.linspace(np.nanmin(cal.b), np.nanmax(cal.b), 100))
    hist_b.fill(cal.b)
    hist_c = dashi.histogram.hist1d(
        np.linspace(np.nanmin(cal.c), np.nanmax(cal.c), 100))
    hist_c.fill(cal.c)
    thresh = (-cal.b + np.sqrt(cal.b**2 - 4 * cal.a * cal.c)) / (2 * cal.a)
    hist_thresh = dashi.histogram.hist1d(
        np.linspace(np.nanmin(thresh), np.nanmax(thresh), 100))
    hist_thresh.fill(thresh)

    plt.figure(figsize=(10, 8))
    hist_a.line()
    hist_a.statbox()
    plt.title("a parameter")
    plt.savefig("plots/cal_report_a_par_hist.png")
    plt.figure(figsize=(10, 8))
    hist_b.line()
    hist_b.statbox()
    plt.title("b parameter")
    plt.savefig("plots/cal_report_b_par_hist.png")
    plt.figure(figsize=(10, 8))
    hist_c.line()
    hist_c.statbox()
    plt.title("c parameter")
    plt.savefig("plots/cal_report_c_par_hist.png")

    plt.figure(figsize=(10, 8))
    hist_thresh.line()
    hist_thresh.statbox()
    plt.title("Threshold")
    plt.savefig("plots/cal_report_threshold_hist.png")

    from target_calib import CameraConfiguration

    cam_config = CameraConfiguration("1.1.0")
    mapping = cam_config.GetMapping()
    pixsize = mapping.GetSize()
    pix_posx = np.array(mapping.GetXPixVector())
    pix_posy = np.array(mapping.GetYPixVector())
    from CHECLabPy.plotting.camera import CameraImage

    f, a = plt.subplots(figsize=(13, 8))
    camera = CameraImage(pix_posx, pix_posy, pixsize, ax=a)
    camera.image = cal.a
    camera.add_colorbar("")
    camera.ax.set_title("a parameter")
    camera.highlight_pixels(list(cal.badpixs["unphysical_cal"]),
                            color="r",
                            linewidth=2)
    # camera.highlight_pixels(np.where(unphysical_rate)[0],color='b',linewidth=1.4)
    camera.highlight_pixels(list(cal.badpixs["no_cal"]), color="k")
    camera.highlight_pixels(list(cal.badpixs["bad_fit"]),
                            color="b",
                            linewidth=1.4)
    camera.set_limits_minmax(np.nanmin(cal.a), 0)
    plt.savefig("plots/cal_report_a_par.png")

    f, a = plt.subplots(figsize=(13, 8))
    camera = CameraImage(pix_posx, pix_posy, pixsize, ax=a)
    camera.image = cal.b
    camera.add_colorbar("")
    camera.ax.set_title("b parameter")
    camera.highlight_pixels(list(cal.badpixs["unphysical_cal"]),
                            color="r",
                            linewidth=2)
    # camera.highlight_pixels(np.where(unphysical_rate)[0],color='b',linewidth=1.4)
    camera.highlight_pixels(list(cal.badpixs["no_cal"]), color="k")
    camera.highlight_pixels(list(cal.badpixs["bad_fit"]),
                            color="b",
                            linewidth=1.4)
    camera.set_limits_minmax(0, np.nanmax(cal.b))
    plt.savefig("plots/cal_report_b_par.png")

    f, a = plt.subplots(figsize=(13, 8))
    camera = CameraImage(pix_posx, pix_posy, pixsize, ax=a)
    camera.image = cal.c
    camera.add_colorbar("")
    camera.ax.set_title("c parameter")
    camera.highlight_pixels(list(cal.badpixs["unphysical_cal"]),
                            color="r",
                            linewidth=2)
    # camera.highlight_pixels(np.where(unphysical_rate)[0],color='b',linewidth=1.4)
    camera.highlight_pixels(list(cal.badpixs["no_cal"]), color="k")
    camera.highlight_pixels(list(cal.badpixs["bad_fit"]),
                            color="b",
                            linewidth=1.4)
    camera.set_limits_minmax(np.nanmin(cal.c), 0)
    plt.savefig("plots/cal_report_c_par.png")

    f, a = plt.subplots(figsize=(13, 8))
    camera = CameraImage(pix_posx, pix_posy, pixsize, ax=a)
    camera.image = thresh
    camera.add_colorbar("photon rate (MHz)")
    camera.ax.set_title("NSB threshold")
    camera.highlight_pixels(list(cal.badpixs["unphysical_cal"]),
                            color="r",
                            linewidth=2)
    # camera.highlight_pixels(np.where(unphysical_rate)[0],color='b',linewidth=1.4)
    camera.highlight_pixels(list(cal.badpixs["no_cal"]), color="k")
    camera.highlight_pixels(list(cal.badpixs["bad_fit"]),
                            color="b",
                            linewidth=1.4)
    # camera.set_limits_minmax(np.nanmin(cal.c),0)
    plt.savefig("plots/cal_report_nsb_thres.png")
예제 #28
0
    plt.plot(index, match[index, 3], 'or')
    # print(match[:, 2], match[:, 3], match[:, 1])
else:
    telescope_pointing = SkyCoord(alt=alt * u.rad,
                                  az=az * u.rad,
                                  frame=altaz_frame)
    print("True pointing:", telescope_pointing.transform_to("icrs"))
    if matched_hs is None or len(matched_hs) == 0:
        ra = dec = np.nan
        matched_hs = []
    else:
        ra, dec = matcher.determine_pointing(matched_hs)
    print("Estimated pointing:", np.rad2deg(ra), np.rad2deg(dec))
    fig, axs = plt.subplots(constrained_layout=True, figsize=(10, 6))
    # Different average camera images
    camera = CameraImage(xpix, ypix, mapping.GetSize(), ax=axs)
    camera.image = np.ones(2048)
    axs.plot(true_hotspots[0, 0], true_hotspots[0, 1], "ob")
    axs.plot(
        true_hotspots[:, 0],
        true_hotspots[:, 1],
        "o",
        color="gray",
        mfc="none",
        ms=25,
        mew=2,
    )
    for ths, hs in zip(true_hotspots, hotspots):
        if tuple(ths) != tuple(hs):
            axs.plot(hs[0], hs[1], "yo", mfc="none", ms=25, mew=3)
    for i, sid in enumerate(all_hips):
예제 #29
0
def make_ssmovie(data,
                 red,
                 highlightpix=None,
                 minmax=(-10, 100),
                 path='movie',
                 dpi=800,
                 scale=0.2,
                 title="",
                 fps=25,
                 filename="out",
                 zlabel="Amplitude (mV)"):
    """Summary

    Args:
        data (TYPE): A SlowsignalData object
        red (TYPE): A range object or a list of indices
        highlightpix (None, optional): A list of pixel highlight index arrays
        minmax (tuple, optional): min max for the z-scale
        path (str, optional): The path from the current working directory where to store images for the movie
        dpi (int, optional): Description
        scale (float, optional): Description
        title (str, optional): The title to be shown
        fps (int, optional): Number of frames per second in the movie
        filename (str, optional): output name of the movie
        zlabel (str, optional): The colorbar label
    """
    import os
    import subprocess

    import glob
    impath = os.path.join(os.getcwd(), path)
    if not os.path.isdir(impath):
        os.mkdir(impath)

    files = glob.glob(os.path.join(impath, "*"))
    for f in files:
        os.remove(f)

    dpi -= int(scale * 19.20 * dpi) % 2
    dpii = 400
    scale = 0.70
    fig, ax = plt.subplots(figsize=(1920 / dpii * scale, 1080 / dpii * scale),
                           dpi=dpii * scale)
    camera = CameraImage(data.xpix, data.ypix, data.size, ax=ax)

    camera.add_colorbar('Amplitdue (mV)')
    camera.set_limits_minmax(*minmax)
    im = copy.deepcopy(data.data[0])
    camera.image = im
    highl = None
    for i in tqdm(red, total=len(red)):
        im = copy.deepcopy(data.data[i])
        im[np.isnan(im)] = np.nanmean(im)

        camera.ax.set_title(title)
        if highl is None:
            highl = camera.highlight_pixels(highlightpix[i])
        else:
            lw_array = np.zeros(camera.image.shape[0])
            lw_array[highlightpix[i]] = 0.5
            highl.set_linewidth(lw_array)

        camera.image = im
        plt.savefig(os.path.join(path, "SlowSignalImage%.10d.png" % i),
                    dpi=dpi)
    subprocess.check_call([
        "ffmpeg", "-pattern_type", "glob", "-i", "{}".format(
            os.path.join(impath, "SlowSignalImage*.png")), "-c:v", "libx264",
        "-vf", " scale=iw:-2", "-vf", "fps={}".format(fps), "-pix_fmt",
        "yuv420p", '-y', "{}.mp4".format(filename)
    ],
                          cwd=os.getcwd())
예제 #30
0
 def create_image(mapping, ax, clabel):
     ci = CameraImage.from_mapping(mapping, ax=ax)
     ci.add_colorbar(clabel, pad=0)
     return ci