barycenter¶
This module’s scope is the creation of barycenter “maps” from Fabry-Pérot interferogram data.
The barycenter map is one of the so-called “wrapped” phase map types.
Example:
>>> import tuna
>>> import numpy
>>> raw = tuna.io.read ( "tuna/test/unit/unit_io/adhoc_3_planes.fits" )
>>> barycenter = tuna.plugins.run ( "Barycenter algorithm" ) ( data_can = raw )
>>> barycenter.shape
(512, 512)
-
class
tuna.tools.barycenter.
barycenter_detector
(data)[source]¶ This class’ responsibility is to generate barycenter maps from spectral cubes.
Its algorithm utilizes a fitter to fit a parabola to each pixel, and find the barycenter from the fit parameters.
It inherits from the threading.Thread class, and it auto-starts its thread execution. Clients are expected to use its .join ( ) method before using its results.
Its constructor expects the following parameters:
- data : can
Containing the interferograph data.
-
create_barycenter
()[source]¶ This method’s goal is to find the barycenter for each pixel by fitting a 1D gaussian model to each pixel’s spectral data, and then calculating the barycenter of the gaussian.
Returns:
- barycenter : numpy.ndarray
Containing the generated barycenter map.
-
get_center_of_mass
(peak)[source]¶ This method’s goal is to calculate the center-of-mass of an array, assuming as the distance one “unit” of distance per column.
Parameters:
- peak: numpy.ndarray
One dimensional data (spectra) corresponding to 1 pixel’s “depth” in the cube.
Returns:
- center_of_mass : float
The value of the “pseudo channel” where the center of mass resider, for this spectra.
-
class
tuna.tools.barycenter.
barycenter_fast
(data)[source]¶ This class’ responsibility is to generate and store barycenter maps from spectral cubes.
Its algorithm uses geometric considerations to determine where is the center of mass for each spectrum, and is generally much faster than the algorithm using fitted data, with very similar numerical results. However, some pixelation is observed, when using this algorithm instead of the “slow” one.
It inherits from the threading.Thread class, and it auto-starts its thread execution. Clients are expected to use its .join ( ) method before using its results.
Its constructor expects the following parameters:
- data : can
Containing the interferograph data.
-
create_barycenter_using_peak
()[source]¶ This method’s goal is to generate the barycenter map using the peak method. Will find the center of mass of each spectrum, using the shoulder-to-shoulder peak channels as the relevant signals. To understand what is meant by this, consider the profile of a pixel has the following appearance:
_ _ _/ \_/ \ __ / \ _ \ / \__/ \ / \__/ \__/ 01234567890123456789012345678 1111111111222222222
The FWHH channels would encompass the channels 8 to 17. But we want more signal, so we extend the channel interval until the first channel that would belong to another “peak”, so the channels considered for the barycenter are actually the channels 4 to 20, inclusive.
Once this “peak” is found, the center of mass for it is calculated, and the result is mapped onto the complete spectra, which yields the barycenter for that spectrum.
Returns:
- barycenter_array : numpy.ndarray
Containing the barycenter map as calculated above, for each pixel in the input data.
-
get_fwhh
(profile=<class 'numpy.ndarray'>)[source]¶ This method’s goal is to map “geometrical” features of the input spectra. The features are the indices of the FWHH channels in the profile, and the relevant data for FWHH calculation.
This is done using auxiliary methods to get the next channel to the right or left, wrapping around the end of the array as appropriate. First the FWHH values are found, by searching the first channel that has the maximal value in the profile, and adding channels left and right while their values are greater or equal to the half height of the maximal channel.
Then this region is increased in both directions as long as the channels adjacent to the current spectral ROI have values smaller or equal to the “border” channels of the ROI. This extends the FWHH region to the “base” of the peak set that contains the FWHH.
Parameters:
- profile : numpy.ndarray
Containing the spectrum to be mapped.
Returns:
- fwhh_dict : dictionary
Containing the following entries:
max_height : The value contained in the channel with maximum signal. half_height : Half of max_height. max_height_index : The index of the channel with maximum signal. leftmost_hh : The "leftmost" channel that has signal >= half_height. rightmost_hh : The "rightmost" channel that has signal >= half_height. profile_indices : All indices of the spectra that are contained in the "half height peak". i_left_shoulder : The index of the leftmost channel of the peak. i_right_shoulder : The index of the rightmost channel of the peak. il_shoulder_indices : All indices of the spectra that are contained in the peak.
-
get_left_channel
(channel=<class 'int'>, profile=<class 'numpy.ndarray'>)[source]¶ This method’s goal is to find the next channel ‘to the left’ in the profile. If the channel is the leftmost channel in the profile, consider the last channel as its left neighbour.
Parameters:
- channel : int
The channel for which we want to find the left “neighbour”.
- profile : numpy.ndarray
The unidimensional profile.
Returns:
- unnamed variable : integer
The index of the channel to the “left” of the input channel.
-
get_right_channel
(channel=<class 'int'>, profile=<class 'numpy.ndarray'>)[source]¶ This method’s goal is to find the next channel ‘to the right’ in the profile. If the channel is the last channel in the profile, consider the first channel as its right neighbour.
Parameters:
- channel : int
The channel for which we want to find the right “neighbour”.
- profile : numpy.ndarray
The unidimensional profile.
Returns:
- unnamed variable : integer
The index of the channel to the “right” of the input channel.
-
tuna.tools.barycenter.
barycenter_geometry
(data_can: tuna.io.can.can) → tuna.io.can.can[source]¶ This function’s goal is to conveniently return an array of the barycenter position for each pixel of the input.
Arguments:
- data_can : tuna.io.can
Should contain a 3D cube of raw Fabry-Pérot data.
Returns:
- tuna.io.can
Containing a 2D array of floats, where each point is the barycenter of the respective spectrum on the input data.
-
tuna.tools.barycenter.
barycenter_polynomial_fit
(data_can: tuna.io.can.can) → tuna.io.can.can[source]¶ This function’s goal is to conveniently return an array of the barycenter position for each pixel of the input.
Arguments:
- data_can : tuna.io.can
Should contain a 3D cube of raw Fabry-Pérot data.
Returns:
- tuna.io.can
Containing a 2D array of floats, where each point is the barycenter of the respective spectrum on the input data.