hdrl.core

Core data types used by every high-level algorithm.

Load FITS with PyCPL (cpl.core.Image.load and related I/O), then construct hdrl.core.Image(data, error). There is no Image.load on this class. Construction copies both input images, ignores the error-plane bad-pixel mask, and uses the data-plane mask. Use Image.duplicate() to make another independent HDRL copy.

See also HDRL C → PyHDRL and Errors.

Image and ImageList

class hdrl.core.Image

Bases: pybind11_object

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

Construction copies both input images. Later changes to data or error do not affect this object. The bad-pixel mask on error is ignored; the mask on data becomes this image’s mask.

A new empty hdrl.core.Image of width x height dimension can be created using hdrl.core.Image.zeros. There is no Image.load: load FITS with cpl.core.Image.load (or related PyCPL I/O), then pass the data and error planes to the hdrl.core.Image constructor.

See also

hdrl.core.Image.zeros

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

cpl.core.Image.load

Load a FITS image in PyCPL.

static zeros(width: SupportsInt | SupportsIndex, height: SupportsInt | SupportsIndex) → 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 | SupportsIndex, xpos: SupportsInt | SupportsIndex) → None

Marks pixel as good.

Parameters:
  • ypos (int) – y coordinate

  • xpos (int) – x coordinate

See also

hdrl.core.Image.accept_all

Marks all pixels as good.

hdrl.core.Image.count_rejected

Returns the number of rejected pixels.

accept_all(self: hdrl.core.Image) → None

Marks all pixels as good.

See also

hdrl.core.Image.accept

Marks a single pixel as good.

hdrl.core.Image.count_rejected

Returns the number of rejected pixels.

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 | SupportsIndex, xpos: SupportsInt | SupportsIndex) → 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 | SupportsIndex, nhigh: SupportsFloat | SupportsIndex) → 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 | SupportsIndex, histo_max: SupportsFloat | SupportsIndex, bin_size: SupportsFloat | SupportsIndex, method: hdrl_mode_type, niter: SupportsInt | SupportsIndex) → 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 | SupportsIndex, xpos: SupportsInt | SupportsIndex) → 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 | SupportsIndex, kappa_high: SupportsFloat | SupportsIndex, niter: SupportsInt | SupportsIndex) → 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 | SupportsIndex, xpos: SupportsInt | SupportsIndex) → 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 | SupportsIndex, xpos: SupportsInt | SupportsIndex) → 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 | SupportsIndex, xpos: SupportsInt | SupportsIndex) → 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:
  • hdrl.core.UnsupportedModeError – If something other than one of the supported special values is in the values parameter.

  • hdrl.core.InvalidTypeError – If the image is a complex type.

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 | SupportsIndex, xpos: SupportsInt | SupportsIndex, 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 | SupportsIndex) → 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

Bases: pybind11_object

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 | SupportsIndex, nhigh: SupportsFloat | SupportsIndex) → 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 | SupportsIndex, histo_max: SupportsFloat | SupportsIndex, bin_size: SupportsFloat | SupportsIndex, mode_method: hdrl_mode_type, error_niter: SupportsInt | SupportsIndex) → 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 | SupportsIndex, kappa_high: SupportsFloat | SupportsIndex, niter: SupportsInt | SupportsIndex) → 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 | SupportsIndex | 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

Spectrum types

Unlike the HDRL C constructors, which may accept unsorted wavelengths and sort a copy for some operations, PyHDRL constructors require wavelengths to be strictly increasing. FitWindowed and resample_windowed_fit expose an experimental HDRL interface whose C API is not guaranteed to be stable.

class hdrl.core.Spectrum1D

Bases: pybind11_object

A hdrl.core.Spectrum1D is an HDRL 1D spectrum containing the wavelengths, the fluxes at each wavelength together with their errors, a bad-pixel map, and a wavelength scale (linear or logarithmic).

Wavelengths are treated as error-free, so wavelength operations do not propagate errors. Flux operations support linear error propagation. Arithmetic between two spectra requires that they are defined on the same wavelengths in the same order. Constructors require the wavelengths to be strictly increasing. This is a PyHDRL restriction; HDRL C may accept unsorted wavelengths and sort a copy for some operations.

Resampling supports interpolation (resample / resample_to_wavelengths), fitting (resample_fit, resample_windowed_fit), and integration (resample_integrate).

add_scalar(self: hdrl.core.Spectrum1D, scalar: SupportsFloat | SupportsIndex) → None

