pynpoint.util package

Submodules

pynpoint.util.analysis module

Functions for point source analysis.

pynpoint.util.analysis.fake_planet(images: numpy.ndarray, psf: numpy.ndarray, parang: numpy.ndarray, position: Tuple[float, float], magnitude: float, psf_scaling: float, interpolation: str = 'spline') → numpy.ndarray[source]

Function to inject artificial planets in a dataset.

Parameters:
  • images (numpy.ndarray) – Input images (3D).
  • psf (numpy.ndarray) – PSF template (3D).
  • parang (numpy.ndarray) – Parallactic angles (deg).
  • position (tuple(float, float)) – Separation (pix) and position angle (deg) measured in counterclockwise with respect to the upward direction.
  • magnitude (float) – Magnitude difference used to scale input PSF.
  • psf_scaling (float) – Extra factor used to scale input PSF.
  • interpolation (str) – Interpolation type (‘spline’, ‘bilinear’, or ‘fft’).
Returns:

Images with artificial planet injected.

Return type:

numpy.ndarray

pynpoint.util.analysis.false_alarm(image: numpy.ndarray, x_pos: float, y_pos: float, size: float, ignore: bool) → Tuple[float, float, float, float][source]

Function for the formal t-test for high-contrast imaging at small working angles and the related false positive fraction (Mawet et al. 2014).

Parameters:
  • image (numpy.ndarray) – Input image (2D).
  • x_pos (float) – Position (pix) along the horizontal axis. The pixel coordinates of the bottom-left corner of the image are (-0.5, -0.5).
  • y_pos (float) – Position (pix) along the vertical axis. The pixel coordinates of the bottom-left corner of the image are (-0.5, -0.5).
  • size (float) – Aperture radius (pix).
  • ignore (bool) – Ignore the neighboring apertures for the noise estimate.
Returns:

  • float – Signal.
  • float – Noise level.
  • float – Signal-to-noise ratio.
  • float – False positive fraction (FPF).

pynpoint.util.analysis.merit_function(residuals: numpy.ndarray, merit: str, aperture: Tuple[int, int, float], sigma: float) → float[source]

Function to calculate the figure of merit at a given position in the image residuals.

Parameters:
  • residuals (numpy.ndarray) – Residuals of the PSF subtraction (2D).
  • merit (str) – Figure of merit for the chi-square function (‘hessian’, ‘poisson’, or ‘gaussian’).
  • aperture (tuple(int, int, float)) – Position (y, x) of the aperture center (pix) and aperture radius (pix).
  • sigma (float) – Standard deviation (pix) of the Gaussian kernel which is used to smooth the residuals before the chi-square is calculated.
Returns:

Chi-square (‘poisson’ and ‘gaussian’) or sum of the absolute values (‘hessian’).

Return type:

float

pynpoint.util.analysis.student_t(t_input: Tuple[str, float], radius: float, size: float, ignore: bool) → float[source]

Function to calculate the false positive fraction for a given sigma level (Mawet et al. 2014).

Parameters:
  • t_input (tuple(str, float)) – Tuple with the input type (‘sigma’ or ‘fpf’) and the input value.
  • radius (float) – Aperture radius (pix).
  • size (float) – Separation of the aperture center (pix).
  • ignore (bool) – Ignore neighboring apertures of the point source to exclude the self-subtraction lobes.
Returns:

False positive fraction (FPF).

Return type:

float

pynpoint.util.attributes module

Functions for adding attributes to a dataset in the central database.

pynpoint.util.attributes.set_extra_attr(fits_file: str, nimages: int, config_port: pynpoint.core.dataio.ConfigPort, image_out_port: pynpoint.core.dataio.OutputPort, first_index: int) → int[source]

Function which adds extra attributes to the central database.

Parameters:
  • fits_file (str) – Absolute path and filename of the FITS file.
  • nimages (int) – Number of images.
  • config_port (pynpoint.core.dataio.ConfigPort) – Configuration port.
  • image_out_port (pynpoint.core.dataio.OutputPort) – Output port of the images to which the attributes are stored.
  • first_index (int) – First image index of the current subset.
Returns:

First image index for the next subset.

Return type:

int

pynpoint.util.attributes.set_nonstatic_attr(header: astropy.io.fits.header.Header, config_port: pynpoint.core.dataio.ConfigPort, image_out_port: pynpoint.core.dataio.OutputPort, check: bool = True) → None[source]

Function which adds the non-static attributes to the central database.

Parameters:
Returns:

None

Return type:

NoneType

pynpoint.util.attributes.set_static_attr(fits_file: str, header: astropy.io.fits.header.Header, config_port: pynpoint.core.dataio.ConfigPort, image_out_port: pynpoint.core.dataio.OutputPort, check: bool = True) → None[source]

Function which adds the static attributes to the central database.

Parameters:
  • fits_file (str) – Name of the FITS file.
  • header (astropy.io.fits.header.Header) – Header information from the FITS file that is read.
  • config_port (pynpoint.core.dataio.ConfigPort) – Configuration port.
  • image_out_port (pynpoint.core.dataio.OutputPort) – Output port of the images to which the static attributes are stored.
  • check (bool) – Print a warning if certain attributes from the configuration file are not present in the FITS header. If set to False, attributes are still written to the dataset but there will be no warning if a keyword is not found in the FITS header.
Returns:

None

Return type:

NoneType

pynpoint.util.continuous module

pynpoint.util.continuous.angularfreq(N, dt)[source]

Compute angular frequencies.

Parameters:
  • N (int) – Number of data samples.
  • dt (int) – Time step.
Returns:

Angular frequencies (1D).

Return type:

numpy.ndarray

pynpoint.util.continuous.autoscales(N, dt, dj, wf, p)[source]

Compute scales as fractional power of two.

Parameters:
  • N (int) – Number of data samples.
  • dt (int) – Time step.
  • dj (float) – Scale resolution (smaller values of give finer resolution).
  • wf (str) – Wavelet function (“morlet”, “paul”, or “dog”).
  • p (int) – omega0 (“morlet”) or order (“paul”, “dog”).
Returns:

Scales (1D).

Return type:

numpy.ndarray

pynpoint.util.continuous.cwt(x, dt, scales, wf='dog', p=2)[source]

Continuous Wavelet Transform.

Parameters:
  • x (numpy.ndarray) – Data (1D).
  • dt (int) – Time step.
  • scales (numpy.ndarray) – Scales (1D).
  • wf (str) – Wavelet function (“morlet”, “paul”, or “dog”).
  • p (int) – omega0 (“morlet”) or order (“paul”, “dog”).
Returns:

Transformed data (2D).

Return type:

numpy.ndarray

pynpoint.util.continuous.dogft(s, w, order, dt)[source]

Fourier transformed DOG function.

Parameters:
  • s (numpy.ndarray) – Scales.
  • w (numpy.ndarray) – Angular frequencies.
  • order (int) – Wavelet order.
  • dt (int) – Time step.
