hdrl.core

HDRL Core submodule This module provides the features to implement the HDRL core capabilities.

exception hdrl.core.AccessOutOfRangeError(*args)

Data were accessed beyond boundaries.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.AssigningStreamError(*args)

Could not associate a stream with a file descriptor.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.BadFileFormatError(*args)

Input file had not the expected format.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.ContinueError(*args)

An iterative process did not converge.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.DataNotFoundError(*args)

Data searched within a valid object were not found.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.DivisionByZeroError(*args)

Attempted to divide a number by zero.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.DuplicatingStreamError(*args)

Could not duplicate output stream.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.EOLError(*args)

To permit extensibility of error handling.Do not raise this in Python as it will be a conding error in itself

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.Error(*args)

Abstract base class of all CPL exceptions, Do not instantiate this class, instead use hdrl.core.NullInputError, hdrl.core.InvalidArgumentError, or any other subclass. However this class implements has all documentation for those error subclasses.

In order to copy a cpl error, where you do not know the type of the error, use the hdrl.core.Error.create classmethod, as create can dispatch to the relevant subclass.

Examples

try:
    # Some PyCPL functions are called here
except hdrl.core.IllegalInputError as e:
    print(str(e.message))
except hdrl.core.Error as e:
    print(str(e))
classmethod create(*args)

Create a subclass of Error, choosing subclass based on input arguments, so you don’t need to know which subclass of error to create one. Instantiating a InvalidTypeError, FileIOError, etc… are preferred over using this function, when you know the error you’re creating.

This method has several overloads:
  • (copy: Error) Copy constructor copies the given error

  • (trace: List of Error) Given a list of Errors, this creates a stack trace out of those errors (essentially concatenating them) and produces a type the same as the final error in the list

  • (code: int, function_name: str, file_name: str, line: unsigned, error_message: str) Creates a new error, (Only 1 frame in the trace) based on CPL error code Cpl error codes are available on subclasses as the ‘code’ class member e.g. IllegalInputError.code

  • (data: _Error_Data) Since Error is a wrapper around _Error_Data, this is the main constructor

The class that is returned is a subclass of hdrl.core.Error

property file

C/C++ File where this error occurred or was re-thrown

property line

Line number (in a C/C++ file) where this error or was re-thrown

exception hdrl.core.ErrorLostError(*args)

Actual CPL error has been lost.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.FileAlreadyOpenError(*args)

Attempted to open a file twice.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.FileIOError(*args)

Access to file IO denied.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.FileNotCreatedError(*args)

Could not create a file.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.FileNotFoundError(*args)

A specified file or directory was not found.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.IllegalInputError(*args)

Illegal values were detected.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.IllegalOutputError(*args)

A given operation would have generated an illegal object.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.IncompatibleInputError(*args)

Data that had to be processed together did not match.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.InvalidTypeError(*args)

Data type was unsupported or invalid.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.NoWCSError(*args)

The WCS functionalities are missing.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.NullInputError(*args)

A __null pointer was found where a valid pointer was expected .Shouldnt appear in PyCPL but present in case such an error arises.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.SingularMatrixError(*args)

Could not invert a matrix.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.TypeMismatchError(*args)

Data were not of the expected type.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.UnspecifiedError(*args)

Unspecified error

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

exception hdrl.core.UnsupportedModeError(*args)

The requested functionality is not supported.

A CPL Error subclass. This is a CPL Error that is thrown from C/C++ and has C/C++ stacktrace available, with line numbers, file names, function names, and CPL Error codes. See hdrl.core.Error help documentation for more help on members and methods (scroll down to inherited methods)

class hdrl.core.Image

A hdrl.core.Image is a HDRL image (a two-dimensional array object) containing data and its associated errors. It provides a similar API to cpl.core.Image and performs linear error propagation where it makes sense.

The pixel indexing follows 0-indexing with the lower left corner having index (0, 0). The pixel buffer is stored row-wise so for optimum performance any pixel-wise access should be done likewise.

The pixel ordering is of the order (y, x) to be consistent with PyCPL

Parameters:
  • data (cpl.core.Image) – Image with data values.

  • error (cpl.core.Image) – Image with error values.

Notes

A new empty hdrl.core.Image of width x height dimension can be created using hdrl.core.Image.zeros

See also

hdrl.core.Image.zeros

Create a new zeros filled hdrl.core.Image of width x height dimensions.

static zeros(width: SupportsInt, height: SupportsInt) hdrl.core.Image

Create a new zeros filled hdrl.core.Image of width x height dimensions.

Parameters:
  • width (int) – Width of Image.

  • height (int) – Height of Image.

Returns:

New hdrl.core.Image (width x height) initialised with all 0’s.

Return type:

hdrl.core.Image

