panoptes.pocs.mount package

Subpackages

Submodules

panoptes.pocs.mount.bisque module

Bisque/TheSkyX-based mount driver.

Implements a mount driver that communicates with Software Bisque’s TheSkyX via its TCP scripting interface, using small JavaScript templates for commands.

class panoptes.pocs.mount.bisque.Mount(*args, **kwargs)[source]

Bases: AbstractMount

Mount driver that proxies motions and queries to TheSkyX.

Uses small JavaScript template files to issue commands over TheSkyX’s TCP interface and parses JSON-like responses to update status and execute slews.

property at_mount_park

Mount slewing status.

Type:

bool

connect()[source]

Connects to the mount via the serial port (self._port)

Returns:

Returns the self.is_connected property which checks

the actual serial connection.

Return type:

bool

disconnect()[source]

Disconnect from TheSkyX and mark connection closed.

Returns:

True if now disconnected.

Return type:

bool

initialize(unpark=False, *args, **kwargs)[source]

Initialize the connection with the mount and setup for location.

If the mount is successfully initialized, the _setup_location_for_mount method is also called.

Returns:

Returns the value from self.is_initialized.

Return type:

bool

property is_home

Mount home status.

Type:

bool

property is_parked

Mount parked status.

Type:

bool

property is_slewing

Mount slewing status.

Type:

bool

property is_tracking

Mount tracking status.

Type:

bool

move_direction(direction='north', seconds=1.0, arcmin=None, rate=None)[source]

Move mount in specified direction for given amount of seconds

park(timeout=120)[source]

Slews to the park position and parks the mount.

Note

When mount is parked no movement commands will be accepted.

Returns:

indicating success

Return type:

bool

query(*args, **kwargs)[source]

Override the query method to use the command lock.

This is required because TheSkyX cannot handle simulataneous commands. This function will block until the lock is released.

read(timeout=5)[source]

Read and parse a JSON-like response from TheSkyX.

Parameters:

timeout (int) – Seconds to wait for a response before giving up.

Returns:

A best-effort parsed object with ‘response’ and ‘success’ keys.

Return type:

dict

set_park_position()[source]

Send command to set current position as park in TheSkyX.

set_target_coordinates(coords)[source]

Sets the RA and Dec for the mount’s current target.

Parameters:

coords (astropy.coordinates.SkyCoord) – coordinates specifying target location

Returns:

Boolean indicating success

Return type:

bool

slew_to_home(blocking=False, timeout=120)[source]

Slews the mount to the home position.

Note

Home position and Park position are not the same thing

Parameters:
  • blocking (bool, optional) – If command should block while slewing to home, default False.

  • timeout (int, optional) – Timeout in seconds, default 120.

Returns:

indicating success

Return type:

bool

slew_to_target(timeout=120, **kwargs)[source]

Slews to the current _target_coordinates

Returns:

indicating success

Return type:

bool

slew_to_zero(blocking=False)[source]

Calls slew_to_home in base class. Can be overridden.

unpark()[source]

Unparks the mount. Does not do any movement commands but makes them available again.

Returns:

indicating success

Return type:

bool

write(value)[source]

Send a JavaScript command string to TheSkyX.

Parameters:

value (str) – JavaScript to execute on TheSkyX.

Returns:

None

panoptes.pocs.mount.mount module

Abstract base class and helpers for telescope mounts.

Provides AbstractMount, a hardware-agnostic base with common properties (status, tracking, parking, slewing) and orchestration helpers (target handling, coordinate conversion, command table mapping). Concrete mount implementations (iOptron, Bisque, simulator, etc.) subclass this and implement device-specific read/write/query and motion control.

class panoptes.pocs.mount.mount.AbstractMount(location, commands=None, *args, **kwargs)[source]

Bases: PanBase

Abstract Base class for controlling a mount. This provides the basic functionality for the mounts. Sub-classes should override the initialize method for mount-specific issues as well as any helper methods specific mounts might need. See “NotImplemented Methods” section of this module.

Sets the following properties:

  • self.non_sidereal_available = False

  • self.PEC_available = False

  • self._is_initialized = False

Parameters:
  • config (dict) – Custom configuration passed to base mount. This is usually read from the main system config.

  • commands (dict) – Commands for the telescope. These are read from a yaml file that maps the mount-specific commands to common commands.

  • location (EarthLocation) – An astropy.coordinates.EarthLocation that contains location information.

property at_mount_park

True if mount is at park position.

Type:

bool

abstractmethod connect()[source]

Connect to the mount.

correct_tracking(correction_info, axis_timeout=30.0)[source]

Make tracking adjustment corrections.

Parameters:
  • correction_info (dict[tuple]) – Correction info to be applied, see get_tracking_correction.

  • axis_timeout (float, optional) – Timeout for adjustment in each axis, default 30 seconds.