Returns:

Normalized Fourier transformed DOG function.

Return type:

numpy.ndarray

pynpoint.util.continuous.icwt(X, scales)[source]

Inverse Continuous Wavelet Transform. The reconstruction factor is not applied.

Parameters:
  • X (numpy.ndarray) – Transformed data (2D).
  • scales (numpy.ndarray) – Scales (1D).
Returns:

1D data.

Return type:

numpy.ndarray

pynpoint.util.continuous.morletft(s, w, w0, dt)[source]

” Fourier transformed morlet function.

Parameters:
  • s (numpy.ndarray) – Scales.
  • w (numpy.ndarray) – Angular frequencies.
  • w0 (int) – Omega0 frequency.
  • dt (int) – Time step.
Returns:

Normalized Fourier transformed morlet function

Return type:

numpy.ndarray

pynpoint.util.continuous.normalization(s, dt)[source]

” :param s: Scales. :type s: numpy.ndarray :param dt: Time step. :type dt: int

Returns:Normalized data.
Return type:numpy.ndarray

pynpoint.util.image module

Functions for image processing.

pynpoint.util.image.cartesian_to_polar(center: Tuple[float, float], y_pos: float, x_pos: float) → Tuple[float, float][source]

Function to convert pixel coordinates to polar coordinates.

Parameters:
  • center (tuple(float, float)) – Image center (y, x) from center_subpixel().
  • y_pos (float) – Pixel coordinate along the vertical axis. The bottom left corner of the image is (-0.5, -0.5).
  • x_pos (float) – Pixel coordinate along the horizontal axis. The bottom left corner of the image is (-0.5, -0.5).
Returns:

Separation (pix) and position angle (deg). The angle is measured counterclockwise with respect to the positive y-axis.

Return type:

tuple(float, float)

pynpoint.util.image.center_pixel(image: numpy.ndarray) → Tuple[int, int][source]

Function to get the pixel position of the image center. Note that this position can not be unambiguously defined for an even-sized image. Python indexing starts at 0 so the coordinates of the pixel in the bottom-left corner are (0, 0).

Parameters:image (numpy.ndarray) – Input image (2D or 3D).
Returns:Pixel position (y, x) of the image center.
Return type:tuple(int, int)
pynpoint.util.image.center_subpixel(image: numpy.ndarray) → Tuple[float, float][source]

Function to get the precise position of the image center. The center of the pixel in the bottom left corner of the image is defined as (0, 0), so the bottom left corner of the image is located at (-0.5, -0.5).

Parameters:image (numpy.ndarray) – Input image (2D or 3D).
Returns:Subpixel position (y, x) of the image center.
Return type:tuple(float, float)
pynpoint.util.image.create_mask(im_shape: Tuple[int, int], size: Union[Tuple[float, float], Tuple[float, None], Tuple[None, float], Tuple[None, None]]) → numpy.ndarray[source]

Function to create a mask for the central and outer image regions.

Parameters:
  • im_shape (tuple(int, int)) – Image size in both dimensions.
  • size (tuple(float, float)) – Size (pix) of the inner and outer mask.
Returns:

Image mask.

Return type:

numpy.ndarray

pynpoint.util.image.crop_image(image: numpy.ndarray, center: Optional[tuple], size: int, copy: bool = True) → numpy.ndarray[source]

Function to crop square images around a specified position.

Parameters:
  • image (numpy.ndarray) – Input image (2D or 3D).
  • center (tuple(int, int), None) – The new image center (y, x). The center of the image is used if set to None.
  • size (int) – Image size (pix) for both dimensions. Increased by 1 pixel if size is an even number.
  • copy (bool) – Whether or not to return a copy (instead of a view) of the cropped image (default: True).
Returns:

Cropped odd-sized image (2D or 3D).

Return type:

numpy.ndarray

pynpoint.util.image.pixel_distance(im_shape: Tuple[int, int], position: Tuple[int, int] = None) → numpy.ndarray[source]

Function to calculate the distance of each pixel with respect to a given pixel position.

Parameters:
  • im_shape (tuple(int, int)) – Image shape (y, x).
  • position (tuple(int, int)) – Pixel center (y, x) from which the distance is calculated. The image center is used if set to None. Python indexing starts at zero so the bottom left pixel is (0, 0).
Returns:

2D array with the distances of each pixel from the provided pixel position.

Return type:

numpy.ndarray

pynpoint.util.image.polar_to_cartesian(image: numpy.ndarray, sep: float, ang: float) → Tuple[float, float][source]

Function to convert polar coordinates to pixel coordinates.

Parameters:
  • image (numpy.ndarray) – Input image (2D or 3D).
  • sep (float) – Separation (pix).
  • ang (float) – Position angle (deg), measured counterclockwise with respect to the positive y-axis.
Returns:

Cartesian coordinates (y, x). The bottom left corner of the image is (-0.5, -0.5).

Return type:

tuple(float, float)

pynpoint.util.image.rotate_coordinates(center: Tuple[float, float], position: Tuple[float, float], angle: float) → Tuple[float, float][source]

Function to rotate coordinates around the image center.

Parameters:
  • center (tuple(float, float)) – Image center (y, x).
  • position (tuple(float, float)) – Position (y, x) in the image.
  • angle (float) – Angle (deg) to rotate in counterclockwise direction.
Returns:

New position (y, x).

Return type:

tuple(float, float)

pynpoint.util.image.rotate_images(images: numpy.ndarray, angles: numpy.ndarray) → numpy.ndarray[source]

Function to rotate all images in clockwise direction.

Parameters:
  • images (numpy.ndarray) – Stack of images (3D).
  • angles (numpy.ndarray) – Rotation angles (deg).
Returns:

Rotated images.

Return type:

numpy.ndarray

pynpoint.util.image.scale_image(image: numpy.ndarray, scaling_y: float, scaling_x: float) → numpy.ndarray[source]

Function to spatially scale an image.

Parameters:
  • image (numpy.ndarray) – Input image (2D).
  • scaling_y (float) – Scaling factor y.
  • scaling_x (float) – Scaling factor x.
Returns:

Shifted image (2D).

Return type:

numpy.ndarray

pynpoint.util.image.select_annulus(image_in: numpy.ndarray, radius_in: float, radius_out: float, mask_position: Tuple[float, float] = None, mask_radius: float = None) → numpy.ndarray[source]
image_in : numpy.ndarray
Input image.
radius_in : float
Inner radius of the annulus (pix).
radius_out : float
Outer radius of the annulus (pix).
mask_position : tuple(float, float), None
Center (pix) position (y, x) in of the circular region that is excluded. Not used if set to None.
mask_radius : float, None
Radius (pix) of the circular region that is excluded. Not used if set to None.
pynpoint.util.image.shift_image(image: numpy.ndarray, shift_yx: Union[Tuple[float, float], numpy.ndarray], interpolation: str, mode: str = 'constant') → numpy.ndarray[source]