accept(self: hdrl.core.Image, ypos: SupportsInt, xpos: SupportsInt) None

Marks pixel as good.

Parameters:
  • ypos (int) – y coordinate

  • xpos (int) – x coordinate

See also

hdrl.core.Image.accept_all

Returns the number of rejected pixels.

accept_all(self: hdrl.core.Image) None

Returns the number of rejected pixels.

See also

hdrl.core.Image.accept

Marks pixel as good.

add_image(self: hdrl.core.Image, other: hdrl.core.Image) None

Adds values from Image other to self. Modified in place.

Parameters:

other (hdrl.core.Image) – Image added to self

See also

hdrl.core.Image.add_image_create

Add two images and return the resulting image.

hdrl.core.Image.add_scalar

Elementwise addition of a scalar to an image. Modified in place.

add_image_create(self: hdrl.core.Image, other: hdrl.core.Image) hdrl.core.Image

Add two images and return the resulting image.

Parameters:

other (hdrl.core.Image) – Image added to self

Returns:

A newly allocated image.

Return type:

hdrl.core.Image

See also

hdrl.core.Image.add_image

Adds values from Image other to self. Modified in place.

hdrl.core.Image.add_scalar

Elementwise addition of a scalar to an image. Modified in place.

add_scalar(self: hdrl.core.Image, value: tuple) None

Elementwise addition of a scalar to an image. Modified in place.

Parameters:

value (tuple(float, float)) – Non-zero number to add to image values. The first component is the data value, the second is the error value.

See also

hdrl.core.Image.add_image

Adds values from Image other to self. Modified in place.

hdrl.core.Image.add_image_create

Add two images and return the resulting image.

copy_into(self: hdrl.core.Image, other: hdrl.core.Image, ypos: SupportsInt, xpos: SupportsInt) None

Copy one hdrl.core.Image into another

The two input images must be of the same type, namely one of cpl.core.Type.INT, cpl.core.Type.FLOAT, cpl.core.Type.DOUBLE.

Parameters:
  • other (hdrl.core.Image) – The inserted image.

  • ypos (int) – the y pixel position in self where the lower left pixel of other should go (from 0 to the y-1 size of self)

  • xpos (int) – the x pixel position in self where the lower left pixel of other should go (from 0 to the x-1 size of self)

See also

hdrl.core.Image.insert_into

Copy cpl.core.Image into an hdrl.core.Image

count_rejected(self: hdrl.core.Image) int

Returns the number of rejected pixels.

See also

hdrl.core.Image.reject_from_mask

Sets the bad pixel mask of hdrl.core.Image

hdrl.core.Image.reject

Marks pixel as bad.

hdrl.core.Image.reject_value

Reject pixels with the specified special value(s)

hdrl.core.Image.is_rejected

Return if the pixel is marked bad

div_image(self: hdrl.core.Image, other: hdrl.core.Image) None

Divides self Image values by other Image values. Modified in place.

Parameters:

other (hdrl.core.Image) – Image that self is divided by.

See also

hdrl.core.Image.div_scalar

Elementwise division of an image with a scalar. Modified in place.

hdrl.core.Image.div_image_create

Divide two images and return the resulting image.

div_image_create(self: hdrl.core.Image, other: hdrl.core.Image) hdrl.core.Image

Divide two images and return the resulting image.

Parameters:

other (hdrl.core.Image) – Image that self is divided by.

Returns:

A newly allocated image.

Return type:

hdrl.core.Image

See also

hdrl.core.Image.div_image

Divides self Image values by other Image values. Modified in place.

hdrl.core.Image.div_scalar

Elementwise division of an image with a scalar. Modified in place.

div_scalar(self: hdrl.core.Image, value: tuple) None

Elementwise division of an image with a scalar. Modified in place.

Parameters:

value (tuple(float, float)) – Non-zero number to divide with. The first component is the data value, the second is the error value.

See also

hdrl.core.Image.div_image

Divides self Image values by other Image values. Modified in place.

hdrl.core.Image.div_image_create

Divide two images and return the resulting image.

dump(self: hdrl.core.Image, filename: str | None = '', mode: str | None = 'w', window: tuple | None = None, show: bool | None = True) str

Dump the image contents to a file, stdout or a string.

This function is intended just for debugging. It prints the contents of an image to the file path specified by filename. If a filename is not specified, output goes to stdout (unless show is False). In both cases, the contents are also returned as a string.

Parameters:
  • filename (str, optional) – File to dump image contents to

  • mode (str, optional) – Mode to open the file with. Defaults to “w” (write, overwriting the contents of the file if it already exists), but can also be set to “a” (append, creating the file if it does not already exist or appending to the end of it if it does).

  • window (tuple(int,int,int,int), optional) – Window to dump with value in the format (llx, lly, urx, ury) where: - llx Lower left X coordinate - lly Lower left Y coordinate - urx Upper right X coordinate - ury Upper right Y coordinate Defaults to None (no window).

  • show (bool, optional) – Send image contents to stdout. Defaults to True.

