Interfaces (pyobs.interfaces)

Using interface, a Module signals another one, what functionality it provides for remote procedure calls. The base class for all interfaces in pyobs is:

class Interface

Base class for all interfaces in pyobs.

get_capabilities(interface: type[Interface]) Any | None[source]

Return the capabilities for the given interface, or None.

get_state(interface: type[Interface]) Any | None[source]

Return the last received state for the given interface, or None.

classmethod has_own_state() bool[source]

True if this interface defines its own state, as opposed to merely inheriting one from a component interface it combines (e.g. ICamera inheriting IExposure’s state). Modules publish state under the interface that actually defines it, so composite interfaces would otherwise be (wrongly) treated as publishing state too.

async wait_for_state(interface: type[Interface], timeout: float = 10.0) Any | None[source]

Return state immediately if available, otherwise wait for the first update.

Modules need to implement the required interfaces. For instance, if a module operates a camera, it probably should implement ICamera.

IAbortable

class IAbortable

Bases: Interface

The module has an abortable action.

abstractmethod async abort(**kwargs: Any) None[source]

Abort current actions.

IAcquisition

class IAcquisition

Bases: IRunning, IAbortable

The module can acquire a target, usually by accessing a telescope and a camera.

abstractmethod async acquire_target(**kwargs: Any) AcquisitionResult[source]

Acquire target at given coordinates.

If no RA/Dec are given, start from current position. Might not work for some implementations that require coordinates.

Returns:

Result with time, ra, dec, alt, az, and an offset in whichever frame the mount supports.

Raises:

ValueError – If target could not be acquired.

state

alias of AcquisitionState

IAutoFocus

class IAutoFocus

Bases: IRunning, IAbortable

The module can perform an autofocus.

abstractmethod async auto_focus(count: int, step: float, exposure_time: ~typing.Annotated[float, <Unit.SECONDS: 'seconds'>], **kwargs: ~typing.Any) AutoFocusResult[source]

Perform an autofocus series.

This method performs an autofocus series with “count” images on each side of the initial guess and the given step size. With count=3, step=1 and guess=10, this takes images at the following focus values: 7, 8, 9, 10, 11, 12, 13

Parameters:
  • count – Number of images to take on each side of the initial guess. Should be an odd number.

  • step – Step size.

  • exposure_time – Exposure time for images.

Returns:

Result of autofocus.

Raises:

ValueError – If focus could not be obtained.

state

alias of AutoFocusState

IAutoGuiding

class IAutoGuiding

Bases: IStartStop, IExposureTime

The module can perform auto-guiding.

state

alias of GuidingState

IAutonomous

class IAutonomous

Bases: IStartStop

The module does some autonomous actions, mainly used for warnings to users.

IBinning

class IBinning

Bases: Interface

The camera supports binning, to be used together with ICamera.

capabilities

alias of BinningCapabilities

abstractmethod 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.

state

alias of BinningState

ICalibrate

class ICalibrate

Bases: Interface

The module can calibrate a device.

abstractmethod async calibrate(**kwargs: Any) None[source]

Calibrate the device.

ICamera

class ICamera

Bases: IData, IExposure

The module controls a camera.

IConfig

class IConfig

Bases: Interface

The module allows access to some of its configuration options.

capabilities

alias of ConfigCapabilities

abstractmethod async get_config_value(name: str, **kwargs: Any) bool | int | float | str | list[bool | int | float | str] | dict[str, bool | int | float | str][source]

Returns current value of config item with given name.

Parameters:

name – Name of config item.

Returns:

Current value.

Raises:

ValueError – If config item of given name does not exist.

abstractmethod async set_config_value(name: str, value: bool | int | float | str | list[bool | int | float | str] | dict[str, bool | int | float | str], **kwargs: Any) None[source]

Sets value of config item with given name.

Parameters:
  • name – Name of config item.

  • value – New value.

Raises:

ValueError – If config item of given name does not exist or value is invalid.

ICooling

class ICooling

Bases: ITemperatures

The module can control the cooling of a device.