Function to shift an image.

Parameters:
  • image (numpy.ndarray) – Input image (2D or 3D). If 3D the image is not shifted along the 0th axis.
  • shift_yx (tuple(float, float), np.ndarray) – Shift (y, x) to be applied (pix). An additional shift of zero pixels will be added for the first dimension in case the input image is 3D.
  • interpolation (str) – Interpolation type (‘spline’, ‘bilinear’, or ‘fft’).
  • mode (str) – Interpolation mode.
Returns:

Shifted image.

Return type:

numpy.ndarray

pynpoint.util.image.subpixel_distance(im_shape: Tuple[int, int], position: Tuple[float, float]) → numpy.ndarray[source]

Function to calculate the distance of each pixel with respect to a given subpixel position.

Parameters:
  • im_shape (tuple(int, int)) – Image shape (y, x).
  • position (tuple(float, float)) – Pixel center (y, x) from which the distance is calculated. Python indexing starts at zero so the bottom left image corner is (-0.5, -0.5).
Returns:

2D array with the distances of each pixel from the provided pixel position.

Return type:

numpy.ndarray

pynpoint.util.limits module

Functions for calculating detection limits.

pynpoint.util.limits.contrast_limit(path_images: str, path_psf: str, noise: numpy.ndarray, mask: numpy.ndarray, parang: numpy.ndarray, psf_scaling: float, extra_rot: float, pca_number: int, threshold: Tuple[str, float], aperture: float, residuals: str, snr_inject: float, position: Tuple[float, float]) → Tuple[float, float, float, float][source]

Function for calculating the contrast limit at a specified position for a given sigma level or false positive fraction, both corrected for small sample statistics.

Parameters:
  • path_images (str) – System location of the stack of images (3D).
  • path_psf (str) – System location of the PSF template for the fake planet (3D). Either a single image or a stack of images equal in size to science data.
  • noise (numpy.ndarray) – Residuals of the PSF subtraction (3D) without injection of fake planets. Used to measure the noise level with a correction for small sample statistics.
  • mask (numpy.ndarray) – Mask (2D).
  • parang (numpy.ndarray) – Derotation angles (deg).
  • psf_scaling (float) – Additional scaling factor of the planet flux (e.g., to correct for a neutral density filter). Should have a positive value.
  • extra_rot (float) – Additional rotation angle of the images in clockwise direction (deg).
  • pca_number (int) – Number of principal components used for the PSF subtraction.
  • threshold (tuple(str, float)) – Detection threshold for the contrast curve, either in terms of ‘sigma’ or the false positive fraction (FPF). The value is a tuple, for example provided as (‘sigma’, 5.) or (‘fpf’, 1e-6). Note that when sigma is fixed, the false positive fraction will change with separation. Also, sigma only corresponds to the standard deviation of a normal distribution at large separations (i.e., large number of samples).
  • aperture (float) – Aperture radius (pix) for the calculation of the false positive fraction.
  • residuals (str) – Method used for combining the residuals (‘mean’, ‘median’, ‘weighted’, or ‘clipped’).
  • snr_inject (float) – Signal-to-noise ratio of the injected planet signal that is used to measure the amount of self-subtraction.
  • position (tuple(float, float)) – The separation (pix) and position angle (deg) of the fake planet.
Returns:

  • float – Separation (pix).
  • float – Position angle (deg).
  • float – Contrast (mag).
  • float – False positive fraction.

pynpoint.util.mcmc module

Functions for MCMC sampling.

pynpoint.util.mcmc.lnprob(param: numpy.ndarray, bounds: Tuple[Tuple[float, float], Tuple[float, float], Tuple[float, float]], images: numpy.ndarray, psf: numpy.ndarray, mask: numpy.ndarray, parang: numpy.ndarray, psf_scaling: float, pixscale: float, pca_number: int, extra_rot: float, aperture: Tuple[int, int, float], indices: numpy.ndarray, merit: str, residuals: str) → float[source]

Function for the log posterior function. Should be placed at the highest level of the Python module to be pickable for the multiprocessing.

Parameters:
  • param (numpy.ndarray) – The separation (arcsec), angle (deg), and contrast (mag). The angle is measured in counterclockwise direction with respect to the positive y-axis.
  • bounds (tuple(tuple(float, float), tuple(float, float), tuple(float, float))) – The boundaries of the separation (arcsec), angle (deg), and contrast (mag). Each set of boundaries is specified as a tuple.
  • images (numpy.ndarray) – Stack with images.
  • psf (numpy.ndarray) – PSF template, either a single image (2D) or a cube (3D) with the dimensions equal to images.
  • mask (numpy.ndarray) – Array with the circular mask (zeros) of the central and outer regions.
  • parang (numpy.ndarray) – Array with the angles for derotation.
  • psf_scaling (float) – Additional scaling factor of the planet flux (e.g., to correct for a neutral density filter). Should be negative in order to inject negative fake planets.
  • pixscale (float) – Additional scaling factor of the planet flux (e.g., to correct for a neutral density filter). Should be negative in order to inject negative fake planets.
  • pca_number (int) – Number of principal components used for the PSF subtraction.
  • extra_rot (float) – Additional rotation angle of the images (deg).
  • aperture (tuple(int, int, float)) – Position (y, x) of the aperture center (pix) and aperture radius (pix).
  • indices (numpy.ndarray) – Non-masked image indices.
  • merit (str) – Figure of merit that is used for the likelihood function (‘gaussian’ or ‘poisson’). Pixels are assumed to be independent measurements which are expected to be equal to zero in case the best-fit negative PSF template is injected. With ‘gaussian’, the variance is estimated from the pixel values within an annulus at the separation of the aperture (but excluding the pixels within the aperture). With ‘poisson’, a Poisson distribution is assumed for the variance of each pixel value.
  • residuals (str) – Method used for combining the residuals (‘mean’, ‘median’, ‘weighted’, or ‘clipped’).
Returns:

Log posterior probability.

Return type:

float

pynpoint.util.module module

Functions for Pypeline modules.

pynpoint.util.module.input_info(pipeline_module) → None[source]

Function to print information about the input data.

Parameters:pipeline_module (PypelineModule) – Pipeline module.
Returns:None
Return type:NoneType
pynpoint.util.module.memory_frames(memory: Union[int, numpy.int64], nimages: int) → numpy.ndarray[source]

Function to subdivide the input images is in quantities of MEMORY.

Parameters:
  • memory (int) – Number of images that is simultaneously loaded into the memory.
  • nimages (int) – Number of images in the stack.
Returns:

Return type:

numpy.ndarray

pynpoint.util.module.module_info(pipeline_module) → None[source]

Function to print the module name.

Parameters:pipeline_module (PypelineModule) – Pipeline module.
Returns:None
Return type:NoneType
pynpoint.util.module.output_info(pipeline_module, output_shape) → None[source]

Function to print information about the output data.

