panoptes.pocs.camera.gphoto package

Submodules

panoptes.pocs.camera.gphoto.base module

Base classes and helpers for DSLR cameras controlled via gphoto2.

Provides AbstractGPhotoCamera, a concrete AbstractCamera subclass that shells out to the system gphoto2 binary for exposure control and property management. This module is used by gphoto-based DSLR drivers.

class panoptes.pocs.camera.gphoto.base.AbstractGPhotoCamera(*arg, **kwargs)[source]

Bases: AbstractCamera, ABC

Abstract camera class that uses gphoto2 interaction.

Parameters:

config (Dict) – Config key/value pairs, defaults to empty dict.

command(cmd: list[str] | str, check_exposing: bool = True)[source]

Run a gphoto2 command and start tracking the subprocess.

Parameters:
  • cmd (list[str] | str) – The gphoto2 arguments to run, e.g., [”–capture-image-and-download”] or a single string.

  • check_exposing (bool) – If True, prevent starting a new command while an exposure command is still running. Defaults to True.

Raises:
Returns:

None

connect()[source]

Connect to the DSLR via gphoto2.

Implementations should validate communication to the camera (e.g., by listing capabilities) and set internal flags required by AbstractCamera.

Raises:

NotImplementedError – This base class does not implement device-specific logic.

property cooling_power

Cooling power level for the camera, if available.

Returns:

DSLRs via gphoto2 typically do not expose cooling power metrics.

Return type:

None

get_command_result(timeout: float = 10) list[str] | None[source]

Retrieve stdout lines from the last gphoto2 subprocess.

Parameters:

timeout (float) – Seconds to wait for the subprocess to finish before killing it and collecting output. Defaults to 10.

Returns:

Lines of stdout from gphoto2, or None if no command

has been initiated.

Return type:

list[str] | None

get_property(prop: str) str[source]

Get a configuration property value from the camera.

Parameters:

prop (str) – The gphoto2 property identifier or label to query.

Returns:

The current value of the requested property (as reported by gphoto2).

Return type:

str

classmethod gphoto_file_download(port: str, filename_pattern: str, only_new: bool = True)[source]

Download files from the camera using gphoto2.

Parameters:
  • port (str) – The gphoto2 port identifier (e.g., “usb:001,005”).

  • filename_pattern (str) – Pattern for naming downloaded files.

  • only_new (bool) – If True, only fetch files not previously downloaded. Defaults to True.

Returns:

The list of file paths reported as saved by gphoto2.

Return type:

list[str]

property is_exposing

Whether a gphoto2 command (exposure) is still running.

Returns:

True if the current exposure subprocess is active.

Return type:

bool

load_properties() dict[source]

Load properties from the camera.

Reads all the configuration properties available via gphoto2 and returns as dictionary.

Returns:

A mapping of property labels to their detailed descriptors as

parsed from gphoto2 output.

Return type:

dict

process_exposure(metadata, **kwargs)[source]

Convert the CR2 to FITS and pass to common processing.

Parameters:
  • metadata (dict) – Header metadata saved for the image.

  • **kwargs – Forwarded to AbstractCamera.process_exposure.

Returns:

None

set_properties(prop2index: dict[str, int] = None, prop2value: dict[str, str] = None)[source]

Sets a number of properties all at once, by index or value.

Parameters:
  • prop2index (dict or None) – A dict with keys corresponding to the property to be set and values corresponding to the index option.

  • prop2value (dict or None) – A dict with keys corresponding to the property to be set and values corresponding to the literal value.

set_property(prop: str, val: str | int, is_value: bool = False, is_index: bool = False)[source]

Set a property on the camera.

Parameters:
  • prop (str) – The property to set.

  • val (str, int) – The value to set the property to.

  • is_value (bool) – If True, then the value is a literal value. Default False.

  • is_index (bool) – If True, then the value is an index. Default False.

Raises:

ValueError – If the property is not found.

classmethod start_tether(port, filename_pattern: str = '%Y%m%dT%H%M%S.%C')[source]

