CalibrationImage

class CalibrationImage[source]

Class representing a calibration FITS image (e.g., bias or dark frame).

Inherits from BaseImage and provides methods for managing calibration image metadata, processing status tracking, and handling associated products like logs, masks, and status files. This class is used to manage bias or dark frames and is typically used in preprocessing steps like bias correction or dark subtraction.

Parameters:
  • path (str or Path) – Path to the calibration FITS image.

  • telinfo (dict, optional) – Telescope metadata dictionary (e.g., observatory name, CCD ID, pixel scale).

  • status (Status, optional) – Status object tracking processing completion for each calibration step. If not provided, status is initialized or loaded from disk.

  • load (bool, optional) – Whether to automatically load header and status from the file at initialization.

__init__(path, telinfo=None, status=None, load=True)[source]

Methods

run_ds9(self)

Open the image with SAOImage DS9.

Parameters:

None

Return type:

None

show_position(self, x, y, coord_type='coord', radius_arcsec=None, a_arcsec=None, b_arcsec=None, theta_deg=None, aperture_linewidth=1.0, aperture_color='red', aperture_label='detected', downsample=4, zoom_radius_pixel=100, cmap='gray', scale='zscale', figsize=(6, 6), title=None, title_fontsize=18, ax=None, save_path=None)

Display a zoomed-in view around a given (x, y) or (RA, Dec) position.

Parameters:
  • x (float) – X-coordinate (pixel or RA)

  • y (float) – Y-coordinate (pixel or Dec)

  • radius_arcsec (float, optional) – Radius of the circle in arcseconds. Default is None.

  • a_arcsec (float, optional) – Semi-major axis of the ellipse in arcseconds. Default is None.

  • b_arcsec (float, optional) – Semi-minor axis of the ellipse in arcseconds. Default is None.

  • theta_deg (float, optional) – Position angle of the ellipse in degrees. Default is None.

  • coord_type (str, optional) – β€˜pixel’ or β€˜coord’. Default is β€˜pixel’.

  • downsample (int, optional) – Step size for downsampling via slicing. Default is 4.

  • zoom_radius_pixel (int, optional) – Radius of the zoom-in region in pixels. Default is 100.

  • cmap (str, optional) – Matplotlib colormap. Default is β€˜gray’.

  • scale (str, optional) – Scaling method. Default is β€˜zscale’.

  • figsize (tuple, optional) – Matplotlib figure size. Default is (6, 6).

  • ax (matplotlib Axes object, optional) – If provided, the image will be plotted on this axis. Default is None.

  • save_path (str, optional) – Path to save the figure. Default is None.

  • title (bool, optional) – Whether to display the title. Default is True.

load(self)

Load both image data and header from disk.

Parameters:

None

Return type:

None

write(self, verbose=True)

Write CalibrationImage data to savepath.

Parameters:

None

Return type:

None

remove(self, remove_main=True, remove_connected_files=True, skip_patterns=[], verbose=True)
Return type:

dict

copy(self)

Make a deep copy of the CalibrationImage instance.

Parameters:

None

Returns:

new_instance – A deep copy of the CalibrationImage instance.

Return type:

CalibrationImage

rename(self, new_name, verbose=True)

Rename the image file and update the internal path.

Parameters:

new_name (str) – New name of the image file.

Return type:

None

clear(self, clear_data=True, clear_header=False, verbose=True)

Clear the image data and/or header from memory.

Parameters:
  • clear_data (bool, optional) – If True, clear the image data. Default is True.

  • clear_header (bool, optional) – If True, clear the image header. Default is False.

Additional Methods

update_header(self, **kwargs)

Update FITS header values using known key variants.

Parameters:

kwargs (dict) – Keyword arguments to update the FITS header.

Return type:

None

load_status(self)

Load processing status from a JSON file.

Parameters:

None

Returns:

status – Status object loaded from the JSON file.

Return type:

Status

save_status(self)

Save processing status to a JSON file.

Parameters:

None

Return type:

None

update_status(self, process_name)

Mark a process as completed and update time.

Parameters:

process_name (str) – Name of the process to update.

save_info(self)

Save processing info to a JSON file.

Parameters:

None

Return type:

None

Properties

Key Properties

Property

Description

altitude

Altitude of the telescope.

available_telescope_keys

Return a list of available telescope keys.

azimuth

Azimuth of the telescope.

biaspath

Path to the bias image.

binning

Binning of the image.

bkgtype

Type of the background image.

ccd

Name of the CCD.

ccdtemp

CCD temperature.

center

Center pixel (0-based) and its world coordinates (RA, Dec).

connected_files

Return all associated files that would be deleted in remove() if remove_connected_files=True,

darkpath

Path to the dark image.

data

Image data array.

dec

Declination of the target.

depth

Depth of the image.

egain

Electron gain of the image.

emaptype

Type of the emap image.

exptime

Exposure time of the image.

filter

Filter name.

flatpath

Path to the flat image.

fovx

Field of view along the first axis.

fovy

Field of view along the second axis.

gain

Gain of the image.

header

FITS header object.

imgtype

Type of the image. Among BIAS, DARK, FLAT, LIGHT, OBJECT, UNKNOWN.

info

Register necessary info fields

is_data_loaded

Whether the image data is loaded.

is_exists

Whether the image file exists.

is_header_loaded

Whether the image header is loaded.

is_saved

Check if the image has been saved

jd

Julian date of the observation.

masktype

Type of the mask image.

mjd

Modified Julian date of the observation.

naxis1

Number of pixels along the first axis.

naxis2

Number of pixels along the second axis.

ncombine

Number of combined images.

objname

Object name.

obsdate

Observation date in UTC.

observatory

Name of the observatory.

obsmode

Observation mode.

pixelscale

Pixel scale of the image.

ra

Right ascension of the target.

savedir

Return the directory where this image and associated files will be saved.

savepath

Dynamically builds save paths based on current header info

seeing

Seeing of the image.

specmode

Spectroscopic mode.

telname

Name of the telescope.

wcs

WCS information of the image.

zp

Zero point of the image.

zperr

Zero point error of the image.