Array Utilities

class pumpia.utilities.array_utils.Pixel(x: int, y: int, value: int | float = 0)

Represents a pixel with x, y coordinates and a value.

x

The x-coordinate of the pixel.

Type:

int

y

The y-coordinate of the pixel.

Type:

int

value

The value of the pixel (default is 0).

Type:

int or float, optional

class pumpia.utilities.array_utils.Position(x: float, y: float)

Represents a position with x, y coordinates.

x

The x-coordinate of the position.

Type:

float

y

The y-coordinate of the position.

Type:

float

class pumpia.utilities.array_utils.Vector(x1: float, x2: float, y1: float, y2: float)

Represents a vector with start and end coordinates.

x1

The x-coordinate of the start point.

Type:

float

x2

The x-coordinate of the end point.

Type:

float

y1

The y-coordinate of the start point.

Type:

float

y2

The y-coordinate of the end point.

Type:

float

class pumpia.utilities.array_utils.MinMax(minimum: float | int, maximum: float | int)

Represents minimum and maximum values.

minimum

The minimum value.

Type:

np.floating or float or int

maximum

The maximum value.

Type:

np.floating or float or int

difference
Type:

np.floating or float or int

class pumpia.utilities.array_utils.MinMaxPix(minimum: int, maximum: int)

Represents minimum and maximum pixel position.

minimum

The minimum pixel position.

Type:

int

maximum

The maximum pixel position.

Type:

int

pumpia.utilities.array_utils.nth_max_positions(array: ndarray, divisor: float, minimum: float | floating | None = None, maximum: float | floating | None = None)

Finds the interpolated positions in the array where the value is crossing the nth maximum value relative to the minimum.

Parameters:
  • array (np.ndarray) – The input array. Should be 1 dimensional.

  • divisor (float) – The divisor to calculate the nth maximum value. e.g. 2 for half maximum.

  • minimum (float or np.floating or None, optional) – An override for the minimum to use. If None, the minimum value of the array is calculated.(default is None)

  • maximum (float or np.floating or None, optional) – An override for the maximum to use. If None, the maximum value of the array is calculated.(default is None)

Returns:

The positions in the array where the value is crossing the nth maximum value.

Return type:

np.ndarray

pumpia.utilities.array_utils.nth_max_up_positions(array: ndarray, divisor: float, minimum: float | floating | None = None, maximum: float | floating | None = None)

Finds the interpolated positions in the array to the left of where the value is increasing and crosses the nth maximum value relative to the minimum.

Parameters:
  • array (np.ndarray) – The input array. Should be 1 dimensional.

  • divisor (float) – The divisor to calculate the nth maximum value. e.g. 2 for half maximum.

  • minimum (float or np.floating or None, optional) – An override for the minimum to use. If None, the minimum value of the array is calculated.(default is None)

  • maximum (float or np.floating or None, optional) – An override for the maximum to use. If None, the maximum value of the array is calculated.(default is None)

Returns:

The positions in the array where the value is increasing and crosses the nth maximum value.

Return type:

np.ndarray

pumpia.utilities.array_utils.nth_max_down_positions(array: ndarray, divisor: float, minimum: float | floating | None = None, maximum: float | floating | None = None)

Finds the interpolated positions in the array to the left of where the value is decreasing and crosses the nth maximum value relative to the minimum.

Parameters:
  • array (np.ndarray) – The input array. Should be 1 dimensional.

  • divisor (float) – The divisor to calculate the nth maximum value. e.g. 2 for half maximum.

  • minimum (float or np.floating or None, optional) – An override for the minimum to use. If None, the minimum value of the array is calculated.(default is None)

  • maximum (float or np.floating or None, optional) – An override for the maximum to use. If None, the maximum value of the array is calculated.(default is None)

Returns:

The positions in the array where the value is decreasing and crosses the nth maximum value.

Return type:

np.ndarray

pumpia.utilities.array_utils.nth_max_bounds(array: ndarray, divisor: float, minimum: float | floating | None = None, maximum: float | floating | None = None) MinMax

Finds the minimum and maximum locations of the nth maximum value in the array.

Parameters:
  • array (np.ndarray) – The input array. Should be 1 dimensional.

  • divisor (float) – The divisor to calculate the nth maximum value. e.g. 2 for half maximum.

  • minimum (float or np.floating or None, optional) – An override for the minimum to use. If None, the minimum value of the array is calculated.(default is None)

  • maximum (float or np.floating or None, optional) – An override for the maximum to use. If None, the maximum value of the array is calculated.(default is None)

Returns:

The bounds of the nth maximum value in the array.

Return type:

MinMaxPix

pumpia.utilities.array_utils.nth_max_peaks(array: ndarray, divisor: float, minimum: float | floating | None = None, maximum: float | floating | None = None) list[MinMax]

Finds the nth maximum positions for peaks in the array.

Parameters:
  • array (np.ndarray) – The input array. Should be 1 dimensional.

  • divisor (float) – The divisor to calculate the nth maximum value. e.g. 2 for half maximum.

  • minimum (float or np.floating or None, optional) – An override for the minimum to use. If None, the minimum value of the array is calculated.(default is None)

  • maximum (float or np.floating or None, optional) – An override for the maximum to use. If None, the maximum value of the array is calculated.(default is None)