Parameters:
  • pipeline_module (PypelineModule) – Pipeline module.
  • output_shape (dict) – Dictionary with the output dataset names and shapes.
Returns:

None

Return type:

NoneType

pynpoint.util.module.progress(current: int, total: int, message: str, start_time: float = None) → None[source]

Function to show and update the progress as standard output.

Parameters:
  • current (int) – Current index.
  • total (int) – Total index number.
  • message (str) – Message that is printed.
  • start_time (float, None, optional) – Start time in seconds. Not used if set to None.
Returns:

None

Return type:

NoneType

pynpoint.util.module.update_arguments(index: int, nimages: int, args_in: Optional[tuple]) → Optional[tuple][source]

Function to update the arguments of an input function. Specifically, arguments which contain an array with the first dimension equal in size to the total number of images will be substituted by the array element of the image index.

Parameters:
  • index (int) – Image index in the stack.
  • nimages (int) – Total number of images in the stack.
  • args_in (tuple, None) – Function arguments that have to be updated.
Returns:

Updated function arguments.

Return type:

tuple, None

pynpoint.util.multiline module

Utilities for multiprocessing of lines in time with the poison pill pattern.

class pynpoint.util.multiline.LineProcessingCapsule(image_in_port: pynpoint.core.dataio.InputPort, image_out_port: pynpoint.core.dataio.OutputPort, num_proc: numpy.int64, function: Callable, function_args: Optional[tuple], data_length: int)[source]

Bases: pynpoint.util.multiproc.MultiprocessingCapsule

Capsule for parallel processing of lines in time with the poison pill pattern. A function is applied in parallel to each line in time, for example as in WaveletTimeDenoisingModule.

Parameters:
  • image_in_port (pynpoint.core.dataio.InputPort) – Input port.
  • image_out_port (pynpoint.core.dataio.OutputPort) – Output port.
  • num_proc (int) – Number of processors.
  • function (function) – Input function that is applied to the lines.
  • function_args (tuple, None, optional) – Function arguments.
  • data_length (int) – Length of the processed data.
Returns:

None

Return type:

NoneType

create_processors() → List[pynpoint.util.multiline.LineTaskProcessor][source]
Returns:List with instances of LineTaskProcessor
Return type:list(pynpoint.util.multiproc.LineTaskProcessor, )
init_creator(image_in_port: pynpoint.core.dataio.InputPort) → pynpoint.util.multiline.LineReader[source]
Parameters:image_in_port (pynpoint.core.dataio.InputPort) – Input port from where the subsets of lines are read.
Returns:Line reader object.
Return type:pynpoint.util.multiline.LineReader
class pynpoint.util.multiline.LineReader(data_port_in: pynpoint.core.dataio.InputPort, tasks_queue_in: multiprocessing.context.BaseContext.JoinableQueue, data_mutex_in: multiprocessing.context.BaseContext.Lock, num_proc: numpy.int64, data_length: int)[source]

Bases: pynpoint.util.multiproc.TaskCreator

Reader of task inputs for LineProcessingCapsule. Continuously read all rows of a dataset and puts them into a task queue.

Parameters:
  • data_port_in (pynpoint.core.dataio.InputPort) – Input port.
  • tasks_queue_in (multiprocessing.queues.JoinableQueue) – Tasks queue.
  • data_mutex_in (multiprocessing.synchronize.Lock) – A mutex shared with the writer to ensure that no read and write operations happen at the same time.
  • num_proc (int) – Number of processors.
  • data_length (int) – Length of the processed data.
Returns:

None

Return type:

NoneType

run() → None[source]
Returns:None
Return type:NoneType
class pynpoint.util.multiline.LineTaskProcessor(tasks_queue_in: multiprocessing.context.BaseContext.JoinableQueue, result_queue_in: multiprocessing.context.BaseContext.JoinableQueue, function: Callable, function_args: Optional[tuple])[source]

Bases: pynpoint.util.multiproc.TaskProcessor

Processor of task inputs for LineProcessingCapsule. A processor applies a function on a row of lines in time.

Parameters:
  • tasks_queue_in (multiprocessing.queues.JoinableQueue) – Tasks queue.
  • result_queue_in (multiprocessing.queues.JoinableQueue) – Results queue.
  • function (function) – Input function.
  • function_args (tuple, None) – Optional function arguments.
Returns:

None

Return type:

NoneType

run_job(tmp_task: pynpoint.util.multiproc.TaskInput) → pynpoint.util.multiproc.TaskResult[source]
Parameters:tmp_task (pynpoint.util.multiproc.TaskInput) – Task input with the subsets of lines and the job parameters.
Returns:Task result.
Return type:pynpoint.util.multiproc.TaskResult

pynpoint.util.multipca module

Capsule for multiprocessing of the PSF subtraction with PCA. Residuals are created in parallel for a range of principal components for which the PCA basis is required as input.

class pynpoint.util.multipca.PcaMultiprocessingCapsule(mean_out_port: Optional[pynpoint.core.dataio.OutputPort], median_out_port: Optional[pynpoint.core.dataio.OutputPort], weighted_out_port: Optional[pynpoint.core.dataio.OutputPort], clip_out_port: Optional[pynpoint.core.dataio.OutputPort], num_proc: numpy.int64, pca_numbers: numpy.ndarray, pca_model: sklearn.decomposition.pca.PCA, star_reshape: numpy.ndarray, angles: numpy.ndarray, im_shape: Tuple[int, int, int], indices: numpy.ndarray)[source]

Bases: pynpoint.util.multiproc.MultiprocessingCapsule

Capsule for PCA multiprocessing with the poison pill pattern.

Constructor of PcaMultiprocessingCapsule.

Parameters:
  • mean_out_port (pynpoint.core.dataio.OutputPort) – Output port for the mean residuals.
  • median_out_port (pynpoint.core.dataio.OutputPort) – Output port for the median residuals.
  • weighted_out_port (pynpoint.core.dataio.OutputPort) – Output port for the noise-weighted residuals.
  • clip_out_port (pynpoint.core.dataio.OutputPort) – Output port for the mean clipped residuals.
  • num_proc (int) – Number of processors.
  • pca_numbers (numpy.ndarray) – Number of principal components.
  • pca_model (sklearn.decomposition.pca.PCA) – PCA object with the basis.
  • star_reshape (numpy.ndarray) – Reshaped (2D) input images.
  • angles (numpy.ndarray) – Derotation angles (deg).
  • im_shape (tuple(int, int, int)) – Original shape of the input images.
  • indices (numpy.ndarray) – Non-masked pixel indices.
Returns:

None

Return type:

NoneType

create_processors() → List[pynpoint.util.multipca.PcaTaskProcessor][source]

Method to create a list of instances of PcaTaskProcessor.

Returns:PCA task processors.
Return type:list(pynpoint.util.multipca.PcaTaskProcessor, )
create_writer(image_out_port: None) → pynpoint.util.multipca.PcaTaskWriter[source]