Returns:

A multiline string containing the dump of the image contents.

Return type:

str

duplicate(self: hdrl.core.Image) hdrl.core.Image

Copy hdrl.core.Image

Returns:

New image with duplicate values.

Return type:

hdrl.core.Image

See also

hdrl.core.Image.copy_into

Copy one hdrl.core.Image into another.

exp_scalar(self: hdrl.core.Image, base: tuple) None

Computes the exponential of an image by a scalar. Modified in place.

Parameters:

base (tuple(float, float)) – Base of the power. The first component is the data value, the second is the error value.

See also

hdrl.core.Image.exp_scalar_create

Computes the exponential of an image by a scalar creating a new image.

exp_scalar_create(self: hdrl.core.Image, base: tuple) hdrl.core.Image

Computes the exponential of an image by a scalar creating a new image.

Parameters:

base (tuple(float, float)) – Base of the power. The first component is the data value, the second is the error value.

Returns:

A new image containing the powered data.

Return type:

hdrl.core.Image

See also

hdrl.core.Image.exp_scalar

Computes the exponential of an image by a scalar. Modified in place.

extract(self: hdrl.core.Image, window: tuple = None) hdrl.core.Image

Dump the image contents to a file, stdout or a string. Extract copy of window from hdrl.core.Image

Parameters:

window (tuple(int,int,int,int), optional) – Window to dump with value in the format (llx, lly, urx, ury) where: - llx Lower left X coordinate - lly Lower left Y coordinate - urx Upper right X coordinate - ury Upper right Y coordinate Defaults to None (no window).

Returns:

A newly allocated hdrl.core.Image containing the window.

Return type:

hdrl.core.Image

get_mean(self: hdrl.core.Image) tuple

Computes mean pixel value and associated error of an image.

Returns:

The namedtuple Value contains two doubles: It returns the mean (data) and its error (error). If desired, the namedtuple can be converted to a dictionary using its ._asdict() method.

Return type:

namedtuple

See also

hdrl.core.Image.get_weighted_mean

Computes the weighted mean and associated error of an image.

hdrl.core.Image.get_minmax_mean

Computes the minmax rejected mean and the associated error of an image.

hdrl.core.Image.get_sigclip_mean

Computes the sigma-clipped mean and associated error of an image.

get_median(self: hdrl.core.Image) tuple

Computes the median and associated error of an image.

Returns:

The namedtuple Value contains two doubles: It returns the median (data) and its error (error). If desired, the namedtuple can be converted to a dictionary using its ._asdict() method.

Return type:

namedtuple

get_minmax_mean(self: hdrl.core.Image, nlow: SupportsFloat, nhigh: SupportsFloat) tuple

Computes the minmax rejected mean and the associated error of an image.

Parameters:
  • nlow (float) – Number of low pixels to reject.

  • nhigh (float) – Number of high pixels to reject.

Returns:

The namedtuple Value contains two doubles: It returns the minmax rejected mean (data) and its error (error). If desired, the namedtuple can be converted to a dictionary using its ._asdict() method.

Return type:

namedtuple

See also

hdrl.core.Image.get_sigclip_mean

Computes the sigma-clipped mean and associated error of an image.

hdrl.core.Image.get_weighted_mean

Computes the weighted mean and associated error of an image.

hdrl.core.Image.get_mean

Computes mean pixel value and associated error of an image.

get_mode(self: hdrl.core.Image, histo_min: SupportsFloat, histo_max: SupportsFloat, bin_size: SupportsFloat, method: hdrl_mode_type, niter: SupportsInt) tuple

Computes the mode and the associated error of an image.

Parameters:
  • histo_min (float) – minimum value of low pixels to be uses

  • histo_max (float) – maximum value of high pixels to be used

  • bin_size (float) – the size of the histogram bin

  • method (hdrl.func.Collapse.Method) – method to use for the mode computation

  • niter (int) – number of iterations to compute the error of the mode

Returns:

The namedtuple Value contains two doubles: It returns the mode (data) and its error (error). If desired, the namedtuple can be converted to a dictionary using its ._asdict() method.

Return type:

namedtuple

get_pixel(self: hdrl.core.Image, ypos: SupportsInt, xpos: SupportsInt) tuple

Gets pixel values of hdrl.core.Image

Parameters:
  • ypos (int) – y coordinate

  • xpos (int) – x coordinate

Returns:

The namedtuple Value contains two doubles: If desired, the namedtuple can be converted to a dictionary using its ._asdict() method. It returns the pixel data value (data) and its error (error).

Return type:

namedtuple

See also

