ccd_calib#

pyscope.reduction.ccd_calib(fnames, dark_frame=None, bias_frame=None, flat_frame=None, camera_type='ccd', astro_scrappy=(1, 3), bad_columns='', in_place=False, verbose=0, pedestal=1000)[source]#

Calibrate astronomical images using master calibration frames.

The ccd_calib_cli function applies bias, dark, and flat corrections to raw CCD or CMOS images to produce calibrated versions. Calibrated images are saved with the suffix _cal appended to the original filename unless the --in-place option is used, which overwrites the raw files. The calibration process supports additional features like hot pixel removal and bad column correction.

Parameters:
fnameslist of str

List of filenames to calibrate.

dark_framestr, optional

Path to master dark frame. If the camera type is cmos, the exposure time of the dark frame must match the exposure time of the target images.

bias_framestr, optional

Path to master bias frame. Ignored if the camera type is cmos.

flat_framestr, optional

Path to master flat frame. The script assumes the master flat frame has already been bias and dark corrected. The flat frame is normalized by the mean of the entire image before being applied to the target images.

camera_typestr, optional

Camera type. Must be either ccd or cmos. Defaults to "ccd".

astro_scrappytuple of (int, int), optional

Number of hot pixel removal iterations and estimated camera read noise (in root-electrons per pixel per second). Defaults to (1, 3).

bad_columnsstr, optional

Comma-separated list of bad columns to fix by averaging the value of each pixel in the adjacent column. Defaults to "".

in_placebool, optional

If True, overwrites the input files with the calibrated images. Defaults to False.

pedestalint, optional

Pedestal value to add to calibrated images after processing to prevent negative pixel values. Defaults to 1000.

verboseint, optional

Verbosity level for logging output: - 0: Warnings only (default). - 1: Informational messages. - 2: Debug-level messages.

Returns:
None

The function does not return any value. It writes calibrated images to disk.

Raises:
FileNotFoundError

Raised if any of the specified input files do not exist.

ValueError

Raised if the calibration frames (e.g., dark_frame, bias_frame, flat_frame) do not match the target images in terms of critical metadata, such as: - Exposure time - Binning (X and Y) - Readout mode

KeyError

Raised if required header keywords (e.g., IMAGETYP, FILTER, EXPTIME, GAIN) are missing from the calibration frames or the raw image files.