Start a gphoto2 tethering session for auto-download.

Parameters:
  • port (str) – The gphoto2 port identifier, e.g., “usb:001,005”.

  • filename_pattern (str) – The gphoto2 filename pattern to use when saving files (e.g., “%Y%m%dT%H%M%S.%C”). Defaults to that timestamp-based pattern.

Returns:

None

property target_temperature

Target temperature for DSLR sensors (not applicable).

Returns:

DSLRs controlled via gphoto2 generally lack regulated cooling.

Return type:

None

property temperature

Current sensor temperature if available (not typical for DSLRs).

Returns:

gphoto2-controlled DSLRs generally do not report sensor temperature.

Return type:

None

property uid: str

A six-digit serial number for the camera.

Returns:

The first six characters of the camera’s serial number.

Return type:

str

panoptes.pocs.camera.gphoto.canon module

Canon DSLR camera driver using gphoto2.

Provides a concrete Camera subclass for Canon EOS models controlled via gphoto2. Implements exposure sequencing, property setup, and a shutterspeed index helper compatible with the CLI-driven gphoto2 interface.

class panoptes.pocs.camera.gphoto.canon.Camera(readout_time: float = 1.0, file_extension: str = 'cr2', setup_properties: bool = False, *args, **kwargs)[source]

Bases: AbstractGPhotoCamera

Canon EOS DSLR implementation using gphoto2.

Provides Canon-specific property defaults and exposure sequencing on top of AbstractGPhotoCamera.

property bit_depth

ADC bit depth reported by the camera.

Returns:

The analog-to-digital converter resolution in bits.

Return type:

astropy.units.Quantity

connect()[source]

Connect to the camera.

This will attempt to connect to the camera using gphoto2.

property egain

Estimated sensor gain (e-/ADU).

Returns:

Electrons per ADU, used for photometric calibration.

Return type:

astropy.units.Quantity

classmethod get_shutterspeed_index(seconds: float, return_minimum: bool = False)[source]

Look up the gphoto2 shutterspeed index for a given exposure time.

Parameters:
  • seconds (float) – Desired exposure length in seconds.

  • return_minimum (bool) – If True and the requested time is shorter than the minimum supported shutterspeed, return the index of the shortest available speed instead of 0 (bulb). Defaults to False.

Returns:

The index expected by gphoto2 for the nearest matching shutter

speed. Returns 0 to indicate ‘bulb’ when no direct match is found, unless return_minimum is True and the time is below the minimum discrete setting.

Return type:

int

setup_camera()[source]

Set up the camera.

Usually called as part of an initial setup, this will set properties on the canon cameras that should persist across power cycles.

panoptes.pocs.camera.gphoto.remote module

Remote gphoto2 camera wrapper.

Exposes a Camera subclass that delegates gphoto2 commands to a remote HTTP service (panoptes.pocs.utils.service.camera), enabling DSLR control on another host while keeping POCS orchestration local.

class panoptes.pocs.camera.gphoto.remote.Camera(endpoint: AnyHttpUrl = 'http://localhost:6565', *args, **kwargs)[source]

Bases: Camera

A remote gphoto2 camera class.

command(cmd, endpoint: AnyHttpUrl = None)[source]

Run a gphoto2 command on the remote camera service.

Parameters:
  • cmd (list[str] | str) – gphoto2 arguments to execute remotely. If a list is provided it will be joined with spaces for transmission.

  • endpoint (AnyHttpUrl | None) – Optional override for the remote service URL. Defaults to the Camera.endpoint value.

Returns:

None

get_command_result(timeout: float = 10) list[str] | None[source]

Wait for the remote command to finish and return its output.

Parameters:

timeout (float) – Seconds to wait for the remote command to finish before treating it as a timeout. Defaults to 10.

Returns:

Lines of stdout from the remote gphoto2 call, or None if

there was no output.

Return type:

list[str] | None

property is_exposing

Whether a remote exposure command is currently in progress.

Returns:

True if the last remote command is still running.

Return type:

bool

Module contents