hdrl.core.Image.set_pixel

Sets pixel values of hdrl.core.Image

get_sigclip_mean(self: hdrl.core.Image, kappa_low: SupportsFloat, kappa_high: SupportsFloat, niter: SupportsInt) tuple

Computes the sigma-clipped mean and associated error of an image.

Parameters:
  • kappa_low (float) – low sigma bound

  • kappa_high (float) – high sigma bound.

  • niter (int) – maximum number of clipping iterators.

Returns:

The namedtuple Value contains two doubles: It returns the clipped mean (data) and its error (error). If desired, the namedtuple can be converted to a dictionary using its ._asdict() method.

Return type:

namedtuple

See also

hdrl.core.Image.get_minmax_mean

Computes the minmax rejected mean and the associated error of an image.

hdrl.core.Image.get_mean

Computes mean pixel value and associated error of an image.

hdrl.core.Image.get_weighted_mean

Computes the weighted mean and associated error of an image.

get_sqsum(self: hdrl.core.Image) tuple

Computes the sum of all pixel values and the error of a squared image.

Returns:

The namedtuple Value contains two doubles: It returns the squared sum (data) and its error (error). If desired, the namedtuple can be converted to a dictionary using its ._asdict() method.

Return type:

namedtuple

See also

hdrl.core.Image.get_sum

Computes the sum of all pixel values and the associated error of an image.

get_stdev(self: hdrl.core.Image) float

Computes the standard deviation of the data of an image

Returns:

The standard deviation of the data of an image.

Return type:

float

get_sum(self: hdrl.core.Image) tuple

Computes the sum of all pixel values and the associated error of an image.

Returns:

The namedtuple Value contains two doubles: It returns the sum (data) and its error (error). If desired, the namedtuple can be converted to a dictionary using its ._asdict() method.

Return type:

namedtuple

See also

hdrl.core.Image.get_sqsum

Computes the sum of all pixel values and the error of a squared image.

get_weighted_mean(self: hdrl.core.Image) tuple

Computes the weighted mean and associated error of an image.

Returns:

The namedtuple Value contains two doubles: It returns the weighted mean (data) and its error (error). If desired, the namedtuple can be converted to a dictionary using its ._asdict() method.

Return type:

namedtuple

See also

hdrl.core.Image.get_mean

Computes mean pixel value and associated error of an image.

hdrl.core.Image.get_minmax_mean

Computes the minmax rejected mean and the associated error of an image.

hdrl.core.Image.get_sigclip_mean

Computes the sigma-clipped mean and associated error of an image.

insert_into(self: hdrl.core.Image, image: cpl.core.Image, error: cpl.core.Image | None, ypos: SupportsInt, xpos: SupportsInt) None

Copy cpl.core.Image into an hdrl.core.Image

Parameters:
  • image (cpl.core.Image) – the inserted image

  • error (cpl.core.Image) – the inserted error, may be NULL

  • ypos (int) – the y pixel position in image 1 where the lower left pixel of image 2 should go (from 1 to the y size of image 1)

  • xpos (int) – the x pixel position in image 1 where the lower left pixel of image 2 should go (from 1 to the x size of image 1)

See also

hdrl.core.Image.copy_into

Copy one hdrl.core.Image into another

is_rejected(self: hdrl.core.Image, ypos: SupportsInt, xpos: SupportsInt) bool

Return if the pixel is marked bad

Parameters:
  • ypos (int) – y coordinate

  • xpos (int) – x coordinate

See also

hdrl.core.Image.reject_from_mask

Sets the bad pixel mask of hdrl.core.Image

hdrl.core.Image.reject

Marks pixel as bad.

hdrl.core.Image.reject_value

Reject pixels with the specified special value(s).

hdrl.core.Image.count_rejected

Returns the number of rejected pixels.

mul_image(self: hdrl.core.Image, other: hdrl.core.Image) None

Multiplies self Image values by other Image values. Modified in place.

Parameters:

other (hdrl.core.Image) – Image that self is multiplied by.

See also

hdrl.core.Image.mul_image_create

Multiply two images and return the resulting image.

hdrl.core.Image.mul_scalar

Elementwise multiplication of an image by a scalar. Modified in place.

mul_image_create(self: hdrl.core.Image, other: hdrl.core.Image) hdrl.core.Image

Multiply two images and return the resulting image.

Parameters:

other (hdrl.core.Image) – Image that self is multiplied by.

Returns:

A newly allocated image.

Return type:

hdrl.core.Image

See also

hdrl.core.Image.mul_image

Multiplies self Image values by other Image values. Modified in place.

hdrl.core.Image.mul_scalar

Elementwise multiplication of an image by a scalar. Modified in place.

mul_scalar(self: hdrl.core.Image, value: tuple) None

