ReadoutSmearPixelDefect

ReadoutSmearPixelDefect#

class cabaret.camera.ReadoutSmearPixelDefect(name: str = 'defect', rate: float = 0.0, seed: int = 0, apply_before_base: bool = True, _rng: Generator | None = None, _pixels: ndarray | None = None, readout_time: float = 0.1, dim: int = 0)[source]#

Simulates readout smear (frame transfer smear) caused by continued exposure during readout.

Parameters:
  • smear_fraction (float) – Fraction of the exposure time spent during readout (smear strength).

  • dim (int) – Direction of readout: 0 for vertical (default), 1 for horizontal.

  • readout_time (float) – Time taken to read out the entire frame (seconds).

  • seed (int) – Random seed for reproducibility.

Notes

This defect has apply_before_base = True because readout smear is a function of the light signal only and must be applied before bias, dark current, and read noise are added.

Examples

>>> from cabaret import Observatory, Sources
>>> pixel_defects = {"smear": {"type": "readout_smear", "readout_time": 1}}
>>> observatory = Observatory(camera={"pixel_defects": pixel_defects})
>>> sources = Sources.get_test_sources()
>>> ra, dec = sources.center
>>> _, clean_image, image = observatory.generate_image_stack(
...     exp_time=5, ra=ra, dec=dec, sources=sources, convert_all_to_adu=True
... )

To plot the images, you can use the plot_image function from cabaret.plot:

>>> from cabaret.plot import plot_image
>>> import matplotlib.pyplot as plt
>>> fig, axes = plt.subplots(1, 2, figsize=(7, 5), sharex=True, sharey=True)
>>> _ = plot_image(clean_image, ax=axes[0], title="Image without defects")
>>> _ = plot_image(image, ax=axes[1], title="Image with readout smear")
>>> plt.subplots_adjust(wspace=0.1)
>>> plt.show()

Methods

__init__([name, rate, seed, ...])

introduce_pixel_defect(image, camera, ...)

Introduce the defect into the image.

number_of_defect_pixels(camera)

Calculate the number of pixels affected by the defect.

set_pixels(pixels, camera)

Set the pixels for the defect.

Attributes

apply_before_base

Readout smear depends on the light signal and must precede the base image.

dim

0 for vertical, 1 for horizontal.

name

Name of the defect.

pixels

Pixel coordinates affected by the defect.

rate

Fraction of pixels affected by the defect.

readout_time

Time taken to read out the entire frame (seconds).

rng

Random number generator instance.

seed

Random seed for reproducibility.