Mixins (pyobs.mixins)
Mixins are classes that can be inherited from to automatically add some functionality to a module.
CameraSettingsMixin
- class CameraSettingsMixin(filters: Optional[Union[str, pyobs.interfaces.IFilters]] = None, filter_name: Optional[str] = None, binning: Optional[int] = None, **kwargs: Any)
Mixin for a device that should be able to set camera settings.
Initializes the mixin.
- Parameters:
filters – Filter wheel module.
filter – Filter to set.
binning – Binning to set.
- async _do_camera_settings(camera: Union[pyobs.modules.Module, pyobs.interfaces.IImageGrabber, pyobs.interfaces.IFilters, pyobs.interfaces.IBinning, pyobs.interfaces.IWindow]) None [source]
Do camera settings for given camera.
FitsHeaderMixin
- class FitsHeaderMixin(fits_namespaces: Optional[List[str]] = None, fits_headers: Optional[Dict[str, Any]] = None, filenames: str = '/cache/pyobs-{DAY-OBS|date:}-{FRAMENUM|string:04d}.fits', frame_number: bool = True, night_obs: bool = False, **kwargs: Any)
Helper methods for all modules that implement IImageGrabber.
Initialise the mixin.
- Parameters:
fits_namespaces – List of namespaces for FITS headers that this camera should request.
fits_headers – Additional FITS headers.
filename – Filename pattern for FITS images.
frame_number – Whether to add frame number to FITS file header.
night_obs – If True, DAY-OBS will contain the night of observation, not the calendar day.
- _fitsheadermixin_add_fits_headers(image: Union[pyobs.images.Image, astropy.io.fits.hdu.image.PrimaryHDU]) None [source]
Add FITS header keywords to the given FITS header.
- Parameters:
image – Image with header to add to.
Add FRAMENUM keyword to header
- Parameters:
image – Image with header to add to.
- async add_fits_headers(image: Union[pyobs.images.Image, astropy.io.fits.hdu.image.PrimaryHDU]) None [source]
Add requested FITS headers to header of given image.
- Parameters:
image – Image with header to add to.
- async add_requested_fits_headers(image: Union[pyobs.images.Image, astropy.io.fits.hdu.image.PrimaryHDU], futures: Dict[str, collections.abc.Coroutine]) None [source]
Add requested FITS headers to header of given image.
- Parameters:
image – Image with header to add to.
futures – Futures to get headers from.
- format_filename(image: Union[pyobs.images.Image, astropy.io.fits.hdu.image.PrimaryHDU]) Optional[str] [source]
Format filename according to given pattern and store in header of image.
- Parameters:
image – Image with header to add to.
FitsNamespaceMixin
- class FitsNamespaceMixin(fits_namespaces: Optional[Dict[str, List[str]]] = None, **kwargs: Any)
Mixin for IFitsHeaderProvider modules that filters FITS headers by namespace.
- __add_namespace(name: str, keywords: List[str], hdr: Dict[str, Any]) None
Add FITS header keywords from namespace to list of valid keywords
- Parameters:
name – Name of namespace
keywords – List of valid keywords, which will be added to
hdr – Full unfiltered header
- _filter_fits_namespace(hdr: Dict[str, Tuple[Any, str]], sender: str, namespaces: Optional[List[str]] = None) Dict[str, Tuple[Any, str]] [source]
Filter FITS header keywords by given namespaces. If no namespaces are given, let all through. Always let keywords with this module’s name as namespace pass.
- Parameters:
hdr – Input header to filter
namespaces – Requested namespaces
sender – Name of module that requested headers
- Returns:
Filtered FITS header
FollowMixin
- class FollowMixin(device: Optional[str], mode: Type[Union[pyobs.interfaces.IPointingAltAz, pyobs.interfaces.IPointingRaDec]], interval: float = 10, tolerance: float = 1, only_follow_when_ready: bool = True, *args: Any, **kwargs: Any)
Mixin for a device that should follow the motion of another.
Initializes the mixin.
- Parameters:
device – Name of device to follow
interval – Interval in seconds between position checks.
tolerance – Tolerance in degrees between both devices to trigger new movement.
mode – Set to “altaz” to follow Alt/Az coordinates or “radec” to follow RA/Dec.
only_follow_when_ready – Only follow if is_ready() is True.
- async __update_follow() None
Update function.
- property is_following: bool
Returns True, if we’re following another device.
ImageFitsHeaderMixin
- class ImageFitsHeaderMixin(centre: Optional[Tuple[float, float]] = None, rotation: float = 0.0, **kwargs: Any)
Helper methods for all modules that need FITS headers for an image.
Initialise the mixin.
- Parameters:
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.
filename – Filename pattern for FITS images.
- _fitsheadermixin_add_fits_headers(image: Union[pyobs.images.Image, astropy.io.fits.hdu.image.PrimaryHDU]) None [source]
Add FITS header keywords to the given FITS header.
- Parameters:
image – Image with header to add to.
MotionStatusMixin
- class MotionStatusMixin(motion_status_interfaces: Optional[List[str]] = None, **kwargs: Any)
Mixin for IMotion devices for handling status.
Initializes the mixin.
- Parameters:
interfaces – List of interfaces to handle or None
- async _change_motion_status(status: pyobs.utils.enums.MotionStatus, interface: Optional[str] = None) None [source]
Change motion status and send event,
- Parameters:
status – New motion status
interface – Interface to set motion status for
- _combine_motion_status() pyobs.utils.enums.MotionStatus [source]
Method for combining motion statuses for individual interfaces into the global one. Can be overriden.
- async get_motion_status(device: Optional[str] = None, **kwargs: Any) pyobs.utils.enums.MotionStatus [source]
Returns current motion status.
- Parameters:
device – Name of device to get status for, or None.
- Returns:
A string from the Status enumerator.
SpectrumFitsHeaderMixin
- class SpectrumFitsHeaderMixin(fits_namespaces: Optional[List[str]] = None, fits_headers: Optional[Dict[str, Any]] = None, filenames: str = '/cache/pyobs-{DAY-OBS|date:}-{FRAMENUM|string:04d}.fits', frame_number: bool = True, night_obs: bool = False, **kwargs: Any)
Helper methods for all modules that need FITS headers for an image.
Initialise the mixin.
- Parameters:
fits_namespaces – List of namespaces for FITS headers that this camera should request.
fits_headers – Additional FITS headers.
filename – Filename pattern for FITS images.
frame_number – Whether to add frame number to FITS file header.
night_obs – If True, DAY-OBS will contain the night of observation, not the calendar day.
WaitForMotionMixin
- class WaitForMotionMixin(wait_for_modules: Optional[List[str]] = None, wait_for_states: Optional[List[Union[pyobs.utils.enums.MotionStatus, str]]] = None, wait_for_timeout: float = 0, **kwargs: Any)
Mixin for a device that should wait for the motion status of another device.
Initializes the mixin.
- Parameters:
wait_for_modules – One or more modules to wait for.
wait_for_states – List of states to wait for.
wait_for_timeout – Wait timeout in seconds.
WeatherAwareMixin
- class WeatherAwareMixin(weather: Optional[Union[str, pyobs.interfaces.IWeather]] = None, **kwargs: Any)
Mixin for IMotion devices that should park(), when weather gets bad.
- async __on_bad_weather(event: pyobs.events.Event, sender: str) bool
Abort exposure if a bad weather event occurs.
- Parameters:
event – The bad weather event.
sender – Who sent it.
- async __weather_check() None
Thread for continuously checking for good weather
- async _on_good_weather(event: pyobs.events.Event, sender: str) bool [source]
Change status of weather.
- Parameters:
event – The good weather event.
sender – Who sent it.