Method to create an instance of PcaTaskWriter.

Parameters:image_out_port (None) – Output port, not used.
Returns:PCA task writer.
Return type:pynpoint.util.multipca.PcaTaskWriter
init_creator(image_in_port: None) → pynpoint.util.multipca.PcaTaskCreator[source]

Method to create an instance of PcaTaskCreator.

Parameters:image_in_port (None) – Input port, not used.
Returns:PCA task creator.
Return type:pynpoint.util.multipca.PcaTaskCreator
class pynpoint.util.multipca.PcaTaskCreator(tasks_queue_in: multiprocessing.context.BaseContext.JoinableQueue, num_proc: numpy.int64, pca_numbers: numpy.ndarray)[source]

Bases: pynpoint.util.multiproc.TaskCreator

The TaskCreator of the PCA multiprocessing. Creates one task for each principal component number. Does not require an input port since the data is directly given to the task processors.

Parameters:
  • tasks_queue_in (multiprocessing.queues.JoinableQueue) – Input task queue.
  • num_proc (int) – Number of processors.
  • pca_numbers (numpy.ndarray) – Principal components for which the residuals are computed.
Returns:

None

Return type:

NoneType

run() → None[source]

Run method of PcaTaskCreator.

Returns:None
Return type:NoneType
class pynpoint.util.multipca.PcaTaskProcessor(tasks_queue_in: multiprocessing.context.BaseContext.JoinableQueue, result_queue_in: multiprocessing.context.BaseContext.JoinableQueue, star_reshape: numpy.ndarray, angles: numpy.ndarray, pca_model: sklearn.decomposition.pca.PCA, im_shape: Tuple[int, int, int], indices: numpy.ndarray, requirements: Tuple[bool, bool, bool, bool])[source]

Bases: pynpoint.util.multiproc.TaskProcessor

The TaskProcessor of the PCA multiprocessing is the core of the parallelization. An instance of this class will calculate one forward and backward PCA transformation given the pre-trained scikit-learn PCA model. It does not get data from the TaskCreator but uses its own copy of the input data, which are the same and independent for each task. The following residuals can be created:

  • Mean residuals – requirements[0] = True
  • Median residuals – requirements[1] = True
  • Noise-weighted residuals – requirements[2] = True
  • Clipped mean of the residuals – requirements[3] = True
Parameters:
  • tasks_queue_in (multiprocessing.queues.JoinableQueue) – Input task queue.
  • result_queue_in (multiprocessing.queues.JoinableQueue) – Input result queue.
  • star_reshape (numpy.ndarray) – Reshaped (2D) stack of images.
  • angles (numpy.ndarray) – Derotation angles (deg).
  • pca_model (sklearn.decomposition.pca.PCA) – PCA object with the basis.
  • im_shape (tuple(int, int, int)) – Original shape of the stack of images.
  • indices (numpy.ndarray) – Non-masked image indices.
  • requirements (tuple(bool, bool, bool, bool)) – Required output residuals.
Returns:

None

Return type:

NoneType

run_job(tmp_task: pynpoint.util.multiproc.TaskInput) → pynpoint.util.multiproc.TaskResult[source]

Run method of PcaTaskProcessor.

Parameters:tmp_task (pynpoint.util.multiproc.TaskInput) – Input task.
Returns:Output residuals.
Return type:pynpoint.util.multiproc.TaskResult
class pynpoint.util.multipca.PcaTaskWriter(result_queue_in: multiprocessing.context.BaseContext.JoinableQueue, mean_out_port: Optional[pynpoint.core.dataio.OutputPort], median_out_port: Optional[pynpoint.core.dataio.OutputPort], weighted_out_port: Optional[pynpoint.core.dataio.OutputPort], clip_out_port: Optional[pynpoint.core.dataio.OutputPort], data_mutex_in: multiprocessing.context.BaseContext.Lock, requirements: Tuple[bool, bool, bool, bool])[source]

Bases: pynpoint.util.multiproc.TaskWriter

The TaskWriter of the PCA parallelization. Four different ports are used to save the results of the task processors (mean, median, weighted, and clipped).

Constructor of PcaTaskWriter.

Parameters:
  • result_queue_in (multiprocessing.queues.JoinableQueue) – Input result queue.
  • mean_out_port (pynpoint.core.dataio.OutputPort) – Output port with the mean residuals. Not used if set to None.
  • median_out_port (pynpoint.core.dataio.OutputPort) – Output port with the median residuals. Not used if set to None.
  • weighted_out_port (pynpoint.core.dataio.OutputPort) – Output port with the noise-weighted residuals. Not used if set to None.
  • clip_out_port (pynpoint.core.dataio.OutputPort) – Output port with the clipped mean residuals. Not used if set to None.
  • data_mutex_in (multiprocessing.synchronize.Lock) – A mutual exclusion variable which ensure that no read and write simultaneously occur.
  • requirements (tuple(bool, bool, bool, bool)) – Required output residuals.
Returns:

None

Return type:

NoneType

run() → None[source]

Run method of PcaTaskWriter. Writes the residuals to the output ports.

Returns:None
Return type:NoneType

pynpoint.util.multiproc module

Abstract interfaces for multiprocessing applications with the poison pill pattern.

class pynpoint.util.multiproc.MultiprocessingCapsule(image_in_port: Optional[pynpoint.core.dataio.InputPort], image_out_port: Optional[pynpoint.core.dataio.OutputPort], num_proc: numpy.int64)[source]

Bases: object

Abstract interface for multiprocessing capsules based on the poison pill pattern.

Parameters:
Returns:

None

Return type:

NoneType

create_processors() → None[source]

Function that is called from the constructor to create a list of instances of TaskProcessor.

Returns:None
Return type:NoneType
create_writer(image_out_port: Optional[pynpoint.core.dataio.OutputPort]) → pynpoint.util.multiproc.TaskWriter[source]

Function that is called from the constructor to create the TaskWriter.

Parameters:image_out_port (pynpoint.core.dataio.OutputPort, None) – Output port for the creator.
Returns:Task writer.
Return type:pynpoint.util.multiproc.TaskWriter
init_creator(image_in_port: Optional[pynpoint.core.dataio.InputPort]) → None[source]

Function that is called from the constructor to create a TaskCreator.

Parameters:image_in_port (pynpoint.core.dataio.InputPort, None) – Input port for the task creator.
Returns:None
Return type:NoneType
run() → None[source]

Run method that starts the TaskCreator, the instances of TaskProcessor, and the TaskWriter. They will be shut down when all tasks have finished.

Returns:None
Return type:NoneType
class pynpoint.util.multiproc.TaskCreator(data_port_in: Optional[pynpoint.core.dataio.InputPort], tasks_queue_in: multiprocessing.context.BaseContext.JoinableQueue, data_mutex_in: Optional[multiprocessing.context.BaseContext.Lock], num_proc: numpy.int64)[source]

Bases: multiprocessing.context.Process

