Cred3 Camera#

Note

The Cred3 camera class requires the xaosim package, which is only compatible with Linux/Unix systems. To install with camera support: pip install phobos-controls[camera]

class phobos.Cred3(*args, **kwargs)[source]#

Bases: object

Singleton Class to interface with the Cred3 camera via shared memory.

The camera writes frames to a shared memory location that can be read by this class. Optionally, dark frames can be subtracted.

Configuration is loaded from phobos.config.

__init__()[source]#

Initialize the Cred3 camera interface using global configuration.

get_image(
subtract_dark: bool = True,
stack: int = 1,
) ndarray[source]#

Get the latest image from the shared memory.

Parameters:
  • subtract_dark (bool, optional) – If True, subtract the dark frame. If None, uses the default set during initialization. Default is True.

  • stack (int, optional) – Number of frames to stack for averaging. Default is 1.

Returns:

img – Latest camera frame, optionally dark-subtracted.

Return type:

ndarray

Examples

>>> camera = Cred3()
>>> img = camera.get_image()
>>> img_no_dark = camera.get_image(subtract_dark=False)
crop_outputs_from_image(
img: ndarray,
) list[ndarray][source]#

Crop output regions from an image using configured centers and sizes.

Parameters:

img (ndarray) – Input image to crop from.

Returns:

crops – List of cropped sub-images for each configured output.

Return type:

list of ndarray

get_outputs(
subtract_dark: bool = True,
flux_mode: str = 'mean',
stack=1,
) ndarray[source]#

Get the flux around configured output centers.

This method crops regions around the output centers defined in the configuration and returns the flux in each region. The flux can be the mean pixel value or the sum of pixel values.

Parameters:
  • subtract_dark (bool, optional) – Whether to subtract dark frame. Default is True.

  • flux_mode (str, optional, 'mean' or 'sum') – Method to compute the flux. ‘mean’: average of pixel values (default) ‘sum’: sum of pixel values

  • stack (int, optional) – Number of frames to stack for averaging. Default is 1.

Returns:

flux – Flux in each cropped region, shape (N,).

Return type:

ndarray

Examples

>>> camera = Cred3()
>>> # Get averaged outputs from configured centers
>>> flux = camera.get_outputs()
>>>
>>> # Get integrated flux (sum)
>>> flux_sum = camera.get_outputs(flux_mode='sum')
get_bulk(
subtract_dark: bool = True,
flux_mode: str = 'mean',
) float[source]#

Get the flux of the bulk channel using configured center and size.

Parameters:
  • subtract_dark (bool, optional) – Whether to subtract dark frame. Default is True.

  • flux_mode (str, optional) – ‘mean’ or ‘sum’. Default is ‘mean’.

Returns:

flux – Flux in the bulk region.

Return type:

float

update_dark(dark_shm_path: str = None)[source]#

Update the dark frame from shared memory.

Parameters:

dark_shm_path (str, optional) – Shared memory path for the new dark frame. If None, uses the default dark_shm_path. Default is None.

Examples

>>> camera = Cred3()
>>> camera.update_dark()  # Reload dark from default location
take_darks(
nb_frames: int = 1000,
save_to_shm: bool = True,
) ndarray[source]#

Acquire dark frames and compute the average.

This method acquires a specified number of frames, computes their average, and optionally saves the result to shared memory for use as a dark frame.

Parameters:
  • nb_frames (int, optional) – Number of frames to acquire and average. Default is 1000.

  • save_to_shm (bool, optional) – If True, save the averaged dark frame to shared memory at self.dark_shm_path. Default is True.

Returns:

dark_mean – The averaged dark frame.

Return type:

ndarray

Notes

  • Ensure the camera source is turned OFF before acquiring darks

  • The method checks for late frames (when semaphore value > 0)

  • The dark frame is automatically loaded if save_to_shm is True

Examples

>>> camera = Cred3()
>>> # Acquire 100 dark frames (default)
>>> dark = camera.take_darks()
>>>
>>> # Acquire 50 frames without saving to shared memory
>>> dark = camera.take_darks(nb_frames=50, save_to_shm=False)
check_cropping(subtract_dark: bool = True)[source]#

Display the cropped output regions to verify they well capture the output signals.

Acquires a frame and shows each cropped output as a subplot with a shared color scale, useful for checking that output_centers and output_sizes are correctly configured.

Parameters:

subtract_dark (bool, optional) – Whether to subtract the dark frame. Default is True.

Examples

>>> camera = Cred3()
>>> camera.check_cropping()
close()[source]#

Close the shared memory connections.

This method is provided for compatibility but shared memory objects are typically managed by the system.

reset()[source]#

Reset the camera settings (use_dark, outputs strategies) to the configuration.