noise

This module’s scope is the detection of noise in Fabry-Pérot interferographs.

Example:

>>> import tuna
>>> raw = tuna.io.read ( "tuna/test/unit/unit_io/adhoc.ad3" )
>>> barycenter = tuna.tools.phase_map.barycenter_fast ( raw ); barycenter.join ( )
>>> noise = tuna.tools.phase_map.noise_detector ( raw = raw,                                                       wrapped = barycenter.result,                                                       noise_mask_radius = 1,                                                       noise_threshold = 1 ); noise.join ( )
>>> noise.noise.array [ 500 : 511, 500 ]
array([ 1.,  0.,  1.,  1.,  0.,  1.,  1.,  1.,  1.,  1.,  1.])
tuna.tools.phase_map.noise.detect_noise(raw: numpy.ndarray, wrapped: numpy.ndarray, noise_mask_radius: int=1, noise_threshold: float=None) → tuna.io.can.can[source]

This function’s goal is to conveniently return a numpy.ndarray containing the noise map calculated from the input parameters.

tuna.tools.phase_map.noise.include_noise_circle(position=(<class 'int'>, <class 'int'>), radius=<class 'int'>, array=<built-in function array>)[source]

This function will “draw” a circle with center position, radius radius in the array array, using the value 1 as its filling.

Parameters:

  • position : tuple of 2 integers

    Corresponding to the center of the circle to be masked.

  • radius : integer

    Containing the length (in pixels) of the circle to be masked.

  • array : numpy.ndarray

    Specifies where the mask is to be drawn.

class tuna.tools.phase_map.noise.noise_detector(raw: numpy.ndarray, wrapped: numpy.ndarray, noise_mask_radius: int=1, noise_threshold: float=None) → None[source]

This class is responsible for detecting noise from a raw Fabry-Pérot interferograph.

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.

The algorithm consists of creating a temporary array, summing the data on “depth” or spectra, for each pixel. If a threshold is passed on the input, it is the minimal value for a pixel be considered “non noisy”. If no threshold was supplied by the user, the algorithm will search for the smallest percentile on the temporary array which is non-null. The value that corresponds to this percentile will be used as the threshold.

The noise_mask_radius is useful to “fill” small gaps inside noise regions. Some tools (such as the ones used to produce fsr maps) relie on the noise being made of “continuous” pixel sets. By increasing this parameter, it is possible to force noisy regions to overlap and become “continuous”, if they aren’t.

Its constructor expects the following parameters:

  • raw : numpy.ndarray

    Containing the raw interferometry data.

  • wrapped : numpy.ndarray

    Containing the wrapped phase map.

  • noise_mask_radius : integer : 1

    Encoding the radius (in pixels) of the circle to be marked as noisy around each pixel detected as noisy.

  • noise_threshold : float : None

    Encoding the minimum value to be considered signal.

detect_signalless(threshold)[source]

This method will mask out pixels whose total signal (the curve below its profile) is less than X % of the average total signal per pixel. Observing the profiles for pixels on the edges of a interferogram, one notices that there is much less signal in these regions, when the observable is centered on the field of view. This causes these regions to be highly susceptible to noise. To detect them, one finds the average value for the flux for a pixel, and masks out the pixels that are much lower than that. By default, much lower means less than 10% the flux.

Parameters:

  • threshold : float

    Sets the minimal value for a pixel data be considered signal.

refresh_database()[source]

Attempts to updated the database with information about the result of a noise object.

First, it obtains the hash of the current noise array. Then, it attempts to find the database record related to that hash. If found, the record is updated; otherwise, it is created.

run()[source]

Method required by threading, which allows parallel exection in a separate thread.

The execution creates a zero-filled numpy.ndarray, fills it with the noise values as detected by the method self.detect_signalless ( ) and then updates Tuna’s database through the method self.refresh_database ( ).

tuna.tools.phase_map.noise.position_is_valid_pixel_address(position=(<class 'int'>, <class 'int'>), array=<built-in function array>)[source]

This function returns True if the argument position is a valid coordinate of the input array.

Parameters:

  • position : tuple of 2 integers

    Encoding a possible coordinate of the input array.

  • array : numpy.ndarray

    The array where the position validness is to be probed.