Elementwise multiplication of an image by a scalar. Modified in place.

Parameters:

value (tuple(float, float)) – Non-zero number to multiply with. The first component is the data value, the second is the error value.

See also

hdrl.core.Image.mul_image_create

Multiply two images and return the resulting image.

hdrl.core.Image.mul_image

Multiplies self Image values by other Image values. Modified in place.

pow_scalar(self: hdrl.core.Image, exponent: tuple) None

Computes the power of an image by a scalar. Modified in place.

Parameters:

exponent (tuple(float, float)) – Exponent of the power. The first component is the data value, the second is the error value.

See also

hdrl.core.Image.pow_scalar_create

Computes the power of an image by a scalar creating a new image.

pow_scalar_create(self: hdrl.core.Image, exponent: tuple) hdrl.core.Image

Computes the power of an image by a scalar creating a new image.

Parameters:

exponent (tuple(float, float)) – Exponent of the power. The first component is the data value, the second is the error value.

Returns:

A new image containing the powered data.

Return type:

hdrl.core.Image

See also

hdrl.core.Image.pow_scalar

Computes the power of an image by a scalar. Modified in place.

reject(self: hdrl.core.Image, ypos: SupportsInt, xpos: SupportsInt) None

Marks pixel as bad.

Parameters:
  • ypos (int) – y coordinate

  • xpos (int) – x coordinate

See also

hdrl.core.Image.reject_from_mask

Sets the bad pixel mask of hdrl.core.Image

hdrl.core.Image.is_rejected

Return if the pixel is marked bad

hdrl.core.Image.reject_value

Reject pixels with the specified special value(s).

hdrl.core.Image.count_rejected

Returns the number of rejected pixels.

reject_from_mask(self: hdrl.core.Image, map: cpl.core.Mask) None

Sets the bad pixel mask of hdrl.core.Image

Parameters:

map (cpl.core.Mask) – Bad pixel mask to set.

See also

hdrl.core.Image.reject

Marks pixel as bad.

hdrl.core.Image.is_rejected

Return if the pixel is marked bad

hdrl.core.Image.reject_value

Reject pixels with the specified special value(s).

hdrl.core.Image.count_rejected

Returns the number of rejected pixels.

reject_value(self: hdrl.core.Image, values: set) None

Reject pixels with the specified special value(s)

Parameters:

values (set) – The set of special values that should be marked as rejected pixels. The supported special values are 0, math.inf, -math.inf, math.nan and their numpy equivalents, and any combination is allowed.

Raises:

See also

hdrl.core.Image.reject_from_mask

Sets the bad pixel mask of hdrl.core.Image

hdrl.core.Image.reject

Marks pixel as bad.

hdrl.core.Image.is_rejected

Return if the pixel is marked bad.

hdrl.core.Image.count_rejected

Returns the number of rejected pixels.

set_pixel(self: hdrl.core.Image, ypos: SupportsInt, xpos: SupportsInt, value: tuple) None

Sets pixel values of hdrl.core.Image

Parameters:
  • ypos (int) – y coordinate

  • xpos (int) – x coordinate

  • value (tuple(float, float)) – Data value to set. The first component is the data value, the second is the error value.

See also

hdrl.core.Image.get_pixel

Gets pixel values of hdrl.core.Image

sub_image(self: hdrl.core.Image, other: hdrl.core.Image) None

Subtracts other Image values from self Image values. Modified in place.

Parameters:

other (hdrl.core.Image) – Image subtracted from self.

See also

hdrl.core.Image.sub_image_create

Subtract two images and return the resulting image.

hdrl.core.Image.sub_scalar

Elementwise subtraction of a scalar from an image. Modified in place.

sub_image_create(self: hdrl.core.Image, other: hdrl.core.Image) hdrl.core.Image

Subtract two images and return the resulting image.

Parameters:

other (hdrl.core.Image) – Image subtracted from self.

Returns:

A newly allocated image.

Return type:

hdrl.core.Image

See also

hdrl.core.Image.sub_image

Subtracts other Image values from self Image values. Modified in place.

hdrl.core.Image.sub_scalar

Elementwise subtraction of a scalar from an image. Modified in place.

sub_scalar(self: hdrl.core.Image, value: tuple) None

Elementwise subtraction of a scalar from an image. Modified in place.

Parameters:

value (tuple(float, float)) – Non-zero number to subtract from self. The first component is the data value, the second is the error value.

See also

hdrl.core.Image.sub_image

Subtracts other Image values from self Image values. Modified in place.

hdrl.core.Image.sub_image_create

Subtract two images and return the resulting image.

turn(self: hdrl.core.Image, rot: SupportsInt) None

Rotate an image by a multiple of 90 degrees clockwise. Modified in place.

Parameters:

rot (int) – Value for rotating image by 90 deg in the counterclockwise direction.