Abstract interface for TaskCreator classes. A TaskCreator creates instances of TaskInput, which will be processed by the TaskProcessor, and appends them to the central task queue. In general there is only one TaskCreator running for a poison pill multiprocessing application. A TaskCreator communicates with to the TaskWriter in order to avoid simultaneously access to the central database.

Parameters:
  • data_port_in (pynpoint.core.dataio.InputPort, None) – An input port which links to the data that has to be processed.
  • tasks_queue_in (multiprocessing.queues.JoinableQueue) – The central task queue.
  • data_mutex_in (multiprocessing.synchronize.Lock, None) – A mutex shared with the writer to ensure that no read and write operations happen at the same time.
  • num_proc (int) – Maximum number of instances of TaskProcessor that run simultaneously.
Returns:

None

Return type:

NoneType

create_poison_pills() → None[source]

Creates poison pills for the TaskProcessor and TaskWriter. A process will shut down if it receives a poison pill as a new task. This method should be executed at the end of the run() method.

Returns:None
Return type:NoneType
run() → None[source]

Creates objects of the TaskInput until all tasks are placed in the task queue.

Returns:None
Return type:NoneType
class pynpoint.util.multiproc.TaskInput(input_data: Union[numpy.ndarray, numpy.int64], job_parameter: tuple)[source]

Bases: object

Class for tasks that are processed by the TaskProcessor.

Parameters:
  • input_data (int, float, numpy.ndarray) – Input data for by the TaskProcessor.
  • job_parameter (tuple) – Additional data or parameters.
Returns:

None

Return type:

NoneType

class pynpoint.util.multiproc.TaskProcessor(tasks_queue_in: multiprocessing.context.BaseContext.JoinableQueue, result_queue_in: multiprocessing.context.BaseContext.JoinableQueue)[source]

Bases: multiprocessing.context.Process

Abstract interface for TaskProcessor classes. The number of instances of TaskProcessor that run simultaneously in a poison pill multiprocessing application can be set with CPU parameter in the central configuration file. A TaskProcessor takes tasks from a task queue, processes the task, and stores the results back into a result queue. The process will shut down if the next task is a poison pill. The order in which process finish is not fixed.

Parameters:
  • tasks_queue_in (multiprocessing.queues.JoinableQueue) – The input task queue with instances of TaskInput.
  • result_queue_in (multiprocessing.queues.JoinableQueue) – The result task queue with instances of TaskResult.
Returns:

None

Return type:

NoneType

check_poison_pill(next_task: Union[pynpoint.util.multiproc.TaskInput, int, None]) → bool[source]

Function to check if the next task is a poison pill.

Parameters:next_task (int, None, pynpoint.util.multiproc.TaskInput) – The next task.
Returns:True if the next task is a poison pill, False otherwise.
Return type:bool
run() → None[source]

Run method to start the TaskProcessor. The run method will continue to process tasks from the input task queue until it receives a poison pill.

Returns:None
Return type:NoneType
run_job(tmp_task: pynpoint.util.multiproc.TaskInput) → None[source]

Abstract interface for the run_job() method which is called from the run() method for each task individually.

Parameters:tmp_task (pynpoint.util.multiproc.TaskInput) – Input task.
Returns:None
Return type:NoneType
class pynpoint.util.multiproc.TaskResult(data_array: numpy.ndarray, position: tuple)[source]

Bases: object

Class for results that can be stored by the TaskWriter.

Parameters:
  • data_array (numpy.ndarray) – Array with the results for a given position.
  • position (tuple(tuple(int, int, int), tuple(int, int, int), tuple(int, int, int))) – The position where the results will be stored.
Returns:

None

Return type:

NoneType

class pynpoint.util.multiproc.TaskWriter(result_queue_in: multiprocessing.context.BaseContext.JoinableQueue, data_out_port_in: Optional[pynpoint.core.dataio.OutputPort], data_mutex_in: multiprocessing.context.BaseContext.Lock)[source]

Bases: multiprocessing.context.Process

The TaskWriter receives results from the result queue, which have been computed by a TaskProcessor, and stores the results in the central database. The position parameter of the TaskResult is used to slice the result to the correct position in the complete output dataset.

Parameters:
  • result_queue_in (multiprocessing.queues.JoinableQueue) – The result queue.
  • data_out_port_in (pynpoint.core.dataio.OutputPort, None) – The output port where the results will be stored.
  • data_mutex_in (multiprocessing.synchronize.Lock) – A mutex that is shared with the TaskWriter which ensures that read and write operations to the database do not occur simultaneously.
Returns:

None

Return type:

NoneType

check_poison_pill(next_result: Optional[pynpoint.util.multiproc.TaskResult]) → int[source]

Function to check if the next result is a poison pill.

Parameters:next_result (None, pynpoint.util.multiproc.TaskResult) – The next result.
Returns:0 -> no poison pill, 1 -> poison pill, 2 -> poison pill but still results in the queue (rare error case).
Return type:int
run() → None[source]

Run method of the TaskWriter. It is called once when it has to start storing the results until it receives a poison pill.

Returns:None
Return type:NoneType
pynpoint.util.multiproc.apply_function(tmp_data: numpy.ndarray, func: Callable, func_args: Optional[tuple]) → numpy.ndarray[source]

Apply a function with optional arguments to the input data.

Parameters:
  • tmp_data (numpy.ndarray) – Input data.
  • func (function) – Function.
  • func_args (tuple, None) – Function arguments.
Returns:

The results of the function.

Return type:

numpy.ndarray

pynpoint.util.multiproc.to_slice(tuple_slice: tuple) → tuple[source]

Function to convert tuples into slices for a multiprocessing queue.

Parameters:tuple_slice (tuple) – Tuple to be converted into a slice.
Returns:Tuple with three slices.
Return type:tuple(slice, slice, slice)

pynpoint.util.multistack module

Utilities for multiprocessing of stacks of images.

class pynpoint.util.multistack.StackProcessingCapsule(image_in_port: pynpoint.core.dataio.InputPort, image_out_port: pynpoint.core.dataio.OutputPort, num_proc: numpy.int64, function: Callable, function_args: Optional[tuple], stack_size: int, result_shape: tuple, nimages: int)[source]

Bases: pynpoint.util.multiproc.MultiprocessingCapsule

Capsule for parallel processing of stacks of images with the poison pill pattern. A function is applied in parallel to each stack of images.

Parameters:
  • image_in_port (pynpoint.core.dataio.InputPort) – Input port.
  • image_out_port (pynpoint.core.dataio.OutputPort) – Output port.
  • num_proc (int) – Number of processors.
  • function (function) – Input function.
  • function_args (tuple, None) – Function arguments.
  • stack_size (int) – Number of images per stack.
  • result_shape (tuple(int, )) – Shape of the array with output results (usually a stack of images).
  • nimages (int) – Total number of images.
Returns:

None

Return type:

NoneType