Computes the elementwise addition of a spectrum by a scalar. Spectrum is modified.

Parameters:

scalar (float) – The scalar factor.

add_spectrum(self: hdrl.core.Spectrum1D, other: hdrl.core.Spectrum1D) → None

Sum two spectra.

Parameters:

other (hdrl.core.Spectrum1D) – The other spectrum.

add_spectrum_create(self: hdrl.core.Spectrum1D, other: hdrl.core.Spectrum1D) → hdrl.core.Spectrum1D

Sum two spectra.

Parameters:

other (hdrl.core.Spectrum1D) – The other spectrum.

Returns:

The modified copy of spectrum.

Return type:

hdrl.core.Spectrum1D

compute_shift_fit(self: hdrl.core.Spectrum1D, wguess: SupportsFloat | SupportsIndex, wrange: Annotated[collections.abc.Sequence[SupportsFloat | SupportsIndex], 'FixedSize(2)'], fitrange: Annotated[collections.abc.Sequence[SupportsFloat | SupportsIndex], 'FixedSize(2)'], halfsize: SupportsFloat | SupportsIndex) → float

Compute the spectral shift of the spectrum with respect to an expected position of a spectral line.

Parameters:
  • wguess (float) – Expected wavelength of the spectral line.

  • wrange (tuple(float, float)) – Tuple of the minimum and maximum wavelength defining the wavelength range of the spectrum to use.

  • fitrange (tuple(float, float)) – Tuple of the minimum and maximum wavelength defining the wavelength range that is ignored when fitting the ratio of the spectrum and the fitted model with a polynomial.

  • halfsize (float) – Window half size defining the wavelength limits for the polynomial fit.

Returns:

The relative shift of the spectrum with respect to the reference wavelength.

Return type:

float

compute_shift_xcorrelation(self: hdrl.core.Spectrum1D, other: hdrl.core.Spectrum1D, half_win: SupportsInt | SupportsIndex, normalize: bool = True) → hdrl.core.XCorrelationResult

Calculate cross-correlation.

Parameters:
  • other (hdrl.core.Spectrum1D) – The other spectrum.

  • half_win (int) – The half search window where the correlation is calculated.

  • normalize (boolean) – Flag, true if normalize correlation in mean and rms.

Returns:

Object with cross-correlation results.

Return type:

XCorrelationResult

div_scalar(self: hdrl.core.Spectrum1D, scalar: SupportsFloat | SupportsIndex) → None

Computes the elementwise division of a spectrum by a scalar. Spectrum is modified.

Parameters:

scalar (float) – The scalar factor.

div_spectrum(self: hdrl.core.Spectrum1D, other: hdrl.core.Spectrum1D) → None

Divide one spectrum by another spectrum.

Parameters:

other (hdrl.core.Spectrum1D) – The denumerator.

div_spectrum_create(self: hdrl.core.Spectrum1D, other: hdrl.core.Spectrum1D) → hdrl.core.Spectrum1D

Divide one spectrum by another spectrum.

Parameters:

other (hdrl.core.Spectrum1D) – The denumerator.

Returns:

The modified copy of spectrum.

Return type:

hdrl.core.Spectrum1D

duplicate(self: hdrl.core.Spectrum1D) → hdrl.core.Spectrum1D

Create a duplicate of the spectrum.

Returns:

A new copy of the Spectrum1D.

Return type:

hdrl.core.Spectrum1D

exp_scalar(self: hdrl.core.Spectrum1D, scalar: SupportsFloat | SupportsIndex) → None

Computes the elementwise power of the scalar to the flux. Spectrum is modified.

Parameters:

scalar (float) – The scalar factor.

is_compatible_with(self: hdrl.core.Spectrum1D, other: hdrl.core.Spectrum1D) → bool

Checks if two spectrum wavelengths are equal.

Parameters:

other (hdrl.core.Spectrum1D) – The spectrum to be compared with.

Returns:

The flag, true if compatible.

Return type:

boolean

is_uniformly_sampled(self: hdrl.core.Spectrum1D) → tuple[bool, float]

Checks if the spectrum is defined on uniformly sampled wavelengths.

Returns:

The flag if the spectrum is defined on uniformly sampled wavelengths and bin width.

Return type:

std.pair

mul_scalar(self: hdrl.core.Spectrum1D, scalar: SupportsFloat | SupportsIndex) → None

Computes the elementwise multiplication of a spectrum by a scalar. Spectrum is modified.

