eloy.calibration
================

.. py:module:: eloy.calibration

.. autoapi-nested-parse::

   Calibration routines for astronomical images.

   This module provides functions to compute master bias, dark, and flat frames,
   as well as to calibrate raw image data using these frames.



Functions
---------

.. autoapisummary::

   eloy.calibration.divisors
   eloy.calibration.easy_median
   eloy.calibration.default_fun_load
   eloy.calibration.default_fun_exp
   eloy.calibration.master_dark
   eloy.calibration.master_flat
   eloy.calibration.master_bias
   eloy.calibration.calibrate


Module Contents
---------------

.. py:function:: divisors(n)

   Find all divisors of an integer.

   :param n: The integer to find divisors for.
   :type n: int

   :returns: Array of divisors of n.
   :rtype: np.ndarray


.. py:function:: easy_median(images, m=50)

   Compute the median of images in chunks to avoid memory errors.

   :param images: List or array of images.
   :type images: array-like
   :param m: Chunk size for splitting the computation.
   :type m: int, optional

   :returns: Concatenated median of the images.
   :rtype: np.ndarray


.. py:function:: default_fun_load(file)

   The default function to load image data from a file.

   :param file: Path to the file to load.
   :type file: str or Path

   :returns: Loaded image data.
   :rtype: np.ndarray


.. py:function:: default_fun_exp(file)

   The default function to extract exposure time from a file.

   :param file: Path to the file to extract exposure time from.
   :type file: str or Path

   :returns: Exposure time extracted from the file header.
   :rtype: float


.. py:function:: master_dark(bias=None, files=None, fun_load=None, fun_exp=None)

   Create a master dark frame from a list of dark files.

   :param bias: Master bias frame to subtract.
   :type bias: np.ndarray or None
   :param files: List of file paths to dark frames.
   :type files: list or None
   :param fun_load: Function to load image data from file.
   :type fun_load: callable or None
   :param fun_exp: Function to extract exposure time from file. Default is :func:`default_fun_exp`
   :type fun_exp: callable or None

   :returns: Master dark frame.
   :rtype: np.ndarray


.. py:function:: master_flat(bias=None, dark=None, files=None, fun_load=None, fun_exp=None)

   Create a master flat frame from a list of flat files.

   :param bias: Master bias frame to subtract.
   :type bias: np.ndarray or None
   :param dark: Master dark frame to subtract.
   :type dark: np.ndarray or None
   :param files: List of file paths to flat frames.
   :type files: list or None
   :param fun_load: Function to load image data from file. Default is :func:`default_fun_load`
   :type fun_load: callable or None
   :param fun_exp: Function to extract exposure time from file. Default is :func:`default_fun_exp`
   :type fun_exp: callable or None

   :returns: Master flat frame.
   :rtype: np.ndarray


.. py:function:: master_bias(files=None, fun_load=None)

   Create a master bias frame from a list of bias files.

   :param files: List of file paths to bias frames.
   :type files: list or None
   :param fun_load: Function to load image data from file. Default is :func:`default_fun_load`
   :type fun_load: callable or None

   :returns: Master bias frame.
   :rtype: np.ndarray


.. py:function:: calibrate(data, exposure, dark, flat, bias)

   Calibrate raw image data using master calibration frames.

   :param data: Raw image data.
   :type data: np.ndarray
   :param exposure: Exposure time of the image.
   :type exposure: float
   :param dark: Master dark frame.
   :type dark: np.ndarray
   :param flat: Master flat frame.
   :type flat: np.ndarray
   :param bias: Master bias frame.
   :type bias: np.ndarray

   :returns: Calibrated image data.
   :rtype: np.ndarray


