Cameras (pyobs.modules.camera)¶
Camera modules. TODO: write doc
BaseCamera¶
- class BaseCamera(fits_headers: Dict[str, Any] | None = None, centre: Tuple[float, float] | None = None, rotation: float = 0.0, flip: bool = False, filenames: str = '/cache/pyobs-{DAY-OBS|date:}-{FRAMENUM|string:04d}-{IMAGETYP|type}00.fits.gz', fits_namespaces: List[str] | None = None, **kwargs: Any)¶
Bases:
Module
,ImageFitsHeaderMixin
,ICamera
,IExposureTime
,IImageType
Base class for all camera modules.
Creates a new BaseCamera.
- Parameters:
fits_headers – Additional FITS headers.
centre – (x, y) tuple of camera centre.
rotation – Rotation east of north.
flip – Whether or not to flip the image along its first axis.
filenames – Template for file naming.
fits_namespaces – List of namespaces for FITS headers that this camera should request
- async abort(**kwargs: Any) None [source]¶
Aborts the current exposure and sequence. Derived class must implement IAbortable for this!
- Returns:
Success or not.
- async get_exposure_progress(**kwargs: Any) float [source]¶
Returns the progress of the current exposure in percent.
- Returns:
Progress of the current exposure in percent.
- async get_exposure_status(**kwargs: Any) ExposureStatus [source]¶
Returns the current status of the camera, which is one of ‘idle’, ‘exposing’, or ‘readout’.
- Returns:
Current status of camera.
- async get_exposure_time(**kwargs: Any) float [source]¶
Returns the exposure time in seconds.
- Returns:
Exposure time in seconds.
- async get_exposure_time_left(**kwargs: Any) float [source]¶
Returns the remaining exposure time on the current exposure in seconds.
- Returns:
Remaining exposure time in seconds.
- async get_image_type(**kwargs: Any) ImageType [source]¶
Returns the current image type.
- Returns:
Current image type.
- async grab_data(broadcast: bool = True, **kwargs: Any) str [source]¶
Grabs an image ans returns reference.
- Parameters:
broadcast – Broadcast existence of image.
- Returns:
Name of image that was taken.
- Raises:
GrabImageError – If there was a problem grabbing the image.
- async list_binnings(**kwargs: Any) List[Tuple[int, int]] [source]¶
List available binnings.
- Returns:
List of available binnings as (x, y) tuples.
- static set_biassec_trimsec(hdr: Header, left: int, top: int, width: int, height: int) None [source]¶
Calculates and sets the BIASSEC and TRIMSEC areas.
- Parameters:
hdr – FITS header (in/out)
left – left edge of data area
top – top edge of data area
width – width of data area
height – height of data area
BaseSpectrograph¶
- class BaseSpectrograph(fits_headers: Dict[str, Any] | None = None, filenames: str = '/cache/pyobs-{DAY-OBS|date:}-{FRAMENUM|string:04d}.fits.gz', fits_namespaces: List[str] | None = None, **kwargs: Any)¶
Bases:
Module
,SpectrumFitsHeaderMixin
,ISpectrograph
Base class for all spectrograph modules.
Creates a new BaseCamera.
- Parameters:
fits_headers – Additional FITS headers.
flip – Whether or not to flip the image along its first axis.
filenames – Template for file naming.
fits_namespaces – List of namespaces for FITS headers that this camera should request
- async abort(**kwargs: Any) None [source]¶
Aborts the current exposure.
- Raises:
ValueError – If exposure could not be aborted.
- async get_exposure_status(**kwargs: Any) ExposureStatus [source]¶
Returns the current status of the spectrograph, which is one of ‘idle’, ‘exposing’, or ‘readout’.
- Returns:
Current status of spectrograph.
- async grab_data(broadcast: bool = True, **kwargs: Any) str [source]¶
Grabs a spectrum and returns reference.
- Parameters:
broadcast – Broadcast existence of image.
- Returns:
Name of image that was taken.
- async store_spectrum(hdulist: HDUList, filename: str, broadcast: bool) None [source]¶
Store spectrum at given destination. Can be overwritten by derived classes to custom store a file. In those cases, this version should be called!
- Parameters:
hdulist – HDU list with spectrum.
filename – Name to store file with.
broadcast – Whether to broadcast new spectrum.
BaseVideo¶
- class BaseVideo(http_port: int = 37077, interval: float = 0.5, video_path: str = '/webcam/video.mjpg', filenames: str = '/webcam/pyobs-{DAY-OBS|date:}-{FRAMENUM|string:04d}.fits', fits_namespaces: List[str] | None = None, fits_headers: Dict[str, Any] | None = None, centre: Tuple[float, float] | None = None, rotation: float = 0.0, cache_size: int = 5, live_view: bool = True, flip: bool = False, sleep_time: int = 600, **kwargs: Any)¶
Bases:
Module
,ImageFitsHeaderMixin
,IVideo
,IImageType
Base class for all webcam modules.
Creates a new BaseWebcam.
On the receiving end, a VFS root with a HTTPFile must exist with the same name as in image_path and video_path, i.e. “webcam” in the default settings.
- Parameters:
http_port – HTTP port for webserver.
exposure_time – Initial exposure time.
interval – Min interval for grabbing images.
video_path – VFS path to video.
filename – Filename pattern for FITS images.
fits_namespaces – List of namespaces for FITS headers that this camera should request.
fits_headers – Additional FITS headers.
centre – (x, y) tuple of camera centre.
rotation – Rotation east of north.
cache_size – Size of cache for previous images.
live_view – If True, live view is served via web server.
flip – Whether to flip around Y axis.
sleep_time – Time in s with inactivity after which the camera should go to sleep.
- property camera_active: bool¶
Whether camera is currently active.
- static create_jpeg(data: ndarray[Any, dtype[Any]]) bytes [source]¶
Create a JPEG ge from a numpy array and return as bytes.
- Parameters:
data – Numpy array to convert to JPEG.
- Returns:
Bytes containing JPEG image.
- async get_image_type(**kwargs: Any) ImageType [source]¶
Returns the current image type.
- Returns:
Current image type.
- async grab_data(broadcast: bool = True, **kwargs: Any) str [source]¶
Grabs an image ans returns reference.
- Parameters:
broadcast – Broadcast existence of image.
- Returns:
Name of image that was taken.
- async image_handler(request: Request) Response [source]¶
Handles access to /* and returns a specified image.
- Parameters:
request – Request to respond to.
- Returns:
Response containing image.
- property opened: bool¶
Whether the server is started.
- async set_image_type(image_type: ImageType, **kwargs: Any) None [source]¶
Set the image type.
- Parameters:
image_type – New image type.
DummyCamera¶
- class DummyCamera(readout_time: float = 2, sim: Dict[str, Any] | None = None, world: SimWorld | None = None, **kwargs: Any)¶
Bases:
BaseCamera
,IWindow
,IBinning
,ICooling
,IGain
A dummy camera for testing.
Creates a new dummy cammera.
- Parameters:
readout_time – Readout time in seconds.
sim – Dictionary with config for image simulator.
- async get_binning(**kwargs: Any) Tuple[int, int] [source]¶
Returns the camera binning.
- Returns:
Tuple with x and y.
- async get_cooling(**kwargs: Any) Tuple[bool, float, float] [source]¶
Returns the current status for the cooling.
- Returns:
- Tuple containing:
Enabled: Whether the cooling is enabled SetPoint: Setpoint for the cooling in celsius. Power: Current cooling power in percent or None.
- Return type:
(tuple)
- async get_full_frame(**kwargs: Any) Tuple[int, int, int, int] [source]¶
Returns full size of CCD.
- Returns:
Tuple with left, top, width, and height set.
- async get_temperatures(**kwargs: Any) Dict[str, float] [source]¶
Returns all temperatures measured by this module.
- Returns:
Dict containing temperatures.
- async get_window(**kwargs: Any) Tuple[int, int, int, int] [source]¶
Returns the camera window.
- Returns:
Tuple with left, top, width, and height set.
- async set_binning(x: int, y: int, **kwargs: Any) None [source]¶
Set the camera binning.
- Parameters:
x – X binning.
y – Y binning.
- Raises:
ValueError – If binning could not be set.
- async set_cooling(enabled: bool, setpoint: float, **kwargs: Any) None [source]¶
Enables/disables cooling and sets setpoint.
- Parameters:
enabled – Enable or disable cooling.
setpoint – Setpoint in celsius for the cooling.
- Raises:
ValueError – If cooling could not be set.
DummySpectrograph¶
- class DummySpectrograph(**kwargs: Any)¶
Bases:
BaseSpectrograph
A dummy spectrograph for testing.
Creates a new dummy cammera.
- Parameters:
readout_time – Readout time in seconds.
sim – Dictionary with config for image simulator.