Cameras (pyobs.modules.camera)

Camera modules. TODO: write doc

BaseCamera

class BaseCamera(fits_headers: Optional[Dict[str, Any]] = None, centre: Optional[Tuple[float, float]] = 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: Optional[List[str]] = None, **kwargs: Any)

Bases: pyobs.modules.Module, pyobs.mixins.ImageFitsHeaderMixin, pyobs.interfaces.ICamera, pyobs.interfaces.IExposureTime, pyobs.interfaces.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.

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) pyobs.utils.enums.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) pyobs.utils.enums.ImageType[source]

Returns the current image type.

Returns:

Current image type.

async grab_image(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.

async open() None[source]

Open module.

static set_biassec_trimsec(hdr: astropy.io.fits.header.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

async set_exposure_time(exposure_time: float, **kwargs: Any) None[source]

Set the exposure time in seconds.

Parameters:

exposure_time – Exposure time in seconds.

Raises:

ValueError – If exposure time could not be set.

async set_image_type(image_type: pyobs.utils.enums.ImageType, **kwargs: Any) None[source]

Set the image type.

Parameters:

image_type – New image type.

BaseSpectrograph

class BaseSpectrograph(fits_headers: Optional[Dict[str, Any]] = None, filenames: str = '/cache/pyobs-{DAY-OBS|date:}-{FRAMENUM|string:04d}.fits.gz', fits_namespaces: Optional[List[str]] = None, **kwargs: Any)

Bases: pyobs.modules.Module, pyobs.mixins.SpectrumFitsHeaderMixin, pyobs.interfaces.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) pyobs.utils.enums.ExposureStatus[source]

Returns the current status of the spectrograph, which is one of ‘idle’, ‘exposing’, or ‘readout’.

Returns:

Current status of spectrograph.

async grab_spectrum(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: astropy.io.fits.hdu.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: Optional[List[str]] = None, fits_headers: Optional[Dict[str, Any]] = None, centre: Optional[Tuple[float, float]] = None, rotation: float = 0.0, cache_size: int = 5, live_view: bool = True, flip: bool = False, sleep_time: int = 600, **kwargs: Any)

Bases: pyobs.modules.Module, pyobs.mixins.ImageFitsHeaderMixin, pyobs.interfaces.IVideo, pyobs.interfaces.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.

async activate_camera() None[source]

Activate camera.

property camera_active: bool

Whether camera is currently active.

async close() None[source]

Close server

static create_jpeg(data: numpy.ndarray[Any, numpy.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 deactivate_camera() None[source]

Deactivate camera.

async get_image_type(**kwargs: Any) pyobs.utils.enums.ImageType[source]

Returns the current image type.

Returns:

Current image type.

async get_video(**kwargs: Any) str[source]

Returns path to video.

Returns:

Path to video.

async grab_image(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: aiohttp.web_request.Request) aiohttp.web_response.Response[source]

Handles access to /* and returns a specified image.

Parameters:

request – Request to respond to.

Returns:

Response containing image.

async image_jpeg() Tuple[Optional[int], Optional[bytes]][source]

Return image as jpeg.

async open() None[source]

Open module.

property opened: bool

Whether the server is started.

async set_image_type(image_type: pyobs.utils.enums.ImageType, **kwargs: Any) None[source]

Set the image type.

Parameters:

image_type – New image type.

async video_handler(request: aiohttp.web_request.Request) aiohttp.web_response.StreamResponse[source]

Handles access to /video.mjpg and returns the video.

Parameters:

request – Request to respond to.

Returns:

Response containing video stream.

async web_handler(request: aiohttp.web_request.Request) aiohttp.web_response.Response[source]

Handles access to / and returns HTML page.

Parameters:

request – Request to respond to.

Returns:

Response containing web page.

DummyCamera

class DummyCamera(readout_time: float = 2, sim: Optional[Dict[str, Any]] = None, world: Optional[SimWorld] = None, **kwargs: Any)

Bases: pyobs.modules.camera.BaseCamera, pyobs.interfaces.IWindow, pyobs.interfaces.IBinning, pyobs.interfaces.ICooling, pyobs.interfaces.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_status(**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_gain(**kwargs: Any) float[source]

Returns the camera binning.

Returns:

Current gain.

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.

async set_gain(gain: float, **kwargs: Any) None[source]

Set the camera gain.

Parameters:

gain – New camera gain.

Raises:

ValueError – If gain could not be set.

async set_window(left: int, top: int, width: int, height: int, **kwargs: Any) None[source]

Set the camera window.

Parameters:
  • left – X offset of window.

  • top – Y offset of window.

  • width – Width of window.

  • height – Height of window.

Raises:

ValueError – If binning could not be set.

DummySpectrograph

class DummySpectrograph(**kwargs: Any)

Bases: pyobs.modules.camera.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.

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.