Raises:

error.Timeout – Timeout error.

disconnect()[source]

Disconnect from the mount, parking if necessary.

If the mount is not currently parked this will issue a park command before closing the connection, then mark the connection as closed.

distance_from_target()[source]

Get current distance from target

Returns:

An angle represeting the current on-sky separation from the target

Return type:

u.Angle

get_current_coordinates()[source]

Reads out the current coordinates from the mount.

Note

See _mount_coord_to_skycoord and _skycoord_to_mount_coord for translation of mount specific coordinates to astropy.coordinates.SkyCoord

Returns:

astropy.coordinates.SkyCoord

get_ms_offset(offset, axis='ra')[source]

Get offset in milliseconds at current speed

Parameters:
  • offset (astropy.units.Angle) – Offset in arcseconds

  • axis (str) – The name of the axis to move, default ‘ra’.

Returns:

Offset in milliseconds at current speed

Return type:

astropy.units.Quantity

get_target_coordinates()[source]

Gets the RA and Dec for the mount’s current target. This does NOT necessarily reflect the current position of the mount, see get_current_coordinates.

Return type:

astropy.coordinates.SkyCoord

get_tracking_correction(offset_info, pointing_ha, min_tracking_threshold=None, max_tracking_threshold=None)[source]

Determine the needed tracking corrections from current position.

This method will determine the direction and number of milliseconds to correct the mount for each axis in order to correct for any tracking drift. The Declination axis correction (‘north’ or ‘south’) depends on the movement of the camera box with respect to the pier, which can be determined from the Hour Angle (HA) of the pointing image in the sequence.

Note

Correction values below 50ms will be skipped and values above 99999ms will be clipped.

Parameters:
  • offset_info (OffsetError) – A named tuple describing the offset error. See pocs.images.OffsetError.

  • pointing_ha (float) – The Hour Angle (HA) of the mount at the beginning of the observation sequence in degrees. This affects the direction of the Dec adjustment.

  • min_tracking_threshold (int, optional) – Minimum size of tracking correction allowed in milliseconds. Tracking corrections lower than this are ignored. Default 100ms from self.min_tracking_threshold.

  • max_tracking_threshold (int, optional) – Maximum size of tracking correction allowed in milliseconds. Tracking corrections higher than this are set to this value. Default 99999ms from self.max_tracking_threshold.

Returns:

Offset corrections for each axis as needed. Example:

{

# axis: (arcsec, millisecond, direction) ‘ra’: (float, float, str), ‘dec’: (float, float, str),

}

Return type:

dict

property has_target

Whether a target coordinate has been set for the mount.

Returns:

True if set_target_coordinates has been called successfully.

Return type:

bool

home_and_park(*args, **kwargs)[source]

Convenience method to first slew to the home position and then park.

abstractmethod initialize(*arg, **kwargs)[source]

Initialize the mount hardware and prepare for use.

Subclasses should perform device-specific setup such as establishing communications, homing, and applying any required configuration so the mount is ready to slew and track.

property is_connected

Checks the serial connection on the mount to determine if connection is open

Type:

bool

property is_home

Mount home status.

Type:

bool

property is_initialized

Has mount been initialised with connection

Type:

bool

property is_parked

Mount parked status.

Type:

bool

property is_slewing

Mount slewing status.

Type:

bool

property is_tracking

Mount tracking status.

Type:

bool

property location

The location details for the mount.

When a new location is set,`_setup_location_for_mount` is called, which will update the mount with the current location. It is anticipated the mount won’t change locations while observing so this should only be done upon mount initialization.

Type:

astropy.coordinates.SkyCoord

property mount_version

Mount version

Type:

str

move_direction(direction='north', seconds=1.0)[source]

Move the mount in a specified direction for a duration.

Parameters:
  • direction (str) – One of {“north”, “south”, “east”, “west”} indicating the direction to move.

  • seconds (float) – Duration in seconds to move in the given direction.

Raises:
  • AssertionError – If the provided direction is not valid.

  • Exception – Propagates any low-level I/O exceptions encountered while issuing movement commands to the mount; movement is stopped in the finally block regardless.

property movement_speed

Movement speed when button pressed.

Type:

bool

park(*args, **kwargs)[source]

Slews to the park position and parks the mount.

The park position must be set manually first for this method to work.

Most mount subclasses will override this method to provide mount-specific park functionality.

Note

When mount is parked no movement commands will be accepted.

Returns:

indicating success

Return type:

bool

query(cmd, params=None, **kwargs)[source]

Send a command to the mount and return the response.

The command key is translated to a mount-specific serial command (using the loaded commands YAML), written to the connection, and the response is read back.

Parameters:
  • cmd (str) – Logical command name defined in the mount commands YAML file.

  • params (str | None) – Optional parameter string to include with the command.

  • **kwargs – Additional keyword arguments forwarded to the low-level read() call.