create_processors() → List[pynpoint.util.multistack.StackTaskProcessor][source]
Returns:List with instances of StackTaskProcessor.
Return type:list(pynpoint.util.multiproc.StackTaskProcessor, )
init_creator(image_in_port: pynpoint.core.dataio.InputPort) → pynpoint.util.multistack.StackReader[source]
Parameters:image_in_port (pynpoint.core.dataio.InputPort) – Input port from where the subsets of images are read.
Returns:Reader of stacks of images.
Return type:pynpoint.util.multistack.StackReader
class pynpoint.util.multistack.StackReader(data_port_in: pynpoint.core.dataio.InputPort, tasks_queue_in: multiprocessing.context.BaseContext.JoinableQueue, data_mutex_in: multiprocessing.context.BaseContext.Lock, num_proc: numpy.int64, stack_size: int, result_shape: tuple)[source]

Bases: pynpoint.util.multiproc.TaskCreator

Reader of task inputs for StackProcessingCapsule. Reads continuously stacks of images of a dataset and puts them into a task queue.

Parameters:
  • data_port_in (pynpoint.core.dataio.InputPort) – Input port.
  • tasks_queue_in (multiprocessing.queues.JoinableQueue) – Tasks queue.
  • data_mutex_in (multiprocessing.synchronize.Lock) – A mutex shared with the writer to ensure that no read and write operations happen at the same time.
  • num_proc (int) – Number of processors.
  • stack_size (int) – Number of images per stack.
  • result_shape (tuple(int, )) – Shape of the array with the output results (usually a stack of images).
Returns:

None

Return type:

NoneType

run() → None[source]
Returns:None
Return type:NoneType
class pynpoint.util.multistack.StackTaskProcessor(tasks_queue_in: multiprocessing.context.BaseContext.JoinableQueue, result_queue_in: multiprocessing.context.BaseContext.JoinableQueue, function: Callable, function_args: Optional[tuple], nimages: int)[source]

Bases: pynpoint.util.multiproc.TaskProcessor

Processor of task inputs for StackProcessingCapsule. A processor applies a function on a stack of images.

Parameters:
  • tasks_queue_in (multiprocessing.queues.JoinableQueue) – Tasks queue.
  • result_queue_in (multiprocessing.queues.JoinableQueue) – Results queue.
  • function (function) – Input function that is applied to the images.
  • function_args (tuple, None) – Function arguments.
  • nimages (int) – Total number of images.
Returns:

None

Return type:

NoneType

run_job(tmp_task: pynpoint.util.multiproc.TaskInput) → pynpoint.util.multiproc.TaskResult[source]
Parameters:tmp_task (pynpoint.util.multiproc.TaskInput) – Task input with the subsets of images and the job parameters.
Returns:Task result.
Return type:pynpoint.util.multiproc.TaskResult

pynpoint.util.psf module

Functions for PSF subtraction.

pynpoint.util.psf.pca_psf_subtraction(images: numpy.ndarray, angles: numpy.ndarray, pca_number: int, pca_sklearn: sklearn.decomposition.pca.PCA = None, im_shape: Tuple[int, int, int] = None, indices: numpy.ndarray = None) → numpy.ndarray[source]

Function for PSF subtraction with PCA.

Parameters:
  • images (numpy.ndarray) – Stack of images. Also used as reference images if pca_sklearn is set to None. Should be in the original 3D shape if pca_sklearn is set to None or in the 2D reshaped format if pca_sklearn is not set to None.
  • parang (numpy.ndarray) – Derotation angles (deg).
  • pca_number (int) – Number of principal components used for the PSF model.
  • pca_sklearn (sklearn.decomposition.pca.PCA, None) – PCA object with the basis if not set to None.
  • im_shape (tuple(int, int, int), None) – Original shape of the stack with images. Required if pca_sklearn is not set to None.
  • indices (numpy.ndarray, None) – Non-masked image indices. All pixels are used if set to None.
Returns:

  • numpy.ndarray – Residuals of the PSF subtraction.
  • numpy.ndarray – Derotated residuals of the PSF subtraction.

pynpoint.util.remove module

Functions to write selected data and attributes to the central database.

pynpoint.util.remove.write_selected_attributes(indices: numpy.ndarray, port_input: pynpoint.core.dataio.InputPort, port_selected: Optional[pynpoint.core.dataio.OutputPort], port_removed: Optional[pynpoint.core.dataio.OutputPort]) → None[source]

Function to write the attributes of a selected number of images.

Parameters:
Returns:

None

Return type:

NoneType

pynpoint.util.remove.write_selected_data(images: numpy.ndarray, indices: numpy.ndarray, port_selected: Optional[pynpoint.core.dataio.OutputPort], port_removed: Optional[pynpoint.core.dataio.OutputPort]) → None[source]

Function to write a selected number of images from a data set.

Parameters:
Returns:

None

Return type:

NoneType

pynpoint.util.residuals module

Functions for combining the residuals of the PSF subtraction.

pynpoint.util.residuals.combine_residuals(method: str, res_rot: numpy.ndarray, residuals: numpy.ndarray = None, angles: numpy.ndarray = None) → numpy.ndarray[source]

Function for combining the derotated residuals of the PSF subtraction.

Parameters:
  • method (str) – Method used for combining the residuals (‘mean’, ‘median’, ‘weighted’, or ‘clipped’).
  • res_rot (numpy.ndarray) – Derotated residuals of the PSF subtraction (3D).
  • residuals (numpy.ndarray, None) – Non-derotated residuals of the PSF subtraction (3D). Only required for the noise-weighted residuals.
  • angles (numpy.ndarray, None) – Derotation angles (deg). Only required for the noise-weighted residuals.
Returns:

Combined residuals (3D).

Return type:

numpy.ndarray

pynpoint.util.star module

Functions for stellar extraction.

pynpoint.util.star.locate_star(image: numpy.ndarray, center: Optional[tuple], width: Optional[int], fwhm: Optional[int]) → numpy.ndarray[source]

Function to locate the star by finding the brightest pixel.

Parameters:
  • image (numpy.ndarray) – Input image (2D).
  • center (tuple(int, int), None) – Pixel center (y, x) of the subframe. The full image is used if set to None.
  • width (int, None) – The width (pix) of the subframe. The full image is used if set to None.
  • fwhm (int, None) – Full width at half maximum (pix) of the Gaussian kernel. Not used if set to None.
Returns:

Position (y, x) of the brightest pixel.

Return type:

numpy.ndarray

pynpoint.util.star.star_positions(input_port: pynpoint.core.dataio.InputPort, fwhm: float, position: Union[Tuple[int, int, float], Tuple[None, None, float], Tuple[int, int, None]] = None) → numpy.ndarray[source]

Function to return the position of the star in each image.

