reducer module

This module provides tools for data reduction

class darclight.reduction.Reducer(data)[source]

Bases: object

Class for general reduction and correction of the provided data

static combine(data, method='mean', sigmaclip=True, sigma=5)[source]

combines the given data to one 2D-array

Parameters:
  • data (list[np.ndarray]) – list of the image arrays

  • method (str, optional) – which method to use for the combination, valid are ‘mean’, ‘median’ and ‘add’, defaults to ‘mean’

  • sigmaclip (bool, optional) – whether or not the data should be clipped or not, defaults to True

  • sigma (int, optional) – standard deviation used for sigma clipping, defaults to 5

Returns:

returns the combined data array

Return type:

np.ndarray

create_master_bias(force_new=False, suffix=None, **kwargs)[source]

Creates a master bias by combining the registered files if it does not exist yet and saves it.

Parameters:
  • force_new (bool, optional) – whether or not a new master file should be forced, defaults to False

  • suffix (str, optional) – suffix to add to the file, defaults to None

  • kwargs – additional keyword arguments passed to ‘combine’

Returns:

the combined data

Return type:

np.ndarray

create_master_dark(exposure=-1, force_new=False, suffix=None, **kwargs)[source]

Creates master darks by combining the registered files if they do not exist yet and saves them.

Parameters:
  • exposure (int, optional) – the exposure time for which the master dark should be created a time of -1 means that for every exposure registered the function is called recursevly, defaults to -1

  • force_new (bool, optional) – whether or not a new master file should be forced, defaults to False

  • kwargs – additional keyword arguments passed to ‘combine’

Returns:

the combined data or None if the exposure time is set to -1

Return type:

np.ndarray | None

create_master_flats(used_filter='all', norm=None, force_new=False, suffix=None, **kwargs)[source]

Creates master flats by combining the registered files if they do not exist yet and saves them.

Parameters:
  • used_filter (str, optional) – the filter for which the master flat should be created a value of ‘all’ means that for every filter registered, the function is called recursevly, defaults to ‘all’

  • norm (Callable | None, optional) – function used to normalize each frame, should take a 2d array as input and return the normalized array, defaults to None

  • force_new (bool, optional) – whether or not a new master file should be forced, defaults to False

  • kwargs – additional keyword arguments passed to ‘combine’

Returns:

the combined data or None if the used_filter is set to ‘all’

Return type:

np.ndarray | None

static generate_filename(frame, obj=None, filt=None, exposure=None, suffix=None)[source]

generates a suitable filename for a masterframe based on the given values. The name follows the following pattern: ‘master_<frame>_<obj>_<exposure>s.fits’

Parameters:
  • frame (str) – name of the frame, for example ‘bias’, can be anything

  • obj (str, optional) – name of the object in the frame, defaults to None

  • filt (str, optional) – the used filter in the frame, defaults to None

  • exposure (str, optional) – duration of the exposure, defaults to None

  • suffix (str, optional) – additional suffix that should be added, defaults to None

Returns:

the name of the file in the format ‘master_<frame>_<obj>_<exposure>s.fits’

Return type:

str

reduce_lights(target='all', force_new=False, **kwargs)[source]

creates reduced light frames and saves them individually for later stacking/analysis

Parameters:
  • target (str, optional) – the object for which the frames should be calibrated, a value of ‘all’ means that the functioin is called recursevly for ever registered target, defaults to ‘all’

  • force_new (bool, optional) – wherther or not the frames should be overwritten if they exist, defaults to False

Raises:

RuntimeError – raised if force_new=False and a file with the same name exists in the reduced data directory

Return type:

None

stack_lights(target='all', alignment=None, **kwargs)[source]

stacking the light frames of a given target. It will automatically loop over every filter.

Parameters:
  • target (str, optional) – the object in the image, a value of ‘all’ means that this function is called recursevely for every registered target, defaults to ‘all’

  • alignment (Callable | None, optional) – function to align the images, should have the signature alignment(np.ndarray, np.ndarray) where the first argument is the target and the second one is the source. The source will be aligned to match the target, defaults to None

Return type:

None

darclight.reduction.inv_median(data)[source]

Function to normalize data by division of the median

Parameters:

data (np.ndarray) – data that should be normalized

Returns:

normalized data

Return type:

np.ndarray