Returns:

The peaks of the nth maximum value in the array.

Return type:

list[MinMax]

pumpia.utilities.array_utils.nth_max_widest_peak(array: ndarray, divisor: float, minimum: float | floating | None = None, maximum: float | floating | None = None) MinMax

Finds the nth maximum positions for the widest peak in the array.

Parameters:
  • array (np.ndarray) – The input array. Should be 1 dimensional.

  • divisor (float) – The divisor to calculate the nth maximum value. e.g. 2 for half maximum.

  • minimum (float or np.floating or None, optional) – An override for the minimum to use. If None, the minimum value of the array is calculated.(default is None)

  • maximum (float or np.floating or None, optional) – An override for the maximum to use. If None, the maximum value of the array is calculated.(default is None)

Returns:

The widest peak of the nth maximum value in the array.

Return type:

MinMaxPix

pumpia.utilities.array_utils.nth_max_troughs(array: ndarray, divisor: float, minimum: float | floating | None = None, maximum: float | floating | None = None) list[MinMax]

Finds the nth maximum positions for troughs in the array.

Parameters:
  • array (np.ndarray) – The input array. Should be 1 dimensional.

  • divisor (float) – The divisor to calculate the nth maximum value. e.g. 2 for half maximum.

  • minimum (float or np.floating or None, optional) – An override for the minimum to use. If None, the minimum value of the array is calculated.(default is None)

  • maximum (float or np.floating or None, optional) – An override for the maximum to use. If None, the maximum value of the array is calculated.(default is None)

Returns:

The troughs of the nth maximum value in the array.

Return type:

list[MinMaxPix]

pumpia.utilities.array_utils.nth_max_widest_trough(array: ndarray, divisor: float, minimum: float | floating | None = None, maximum: float | floating | None = None) MinMax

Finds the nth maximum positions for the widest trough in the array.

Parameters:
  • array (np.ndarray) – The input array. Should be 1 dimensional.

  • divisor (float) – The divisor to calculate the nth maximum value. e.g. 2 for half maximum.

  • minimum (float or np.floating or None, optional) – An override for the minimum to use. If None, the minimum value of the array is calculated.(default is None)

  • maximum (float or np.floating or None, optional) – An override for the maximum to use. If None, the maximum value of the array is calculated.(default is None)

Returns:

The widest trough of the nth maximum value in the array.

Return type:

MinMaxPix

pumpia.utilities.array_utils.half_max_positions(array: ndarray, minimum: float | floating | None = None, maximum: float | floating | None = None)

Finds the positions in the array to the left of where the value is crossing the half maximum value relative to the minimum.

Parameters:
  • array (np.ndarray) – The input array. Should be 1 dimensional.

  • minimum (float or np.floating or None, optional) – An override for the minimum to use. If None, the minimum value of the array is calculated.(default is None)

  • maximum (float or np.floating or None, optional) – An override for the maximum to use. If None, the maximum value of the array is calculated.(default is None)

Returns:

The positions in the array where the value crosses the half maximum value.

Return type:

np.ndarray

pumpia.utilities.array_utils.half_max_bounds(array: ndarray, minimum: float | floating | None = None, maximum: float | floating | None = None) MinMax

Finds the minimum and maximum positions half the maximum value in the array.

Parameters:
  • array (np.ndarray) – The input array. Should be 1 dimensional.

  • minimum (float or np.floating or None, optional) – An override for the minimum to use. If None, the minimum value of the array is calculated.(default is None)

  • maximum (float or np.floating or None, optional) – An override for the maximum to use. If None, the maximum value of the array is calculated.(default is None)

Returns:

The bounds of half the maximum value in the array.

Return type:

MinMaxPix

pumpia.utilities.array_utils.tenth_max_positions(array: ndarray, minimum: float | floating | None = None, maximum: float | floating | None = None)

Finds the positions in the array to the left of where the value is crossing the tenth maximum value relative to the minimum.

Parameters:
  • array (np.ndarray) – The input array. Should be 1 dimensional.

  • minimum (float or np.floating or None, optional) – An override for the minimum to use. If None, the minimum value of the array is calculated.(default is None)

  • maximum (float or np.floating or None, optional) – An override for the maximum to use. If None, the maximum value of the array is calculated.(default is None)

Returns:

The positions in the array where the value crosses the one-tenth maximum value.

Return type:

np.ndarray

pumpia.utilities.array_utils.tenth_max_bounds(array: ndarray, minimum: float | floating | None = None, maximum: float | floating | None = None) MinMax

Finds the maximum and minimum positions of one-tenth the maximum value in the array.

Parameters:
  • array (np.ndarray) – The input array. Should be 1 dimensional.

  • minimum (float or np.floating or None, optional) – An override for the minimum to use. If None, the minimum value of the array is calculated.(default is None)

  • maximum (float or np.floating or None, optional) – An override for the maximum to use. If None, the maximum value of the array is calculated.(default is None)

Returns:

The bounds of one-tenth the maximum value in the array.

Return type:

MinMaxPix