Пример #1
0
def plot_z_fitpar_from_average(fig,
                               fit_par,
                               img_id,
                               channel,
                               led_arrays,
                               window_size=51):
    # make led_arrays a tuple
    if type(led_arrays) == int:
        led_arrays = (led_arrays, )

    fit_parameters = calc.read_hdf(channel)
    fit_parameters = calc.include_column_if_nonexistent(
        fit_parameters, fit_par, channel)
    cropped_parameters = fit_parameters.loc[(
        float(img_id -
              (window_size - 1) // 2), ):(float(img_id +
                                                (window_size - 1) // 2), )][[
                                                    'line', fit_par, 'height'
                                                ]]
    mean = cropped_parameters.mean(axis=0, level='led_id')

    ax = fig.gca(xlabel=fit_par, ylabel='height/m')
    for line in led_arrays:
        plot, = ax.plot(np.array(mean[mean['line'] == line][fit_par]),
                        np.array(mean[mean['line'] == line]['height']))
        plot.set_label(f'LED_Array{line}, C{channel}')
    ax.legend()
    plt.title(
        f'Plot of averaged fit parameter {fit_par} over time against the height.\n'
        f'Image: {img_id}, window_size: {window_size}')
def _calc_t_fitpar_plot_info(led_id, fit_par, channel, image_id_start, image_id_finish):
    times = led.load_file(".{}analysis{}image_infos_analysis.csv".format(sep, sep), delim=',', dtype=str)
    times = pd.DataFrame(times[:, [0, 3]], columns=['img_id', 'experiment_time'], dtype=np.float64)
    times.set_index('img_id', inplace=True)
    fit_parameters = calc.read_hdf(channel)
    fit_parameters = calc.include_column_if_nonexistent(fit_parameters, fit_par, channel)
    idx = pd.IndexSlice
    fit_parameters = fit_parameters.loc[idx[:, led_id], fit_par]
    fit_parameters.reset_index(drop=True, level=1, inplace=True)
    plot_info = pd.concat([times, fit_parameters], axis=1, sort=False)
    plot_info = plot_info.loc[idx[image_id_start:image_id_finish+1]]
    return plot_info
def plot_z_fitpar(fig: plt.figure, fit_par: str, img_id: int, channel: int,
                  led_arrays: Union[Tuple[int, ...], int]) -> None:
    """plots the height of a LED array against one fit parameter"""
    # make led_arrays a tuple
    if type(led_arrays) == int:
        led_arrays = (led_arrays,)

    fit_parameters = calc.read_hdf(channel)
    fit_parameters = calc.include_column_if_nonexistent(fit_parameters, fit_par, channel)
    fit_parameters = fit_parameters.loc[img_id, :]

    ax = fig.gca(xlabel=fit_par, ylabel='height/m')
    for line in led_arrays:
        plot, = ax.plot(np.array(fit_parameters[fit_parameters['line'] == line][fit_par]),
                        np.array(fit_parameters[fit_parameters['line'] == line]['height']))
        plot.set_label(f'LED_Array{line}, C{channel}')
    ax.legend()
    plt.title(f'Plot of fit parameter {fit_par} against the height.\n'
              f'Image: {img_id}')
def load_model(img_id, led_id, channel, window_radius=10):
    fit_parameters = calc.read_hdf(channel)
    model_params = np.array(fit_parameters.loc[img_id, led_id])[1:9]
    pix_pos = get_led_pos(led_id)
    model_params[0:2] = model_params[0:2] - pix_pos + window_radius
    return model_params
 def load_img_data(self) -> None:
     img_data = read_hdf(self.experiment.channel, path=self.experiment.path)
     img_data_cropped = img_data[['line', self.reference_property]]
     self.calculated_img_data = img_data_cropped[img_data_cropped['line'] ==
                                                 self.experiment.led_array]