Parameters:
  • input_port (pynpoint.core.dataio.InputPort) – Input port where the images are stored.
  • fwhm (int) – The FWHM (pix) of the Gaussian kernel that is used to smooth the images before the brightest pixel is located.
  • position (tuple(int, int, int), None) – Subframe that is selected to search for the star. The tuple contains the center (pix) and size (pix) (pos_x, pos_y, size). Setting position to None will use the full image to search for the star. If position=(None, None, size) then the center of the image will be used. If position=(pos_x, pos_y, None) then a fixed position is used for the aperture.
Returns:

Positions (y, x) of the brightest pixel.

Return type:

numpy.ndarray

pynpoint.util.tests module

Functions for testing the pipeline and modules.

pynpoint.util.tests.create_config(filename: str) → None[source]

Create a configuration file.

Parameters:filename (str) – Configuration filename.
Returns:None
Return type:NoneType
pynpoint.util.tests.create_fake(path: str, ndit: List[int], nframes: List[int], exp_no: List[int], npix: Tuple[int, int], fwhm: Optional[float], x0: List[float], y0: List[float], angles: List[List[float]], sep: Optional[float], contrast: Optional[float]) → None[source]

Create ADI test data with a fake planet.

Parameters:
  • path (str) – Working folder.
  • ndit (list(int, )) – Number of exposures.
  • nframes (list(int, )) – Number of images.
  • exp_no (list(int, )) – Exposure numbers.
  • npix (tupe(int, int)) – Number of pixels in x and y direction.
  • fwhm (float, None) – Full width at half maximum (pix) of the PSF.
  • x0 (list(float, )) – Horizontal positions of the star.
  • y0 (list(float, )) – Vertical positions of the star.
  • angles (list(list(float, float), )) – Derotation angles (deg).
  • sep (float, None) – Separation of the planet.
  • contrast (float, None) – Brightness contrast of the planet.
Returns:

None

Return type:

NoneType

pynpoint.util.tests.create_fits(path: str, filename: str, image: numpy.ndarray, ndit: int, exp_no: int = 0, parang: List[float] = [0.0, 0.0], x0: float = 0.0, y0: float = 0.0) → None[source]

Create a FITS file with images and header information.

Parameters:
  • path (str) – Working folder.
  • filename (str) – FITS filename.
  • image (numpy.ndarray) – Images.
  • ndit (int) – Number of integrations.
  • exp_no (int) – Exposure number.
  • parang (list(float, float)) – Start and end parallactic angle.
  • x0 (float) – Horizontal dither position.
  • y0 (float) – Vertical dither position.
Returns:

None

Return type:

NoneType

pynpoint.util.tests.create_near_data(path: str) → None[source]

Create a stack of images with Gaussian distributed pixel values.

Parameters:path (str) – Working folder.
Returns:None
Return type:NoneType
pynpoint.util.tests.create_random(path: str, ndit: int = 10, parang: Optional[numpy.ndarray] = array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])) → None[source]

Create a stack of images with Gaussian distributed pixel values.

Parameters:
  • path (str) – Working folder.
  • ndit (int) – Number of images.
  • parang (numpy.ndarray, None) – Parallactic angles.
Returns:

None

Return type:

NoneType

pynpoint.util.tests.create_star_data(path: str, npix_x: int = 100, npix_y: int = 100, x0: List[float] = [50.0, 50.0, 50.0, 50.0], y0: List[float] = [50.0, 50.0, 50.0, 50.0], parang_start: List[float] = [0.0, 5.0, 10.0, 15.0], parang_end: List[float] = [5.0, 10.0, 15.0, 20.0], exp_no: List[int] = [1, 2, 3, 4], ndit: int = 10, nframes: int = 10, noise: bool = True) → None[source]

Create data with a stellar PSF and Gaussian noise.

Parameters:
  • path (str) – Working folder.
  • npix_x (int) – Number of pixels in horizontal direction.
  • npix_y (int) – Number of pixels in vertical direction.
  • x0 (list(float, )) – Positions of the PSF in horizontal direction.
  • y0 (list(float, )) – Positions of the PSF in vertical direction.
  • parang_start (list(float, )) – Start values of the parallactic angle (deg).
  • parang_end (list(float, )) – End values of the parallactic angle (deg).
  • exp_no (list(int, )) – Exposure numbers.
  • ndit (int) – Number of exposures.
  • nframes (int) – Number of frames.
  • noise (bool) – Adding noise to the images.
Returns:

None

Return type:

NoneType

pynpoint.util.tests.create_waffle_data(path: str, npix: int, x_spot: List[float], y_spot: List[float]) → None[source]

Create data with satellite spots and Gaussian noise.

Parameters:
  • path (str) – Working folder.
  • npix (int) – Number of pixels in both dimensions.
  • x_spot (list(float, )) – Pixel positions in horizontal direction of the satellite spots.
  • y_spot (list(float, )) – Pixel positions in vertical direction of the satellite spots.
Returns:

None

Return type:

NoneType

pynpoint.util.tests.remove_test_data(path: str, folders: List[str] = None, files: List[str] = None) → None[source]

Function to remove data created by the test cases.

Parameters:
  • path (str) – Working folder.
  • folders (list(str, )) – Folders to remove.
  • files (list(str, )) – Files to removes.
Returns:

None

Return type:

NoneType

pynpoint.util.wavelets module

Wrapper utils for the wavelet functions for the mlpy cwt implementation (see continous.py)

class pynpoint.util.wavelets.WaveletAnalysisCapsule(signal_in: numpy.ndarray, wavelet_in: str = 'dog', order: int = 2, padding: str = 'none', frequency_resolution: float = 0.5)[source]

Bases: object

Capsule class to process one 1d time series using the CWT and wavelet de-nosing by wavelet shrinkage.

Parameters:
  • signal_in (numpy.ndarray) – 1D input signal.
  • wavelet_in (str) – Wavelet function (‘dog’ or ‘morlet’).
  • order (int) – Order of the wavelet function.
  • padding (str) – Padding method (‘zero’, ‘mirror’, or ‘none’).
  • frequency_resolution (float) – Wavelet space resolution in scale/frequency.
Returns:

None

Return type:

NoneType

compute_cwt() → None[source]

Compute the wavelet space of the given input signal.

Returns:None
Return type:NoneType
denoise_spectrum(soft: bool = False) → None[source]

Applies wavelet shrinkage on the current wavelet space (m_spectrum) by either a hard of soft threshold function.

Parameters:soft (bool) – If True a soft threshold is used, hard otherwise.
Returns:None
Return type:NoneType
get_signal() → numpy.ndarray[source]

Returns the current version of the 1d signal. Use update_signal() in advance in order to get the current reconstruction of the wavelet space. Removes padded values as well.

Returns:Current version of the 1D signal.
Return type:numpy.ndarray
median_filter() → None[source]

Applies a median filter on the internal 1d signal. Can be useful for cosmic ray correction after temporal de-noising

Returns:None
Return type:NoneType
update_signal() → None[source]

Updates the internal signal by the reconstruction of the current wavelet space.

Returns:None
Return type:NoneType

Module contents