Returns:

The raw response from the mount.

Return type:

str

Raises:
  • AssertionError – If the mount has not been initialized.

  • error.InvalidMountCommand – If the command key is not known.

Examples

>>> from panoptes.pocs.mount import create_mount_from_config
>>> mount = create_mount_from_config()
>>> mount.query('set_local_time', '101503')
'1'
>>> mount.query('get_local_time')
'101503'
abstractmethod read(*args, **kwargs)[source]

Low-level read from the mount connection.

Parameters:
  • *args – Transport-specific positional options (e.g., size).

  • **kwargs – Transport-specific keyword options (e.g., timeout).

Returns:

Raw response string from the device.

Return type:

str

search_for_home()[source]

Search for the home position if supported.

set_target_coordinates(coords)[source]

Sets the RA and Dec for the mount’s current target.

Parameters:

coords (astropy.coordinates.SkyCoord) – coordinates specifying target location

Returns:

Boolean indicating success

Return type:

bool

abstractmethod set_tracking_rate(direction='ra', delta=1.0)[source]

Sets the tracking rate for the mount

slew_to_coordinates(coords, *args, **kwargs)[source]

Slews to given coordinates.

Parameters:

coords (astropy.SkyCoord) – The coordinates to slew to.

Returns:

indicating success

Return type:

bool

slew_to_home(blocking=True, timeout=180)[source]

Slews the mount to the home position.

Note

Home position and Park position are not the same thing

Parameters:
  • blocking (bool, optional) – If command should block while slewing to home, default True.

  • timeout (int, optional) – Maximum time spent slewing to home, default 180 seconds.

Returns:

indicating success

Return type:

bool

slew_to_target(blocking: bool = False, timeout: int | float = 180) bool[source]

Slews to the currently assigned target coordinates.

Slews the mount to the coordinates that have been assigned by ~set_target_coordinates. If no coordinates have been set, do nothing and return False, otherwise return response from the mount.

If blocking=True then wait for up to timeout seconds for the mount to reach the is_tracking state. If a timeout occurs, raise a pocs.error.Timeout exception.

Parameters:
  • blocking (bool, optional) – If command should block while slewing to home, default False.

  • timeout (int, optional) – Maximum time spent slewing to home, default 180 seconds.

Returns:

indicating success

Return type:

bool

slew_to_zero(blocking=False)[source]

Calls slew_to_home in base class. Can be overridden.

property state

Mount state.

Type:

bool

property status

Return a snapshot of current mount parameters and positions.

Returns:

Mapping of basic rates, movement speed, current coordinates

(if available), and target coordinates (if set), augmented by subclass-specific fields from _update_status().

Return type:

dict

property tracking_rate

Mount tracking rate

Type:

bool

unpark()[source]

Unparks the mount. Does not do any movement commands but makes them available again.

Returns:

indicating success

Return type:

bool

update_status()[source]

Thin-wrapper to call the status property.

abstractmethod write(cmd)[source]

Low-level write to the mount connection.

Parameters:

cmd (str) – Fully formatted command string to send to the device.

panoptes.pocs.mount.serial module

Serial-backed mount base class and helpers.

Provides AbstractSerialMount, which opens a configured RS-232 connection and implements common read/write/query helpers reused by concrete serial mounts.

class panoptes.pocs.mount.serial.AbstractSerialMount(location, *args, **kwargs)[source]

Bases: AbstractMount, ABC

Abstract base for mounts controlled via a serial connection.

Handles creating the SerialData connection from configuration and provides default implementations for common connect/read/write helpers.

connect()[source]

Connects to the mount via the serial port (self._port)

Returns:

Returns the self.is_connected property (bool) which checks the actual serial connection.

disconnect()[source]

Disconnect from the serial-connected mount controller.

Closes the underlying serial connection (if open) and updates the connection flag accordingly.

read(*args)[source]

Reads from the serial connection.

Returns:

Response from mount

Return type:

str

set_tracking_rate(direction='ra', delta=0.0)[source]

Set the tracking rate for the mount :param direction: Either ra or dec :type direction: str, optional :param delta: Offset multiple of sidereal rate, defaults to 0.0 :type delta: float, optional

write(cmd)[source]

Sends a string command to the mount via the serial port.

First ‘translates’ the message into the form specific mount can understand using the mount configuration yaml file. This method is most often used from within query and may become a private method in the future.

Note

This command currently does not support the passing of parameters. See query instead.

Parameters:

cmd (str) – A command to send to the mount. This should be one of the commands listed in the mount commands yaml file.

panoptes.pocs.mount.simulator module

Simple in-memory mount simulator for development and tests.

Implements the AbstractMount interface with timed state changes and canned responses so higher-level logic can be exercised without hardware.

