Science Camera
The ScienceCamera component represents the imaging path used to evaluate science output from the AO system. Unlike the wavefront sensor, this component is typically used to observe performance metrics such as PSF structure, long-exposure integration, tip-tilt behavior, and Strehl-related quantities.
The class manages the shared-memory outputs associated with science imaging, including short- and long-exposure PSF products.
Soft-RTC Example
The following example shows the typical soft-RTC pattern for science-camera setup.
from pyRTC.ScienceCamera import ScienceCamera
from pyRTC.utils import read_yaml_file
conf = read_yaml_file("path/to/config.yaml")
sci = ScienceCamera(conf["psf"])
sci.start()
# The short-exposure and long-exposure products are written to shared memory.
sci.expose()
sci.integrate()
Hard-RTC Example
If the science camera is tied to a specific vendor SDK or operational process boundary, it can also be launched in hard-RTC mode.
from pyRTC.Pipeline import hardwareLauncher
config = 'path/to/config.yaml'
port = 3003
sci = hardwareLauncher('path/to/pyRTC/hardware/myScienceCamera.py', config, port)
sci.launch()
sci.run("integrate")
Operational Notes
The science camera is usually responsible for image-quality observables rather than control observables. Common configuration and workflow concerns include:
short- vs long-exposure output products
dark-frame handling
model PSF loading
ROI, gain, binning, and exposure settings
downstream analysis such as Strehl and centroid-derived metrics
This class is often subclassed for site-specific cameras under pyRTC.hardware.
Parameters
- class pyRTC.ScienceCamera.ScienceCamera(conf)[source]
Bases:
pyRTCComponentBase class for cameras that produce science images and image-quality metrics.
ScienceCameracentralizes the parts of imaging that are shared across real and synthetic science-camera backends: SHM publication, dark/model PSF handling, long-exposure accumulation, and simple Strehl/tip-tilt telemetry. Subclasses are expected to implement the device-facing acquisition logic and then call the parent methods so the standard pyRTC products stay updated.Config
- namestr
Name of the camera.
- widthint
Width of the image. Required.
- heightint
Height of the image. Required.
- darkCountint
Number of dark frames to average. Required.
- integrationint
Integration length. Required.
- darkFilestr, optional
File to save the dark frames. Default is “”.
- modelFilestr, optional
File to save the model PSF. Default is “”.
Attributes
- namestr
Name of the camera.
- imageShapetuple
Shape of the image.
- imageRawDTypetype
Data type of the raw image.
- imageDTypetype
Data type of the image.
- psfLongDtypetype
Data type of the long exposure PSF.
- psfShortImageSHM
Shared memory object for the short exposure PSF.
- psfLongImageSHM
Shared memory object for the long exposure PSF.
- strehlShmImageSHM
Shared memory object for the Strehl ratio.
- tipTiltShmImageSHM
Shared memory object for the tip-tilt.
- datanumpy.ndarray
Data array for the image.
- darknumpy.ndarray
Dark frame.
- darkCountint
Number of dark frames to average.
- darkFilestr
File to save the dark frames.
- modelnumpy.ndarray
Model PSF.
- modelFilestr
File to save the model PSF.
- strehl_ratiofloat
Strehl ratio.
- peak_distfloat
Peak distance.
- integrationLengthint
Integration length.
- roiWidthint
Width of the region of interest.
- roiHeightint
Height of the region of interest.
- roiLeftint
Left coordinate of the region of interest.
- roiTopint
Top coordinate of the region of interest.
- exposureint
Exposure time.
- binningint
Binning factor.
- gainint
Gain setting.
- bitDepthint
Bit depth setting.
- computeStrehl(median_filter_size=1, gaussian_sigma=0)[source]
Compute the rough Strehl ratio and tip tilt offset. These values are reference to the modelPSF. If your model PSF is taken empirically, then the Strehl ratio is not absolute, and should only be used as a relative measurement for focal plane feedback.
Parameters
- median_filter_sizeint, optional
Size of the median filter to apply. Default is 1.
- gaussian_sigmafloat, optional
Sigma for the Gaussian filter. Default is 0.
Returns
- float
Strehl ratio.
- expose()[source]
Perform a single exposure.
- integrate()[source]
Perform multiple exposures and integrate the results. Number of frames set by integrationLength.
- loadDark(filename='')[source]
Load the dark frame from a file.
Parameters
- filenamestr, optional
File to load the dark frame from. If not specified, uses the configured darkFile.
- loadModelPSF(filename='')[source]
Load the model PSF from a file.
Parameters
- filenamestr, optional
File to load the model PSF from. If not specified, uses the configured modelFile.
- plot()[source]
Plot the current short exposure PSF.
- read(block=True)[source]
Read the current short exposure PSF.
Returns
- numpy.ndarray
Current short exposure PSF.
- readLong()[source]
Read the current long exposure PSF.
Returns
- numpy.ndarray
Current long exposure PSF.
- saveDark(filename='')[source]
Save the dark frame to a file.
Parameters
- filenamestr, optional
File to save the dark frame to. If not specified, uses the configured darkFile.
- saveModelPSF(filename='')[source]
Save the model PSF to a file.
Parameters
- filenamestr, optional
File to save the model PSF to. If not specified, uses the configured modelFile.
- setIntegrationLength(integrationLength)[source]
Set the integration length.
Parameters
- integrationLengthint
Integration length to set.
- setRoi(roi)[source]
Set the region of interest (ROI).
Parameters
- roituple
Tuple containing (width, height, left, top) of the ROI.
- start()
Start the registered real-time functions.
- stop()
Stops the registered real-time functions.
- takeDark()[source]
Take dark frames and average them to create a dark frame. Number of exposures to average set by darkCount parameter.
- takeModelPSF()[source]
Capture the current long exposure PSF as the model PSF.