nabu.estimation.alignment module

nabu.estimation.alignment.progress_bar(x, verbose=True)[source]
class nabu.estimation.alignment.AlignmentBase(vert_fft_width=False, horz_fft_width=False, verbose=False, logger=None, data_type=<class 'numpy.float32'>, extra_options=None, cor_options=None)[source]

Bases: object

Alignment basic functions.

Parameters:
  • vert_fft_width (boolean, optional) –

    If True, restrict the vertical size to a power of 2:

    >>> new_v_dim = 2 ** math.floor(math.log2(v_dim))
    

  • horz_fft_width (boolean, optional) –

    If True, restrict the horizontal size to a power of 2:

    >>> new_h_dim = 2 ** math.floor(math.log2(h_dim))
    

  • verbose (boolean, optional) – When True it will produce verbose output, including plots.

  • data_type (numpy.float32) – Computation data type.

default_extra_options = {'blocking_plots': False}
static refine_max_position_2d(f_vals: ndarray, fy=None, fx=None)[source]

Computes the sub-pixel max position of the given function sampling.

Parameters:
  • f_vals (numpy.ndarray) – Function values of the sampled points

  • fy (numpy.ndarray, optional) – Vertical coordinates of the sampled points

  • fx (numpy.ndarray, optional) – Horizontal coordinates of the sampled points

Raises:

ValueError – In case position and values do not have the same size, or in case the fitted maximum is outside the fitting region.

Returns:

Estimated (vertical, horizontal) function max, according to the coordinates in fy and fx.

Return type:

tuple(float, float)

static refine_max_position_1d(f_vals, fx=None, return_vertex_val=False, return_all_coeffs=False)[source]

Computes the sub-pixel max position of the given function sampling.

Parameters:
  • f_vals (numpy.ndarray) – Function values of the sampled points

  • fx (numpy.ndarray, optional) – Coordinates of the sampled points

  • return_vertex_val (boolean, option) – Enables returning the vertex values. Defaults to False.

Raises:

ValueError – In case position and values do not have the same size, or in case the fitted maximum is outside the fitting region.

Returns:

Estimated function max, according to the coordinates in fx.

Return type:

float

static extract_peak_region_2d(cc, peak_radius=1, cc_vs=None, cc_hs=None)[source]

Extracts a region around the maximum value.

Parameters:
  • cc (numpy.ndarray) – Correlation image.

  • peak_radius (int, optional) – The l_inf radius of the area to extract around the peak. The default is 1.

  • cc_vs (numpy.ndarray, optional) – The vertical coordinates of cc. The default is None.

  • cc_hs (numpy.ndarray, optional) – The horizontal coordinates of cc. The default is None.

Returns:

  • f_vals (numpy.ndarray) – The extracted function values.

  • fv (numpy.ndarray) – The vertical coordinates of the extracted values.

  • fh (numpy.ndarray) – The horizontal coordinates of the extracted values.

static extract_peak_regions_1d(cc, axis=-1, peak_radius=1, cc_coords=None)[source]

Extracts a region around the maximum value.

Parameters:
  • cc (numpy.ndarray) – Correlation image.

  • axis (int, optional) – Find the max values along the specified direction. The default is -1.

  • peak_radius (int, optional) – The l_inf radius of the area to extract around the peak. The default is 1.

  • cc_coords (numpy.ndarray, optional) – The coordinates of cc along the selected axis. The default is None.

Returns:

  • f_vals (numpy.ndarray) – The extracted function values.

  • fc_ax (numpy.ndarray) – The coordinates of the extracted values, along the selected axis.

close_plot_window(n, errors='raise')[source]

Close a plot window. Applicable only if the class was instantiated with verbose=True.

Parameters:
  • n (int) – Figure number to close

  • errors (str, optional) – What to do with errors. It can be either “raise”, “log” or “ignore”.

close_last_plot_windows(n=1)[source]

Close the last “n” plot windows. Applicable only if the class was instanciated with verbose=True.

Parameters:

n (int, optional) – Integer indicating how many plot windows should be closed.