nabu.estimation.alignment
source module nabu.estimation.alignment
source progress_bar(x, verbose=True)
source class AlignmentBase(vert_fft_width=False, horz_fft_width=False, verbose=False, logger=None, data_type=np.float32, extra_options=None)
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.<span class="mkapi-tooltip" title="numpy._core.float32">float32</span>
— Computation data type.
Methods
-
refine_max_position_2d — Computes the sub-pixel max position of the given function sampling.
-
refine_max_position_1d — Computes the sub-pixel max position of the given function sampling.
-
extract_peak_region_2d — Extracts a region around the maximum value.
-
extract_peak_regions_1d — Extracts a region around the maximum value.
-
close_plot_window — Close a plot window. Applicable only if the class was instantiated with verbose=True.
-
close_last_plot_windows — Close the last "n" plot windows. Applicable only if the class was instanciated with verbose=True.
source staticmethod AlignmentBase.refine_max_position_2d(f_vals: np.ndarray, fy=None, fx=None)
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
-
tuple(float, float) — Estimated (vertical, horizontal) function max, according to the coordinates in fy and fx.
source staticmethod AlignmentBase.refine_max_position_1d(f_vals, fx=None, return_vertex_val=False, return_all_coeffs=False)
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
-
float — Estimated function max, according to the coordinates in fx.
source staticmethod AlignmentBase.extract_peak_region_2d(cc, peak_radius=1, cc_vs=None, cc_hs=None)
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.
source staticmethod AlignmentBase.extract_peak_regions_1d(cc, axis=-1, peak_radius=1, cc_coords=None)
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.
Raises
-
ValueError
source method AlignmentBase.close_plot_window(n, errors='raise')
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".
Raises
-
ValueError
source method AlignmentBase.close_last_plot_windows(n=1)
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.