panoptes.pocs.focuser package¶
Submodules¶
panoptes.pocs.focuser.astromechanics module¶
Astromechanics Canon EF/EF-S electronic focuser driver.
Controls Canon EF/EF-S lenses via the Astromechanics adapter over a serial connection, implementing the AbstractSerialFocuser interface.
- class panoptes.pocs.focuser.astromechanics.Focuser(name='Astromechanics Focuser', model='Canon EF-232', vendor_id=1027, product_id=24577, zero_position=-25000, baudrate=38400, *args, **kwargs)[source]¶
Bases:
AbstractSerialFocuserFocuser class for control of a Canon DSLR lens via an Astromechanics Engineering Canon EF/EF-S adapter.
Min/max commands do not exist for the astromechanics controller, as well as other commands to get serial numbers and library/hardware versions. However, as they are marked with the decorator @abstractmethod, we have to override them.
Astromechanics focuser are currently very slow to respond to position queries. When they do respond, they give the exact position that was requested by the last move_to command (i.e. there is no reported position error). We can therefore avoid such queries by storing the current position in memory.
- property max_position¶
Returns position of far limit of focus travel, in encoder units.
- property min_position¶
Returns position of close limit of focus travel, in encoder units.
- move_by(increment)[source]¶
Move focuser by a given amount. Does not do any checking of the requested increment but will warn if the lens reports hitting a stop. :param increment: distance to move the focuser, in encoder units. :type increment: int
- Returns:
focuser position following the move, in encoder units.
- Return type:
- move_to(position)[source]¶
Moves focuser to a new position. Does not do any checking of the requested position but will warn if the lens reports hitting a stop. :param position: new focuser position, in encoder units. :type position: int
- Returns:
focuser position following the move, in encoder units.
- Return type:
panoptes.pocs.focuser.birger module¶
Birger Engineering Canon EF-232 focuser driver.
Provides a Focuser implementation that controls Canon EF/EF-S lenses via the Birger EF-232 adapter over a serial connection, implementing the AbstractSerialFocuser protocol used by POCS.
- class panoptes.pocs.focuser.birger.Focuser(name='Birger Focuser', model='Canon EF-232', max_command_retries=5, baudrate=115200, **kwargs)[source]¶
Bases:
AbstractSerialFocuserFocuser class for control of a Canon DSLR lens via a Birger Engineering Canon EF-232 adapter.
- connect(port, baudrate, **kwargs)[source]¶
Connect to the Birger focuser. :param port: The serial port. :type port: int :param baudrate: The baudrate of the serial device. :type baudrate: int :param **kwargs: Parsed to super().connect
- property firmware_version¶
Returns the version string of the Birger adaptor library (firmware).
- property hardware_version¶
Returns the hardware version of the Birger adaptor.
- property lens_info¶
Return basic lens info (e.g. ‘400mm,f28’ for a 400 mm f/2.8 lens).
- property max_position¶
Returns position of far limit of focus travel, in encoder units.
- property min_position¶
Returns position of close limit of focus travel, in encoder units.
- move_by(increment)[source]¶
Move focuser by a given amount. Does not do any checking of the requested increment but will warn if the lens reports hitting a stop. :param increment: distance to move the focuser, in encoder units. :type increment: int
- Returns:
focuser position following the move, in encoder units.
- Return type:
- move_to(position)[source]¶
Moves focuser to a new position. Does not do any checking of the requested position but will warn if the lens reports hitting a stop. :param position: new focuser position, in encoder units. :type position: int
- Returns:
focuser position following the move, in encoder units.
- Return type:
- property position¶
Returns current focus position in the lens focus encoder units.
panoptes.pocs.focuser.focuser module¶
Abstract focuser base and autofocus helpers.
Defines AbstractFocuser, a hardware-agnostic base with common movement and autofocus utilities shared by concrete focuser drivers (serial, FocusLynx, astromechanics, simulator). Includes methods to sweep focus positions, measure sharpness, and optionally generate diagnostic plots.
- class panoptes.pocs.focuser.focuser.AbstractFocuser(name='Generic Focuser', model='simulator', port=None, camera=None, timeout=5, initial_position=None, autofocus_range=None, autofocus_step=None, autofocus_seconds=None, autofocus_size=None, autofocus_keep_files=None, autofocus_take_dark=None, autofocus_merit_function=None, autofocus_merit_function_kwargs=None, autofocus_mask_dilations=None, autofocus_make_plots=False, *args, **kwargs)[source]¶
Bases:
PanBaseBase class for all focusers.
- Parameters:
name (str, optional) – name of the focuser
model (str, optional) – model of the focuser
port (str, optional) – port the focuser is connected to, e.g. a device node
camera (pocs.camera.Camera, optional) – camera that this focuser is associated with.
timeout (int, optional) – time to wait for response from focuser.
initial_position (int, optional) – if given the focuser will move to this position following initialisation.
autofocus_range ((int, int) optional) – Coarse & fine focus sweep range, in encoder units
autofocus_step ((int, int), optional) – Coarse & fine focus sweep steps, in encoder units
autofocus_seconds (scalar, optional) – Exposure time for focus exposures
autofocus_size (int, optional) – Size of square central region of image to use, default 500 x 500 pixels.
autofocus_keep_files (bool, optional) – If True will keep all images taken during focusing. If False (default) will delete all except the first and last images from each focus run.
autofocus_take_dark (bool, optional) – If True will attempt to take a dark frame before the focus run, and use it for dark subtraction and hot pixel masking, default True.
autofocus_merit_function (str/callable, optional) – Merit function to use as a focus metric, default vollath_F4
autofocus_merit_function_kwargs (dict, optional) – Dictionary of additional keyword arguments for the merit function.
autofocus_mask_dilations (int, optional) – Number of iterations of dilation to perform on the saturated pixel mask (determine size of masked regions), default 10
(bool (autofocus_make_plots) – Whether to write focus plots to images folder, default False.
optional – Whether to write focus plots to images folder, default False.
- autofocus(seconds=None, focus_range=None, focus_step=None, cutout_size=None, keep_files=None, take_dark=None, merit_function=None, merit_function_kwargs=None, mask_dilations=None, coarse=False, make_plots=None, filter_name=None, blocking=False)[source]¶
Focuses the camera using the specified merit function. Optionally performs a coarse focus to find the approximate position of infinity focus, which should be followed by a fine focus before observing.
- Parameters:
seconds (scalar, optional) – Exposure time for focus exposures, if not specified will use value from config.
focus_range (2-tuple, optional) – Coarse & fine focus sweep range, in encoder units. Specify to override values from config.
focus_step (2-tuple, optional) – Coarse & fine focus sweep steps, in encoder units. Specify to override values from config.
cutout_size (int, optional) – Size of square central region of image to use, default 500 x 500 pixels.
keep_files (bool, optional) – If True will keep all images taken during focusing. If False (default) will delete all except the first and last images from each focus run.
take_dark (bool, optional) – If True will attempt to take a dark frame before the focus run, and use it for dark subtraction and hot pixel masking, default True.
merit_function (str/callable, optional) – Merit function to use as a focus metric, default vollath_F4.
merit_function_kwargs (dict, optional) – Dictionary of additional keyword arguments for the merit function.
mask_dilations (int, optional) – Number of iterations of dilation to perform on the saturated pixel mask (determine size of masked regions), default 10
coarse (bool, optional) – Whether to perform a coarse focus, otherwise will perform a fine focus. Default False.
make_plots (bool, optional) – Whether to write focus plots to images folder. If not given will fall back on value of autofocus_make_plots set on initialisation, and if it wasn’t set then will default to False.
filter_name (str, optional) – The filter to use for focusing. If not provided, will use last light position.
blocking (bool, optional) – Whether to block until autofocus complete, default False.
- Returns:
Event that will be set when autofocusing is complete
- Return type:
- Raises:
ValueError – If invalid values are passed for any of the focus parameters.
- property autofocus_error¶
Error message from the most recent autofocus or None, if there was no error.
- property camera¶
Reference to the Camera object that the Focuser is assigned to, if any. A Focuser should only ever be assigned to one or zero Cameras!
- property is_connected¶
Is the focuser available
- property is_ready¶
Whether the focuser is ready for a new move.
- Returns:
True if the focuser is not currently moving.
- Return type:
- abstractmethod min_position()[source]¶
Get position of close limit of focus travel, in encoder units
- property position¶
Current encoder position of the focuser
- property uid¶
A serial number for the focuser
panoptes.pocs.focuser.focuslynx module¶
Optec FocusLynx focuser driver.
Implements control for Optec FocusLynx-compatible focusers (including Focus Boss II) via a serial connection, following the AbstractFocuser interface used by POCS.
- class panoptes.pocs.focuser.focuslynx.Focuser(port, name='FocusLynx Focuser', initial_position=None, focuser_number=1, min_position=0, max_position=None, *args, **kwargs)[source]¶
Bases:
AbstractFocuserFocuser class for control of telescope focusers using the Optec FocusLynx focus controller.
This includes the Starlight Instruments Focus Boss II controller, which is “powered by Optec”
- Parameters:
port (str) – device node of the serial port the focuser controller is connected to, e.g. ‘/dev/ttyUSB0’
name (str, optional) – default ‘FocusLynx Focuser’
initial_position (int, optional) – if given the focuser will drive to this encoder position following initialisation.
focuser_number (int, optional) – for focus controllers that support more than one focuser set this number to specify which focuser should be controlled by this object. Default 1
min_position (int, optional) – minimum allowed focuser position in encoder units, default 0
max_position (int, optional) – maximum allowed focuser position in encoder units. If not given the value will be taken from the focuser’s internal config.
Additional positional and keyword arguments are passed to the base class, AbstractFocuser. See that class for a complete list.
- connect()[source]¶
Open the serial connection to the FocusLynx controller.
Establishes a 115200 8N1 serial connection to the configured port and assigns the handle to self._serial_port. Raises SerialException on failure.
- property firmware_version¶
Firmware version of the focuser controller
- property hardware_version¶
Device type code of the focuser
- property is_connected¶
Checks status of serial port to determine if connected.
- property is_moving¶
True if the focuser is currently moving
- property max_position¶
Position of far limit of focus travel, in encoder units
- property min_position¶
Position of close limit of focus travel, in encoder units
- move_by(increment, blocking=True)[source]¶
Moves focuser by a given amount.
- Parameters:
- Returns:
- focuser position following the move. If blocking is True this will be the actual
focuser position, if False it will be the target position.
- Return type:
- move_to(position, blocking=True)[source]¶
Moves focuser to a new position.
- Parameters:
- Returns:
- focuser position following the move. If blocking is True this will be the actual
focuser position, if False it will be the target position.
- Return type:
- property position¶
Current focus position in encoder units
- property temperature¶
Current temperature of the focuser, in degrees Celsus, as an astropy.units.Quantity
- property uid¶
The user set ‘nickname’ of the focuser. Must be <= 16 characters
panoptes.pocs.focuser.serial module¶
Abstract serial focuser base.
Provides AbstractSerialFocuser, a small helper that wires up a SerialData connection and common connect/reconnect/cleanup behavior for serial-backed focusers.
- class panoptes.pocs.focuser.serial.AbstractSerialFocuser(baudrate=None, initial_position=None, *args, **kwargs)[source]¶
Bases:
AbstractFocuserBase class for serial-connected focusers.
Handles serial port lifecycle and basic movement flags shared by concrete serial focusers; concrete subclasses must implement _initialize().
- connect(*args, **kwargs)[source]¶
Connect to the serial device. :param *args: Parsed to SerialData. :param **kwargs: Parsed to SerialData.
- property is_connected¶
True if the focuser serial device is currently connected.
- property is_moving¶
True if the focuser is currently moving.
panoptes.pocs.focuser.simulator module¶
Simple focuser simulator for development and tests.
Implements a minimal AbstractFocuser that fakes connection and movement timing without requiring hardware.
- class panoptes.pocs.focuser.simulator.Focuser(name='Simulated Focuser', port='/dev/ttyFAKE', *args, **kwargs)[source]¶
Bases:
AbstractFocuserSimple focuser simulator
- property is_moving¶
Whether the simulated focuser is moving.
- Returns:
True if a simulated move is in progress.
- Return type:
- property max_position¶
Returns position of far limit of focus travel, in encoder units
- property min_position¶
Returns position of close limit of focus travel, in encoder units