Camera

Contents

Camera#

class cabaret.Camera(name: str = 'gaia-camera-simulated', width: int = 1024, height: int = 1024, bin_x: int = 1, bin_y: int = 1, pitch: float = 13.5, plate_scale: float | None = None, max_adu: int = 65535, well_depth: int = 65535, bias: int = 300, gain: float = 1.0, read_noise: float = 6.2, dark_current: float = 0.2, average_quantum_efficiency: float = 0.8, rotation: float = 0.0, pixel_defects: dict | None = None)[source]#

Camera configuration and properties.

Examples

Create a camera with multiple pixel defects:

>>> from cabaret import Camera, Observatory, Sources
>>> pixel_defects = {
...     "cold": {"type": "constant", "value": 0, "rate": 0.01, "seed": 1},
...     "noise": {"type": "noise", "rate": 0.02, "noise_level": 100, "seed": 2},
...     "qe": {"type": "quantum_efficiency_map", "seed": 3},
...     "smear": {"type": "readout_smear", "readout_time": 1},
... }
>>> camera = Camera(width=1024, height=1024, pixel_defects=pixel_defects)
>>> observatory = Observatory(camera=camera)
>>> sources = Sources.get_test_sources()
>>> ra, dec = sources.center

Now generate an image with and without pixel defects:

>>> _, clean_image, image = observatory.generate_image_stack(
...     ra=ra, dec=dec, exp_time=10, seed=42, 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 multiple defects")
>>> plt.subplots_adjust(wspace=0.1)
>>> plt.show()

Methods

__init__([name, width, height, bin_x, ...])

apply_post_base_defects(image, exp_time)

Apply defects that follow the base image (e.g. constant hot/cold pixels).

apply_pre_base_defects(image, exp_time)

Apply defects that must precede the base image (e.g. readout smear).

bin_image(image)

Bin the image according to the camera's binning factors.

create_ideal_camera(**kwargs)

Create a defect-free camera.

get_fov_radius()

Half-diagonal field radius in degrees.

get_wcs(center)

Get a WCS object for the camera centered at the given sky coordinate.

make_base_image(exp_time[, rng])

Generate the detector base image (bias, dark, read noise).

on_camera_mask(pixel_coords)

Clip the given pixel coordinates to the camera's bounds.

set_plate_scale_from_focal_length(focal_length)

Set the plate scale based on the focal length of the telescope.

to_adu_image(image)

Convert to ADU, add bias, clip, and cast to uint16.

Attributes

shape

Tuple of (height, width) of the camera in pixels.

size

Total number of pixels in the camera.

name

Name of the camera.

width

Number of pixels in the x-direction (width).

height

Number of pixels in the y-direction (height).

bin_x

Binning factor in x.

bin_y

Binning factor in y.

pitch

Pixel pitch in microns.

plate_scale

Arcseconds per pixel (if None, calculated from pitch and telescope).

max_adu

Maximum ADU value.

well_depth

Full well capacity in electrons.

bias

Bias level in ADU.

gain

Gain in electrons per ADU.

read_noise

Read noise in electrons.

dark_current

Dark current in electrons per second.

average_quantum_efficiency

Average quantum efficiency (fraction).

rotation

Rotation angle of the camera in degrees.

pixel_defects

Dictionary of pixel defect configurations.