Skip to content

Commit 79f26a1

Browse files
committed
changed to match new interfaces
1 parent 06f290d commit 79f26a1

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

pyobs_fli/flicamera.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def set_window(self, left: float, top: float, width: float, height: float, *args
102102
Raises:
103103
ValueError: If binning could not be set.
104104
"""
105-
self._window = {'left': int(left), 'top': int(top), 'width': int(width), 'height': int(height)}
105+
self._window = (left, top, width, height)
106106
log.info('Setting window to %dx%d at %d,%d...', width, height, left, top)
107107

108108
def set_binning(self, x: int, y: int, *args, **kwargs):
@@ -115,7 +115,7 @@ def set_binning(self, x: int, y: int, *args, **kwargs):
115115
Raises:
116116
ValueError: If binning could not be set.
117117
"""
118-
self._binning = {'x': int(x), 'y': int(y)}
118+
self._binning = (x, y)
119119
log.info('Setting binning to %dx%d...', x, y)
120120

121121
def _expose(self, exposure_time: int, open_shutter: bool, abort_event: threading.Event) -> fits.PrimaryHDU:
@@ -131,18 +131,18 @@ def _expose(self, exposure_time: int, open_shutter: bool, abort_event: threading
131131
"""
132132

133133
# set binning
134-
log.info("Set binning to %dx%d.", self._binning['x'], self._binning['y'])
135-
self._driver.set_binning(self._binning['x'], self._binning['y'])
134+
log.info("Set binning to %dx%d.", self._binning[0], self._binning[1])
135+
self._driver.set_binning(*self._binning)
136136

137137
# set window, divide width/height by binning, from libfli:
138138
# "Note that the given lower-right coordinate must take into account the horizontal and
139139
# vertical bin factor settings, but the upper-left coordinate is absolute."
140-
width = int(math.floor(self._window['width']) / self._binning['x'])
141-
height = int(math.floor(self._window['height']) / self._binning['y'])
140+
width = int(math.floor(self._window[2]) / self._binning[0])
141+
height = int(math.floor(self._window[3]) / self._binning[1])
142142
log.info("Set window to %dx%d (binned %dx%d) at %d,%d.",
143-
self._window['width'], self._window['height'], width, height,
144-
self._window['left'], self._window['top'])
145-
self._driver.set_window(self._window['left'], self._window['top'], width, height)
143+
self._window[2], self._window[3], width, height,
144+
self._window[0], self._window[1])
145+
self._driver.set_window(self._window[0], self._window[1], width, height)
146146

147147
# set some stuff
148148
self._change_exposure_status(ICamera.ExposureStatus.EXPOSING)
@@ -174,8 +174,8 @@ def _expose(self, exposure_time: int, open_shutter: bool, abort_event: threading
174174
# readout
175175
log.info('Exposure finished, reading out...')
176176
self._change_exposure_status(ICamera.ExposureStatus.READOUT)
177-
width = int(math.floor(self._window['width'] / self._binning['x']))
178-
height = int(math.floor(self._window['height'] / self._binning['y']))
177+
width = int(math.floor(self._window[2] / self._binning[0]))
178+
height = int(math.floor(self._window[3] / self._binning[1]))
179179
img = np.zeros((height, width), dtype=np.uint16)
180180
for row in range(height):
181181
img[row, :] = self._driver.grab_row(width)
@@ -192,12 +192,12 @@ def _expose(self, exposure_time: int, open_shutter: bool, abort_event: threading
192192
hdu.header['INSTRUME'] = (self._driver.name, 'Name of instrument')
193193

194194
# binning
195-
hdu.header['XBINNING'] = hdu.header['DET-BIN1'] = (self._binning['x'], 'Binning factor used on X axis')
196-
hdu.header['YBINNING'] = hdu.header['DET-BIN2'] = (self._binning['y'], 'Binning factor used on Y axis')
195+
hdu.header['XBINNING'] = hdu.header['DET-BIN1'] = (self._binning[0], 'Binning factor used on X axis')
196+
hdu.header['YBINNING'] = hdu.header['DET-BIN2'] = (self._binning[1], 'Binning factor used on Y axis')
197197

198198
# window
199-
hdu.header['XORGSUBF'] = (self._window['left'], 'Subframe origin on X axis')
200-
hdu.header['YORGSUBF'] = (self._window['top'], 'Subframe origin on Y axis')
199+
hdu.header['XORGSUBF'] = (self._window[0], 'Subframe origin on X axis')
200+
hdu.header['YORGSUBF'] = (self._window[1], 'Subframe origin on Y axis')
201201

202202
# statistics
203203
hdu.header['DATAMIN'] = (float(np.min(img)), 'Minimum data value')
@@ -206,7 +206,7 @@ def _expose(self, exposure_time: int, open_shutter: bool, abort_event: threading
206206

207207
# biassec/trimsec
208208
full = self.get_full_frame()
209-
self.set_biassec_trimsec(hdu.header, full['left'], full['top'], full['width'], full['height'])
209+
self.set_biassec_trimsec(hdu.header, *full)
210210

211211
# return FITS image
212212
log.info('Readout finished.')

0 commit comments

Comments
 (0)