property error

the error image

Type:

cpl.core.Image

property height

Height of the image

Type:

int

property image

The primary image

Type:

cpl.core.Image

property mask

The image mask

Type:

cpl.core.Mask

property size

Total number of pixels in the image (width*height)

Type:

int

property width

Width of the image

Type:

int

class hdrl.core.ImageList

A hdrl.core.ImageList is an HDRL imagelist containing a list of equally dimensioned HDRL Images. The API is similar to cpl.core.Imagelist and simple arithmetic and collapse operations propagate errors linearly. It follows 0-indexing and must have the same pixel type.

Parameters:
  • datalist (cpl.core.ImageList) – Data cpl.core.ImageList to store in self on init.

  • errorlist (cpl.core.ImageList) – cpl.core.ImageList of corresponding errors to store in self on init.

Notes

A new empty hdrl.core.ImageList can be created using hdrl.core.ImageList()

add_image(self: hdrl.core.ImageList, himg: hdrl.core.Image) None

Add an Image to this ImageList. Modified in place.

The input image must have the same size as those in this Imagelist, the input image is added elementwise to each image in this list.

Parameters:

himg (hdrl.core.Image) – Image to add

See also

hdrl.core.Image.add_image

Adds values from Image other to self. Modified in place.

add_imagelist(self: hdrl.core.ImageList, himagelist: hdrl.core.ImageList) None

Add this ImageList with another. Modified in place.

The two input lists must have the same size, the image number n in the list other is added to the image number n in this list.

Parameters:

himglist (hdrl.core.ImageList) – ImageList to add

See also

hdrl.core.Image.add_image

Adds values from Image other to self. Modified in place.

add_scalar(self: hdrl.core.ImageList, val: tuple) None

Elementwise addition of a scalar to each image in the ImageList. Modified in place

Parameters:

value (tuple (float, float)) – Value to add. The first component is the scalar number to add, the second is the error value.

See also

hdrl.core.Image.add_scalar

Elementwise addition of a scalar to an image. Modified in place.

append(self: hdrl.core.ImageList, to_append: hdrl.core.Image) None

Append an HDRL image to the end of self. To insert an image into a specific position then set via index (e.g. self[i] = new_image). It is not allowed to insert images of different sizes or types into a list.

Parameters:

to_append (hdrl.core.Image) – The image to append

collapse(self: hdrl.core.ImageList, collapse: hdrl::func::Collapse) object

Collapse an imagelist to a single image.

Error propagation is taken to account where the propagation formula is well defined.

Returns:

The namedtuple has two components- one hdrl.core.Image (out), containing the collapsed image and one cpl.core.Image (contrib), which is the output mask containing an integer map that counts the number of pixels contributed to each pixel image.

Return type:

namedtuple

See also

hdrl.func.Collapse

Interface for Collapse operations.

hdrl.func.Collapse.compute

Perform Collapse operations on an HDRL Image or ImageList.

collapse_mean(self: hdrl.core.ImageList) object

Mean collapse of an imagelist to a single image.

Error propagation is taken to account where the propagation formula is well defined.

Returns:

The namedtuple has two components- one hdrl.core.Image (out), containing the collapsed image and one cpl.core.Image (contrib), which is the output mask containing an integer map that counts the number of pixels contributed to each pixel image.

Return type:

namedtuple

See also

hdrl.func.Collapse.Mean

Interface for performing Collapse operation on HDRL ImageList or Image with Mean parameters.

hdrl.func.Collapse.compute

Perform Collapse operations on an HDRL Image or ImageList.

collapse_median(self: hdrl.core.ImageList) object

The median collapse of an imagelist to a single image.

Error propagation is taken to account where the propagation formula is well defined.

Returns:

The namedtuple has two components- one hdrl.core.Image (out), containing the collapsed image and one cpl.core.Image (contrib), which is the output mask containing an integer map that counts how many pixels contributed to each pixel image.

Return type:

namedtuple

See also

hdrl.func.Collapse.Median

Interface for Median Collapse on an HDRL Image or ImageList.

hdrl.func.Collapse.compute

Perform Collapse operations on an HDRL Image or ImageList.

collapse_minmax(self: hdrl.core.ImageList, nlow: SupportsFloat, nhigh: SupportsFloat) object

The min-max clipped collapse of an imagelist to a single image.

Error propagation is taken to account where the propagation formula is well defined.

Parameters:
  • nlow (float) – low number of pixels to reject

  • nhigh (float) – high number of pixels to reject

Returns:

The namedtuple has four components- one hdrl.core.Image (out), containing the collapsed image, one cpl.core.Image (contrib), which is the output mask containing an integer map that counts how many pixels contributed to each pixel image, one cpl.core.Image (reject_low) containing low rejection threshold, one cpl.core.Image (reject_high) containing high rejection threshold.