Parameters:

scalar (float) – The scalar factor.

mul_spectrum(self: hdrl.core.Spectrum1D, other: hdrl.core.Spectrum1D) → None

Multiply one spectrum by another spectrum.

Parameters:

other (hdrl.core.Spectrum1D) – The other spectrum.

mul_spectrum_create(self: hdrl.core.Spectrum1D, other: hdrl.core.Spectrum1D) → hdrl.core.Spectrum1D

Multiply one spectrum by another spectrum.

Parameters:

other (hdrl.core.Spectrum1D) – The other spectrum.

Returns:

The modified copy of spectrum.

Return type:

hdrl.core.Spectrum1D

pow_scalar(self: hdrl.core.Spectrum1D, scalar: SupportsFloat | SupportsIndex) → None

Computes the elementwise power of of the flux to the scalar. Spectrum is modified.

Parameters:

scalar (float) – The scalar factor.

reject_pixels(self: hdrl.core.Spectrum1D, bad_samples: Annotated[numpy.typing.ArrayLike, numpy.int32]) → hdrl.core.Spectrum1D

For every i-th element in bad_samples having value true, the i-th pixel in the 1D spectrum is marked as bad.

Parameters:

bad_samples (array of int) – The flags indicating whether the pixel is bad.

Returns:

The spectrum having the appropriate bad pixels selected.

Return type:

hdrl.core.Spectrum1D

resample(self: hdrl.core.Spectrum1D, other: hdrl.core.Spectrum1D, method: hdrl.core.InterpolationMethod = <InterpolationMethod.AKIMA: 2>) → hdrl.core.Spectrum1D

Resample a spectrum with a provided method.

Parameters:
Returns:

The resampled spectrum.

Return type:

hdrl.core.Spectrum1D

resample_fit(self: hdrl.core.Spectrum1D, wavelengths: Annotated[numpy.typing.ArrayLike, numpy.float64], k: SupportsInt | SupportsIndex, nCoeff: SupportsInt | SupportsIndex) → hdrl.core.Spectrum1D

Resample a spectrum on the wavelengths with an experimental windowed B-spline fit.

This wraps an experimental HDRL interface whose C API is not guaranteed to be stable. The HDRL manual recommends against using windowed fitting in production.

Parameters:
  • wavelengths (vector of float) – The wavelengths the spectrum has to be resampled on.

  • k (int) – The order of the B-spline.

  • nCoeff (int) – The number of coefficients used for the fit.

Returns:

The resampled spectrum.

Return type:

hdrl.core.Spectrum1D

resample_integrate(self: hdrl.core.Spectrum1D, wavelengths: Annotated[numpy.typing.ArrayLike, numpy.float64]) → hdrl.core.Spectrum1D

Resample a spectrum on the wavelengths with integration.

Parameters:

wavelengths (vector of float) – The wavelengths the spectrum has to be resampled on.

Returns:

The resampled spectrum.

Return type:

hdrl.core.Spectrum1D

resample_to_wavelengths(self: hdrl.core.Spectrum1D, wavelengths: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], method: hdrl.core.InterpolationMethod = <InterpolationMethod.AKIMA: 2>) → hdrl.core.Spectrum1D

Resample a spectrum on the wavelengths with a provided method.

Parameters:
  • wavelengths (vector of float) – The wavelengths the spectrum has to be resampled on.

  • method (hdrl.core.InterpolationMethod) – The interpolation method used in resampling.

Returns:

The resampled spectrum.

Return type:

hdrl.core.Spectrum1D

resample_windowed_fit(self: hdrl.core.Spectrum1D, wavelengths: Annotated[numpy.typing.ArrayLike, numpy.float64], k: SupportsInt | SupportsIndex, nCoeff: SupportsInt | SupportsIndex, window: SupportsInt | SupportsIndex, factor: SupportsFloat | SupportsIndex) → hdrl.core.Spectrum1D

Resample a spectrum on the wavelengths with B-spline fit.

Parameters:
  • wavelengths (vector of float) – The wavelengths the spectrum has to be resampled on.

  • k (int) – The order of the B-spline.

  • nCoeff (int) – The number of coefficients used for the fit.

  • window (int) – The number of destination wavelengths whose flux values are computed using the same model.

  • factor (float) – Given window2 = window * factor. window2 is the number of source wavelengths used to compute the fit model.

Returns:

The resampled spectrum.

Return type:

hdrl.core.Spectrum1D

