tools

Overview

The tools module contains general-purpose utility functions used throughout OOPAO — file I/O, array manipulation, photon statistics, and error handling.

Selected API reference

OOPAO.tools.tools.createFolder(path)[source]

Create a directory (and all parent directories) if it does not exist.

Parameters:

path (str) – Directory path.

OOPAO.tools.tools.read_fits(filename)[source]

Read a FITS file and return the data array.

Parameters:

filename (str) – Path to the FITS file.

Returns:

Data array.

Return type:

numpy.ndarray

OOPAO.tools.tools.crop(imageArray, size, axis, maximum=0)[source]

Extract a centred sub-image from a 2-D or 3-D array.

Parameters:
  • imageArray (numpy.ndarray) – Input array.

  • size (int) – Output size in pixels.

  • axis (int) – Axis along which to crop (for 3-D arrays).

  • maximum (int) – If 1, centre on the array maximum instead of the geometric centre. Default 0.

OOPAO.tools.tools.bin_ndarray(ndarray, new_shape, operation='sum')[source]

Bin a 2-D or 3-D NumPy array to a new shape by summing or averaging.

Parameters:
  • ndarray (numpy.ndarray) – Input array.

  • new_shape (tuple) – Target shape after binning.

  • operation (str) – 'sum' (default) or 'mean'.

OOPAO.tools.tools.set_binning(frame, binning)[source]

Apply integer pixel binning to a 2-D frame.

Parameters:
Returns:

Binned array.

Return type:

numpy.ndarray

OOPAO.tools.tools.gaussian_2D(size, sigma, center=None)[source]

Generate a 2-D Gaussian kernel.

Parameters:
  • size (int) – Array side length in pixels.

  • sigma (float) – Gaussian sigma in pixels.

  • center (tuple or None) – (row, col) centre. Default None (geometric centre).

exception OOPAO.tools.tools.OopaoError[source]

Custom exception raised for OOPAO-specific configuration and propagation errors.

OOPAO.tools.tools.warning(message)[source]

Print a formatted OOPAO warning to stdout.

Parameters:

message (str) – Warning text.