Return type:

namedtuple

See also

hdrl.func.Collapse.compute

Perform Collapse operation on an HDRL ImageList to create one HDRL Image.

hdrl.func.Collapse.MinMax

Interface for Min-max Clipped Collapse on an HDRL Image or ImageList.

collapse_mode(self: hdrl.core.ImageList, histo_min: SupportsFloat, histo_max: SupportsFloat, bin_size: SupportsFloat, mode_method: hdrl_mode_type, error_niter: SupportsInt) object

The mode collapse of an imagelist to a single image.

The error is calculated from the data, depending on the error_niter.

Parameters:
  • histo_min (float) – minimum value of low pixels to use

  • histo_max (float) – maximum value of high pixels to be use

  • bin_size (float) – size of the histogram bin

  • mode_method (hdrl.func.Collapse.Mode) – mode_method to use for the mode computation

  • error_niter (int) – size of the histogram bin

Returns:

The namedtuple has two components- one hdrl.core.Image (out), containing the collapsed image and one cpl.core.Image (contrib), which is the output mask containing an integer map that counts how many pixels contributed to each pixel image.

Return type:

namedtuple

Notes

If the error_niter parameter is set to 0, it is doing an analytically error estimation. If the parameter is larger than 0, the error is calculated by a bootstrap Montecarlo simulation from the input data with the value of the parameter specifying the number of simulations. In this case the input data are perturbed with the bootstrap technique and the mode is calculated error_niter times. From this modes the standard deviation is calculated and returned as error.

See also

hdrl.func.Collapse.compute

Perform Collapse operation on an HDRL ImageList to create one HDRL Image.

hdrl.func.Collapse.Mode

Perform Mode Collapse function on an HDRL ImageList or Image.

collapse_sigclip(self: hdrl.core.ImageList, kappa_low: SupportsFloat, kappa_high: SupportsFloat, niter: SupportsInt) object

The sigma clipped collapse of an imagelist to a single image.

Error propagation is taken to account where the propagation formula is well defined.

Parameters:
  • kappa_low (float) – low sigma bound

  • kappa_high (float) – high sigma bound

  • niter (int) – number of clipping iterators

Returns:

The namedtuple has four components- one hdrl.core.Image (out), containing the collapsed image, one cpl.core.Image (contrib), which is the output mask containing an integer map that counts how many pixels contributed to each pixel image, one cpl.core.Image (reject_low) containing low rejection threshold, one cpl.core.Image (reject_high) containing high rejection threshold.

Return type:

namedtuple

See also

hdrl.func.Collapse.Sigclip

Interface for Sigma Clipped Collapse on an HDRL Image or ImageList.

hdrl.func.Collapse.compute

Perform Collapse function on an HDRL ImageList to create one HDRL Image.

collapse_weighted_mean(self: hdrl.core.ImageList) object

The weighted mean collapse of an imagelist to a single image.

Error propagation is taken to account where the propagation formula is well defined.

Returns:

The namedtuple has two components- one hdrl.core.Image (out), containing the collapsed image and one cpl.core.Image (contrib), which is the output mask containing an integer map that counts how many pixels contributed to each pixel image.

Return type:

namedtuple

See also

hdrl.func.Collapse.WeightedMean

Perform Weighted Mean collapse on an HDRL Image or ImageList.

hdrl.func.Collapse.compute

Perform Collapse operations on an HDRL Image or ImageList.

div_image(self: hdrl.core.ImageList, himg: hdrl.core.Image) None

Divide this ImageList by an Image. Modified in place.

The input image must have the same size as those in this Imagelist, each image in this list is divided elementwise by the input image.

Parameters:

himglist (hdrl.core.Image) – Image to divide with

See also

hdrl.core.Image.div_image

Divides self Image values by other Image values. Modified in place.

div_imagelist(self: hdrl.core.ImageList, himagelist: hdrl.core.ImageList) None

Divide this ImageList with another. Modified in place.

The two input lists must have the same size, the image number n in the list other divides the image number n in this list.

Parameters:

himglist (hdrl.core.ImageList) – ImageList to divide with

See also

hdrl.core.Image.div_image

Divides self Image values by other Image values. Modified in place.

div_scalar(self: hdrl.core.ImageList, val: tuple) None

Elementwise division of each image in the ImageList with a scalar.

Parameters:

value (tuple (float, float)) – Non-zero number to divide with. The first component is the divisor, the second is the error value.

See also

hdrl.core.Image.div_scalar

Elementwise division of an image with a scalar. Modified in place.

dump(self: hdrl.core.ImageList, filename: str | None = '', mode: str | None = 'w', window: tuple | None = None, show: bool | None = True) str

Dump the contents of each image in the ImageList to a file, stdout or a string.