abstractmethod async set_cooling(enabled: bool, setpoint: ~typing.Annotated[float, <Unit.CELSIUS: 'celsius'>], **kwargs: ~typing.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.

state

alias of CoolingState

IData

class IData

Bases: Interface

The module can grab and return an image from whatever device.

abstractmethod async grab_data(broadcast: bool = True, **kwargs: Any) str[source]

Grabs an image and 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.

IDome

class IDome

Bases: IRoof, IPointingAltAz

The module controls a dome, i.e. a IRoof with a rotating roof.

IExposure

class IExposure

Bases: Interface

The module controls a camera.

state

alias of ExposureState

IExposureTime

class IExposureTime

Bases: Interface

The camera supports exposure times, to be used together with ICamera.

abstractmethod async set_exposure_time(exposure_time: ~typing.Annotated[float, <Unit.SECONDS: 'seconds'>], **kwargs: ~typing.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.

state

alias of ExposureTimeState

IFilters

class IFilters

Bases: IMotion

The module can change filters in a device.

capabilities

alias of FiltersCapabilities

abstractmethod async set_filter(filter_name: str, **kwargs: Any) None[source]

Set the current filter.

Parameters:

filter_name – Name of filter to set.

Raises:
  • ValueError – If an invalid filter was given.

  • MoveError – If filter wheel cannot be moved.

state

alias of FilterState

IFitsHeaderAfter

class IFitsHeaderAfter

Bases: Interface

The module provides some additional header entries for FITS headers after some event (usually the end of the exposure).

abstractmethod async get_fits_header_after(namespaces: list[str] | None = None, **kwargs: Any) dict[str, FitsHeaderEntry][source]

Returns FITS header for the current status of this module.

Parameters:

namespaces – If given, only return FITS headers for the given namespaces.

Returns:

Dictionary containing FITS headers.

IFitsHeaderBefore

class IFitsHeaderBefore

Bases: Interface

The module provides some additional header entries for FITS headers before some event (usually the start of the exposure).

abstractmethod async get_fits_header_before(namespaces: list[str] | None = None, **kwargs: Any) dict[str, FitsHeaderEntry][source]

Returns FITS header for the current status of this module.

Parameters:

namespaces – If given, only return FITS headers for the given namespaces.

Returns:

Dictionary containing FITS headers.

IFlatField

class IFlatField

Bases: IAbortable

The module performs flat-fielding.

abstractmethod async flat_field(count: int = 20, **kwargs: Any) tuple[int, ~typing.Annotated[float, <Unit.SECONDS: 'seconds'>]][source]

Do a series of flat fields.

Parameters:

count – Number of images to take

Returns:

Number of images actually taken and total exposure time in seconds

IFocusModel

class IFocusModel

Bases: Interface

The module provides a model for the telescope focus, e.g. based on temperatures.

abstractmethod async set_optimal_focus(**kwargs: Any) None[source]

Sets optimal focus.

state

alias of OptimalFocusState

IFocuser

class IFocuser

Bases: IMotion

The module is a focusing device.

abstractmethod async set_focus(focus: ~typing.Annotated[float, <Unit.MM: 'mm'>], **kwargs: ~typing.Any) None[source]

Sets new focus.

Parameters:

focus – New focus value in mm.

Raises:
  • MoveError – If telescope cannot be moved.

  • InterruptedError – If movement was aborted.

abstractmethod async set_focus_offset(offset: ~typing.Annotated[float, <Unit.MM: 'mm'>], **kwargs: ~typing.Any) None[source]

Sets focus offset.

Parameters:

offset – New focus offset in mm.

Raises:
  • ValueError – If given value is invalid.

  • MoveError – If telescope cannot be moved.

state

alias of FocuserState

IGain

class IGain

Bases: Interface

The camera supports setting of gain, to be used together with ICamera.

abstractmethod 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.

abstractmethod async set_offset(offset: float, **kwargs: Any) None[source]

Set the camera offset.

Parameters:

offset – New camera offset.

Raises:

ValueError – If offset could not be set.

state

alias of GainState

IImageFormat

class IImageFormat

Bases: Interface

The module supports different image formats (e.g. INT16, FLOAT32), mainly used by cameras.

capabilities

alias of ImageFormatCapabilities

abstractmethod async set_image_format(fmt: ImageFormat, **kwargs: Any) None[source]

Set the camera image format.

Parameters:

fmt – New image format.

Raises:

ValueError – If format could not be set.

state

alias of ImageFormatState

IImageType

class IImageType

Bases: Interface

The module supports different image types (e.g. object, bias, dark, etc), mainly used by cameras.

abstractmethod async set_image_type(image_type: ImageType, **kwargs: Any) None[source]

Set the image type.

Parameters:

image_type – New image type.

state

alias of ImageTypeState

IMode

class IMode

Bases: Interface

The module can change modes in a device.

capabilities

alias of ModeCapabilities

abstractmethod async set_mode(mode: str, group: str = '', **kwargs: Any) None[source]

Set the current mode.

Parameters:
  • mode – Name of mode to set.

  • group – Name of the group to set the mode for.

Raises:
  • ValueError – If an invalid mode or group was given.

  • MoveError – If mode selector cannot be moved.

state

alias of ModeState

IModule

class IModule

Bases: Interface

The module is actually a module. Implemented by all modules.

capabilities

alias of ModuleCapabilities

abstractmethod async get_permitted_methods(**kwargs: Any) list[str][source]

Returns names of all methods the calling module is allowed to invoke on this module.

abstractmethod async reset_error(**kwargs: Any) bool[source]

Reset error of module, if any.

IMotion

class IMotion

Bases: IReady

The module controls a device that can move.

abstractmethod async init(**kwargs: Any) None[source]

Initialize device.

Raises:

InitError – If device could not be initialized.

abstractmethod async park(**kwargs: Any) None[source]

Park device.

Raises:

ParkError – If device could not be parked.

state

alias of MotionState

abstractmethod async stop_motion(device: str | None = None, **kwargs: Any) None[source]

Stop the motion.

Parameters:

device – Name of device to stop, or None for all.

IMultiFiber

class IMultiFiber

Bases: Interface

An interface for multi-fiber setups that helps to set/get a fiber and retrieve position and size of the current fiber on the acquisition/guiding image.

abstractmethod async abort(**kwargs: Any) None[source]

Abort current actions.

capabilities

alias of MultiFiberCapabilities

abstractmethod async set_fiber(fiber: str, **kwargs: Any) None[source]

Sets the currently active fiber. Must be in fiber_names capability.

Parameters:

fiber – Name of fiber to set.

state

alias of MultiFiberState

IOffsetsAltAz

class IOffsetsAltAz

Bases: Interface

The module supports Alt/Az offsets, usually combined with ITelescope and IPointingAltAz.

abstractmethod async set_offsets_altaz(dalt: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], daz: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], **kwargs: ~typing.Any) None[source]

