pyobs-sbig 2.0.0.dev8__tar.gz → 2.0.0.dev9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyobs_sbig-2.0.0.dev9/.github/workflows/dependabot-automerge.yml +24 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/PKG-INFO +3 -3
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/pyproject.toml +3 -3
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/pyobs_sbig/gui.py +36 -13
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/pyobs_sbig/sbig6303e.py +1 -1
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/pyobs_sbig/sbigcamera.py +119 -102
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/pyobs_sbig/sbigfiltercamera.py +36 -38
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/pyobs_sbig/sbigudrv.pyx +17 -0
- pyobs_sbig-2.0.0.dev9/tests/test_sbigfiltercamera.py +55 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/uv.lock +6 -6
- pyobs_sbig-2.0.0.dev8/tests/test_sbigfiltercamera.py +0 -30
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/.github/dependabot.yml +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/.github/workflows/pypi.yml +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/.github/workflows/pyrefly.yml +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/.github/workflows/pytest.yml +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/.github/workflows/ruff.yml +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/.pre-commit-config.yaml +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/.readthedocs.yml +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/CHANGELOG.rst +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/CMakeLists.txt +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/LICENSE +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/README.md +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/docs/Makefile +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/docs/make.bat +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/docs/requirements.txt +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/docs/source/_static/pyobs.gif +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/docs/source/conf.py +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/docs/source/index.rst +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/lib/libsbigudrv.so +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/pyobs_sbig/__init__.py +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/pyobs_sbig/sbigudrv.pxd +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/sbigudrv/csbigcam.cpp +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/sbigudrv/csbigcam.h +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/sbigudrv/csbigimg.cpp +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/sbigudrv/csbigimg.h +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/sbigudrv/lpardrv.h +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/src/sbigudrv/sbigudrv.h +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/tests/test_import.py +0 -0
- {pyobs_sbig-2.0.0.dev8 → pyobs_sbig-2.0.0.dev9}/tests/test_sbigcamera.py +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Dependabot auto-merge
|
|
2
|
+
|
|
3
|
+
on: pull_request
|
|
4
|
+
|
|
5
|
+
permissions:
|
|
6
|
+
contents: write
|
|
7
|
+
pull-requests: write
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
dependabot:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
|
|
13
|
+
steps:
|
|
14
|
+
- name: Fetch Dependabot metadata
|
|
15
|
+
id: metadata
|
|
16
|
+
uses: dependabot/fetch-metadata@v2
|
|
17
|
+
with:
|
|
18
|
+
compat-lookup: true
|
|
19
|
+
- name: Enable auto-merge for patch and minor updates
|
|
20
|
+
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' }}
|
|
21
|
+
run: gh pr merge --auto --merge "$PR_URL"
|
|
22
|
+
env:
|
|
23
|
+
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
24
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyobs-sbig
|
|
3
|
-
Version: 2.0.0.
|
|
3
|
+
Version: 2.0.0.dev9
|
|
4
4
|
Summary: pyobs module for SBIG cameras
|
|
5
5
|
Author-Email: Tim-Oliver Husser <thusser@uni-goettingen.de>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Requires-Python: >=3.11
|
|
8
8
|
Requires-Dist: astropy<8,>=7.0.1
|
|
9
9
|
Requires-Dist: numpy<3,>=2.2.5
|
|
10
|
-
Requires-Dist: pyobs-core<3,>=2.0.0.
|
|
10
|
+
Requires-Dist: pyobs-core<3,>=2.0.0.dev82
|
|
11
11
|
Provides-Extra: gui
|
|
12
|
-
Requires-Dist: pyobs-core[gui]<3,>=2.0.0.
|
|
12
|
+
Requires-Dist: pyobs-core[gui]<3,>=2.0.0.dev82; extra == "gui"
|
|
13
13
|
Requires-Dist: qasync>=0.28.0; extra == "gui"
|
|
14
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pyobs-sbig"
|
|
3
|
-
version = "2.0.0.
|
|
3
|
+
version = "2.0.0.dev9"
|
|
4
4
|
description = "pyobs module for SBIG cameras"
|
|
5
5
|
authors = [{ name = "Tim-Oliver Husser", email = "thusser@uni-goettingen.de" }]
|
|
6
6
|
requires-python = ">=3.11"
|
|
@@ -8,12 +8,12 @@ license = "MIT"
|
|
|
8
8
|
dependencies = [
|
|
9
9
|
"astropy>=7.0.1,<8",
|
|
10
10
|
"numpy>=2.2.5,<3",
|
|
11
|
-
"pyobs-core>=2.0.0.
|
|
11
|
+
"pyobs-core>=2.0.0.dev82,<3",
|
|
12
12
|
]
|
|
13
13
|
|
|
14
14
|
[project.optional-dependencies]
|
|
15
15
|
gui = [
|
|
16
|
-
"pyobs-core[gui]>=2.0.0.
|
|
16
|
+
"pyobs-core[gui]>=2.0.0.dev82,<3",
|
|
17
17
|
"qasync>=0.28.0",
|
|
18
18
|
]
|
|
19
19
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import sys
|
|
3
|
+
import time
|
|
3
4
|
|
|
4
5
|
import qasync # type: ignore
|
|
5
6
|
from astropy.io import fits
|
|
@@ -54,26 +55,45 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
54
55
|
|
|
55
56
|
@qasync.asyncSlot() # type: ignore
|
|
56
57
|
async def _expose_clicked(self) -> None:
|
|
58
|
+
# get current binning from the widget
|
|
59
|
+
binning = self.binning_widget._binnings[self.binning_widget.combo_binnings.currentIndex()]
|
|
60
|
+
|
|
57
61
|
# init image
|
|
58
62
|
self._img.image_can_close = False
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
self._cam.exposure_time = self.exposure_time.value
|
|
62
|
-
self._cam.window = self.window_widget.values
|
|
63
|
-
self._cam.binning = (1, 1)
|
|
64
|
-
|
|
65
|
-
# start exposure
|
|
66
|
-
self._cam.start_exposure(self._img, False)
|
|
64
|
+
loop = asyncio.get_running_loop()
|
|
67
65
|
|
|
68
|
-
#
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
# set exposure time, window and binning, then start the exposure off the Qt thread
|
|
67
|
+
def _start() -> None:
|
|
68
|
+
self._cam.exposure_time = self.exposure_time.value
|
|
69
|
+
self._cam.window = self.window_widget.values
|
|
70
|
+
self._cam.binning = binning
|
|
71
|
+
self._cam.start_exposure(self._img, False)
|
|
72
|
+
|
|
73
|
+
self.abort_exposure.clear()
|
|
74
|
+
await loop.run_in_executor(None, _start)
|
|
75
|
+
|
|
76
|
+
# wait for it off the Qt thread, checking the abort event
|
|
77
|
+
def _wait() -> bool:
|
|
78
|
+
while not self._cam.has_exposure_finished():
|
|
79
|
+
if self.abort_exposure.is_set():
|
|
80
|
+
return True
|
|
81
|
+
time.sleep(0.01)
|
|
82
|
+
return False
|
|
83
|
+
|
|
84
|
+
aborted = await loop.run_in_executor(None, _wait)
|
|
85
|
+
|
|
86
|
+
if aborted:
|
|
87
|
+
# abort the exposure in the camera
|
|
88
|
+
await loop.run_in_executor(None, self._cam.end_exposure)
|
|
89
|
+
self._img.image_can_close = True
|
|
90
|
+
self.expose.set_exposures_left()
|
|
91
|
+
return
|
|
71
92
|
|
|
72
93
|
# finish exposure
|
|
73
|
-
self._cam.end_exposure
|
|
94
|
+
await loop.run_in_executor(None, self._cam.end_exposure)
|
|
74
95
|
|
|
75
96
|
# wait for readout
|
|
76
|
-
loop = asyncio.get_running_loop()
|
|
77
97
|
await loop.run_in_executor(None, self._cam.readout, self._img, False)
|
|
78
98
|
|
|
79
99
|
# finalize image
|
|
@@ -89,7 +109,10 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
89
109
|
@qasync.asyncSlot() # type: ignore
|
|
90
110
|
async def _abort_clicked(self) -> None:
|
|
91
111
|
self.abort_exposure.set()
|
|
92
|
-
|
|
112
|
+
|
|
113
|
+
def closeEvent(self, event) -> None: # type: ignore[override]
|
|
114
|
+
self._cam.close()
|
|
115
|
+
super().closeEvent(event)
|
|
93
116
|
|
|
94
117
|
|
|
95
118
|
async def async_main(app: QtWidgets.QApplication) -> None:
|
|
@@ -18,7 +18,7 @@ class Sbig6303eCamera(SbigFilterCamera):
|
|
|
18
18
|
"""Actually do the exposure, should be implemented by derived classes.
|
|
19
19
|
|
|
20
20
|
Args:
|
|
21
|
-
exposure_time: The requested exposure time in
|
|
21
|
+
exposure_time: The requested exposure time in seconds.
|
|
22
22
|
open_shutter: Whether or not to open the shutter.
|
|
23
23
|
abort_event: Event that gets triggered when exposure should be aborted.
|
|
24
24
|
|
|
@@ -54,6 +54,10 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
|
|
|
54
54
|
# active lock
|
|
55
55
|
self._lock_active = asyncio.Lock()
|
|
56
56
|
|
|
57
|
+
# shared lock guarding all access to the non-reentrant CSBIGCam object, so an exposure and
|
|
58
|
+
# a filter move (which uses its own _lock_motion) can never overlap on the same driver
|
|
59
|
+
self._lock_cam = asyncio.Lock()
|
|
60
|
+
|
|
57
61
|
# cooling
|
|
58
62
|
self._setpoint = setpoint
|
|
59
63
|
|
|
@@ -163,6 +167,17 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
|
|
|
163
167
|
)
|
|
164
168
|
await self.comm.set_state(IBinning, BinningState(x=self._binning[0], y=self._binning[1]))
|
|
165
169
|
|
|
170
|
+
async def close(self) -> None:
|
|
171
|
+
"""Close module and release the camera link."""
|
|
172
|
+
await BaseCamera.close(self)
|
|
173
|
+
|
|
174
|
+
# take the same lock _expose()/set_filter() use, so close can't tear down the driver
|
|
175
|
+
# out from under a live exposure or filter move
|
|
176
|
+
async with self._lock_cam:
|
|
177
|
+
# release the SBIG device/driver link
|
|
178
|
+
if not await self._run_blocking(self._cam.close):
|
|
179
|
+
log.error("Timed out closing SBIG camera after %.1fs.", _SDK_CALL_TIMEOUT)
|
|
180
|
+
|
|
166
181
|
async def set_window(self, left: int, top: int, width: int, height: int, **kwargs: Any) -> None:
|
|
167
182
|
"""Set the camera window.
|
|
168
183
|
|
|
@@ -180,7 +195,7 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
|
|
|
180
195
|
"""Actually do the exposure, should be implemented by derived classes.
|
|
181
196
|
|
|
182
197
|
Args:
|
|
183
|
-
exposure_time: The requested exposure time in
|
|
198
|
+
exposure_time: The requested exposure time in seconds.
|
|
184
199
|
open_shutter: Whether or not to open the shutter.
|
|
185
200
|
abort_event: Event that gets triggered when exposure should be aborted.
|
|
186
201
|
|
|
@@ -191,107 +206,109 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
|
|
|
191
206
|
pyobs.utils.exceptions.GrabImageError: If exposure was not successful.
|
|
192
207
|
"""
|
|
193
208
|
|
|
194
|
-
async with self.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
209
|
+
async with self._lock_cam:
|
|
210
|
+
async with self._lock_active:
|
|
211
|
+
# binning
|
|
212
|
+
binning = self._binning
|
|
213
|
+
|
|
214
|
+
# set window, CSBIGCam expects left/top also in binned coordinates, so divide by binning
|
|
215
|
+
left = int(math.floor(self._window[0]) / binning[0])
|
|
216
|
+
top = int(math.floor(self._window[1]) / binning[1])
|
|
217
|
+
width = int(math.floor(self._window[2]) / binning[0])
|
|
218
|
+
height = int(math.floor(self._window[3]) / binning[1])
|
|
219
|
+
log.info(
|
|
220
|
+
"Set window to %dx%d (binned %dx%d) at %d,%d.",
|
|
221
|
+
self._window[2],
|
|
222
|
+
self._window[3],
|
|
223
|
+
width,
|
|
224
|
+
height,
|
|
225
|
+
left,
|
|
226
|
+
top,
|
|
227
|
+
)
|
|
228
|
+
window = (left, top, width, height)
|
|
229
|
+
|
|
230
|
+
# get date obs
|
|
231
|
+
log.info("Starting exposure with for %.2f seconds...", exposure_time)
|
|
232
|
+
date_obs = datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%S.%f")
|
|
233
|
+
|
|
234
|
+
def _start() -> None:
|
|
235
|
+
# init image
|
|
236
|
+
self._img.image_can_close = False
|
|
237
|
+
|
|
238
|
+
# set exposure time, window and binning
|
|
239
|
+
self._cam.exposure_time = exposure_time
|
|
240
|
+
self._cam.window = window
|
|
241
|
+
self._cam.binning = binning
|
|
242
|
+
|
|
243
|
+
# start exposure
|
|
244
|
+
self._cam.start_exposure(self._img, open_shutter)
|
|
245
|
+
|
|
246
|
+
await self._run_blocking_or_raise(_start)
|
|
247
|
+
|
|
248
|
+
# wait for it -- runs the whole poll loop as a single blocking call (see
|
|
249
|
+
# _run_blocking), rather than polling has_exposure_finished() every 10ms directly
|
|
250
|
+
# on the event loop
|
|
251
|
+
def _wait() -> bool:
|
|
252
|
+
while not self._cam.has_exposure_finished():
|
|
253
|
+
if abort_event.is_set():
|
|
254
|
+
return True
|
|
255
|
+
time.sleep(0.01)
|
|
256
|
+
return False
|
|
257
|
+
|
|
258
|
+
exposure_timeout = exposure_time + _EXPOSURE_WAIT_MARGIN
|
|
259
|
+
aborted = await self._run_blocking_or_raise(_wait, timeout=exposure_timeout)
|
|
260
|
+
if aborted:
|
|
261
|
+
raise exc.AbortedError("Exposure aborted.")
|
|
262
|
+
|
|
263
|
+
# finish exposure
|
|
264
|
+
await self._run_blocking_or_raise(self._cam.end_exposure)
|
|
265
|
+
|
|
266
|
+
# wait for readout
|
|
267
|
+
log.info("Exposure finished, reading out...")
|
|
268
|
+
await self._change_exposure_status(ExposureStatus.READOUT)
|
|
269
|
+
|
|
270
|
+
# start readout (can raise ValueError)
|
|
271
|
+
loop = asyncio.get_running_loop()
|
|
272
|
+
await loop.run_in_executor(None, self._cam.readout, self._img, open_shutter)
|
|
273
|
+
|
|
274
|
+
# finalize image
|
|
275
|
+
self._img.image_can_close = True
|
|
276
|
+
|
|
277
|
+
# download data
|
|
278
|
+
data = self._img.data
|
|
279
|
+
|
|
280
|
+
# temp & cooling
|
|
281
|
+
def _get_cooling() -> tuple[Any, float, float, Any]:
|
|
282
|
+
return self._cam.get_cooling()
|
|
283
|
+
|
|
284
|
+
_, temp, setpoint, _ = await self._run_blocking_or_raise(_get_cooling)
|
|
285
|
+
|
|
286
|
+
# create FITS image and set header
|
|
287
|
+
img = Image(data)
|
|
288
|
+
img.header["DATE-OBS"] = (date_obs, "Date and time of start of exposure")
|
|
289
|
+
img.header["EXPTIME"] = (exposure_time, "Exposure time [s]")
|
|
290
|
+
img.header["DET-TEMP"] = (temp, "CCD temperature [C]")
|
|
291
|
+
img.header["DET-TSET"] = (setpoint, "Cooler setpoint [C]")
|
|
292
|
+
|
|
293
|
+
# binning
|
|
294
|
+
img.header["XBINNING"] = img.header["DET-BIN1"] = (self._binning[0], "Binning factor used on X axis")
|
|
295
|
+
img.header["YBINNING"] = img.header["DET-BIN2"] = (self._binning[1], "Binning factor used on Y axis")
|
|
296
|
+
|
|
297
|
+
# window
|
|
298
|
+
img.header["XORGSUBF"] = (self._window[0], "Subframe origin on X axis")
|
|
299
|
+
img.header["YORGSUBF"] = (self._window[1], "Subframe origin on Y axis")
|
|
300
|
+
|
|
301
|
+
# statistics
|
|
302
|
+
img.header["DATAMIN"] = (float(np.min(data)), "Minimum data value")
|
|
303
|
+
img.header["DATAMAX"] = (float(np.max(data)), "Maximum data value")
|
|
304
|
+
img.header["DATAMEAN"] = (float(np.mean(data)), "Mean data value")
|
|
305
|
+
|
|
306
|
+
# biassec/trimsec
|
|
307
|
+
self.set_biassec_trimsec(img.header, *self._full_frame)
|
|
308
|
+
|
|
309
|
+
# return FITS image
|
|
310
|
+
log.info("Readout finished.")
|
|
311
|
+
return img
|
|
295
312
|
|
|
296
313
|
async def _abort_exposure(self) -> None:
|
|
297
314
|
"""Abort the running exposure. Should be implemented by derived class.
|
|
@@ -22,7 +22,7 @@ log = logging.getLogger(__name__)
|
|
|
22
22
|
_FILTER_WAIT_TIMEOUT = 30.0
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
class SbigFilterCamera(
|
|
25
|
+
class SbigFilterCamera(SbigCamera, MotionStatusMixin, IFilters):
|
|
26
26
|
"""A pyobs module for SBIG cameras."""
|
|
27
27
|
|
|
28
28
|
__module__ = "pyobs_sbig"
|
|
@@ -33,7 +33,7 @@ class SbigFilterCamera(MotionStatusMixin, SbigCamera, IFilters):
|
|
|
33
33
|
Args:
|
|
34
34
|
filter_names: List of filter names.
|
|
35
35
|
"""
|
|
36
|
-
|
|
36
|
+
super().__init__(motion_status_interfaces=["IFilters"], **kwargs)
|
|
37
37
|
from .sbigudrv import FilterWheelModel, FilterWheelPosition # type: ignore
|
|
38
38
|
|
|
39
39
|
# filter wheel
|
|
@@ -53,9 +53,6 @@ class SbigFilterCamera(MotionStatusMixin, SbigCamera, IFilters):
|
|
|
53
53
|
# current position
|
|
54
54
|
self._position = FilterWheelPosition.UNKNOWN
|
|
55
55
|
|
|
56
|
-
# init mixins
|
|
57
|
-
MotionStatusMixin.__init__(self, **kwargs, motion_status_interfaces=["IFilters"])
|
|
58
|
-
|
|
59
56
|
async def open(self) -> None:
|
|
60
57
|
"""Open module.
|
|
61
58
|
|
|
@@ -108,7 +105,7 @@ class SbigFilterCamera(MotionStatusMixin, SbigCamera, IFilters):
|
|
|
108
105
|
"""Actually do the exposure, should be implemented by derived classes.
|
|
109
106
|
|
|
110
107
|
Args:
|
|
111
|
-
exposure_time: The requested exposure time in
|
|
108
|
+
exposure_time: The requested exposure time in seconds.
|
|
112
109
|
open_shutter: Whether or not to open the shutter.
|
|
113
110
|
abort_event: Event that gets triggered when exposure should be aborted.
|
|
114
111
|
|
|
@@ -160,38 +157,39 @@ class SbigFilterCamera(MotionStatusMixin, SbigCamera, IFilters):
|
|
|
160
157
|
# set status
|
|
161
158
|
await self._change_motion_status(MotionStatus.SLEWING, interface="IFilters")
|
|
162
159
|
|
|
163
|
-
# acquire lock
|
|
164
|
-
async with
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
160
|
+
# acquire the shared camera lock (so the move can't overlap an exposure) and the motion lock
|
|
161
|
+
async with self._lock_cam:
|
|
162
|
+
async with LockWithAbort(self._lock_motion, self._abort_motion):
|
|
163
|
+
# set it
|
|
164
|
+
log.info("Changing filter to %s...", filter_name)
|
|
165
|
+
target = filters[filter_name]
|
|
166
|
+
|
|
167
|
+
def _set_filter() -> None:
|
|
168
|
+
self._cam.set_filter(target)
|
|
169
|
+
|
|
170
|
+
await self._run_blocking_or_raise(_set_filter)
|
|
171
|
+
|
|
172
|
+
# wait for it -- runs the whole poll loop as a single blocking call (see
|
|
173
|
+
# SbigCamera._run_blocking), rather than polling get_filter_position_and_status()
|
|
174
|
+
# every 100ms directly on the event loop
|
|
175
|
+
def _wait() -> bool:
|
|
176
|
+
while True:
|
|
177
|
+
position, status = self._cam.get_filter_position_and_status()
|
|
178
|
+
if position == target and status == FilterWheelStatus.IDLE:
|
|
179
|
+
return False
|
|
180
|
+
if self._abort_motion.is_set():
|
|
181
|
+
return True
|
|
182
|
+
time.sleep(0.1)
|
|
183
|
+
|
|
184
|
+
aborted = await self._run_blocking_or_raise(_wait, timeout=_FILTER_WAIT_TIMEOUT)
|
|
185
|
+
if aborted:
|
|
186
|
+
raise exc.AbortedError("Filter change aborted.")
|
|
187
|
+
|
|
188
|
+
# update cached position and publish new state
|
|
189
|
+
self._position = target
|
|
190
|
+
log.info("Filter changed.")
|
|
191
|
+
await self.comm.send_event(FilterChangedEvent(filter_name))
|
|
192
|
+
await self.comm.set_state(IFilters, FilterState(filter=filter_name))
|
|
195
193
|
|
|
196
194
|
# set status
|
|
197
195
|
await self._change_motion_status(MotionStatus.POSITIONED, interface="IFilters")
|
|
@@ -72,6 +72,10 @@ cdef class SBIGImg:
|
|
|
72
72
|
def __cinit__(self):
|
|
73
73
|
self.obj = new CSBIGImg()
|
|
74
74
|
|
|
75
|
+
def __dealloc__(self):
|
|
76
|
+
if self.obj != NULL:
|
|
77
|
+
del self.obj
|
|
78
|
+
|
|
75
79
|
@property
|
|
76
80
|
def image_can_close(self) -> bool:
|
|
77
81
|
return self.obj.GetImageCanClose()
|
|
@@ -109,6 +113,19 @@ cdef class SBIGCam:
|
|
|
109
113
|
self.aborted = False
|
|
110
114
|
self.lock = threading.Lock()
|
|
111
115
|
|
|
116
|
+
def __dealloc__(self):
|
|
117
|
+
if self.obj != NULL:
|
|
118
|
+
del self.obj
|
|
119
|
+
|
|
120
|
+
def close(self):
|
|
121
|
+
"""Close the camera device and driver.
|
|
122
|
+
|
|
123
|
+
The C++ destructor does this too (via __dealloc__), but closing explicitly lets callers
|
|
124
|
+
release the link without waiting for the GC to collect the object.
|
|
125
|
+
"""
|
|
126
|
+
self.obj.CloseDevice()
|
|
127
|
+
self.obj.CloseDriver()
|
|
128
|
+
|
|
112
129
|
def establish_link(self):
|
|
113
130
|
res = self.obj.EstablishLink()
|
|
114
131
|
if res != 0:
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Unit tests for the non-hardware logic in SbigFilterCamera: filter-name mapping
|
|
2
|
+
and set_filter validation.
|
|
3
|
+
|
|
4
|
+
The SBIG Universal Driver is mocked out / not touched; only the name<->position
|
|
5
|
+
mapping and validation are exercised.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
from pyobs.utils import exceptions as exc
|
|
10
|
+
from pyobs.utils.enums import MotionStatus
|
|
11
|
+
|
|
12
|
+
from pyobs_sbig import SbigFilterCamera
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_constructor_threads_kwargs_cooperatively() -> None:
|
|
16
|
+
"""Locks in the cooperative-super()-chain conversion: SbigFilterCamera(MotionStatusMixin,
|
|
17
|
+
SbigCamera, ...) used to call SbigCamera.__init__() then a separate, redundant
|
|
18
|
+
MotionStatusMixin.__init__(self, **kwargs, motion_status_interfaces=[...]).
|
|
19
|
+
|
|
20
|
+
Unlike the equivalent fix in pyobs-alpaca/pyobs-brot/pyobs-iagvt, there's no kwarg that
|
|
21
|
+
demonstrates a "raises pre-fix, passes post-fix" regression here: motion_status_interfaces
|
|
22
|
+
is the only kwarg MotionStatusMixin's chain needs and it's hardcoded at the call site, so a
|
|
23
|
+
caller passing it explicitly collides (`got multiple values`) both before and after this fix
|
|
24
|
+
rather than leaking. Every other kwarg these live configs set (filter_wheel, filter_names,
|
|
25
|
+
setpoint, fits_headers, comm) is already consumed by SbigCamera's own chain and re-consumes
|
|
26
|
+
cleanly on the old redundant second pass too. This test instead locks in that construction
|
|
27
|
+
with a representative, live-config-shaped kwarg set succeeds and mixin state lands
|
|
28
|
+
correctly -- the actual fix is a correctness/consistency cleanup, not a crash fix, for this
|
|
29
|
+
particular class."""
|
|
30
|
+
camera = SbigFilterCamera(
|
|
31
|
+
filter_wheel="CFW10",
|
|
32
|
+
setpoint=-15.0,
|
|
33
|
+
fits_headers={"DET-PIXL": (0.0054, "Pixel size")},
|
|
34
|
+
comm={"class": "pyobs.comm.dummy.DummyComm"},
|
|
35
|
+
)
|
|
36
|
+
assert camera.motion_status() == MotionStatus.UNKNOWN
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_filter_names_default() -> None:
|
|
40
|
+
camera = SbigFilterCamera(filter_wheel="CFW10")
|
|
41
|
+
assert "UNKNOWN" in camera._filter_names.values()
|
|
42
|
+
assert len(camera._filter_names) == 11 # 10 positions + UNKNOWN
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_filter_names_custom() -> None:
|
|
46
|
+
names = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
|
|
47
|
+
camera = SbigFilterCamera(filter_wheel="CFW10", filter_names=names)
|
|
48
|
+
assert set(names).issubset(set(camera._filter_names.values()))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@pytest.mark.asyncio
|
|
52
|
+
async def test_set_filter_unknown_name() -> None:
|
|
53
|
+
camera = SbigFilterCamera(filter_wheel="CFW10")
|
|
54
|
+
with pytest.raises(exc.InvalidArgumentError):
|
|
55
|
+
await camera.set_filter("does-not-exist")
|
|
@@ -2354,7 +2354,7 @@ wheels = [
|
|
|
2354
2354
|
|
|
2355
2355
|
[[package]]
|
|
2356
2356
|
name = "pyobs-core"
|
|
2357
|
-
version = "2.0.0.
|
|
2357
|
+
version = "2.0.0.dev82"
|
|
2358
2358
|
source = { registry = "https://pypi.org/simple" }
|
|
2359
2359
|
dependencies = [
|
|
2360
2360
|
{ name = "aiohttp" },
|
|
@@ -2386,9 +2386,9 @@ dependencies = [
|
|
|
2386
2386
|
{ name = "tenacity" },
|
|
2387
2387
|
{ name = "typing-extensions" },
|
|
2388
2388
|
]
|
|
2389
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
2389
|
+
sdist = { url = "https://files.pythonhosted.org/packages/13/b8/e0d2a5fa390e15eebd01c86a75360e47e72823036b9e8793f73961c4e24a/pyobs_core-2.0.0.dev82.tar.gz", hash = "sha256:eb5e6510e0ba113700876db409cdce4b5d57e6df399421fc8cf174ec9e5076a8", size = 362959, upload-time = "2026-08-19T04:27:17.94Z" }
|
|
2390
2390
|
wheels = [
|
|
2391
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
2391
|
+
{ url = "https://files.pythonhosted.org/packages/81/17/83f22b85cfd9dea2c18396738d12fcd631232b2e8a111700133b037a7673/pyobs_core-2.0.0.dev82-py3-none-any.whl", hash = "sha256:b0cfe7d7a9dff89a8650ff4c01cdd3423f8ca9188aeef1d799d3e61085484bb2", size = 585768, upload-time = "2026-08-19T04:27:16.531Z" },
|
|
2392
2392
|
]
|
|
2393
2393
|
|
|
2394
2394
|
[package.optional-dependencies]
|
|
@@ -2400,7 +2400,7 @@ gui = [
|
|
|
2400
2400
|
|
|
2401
2401
|
[[package]]
|
|
2402
2402
|
name = "pyobs-sbig"
|
|
2403
|
-
version = "2.0.0.
|
|
2403
|
+
version = "2.0.0.dev9"
|
|
2404
2404
|
source = { editable = "." }
|
|
2405
2405
|
dependencies = [
|
|
2406
2406
|
{ name = "astropy" },
|
|
@@ -2430,8 +2430,8 @@ dev = [
|
|
|
2430
2430
|
requires-dist = [
|
|
2431
2431
|
{ name = "astropy", specifier = ">=7.0.1,<8" },
|
|
2432
2432
|
{ name = "numpy", specifier = ">=2.2.5,<3" },
|
|
2433
|
-
{ name = "pyobs-core", specifier = ">=2.0.0.
|
|
2434
|
-
{ name = "pyobs-core", extras = ["gui"], marker = "extra == 'gui'", specifier = ">=2.0.0.
|
|
2433
|
+
{ name = "pyobs-core", specifier = ">=2.0.0.dev82,<3" },
|
|
2434
|
+
{ name = "pyobs-core", extras = ["gui"], marker = "extra == 'gui'", specifier = ">=2.0.0.dev82,<3" },
|
|
2435
2435
|
{ name = "qasync", marker = "extra == 'gui'", specifier = ">=0.28.0" },
|
|
2436
2436
|
]
|
|
2437
2437
|
provides-extras = ["gui"]
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"""Unit tests for the non-hardware logic in SbigFilterCamera: filter-name mapping
|
|
2
|
-
and set_filter validation.
|
|
3
|
-
|
|
4
|
-
The SBIG Universal Driver is mocked out / not touched; only the name<->position
|
|
5
|
-
mapping and validation are exercised.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import pytest
|
|
9
|
-
from pyobs.utils import exceptions as exc
|
|
10
|
-
|
|
11
|
-
from pyobs_sbig import SbigFilterCamera
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def test_filter_names_default() -> None:
|
|
15
|
-
camera = SbigFilterCamera(filter_wheel="CFW10")
|
|
16
|
-
assert "UNKNOWN" in camera._filter_names.values()
|
|
17
|
-
assert len(camera._filter_names) == 11 # 10 positions + UNKNOWN
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def test_filter_names_custom() -> None:
|
|
21
|
-
names = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
|
|
22
|
-
camera = SbigFilterCamera(filter_wheel="CFW10", filter_names=names)
|
|
23
|
-
assert set(names).issubset(set(camera._filter_names.values()))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@pytest.mark.asyncio
|
|
27
|
-
async def test_set_filter_unknown_name() -> None:
|
|
28
|
-
camera = SbigFilterCamera(filter_wheel="CFW10")
|
|
29
|
-
with pytest.raises(exc.InvalidArgumentError):
|
|
30
|
-
await camera.set_filter("does-not-exist")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|