This function is intended just for debugging. It prints the contents of an image to the file path specified by filename. If a filename is not specified, output goes to stdout (unless show is False). In both cases the contents are also returned as a string.

Parameters:
  • filename (str, optional) – File to dump file image contents to

  • mode (str, optional) – Mode to open the file with. Defaults to “w” (write, overwriting the contents of the file if it already exists), but can also be set to “a” (append, creating the file if it does not already exist or appending to the end of it if it does).

  • window (tuple(int,int,int,int), optional) – Window to dump with value in the format (llx, lly, urx, ury) where: - llx Lower left X coordinate - lly Lower left Y coordinate - urx Upper right X coordinate - ury Upper right Y coordinate

  • show (bool, optional) – Send image contents to stdout. Defaults to True.

Returns:

Multiline string containing the dump of the image contents in the ImageList.

Return type:

str

duplicate(self: hdrl.core.ImageList) hdrl.core.ImageList

Copy the HDRL imagelist into a new HDRL imagelist. The pixels and errors are also copied.

This method is also used when performing a deepcopy on an image.

Returns:

himlist – New HDRL ImageList that is a copy of the original ImageList.

Return type:

hdrl.core.ImageList

empty(self: hdrl.core.ImageList) None

Empty an imagelist and deallocate all its images. After the call the image list can be populated again.

is_consistent(self: hdrl.core.ImageList) int

Determine if an ImageList contains images of equal size and type.

Returns:

result – 0 if ok, positive if not consistent and negative on error. The function returns 1 if the list is empty.

Return type:

int

mul_image(self: hdrl.core.ImageList, himg: hdrl.core.Image) None

Multiply this ImageList by an Image. Modified in place.

The input image must have the same size as those in this Imagelist, each image in this list is multiplied elementwise by the input image.

Parameters:

himglist (hdrl.core.Image) – Image to multiply with

See also

hdrl.core.Image.mul_image

Multiplies self Image values by other Image values. Modified in place.

mul_imagelist(self: hdrl.core.ImageList, himagelist: hdrl.core.ImageList) None

Multiply this ImageList with another. Modified in place.

The two input lists must have the same size, the image number n in the list other is multiplied the image number n in this list.

Parameters:

himglist (hdrl.core.ImageList) – ImageList to multiply with

See also

hdrl.core.Image.mul_image

Multiplies self Image values by other Image values. Modified in place.

mul_scalar(self: hdrl.core.ImageList, val: tuple) None

Elementwise multiplication of a scalar to each image in the ImageList.

Parameters:

value (tuple (float, float)) – Value to multiply with. The first component is the multiplicator, the second is the error value.

See also

hdrl.core.Image.mul_scalar

Elementwise multiplication of an image by a scalar. Modified in place.

pop(self: hdrl.core.ImageList, index: SupportsInt | None = None) hdrl.core.Image

Remove and return the image at the index.

Parameters:

position (int, optional) – Index to pop image from the image list. Defaults to the last image.

Returns:

himg – Image at index.

Return type:

hdrl.core.Image

Raises:

IndexError – If the index is out of range.

pow_scalar(self: hdrl.core.ImageList, val: tuple) None

Compute the elementwise exponential of each image in self. Modified in place.

Parameters:

base (tuple (float, float)) – Base of the exponential. The first component is the base, the second is the error value.

See also

hdrl.core.Image.pow_scalar

Computes the power of an image by a scalar. Modified in place.

sub_image(self: hdrl.core.ImageList, himg: hdrl.core.Image) None

Subtract an Image from this ImageList. Modified in place.

The input image must have the same size as those in this Imagelist, each image in this list is subtracted elementwise by the input image.

Parameters:

himglist (hdrl.core.Image) – Image to subtract with

See also

hdrl.core.Image.sub_image

Subtracts other Image values from self Image values. Modified in place.

sub_imagelist(self: hdrl.core.ImageList, himagelist: hdrl.core.ImageList) None

Elementwise subtract this ImageList with another. Modified in place.

The two input lists must have the same size, the image number n in the list other is subtracted from the image number n in this list.

Parameters:

himglist (hdrl.core.ImageList) – ImageList to subtract with

See also

hdrl.core.Image.sub_image

Subtracts other Image values from self Image values. Modified in place.

sub_scalar(self: hdrl.core.ImageList, val: tuple) None

Elementwise subtraction of a scalar to each image in the ImageList. Modified in place.

Parameters:

value (tuple (float, float)) – Value to subtract. The first component is the scalar number to subtract, the second is the error value.

See also

hdrl.core.Image.sub_scalar

Elementwise subtraction of a scalar from an image. Modified in place.

property size_x

number of columns of images in an imagelist

Type:

int

property size_y

number of rows of images in an imagelist

Type:

int