Move an Alt/Az offset.

Parameters:
  • dalt – Altitude offset in degrees.

  • daz – Azimuth offset in degrees.

Raises:

MoveError – If device could not be moved.

state

alias of AltAzOffsetState

IOffsetsRaDec

class IOffsetsRaDec

Bases: Interface

The module supports RA/Dec offsets, usually combined with ITelescope and IPointingRaDec.

abstractmethod async set_offsets_radec(dra: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], ddec: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], **kwargs: ~typing.Any) None[source]

Move an RA/Dec offset.

Parameters:
  • dra – RA offset in degrees.

  • ddec – Dec offset in degrees.

Raises:

MoveError – If telescope cannot be moved.

state

alias of RaDecOffsetState

IPointingAltAz

class IPointingAltAz

Bases: Interface

The module can move to Alt/Az coordinates, usually combined with ITelescope.

abstractmethod async move_altaz(alt: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], az: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], **kwargs: ~typing.Any) None[source]

Moves to given coordinates.

Parameters:
  • alt – Alt in deg to move to.

  • az – Az in deg to move to.

Raises:

MoveError – If device could not be moved.

state

alias of AltAzState

IPointingHGS

class IPointingHGS

Bases: Interface

The module can move to Mu/Psi coordinates, usually combined with ITelescope.