save(self: hdrl.core.Spectrum1D, filename: str) → None

Save the spectrum to file.

Parameters:

filename (std.filesystem.path) – The filename where spectrum will be saved.

select_window(self: hdrl.core.Spectrum1D, lambda_min: SupportsFloat | SupportsIndex, lambda_max: SupportsFloat | SupportsIndex, is_internal: bool = False) → hdrl.core.Spectrum1D

Selects or discards flux values according to whether the value of the corresponding wavelength belongs to the interval [lambda_min, lambda_max].

Parameters:
  • lambda_min (double) – The lower limit of the interval required for selection.

  • lambda_max (double) – The upper limit of the interval required for selection.

  • is_internal (boolean) – Specify if selection is internal to the interval or external to the interval.

Returns:

The selected subset of spectrum.

Return type:

hdrl.core.Spectrum1D

sub_scalar(self: hdrl.core.Spectrum1D, scalar: SupportsFloat | SupportsIndex) → None

Computes the elementwise subtraction of a spectrum by a scalar. Spectrum is modified.

Parameters:

scalar (float) – The scalar factor.

sub_spectrum(self: hdrl.core.Spectrum1D, other: hdrl.core.Spectrum1D) → None

Subtract two spectra.

Parameters:

other (hdrl.core.Spectrum1D) – The other spectrum.

sub_spectrum_create(self: hdrl.core.Spectrum1D, other: hdrl.core.Spectrum1D) → hdrl.core.Spectrum1D

Subtract two spectra.

Parameters:

other (hdrl.core.Spectrum1D) – The other spectrum.

Returns:

The modified copy of spectrum.

Return type:

hdrl.core.Spectrum1D

wavelength_convert_to_linear(self: hdrl.core.Spectrum1D) → None

Converts the wavelength scale to linear.

wavelength_convert_to_linear_create(self: hdrl.core.Spectrum1D) → hdrl.core.Spectrum1D

Converts the wavelength scale to linear.

Returns:

The modified copy of spectrum.

Return type:

hdrl.core.Spectrum1D

wavelength_convert_to_log(self: hdrl.core.Spectrum1D) → None

Converts the wavelength scale to log.

wavelength_convert_to_log_create(self: hdrl.core.Spectrum1D) → hdrl.core.Spectrum1D

Converts the wavelength scale to log.

Returns:

The modified copy of spectrum.

Return type:

hdrl.core.Spectrum1D

wavelength_mult_scalar_linear(self: hdrl.core.Spectrum1D, scale: SupportsFloat | SupportsIndex) → None

Computes the elementwise multiplication of the scalar for the wavelength.

Parameters:

scale (float) – The scalar factor.

wavelength_mult_scalar_linear_create(self: hdrl.core.Spectrum1D, scale: SupportsFloat | SupportsIndex) → hdrl.core.Spectrum1D

Computes the elementwise multiplication of the scalar for the wavelength.

Parameters:

scale (float) – The scalar factor.

Returns:

The modified copy of spectrum.

Return type:

hdrl.core.Spectrum1D

wavelength_shift(self: hdrl.core.Spectrum1D, shift: SupportsFloat | SupportsIndex) → None

Computes the elementwise shift of the wavelength by the shift parameter.

Parameters:

shift (float) – The shift scalar factor.

wavelength_shift_create(self: hdrl.core.Spectrum1D, shift: SupportsFloat | SupportsIndex) → hdrl.core.Spectrum1D

Computes the elementwise shift of the wavelength by the shift parameter.

Parameters:

shift (float) – The shift scalar factor.

Returns:

The modified copy of spectrum.

Return type:

hdrl.core.Spectrum1D

property bad_pixel_map

Bad pixel map

Type:

array of float

property flux

Flux

Type:

array of float

property flux_error

Error of flux

Type:

array of float

property scale

Scale

Type:

string

property size

Number of samples the 1D spectrum is made of

Type:

int

property wavelengths

Wavelengths the spectrum is defined on

Type:

array of float

class hdrl.core.Spectrum1DList

Bases: pybind11_object

A hdrl.core.Spectrum1DList is a container for storing hdrl.core.Spectrum1D objects. It provides basic list management (indexing, iteration, pop) and can collapse its members onto a common wavelength grid. It corresponds to the HDRL spectrum1Dlist.

An empty list can be created with hdrl.core.Spectrum1DList(). A list can also be constructed from a sequence of hdrl.core.Spectrum1D objects.

