panoptes / POCS

An Observatory Control System for the PANOPTES citizen-science project designed to help find transiting exoplanets! :telescope: :stars:
https://pocs.readthedocs.io/en/latest/
MIT License
80 stars 49 forks source link

Remote Camera Service #1137

Closed wtgee closed 3 years ago

wtgee commented 3 years ago

A simple camera service that wraps the gphoto2 command. Currently just supports the simple taking of a picture via a POST.

Description

The service is a fastapi service that is capable of simple picture taking. The service accepts a POST request defined by the following pydantic class:

class Exposure(BaseModel):
    exptime: float
    filename: Optional[str] = None
    base_dir: Path = '.'
    iso: int = 100

If the filename is not provided it will default to a timestamp. exptime is required and the given value will first be checked if it corresponds to a built-in shutter speed, in which case that shutter speed will be used directly, otherwise a manual bulb setting will be used. exptime is a float so to use, for example the 1/4000 shutter speed index the value of 0.00025 should be given.

Since fastapi is used there is built in documentation available. The endpoints will attempt to mimic the Alpaca API although it deviates from this implementation and may be changed in the future. Currently the only supported endpoint is /camera/{camera_number}/startexposure which accepts the above.

The service will currently block until exposure is complete although there are plans to change this going forward.

Examples:

These examples assume the service is running on the localhost on port 8080. A Dockerfile and docker-compose is provided.

From python:

import requests

camera_host = 'http://localhost'
camera_port = 8080
camera_num = 0

camera_url = f'{camera_host}:{camera_port}/camera/{camera_num}/startexposure'

exptime = 4
save_dir = '/images'
response = requests.post(camera_url, json=dict(exptime=exptime, base_dir=save_dir, iso=400))

From command line (via httpie):

http :8080/camera/0/startexposure exptime=4 base_dir=/images

Related Issue

1112

786

747

/gcbrun

codecov[bot] commented 3 years ago

Codecov Report

Merging #1137 (0b00b5f) into develop (713e08d) will increase coverage by 0.23%. The diff coverage is 61.80%.

:exclamation: Current head 0b00b5f differs from pull request most recent head e44fb80. Consider uploading reports for the commit e44fb80 to get more accurate results Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1137      +/-   ##
===========================================
+ Coverage    83.22%   83.45%   +0.23%     
===========================================
  Files           82       87       +5     
  Lines         7040     7392     +352     
  Branches       608      629      +21     
===========================================
+ Hits          5859     6169     +310     
- Misses        1011     1051      +40     
- Partials       170      172       +2     
Impacted Files Coverage Δ
src/panoptes/pocs/camera/gphoto/base.py 100.00% <ø> (ø)
src/panoptes/pocs/sensor/remote.py 85.00% <ø> (ø)
src/panoptes/pocs/utils/logger.py 100.00% <ø> (ø)
tests/scheduler/test_base_scheduler.py 100.00% <ø> (ø)
tests/scheduler/test_dispatch_scheduler.py 94.11% <ø> (ø)
src/panoptes/pocs/mount/ioptron/ieq30pro.py 19.49% <5.88%> (+0.68%) :arrow_up:
src/panoptes/pocs/focuser/astromechanics.py 32.14% <25.00%> (+5.02%) :arrow_up:
src/panoptes/pocs/focuser/serial.py 46.93% <30.76%> (+23.12%) :arrow_up:
src/panoptes/pocs/sensor/power.py 41.97% <39.53%> (ø)
src/panoptes/pocs/mount/ioptron/cem40.py 40.34% <44.24%> (+13.14%) :arrow_up:
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2341ba6...e44fb80. Read the comment docs.

wtgee commented 3 years ago

Closing in favor of #1144.