class panoptes.pocs.mount.simulator.Mount(location, *args, **kwargs)[source]

Bases: AbstractMount

Mount class for a simulator. Use this when you don’t actually have a mount attached.

connect()[source]

Connect to the simulated mount (instant success).

disconnect()[source]

Disconnect from the simulated mount (instant success).

get_current_coordinates()[source]

Return the simulator’s current coordinates (SkyCoord or None).

get_ms_offset(offset, axis='ra')[source]

Fake offset in milliseconds

Parameters:

offset (astropy.units.Angle) – Offset in arcseconds

Returns:

Offset in milliseconds at current speed

Return type:

astropy.units.Quantity

initialize(unpark=False, *arg, **kwargs)[source]

Initialize the connection with the mount and setup for location.

iOptron mounts are initialized by sending the following two commands to the mount:e

  • Version

  • MountInfo

If the mount is successfully initialized, the _setup_location_for_mount method is also called.

Returns:

Returns the value from self._is_initialized.

Return type:

bool

move_direction(direction='north', seconds=1.0)[source]

Move mount in specified direction for given amount of seconds

park()[source]

Sets the mount to park for simulator

query(cmd, params=None, **kwargs)[source]

Simulate a mount command query.

Parameters:
  • cmd (str) – Logical command name.

  • params (str | dict | None) – Optional parameters for the command.

Returns:

Always True for the simulator; may sleep briefly for actions.

Return type:

bool

read(*args)[source]

Simulate reading a response from the mount (logs only).

set_tracking_rate(direction='ra', delta=0.0)[source]

Set a simulated custom tracking rate.

Parameters:
  • direction (str) – Axis label (‘ra’ or ‘dec’).

  • delta (float) – Offset multiple of sidereal rate.

slew_to_home(blocking=False, timeout=1)[source]

Slews the mount to the home position.

Note

Home position and Park position are not the same thing

Returns:

indicating success

Return type:

bool

slew_to_target(slew_delay=0.5, *args, **kwargs)[source]

Simulate slewing to the current target, then begin tracking.

Parameters:
  • slew_delay (float) – Seconds to wait before setting tracking True.

  • *args – Forwarded to AbstractMount.slew_to_target.

  • **kwargs

    Forwarded to AbstractMount.slew_to_target.

Returns:

True if the superclass slew_to_target reports success.

Return type:

bool

stop_slew(next_position='is_tracking')[source]

Stop slewing and set the next simulated state flag.

Parameters:

next_position (str) – One of ‘is_tracking’, ‘is_home’, etc.; the corresponding private flag will be set to True.

unpark()[source]

Unpark the simulated mount (sets connected and clears parked).

write(cmd)[source]

Simulate writing a command to the mount (logs only).

Module contents

panoptes.pocs.mount.create_mount_from_config(mount_info=None, earth_location=None, *args, **kwargs) AbstractMount[source]

Create a mount instance based on the provided config.

Creates an instance of the AbstractMount sub-class in the module specified in the config. Specifically, the class must be in a file called pocs/mount/<DRIVER_NAME>.py, and the class must be called Mount.

Parameters:
  • mount_info – Optional param which overrides the ‘mount’ entry in config if provided. Useful for testing.

  • earth_locationastropy.coordinates.EarthLocation instance, representing the location of the mount on the Earth. If not specified, the config must include the observatory’s location (Latitude, Longitude and Altitude above mean sea level). Useful for testing.

  • *args – Other positional args will be passed to the concrete class specified in the config.

  • **kwargs – Other keyword args will be passed to the concrete class specified in the config.

Returns:

An instance of the Mount class if the config (or mount_info) is complete. None if neither mount_info nor config[‘mount’] is provided.

Raises:

error.MountNotFound – Exception raised when mount cannot be created because of incorrect configuration.

panoptes.pocs.mount.create_mount_simulator(mount_info=None, earth_location=None, db_type='memory', *args, **kwargs)[source]

Create and return a simulator-backed Mount instance.

Updates the config to point the ‘mount’ section at the simulator driver and constructs a Mount object from panoptes.pocs.mount.simulator using the provided EarthLocation (or one derived from configuration).

Parameters:
  • mount_info (dict | None) – Optional dict to write to the ‘mount’ config. If None, uses a default simulator config pointing at panoptes.pocs.mount.simulator.

  • earth_location (astropy.coordinates.EarthLocation | None) – Site location to pass to the Mount constructor. If None, it is created from configuration via create_location_from_config().

  • db_type (str) – Database backend type for the PanBase used by the Mount (default ‘memory’).

  • *args – Additional positional args forwarded to the simulator Mount constructor.

  • **kwargs – Additional keyword args forwarded to the simulator Mount constructor.

Returns:

A newly constructed simulator Mount instance.

Return type:

AbstractMount