collapse(self: hdrl.core.Spectrum1DList, stacking_par: hdrl::func::Collapse, wavelengths: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], resample_par: hdrl.core.Spectrum1DResampleMethod, mark_bpm_in_interpolation: bool = False) → hdrl::core::CollapseResult

Collapsing a hdrl.core.Spectrum1DList.

Parameters:
  • stacking_par (hdrl.func.Collapse) – Parameter regulating the stacking.

  • wavelengths (array of float) – Wavelengths the resulting spectrum is defined on.

  • resample_par (Spectrum1DResampleMethod) – Parameter regulating the resampling.

  • mark_bpm_in_interpolation (boolean, default = False) – If true interpolated pixels whose neighbors (in the original spectrum) are rejected, are not considered during collapsing.

Returns:

The collapse result object, containing the resulting spectrum, output contribution mask, and resampled and aligned fluxes to be collapsed.

Return type:

hdrl.core.CollapseResult

duplicate(self: hdrl.core.Spectrum1DList) → hdrl.core.Spectrum1DList

Create a duplicate of the spectrum list.

Returns:

A new copy of the Spectrum1DList.

Return type:

hdrl.core.Spectrum1DList

pop(self: hdrl.core.Spectrum1DList, index: SupportsInt | SupportsIndex | None = None) → hdrl.core.Spectrum1D

Remove and return the spectrum at the index.

Parameters:

index (int, optional) – Index of spectrum to remove from the list. If no index is given the last spectrum in the list is removed.

Returns:

Spectrum at index.

Return type:

hdrl.core.Spectrum1D

Raises:

IndexError – If the index is out of range.

class hdrl.core.Spectrum1DResampleMethod

Bases: pybind11_object

static Fit(k: SupportsInt | SupportsIndex, n_coeff: SupportsInt | SupportsIndex) → hdrl.core.Spectrum1DResampleMethod

Constructor for the hdrl_parameter in the case of interpolation.

Parameters:
  • k (int) – The order of the B-spline.

  • n_coeff (int) – The number of coefficients used for the fit.

static FitWindowed(k: SupportsInt | SupportsIndex, n_coeff: SupportsInt | SupportsIndex, window: SupportsInt | SupportsIndex, factor: SupportsFloat | SupportsIndex) → hdrl.core.Spectrum1DResampleMethod

Constructor for the hdrl_parameter in the case of interpolation.

Parameters:
  • k (int) – The order of the B-spline.

  • n_coeff (int) – The number of coefficients used for the fit.

  • window (int) – The number of destination wavelengths whose flux values are computed using the same model.

  • factor (double) – The given window2 = window * factor. window2 is the number of source wavelengths used to compute the fit model.

static Integrate() → hdrl.core.Spectrum1DResampleMethod

Constructor for the hdrl_parameter in the case of integration.

static Interpolate(method: hdrl.core.InterpolationMethod) → hdrl.core.Spectrum1DResampleMethod

Construct parameters for experimental windowed B-spline fitting.

This wraps an experimental HDRL interface whose C API is not guaranteed to be stable. The HDRL manual recommends against using windowed fitting in production.

Parameters:

method (hdrl.core.InterpolationMethod) – The interpolation methods.

class hdrl.core.WaveScale

Bases: pybind11_object

Members:

LINEAR

LOG

LINEAR = <WaveScale.LINEAR: 0>
LOG = <WaveScale.LOG: 1>
WaveScale.name -> str
property value
class hdrl.core.InterpolationMethod

Bases: pybind11_object

Members:

LINEAR

CSPLINE

AKIMA

AKIMA = <InterpolationMethod.AKIMA: 2>
CSPLINE = <InterpolationMethod.CSPLINE: 1>
LINEAR = <InterpolationMethod.LINEAR: 0>
InterpolationMethod.name -> str
property value

Result and helper types

class hdrl.core.CollapseResult

Bases: pybind11_object

property aligned_images

The aligned fluxes to be collapsed

Type:

hdrl.core.CollapseResult.aligned_images

property contrib

The output contribution mask

Type:

hdrl.core.CollapseResult.contrib

property result

The resulting spectrum

Type:

hdrl.core.CollapseResult.result

class hdrl.core.XCorrelationResult

Bases: pybind11_object

property error

Estimated standard deviation of the correlation

Type:

float

property quality

Mean squared error of the best fit

Type:

float

property shift

Index where the cross correlation reaches its maximum, with sub-pixel precision

Type:

float

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