abstractmethod async move_hgs_lon_lat(lon: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], lat: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], **kwargs: ~typing.Any) None[source]

Moves on given coordinates.

Parameters:
  • lon – Longitude in deg to track.

  • lat – Latitude in deg to track.

Raises:

MoveError – If device could not be moved.

state

alias of HGSState

IPointingHelioprojective

class IPointingHelioprojective

Bases: Interface

The module can move to Mu/Psi coordinates, usually combined with ITelescope.

abstractmethod async move_helioprojective(theta_x: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], theta_y: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], **kwargs: ~typing.Any) None[source]

Moves on given coordinates.

Parameters:
  • theta_x – The theta_x coordinate.

  • theta_y – The theta_y coordinate.

Raises:

MoveError – If device could not be moved.

state

alias of HelioprojectiveState

IPointingRaDec

class IPointingRaDec

Bases: Interface

The module can move to RA/Dec coordinates, usually combined with ITelescope.

abstractmethod async move_radec(ra: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], dec: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], **kwargs: ~typing.Any) None[source]

Starts tracking on given coordinates.

Parameters:
  • ra – RA in deg to track.

  • dec – Dec in deg to track.

Raises:

MoveError – If device could not be moved.

state

alias of RaDecState

IPointingSeries

class IPointingSeries

Bases: Interface

The module provides the interface for a device that initializes and finalizes a pointing series and adds points to it.

abstractmethod async add_pointing_measurement(**kwargs: Any) None[source]

Add a new measurement to the pointing series.

IReady

class IReady

Bases: Interface

The module can be in a “not ready” state for science and need to be initialized in some way.

state

alias of ReadyState

IRoof

class IRoof

Bases: IMotion

The module controls a roof.

IRotation

class IRotation

Bases: IMotion

The module controls a device that can rotate.

abstractmethod async set_rotation(angle: ~typing.Annotated[float, <Unit.DEGREES: 'deg'>], **kwargs: ~typing.Any) None[source]

Sets the rotation angle to the given value in degrees.

state

alias of RotationState

IRunnable

class IRunnable

Bases: IAbortable

The module has some action that can be started remotely.

abstractmethod async run(**kwargs: Any) None[source]

Perform module task

IRunning

class IRunning

Bases: Interface

The module can be running.

abstractmethod async is_running(**kwargs: Any) bool[source]

Whether a service is running.

state

alias of RunningState

IScriptRunner

class IScriptRunner

Bases: Interface

The module can execute a script.

abstractmethod async run_script(script: str, **kwargs: Any) None[source]

Run the given script.

Parameters:

script – Script to run.

ISpectrograph

class ISpectrograph

Bases: IData, IExposure

The module controls a camera.

IStartStop

class IStartStop

Bases: IRunning

The module can be started and stopped.

abstractmethod async start(**kwargs: Any) None[source]

Starts a service.

abstractmethod async stop(**kwargs: Any) None[source]

Stops a service.

ISyncTarget

class ISyncTarget

Bases: Interface

The module can synchronize a target, e.g. via a telescope control software behinde an ITelescope.

abstractmethod async sync_target(**kwargs: Any) None[source]

Synchronize device on current target.

ITelescope

class ITelescope

Bases: IMotion

The module controls a telescope.

ITemperatures

class ITemperatures

Bases: Interface

The module can return temperatures measured on some device.

state

alias of TemperaturesState

IVideo

class IVideo

Bases: IData

The module controls a video streaming device.

capabilities

alias of VideoCapabilities

IWeather

class IWeather

Bases: IStartStop

The module acts as a weather station.

abstractmethod async get_sensor_value(station: str, sensor: WeatherSensors, **kwargs: Any) WeatherSensorReading[source]

Return value for given sensor.

Parameters:
  • station – Name of weather station to get value from.

  • sensor – Name of sensor to get value from.

Returns:

Current reading for the given sensor.

state

alias of WeatherState

IWindow

class IWindow

Bases: Interface

The camera supports windows, to be used together with ICamera.

capabilities

alias of WindowCapabilities

abstractmethod 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 window could not be set.

state

alias of WindowState