Skip to content

Commit ed182ab

Browse files
authored
Merge pull request #401 from aaronwmorris/dev
pull bayer pattern from FITs header instead of indi properties
2 parents 4ae6eb4 + b19548b commit ed182ab

4 files changed

Lines changed: 21 additions & 14 deletions

File tree

indi_allsky/allsky.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def sighup_handler(self, signum, frame):
196196

197197
# CFA/Debayer setting
198198
if not self.config.get('CFA_PATTERN'):
199+
# this is not always populated
199200
self.config['CFA_PATTERN'] = self.config['CCD_INFO']['CCD_CFA']['CFA_TYPE'].get('text')
200201

201202

@@ -433,6 +434,7 @@ def _initialize(self, connectOnly=False):
433434

434435
# CFA/Debayer setting
435436
if not self.config.get('CFA_PATTERN'):
437+
# this is not always populated
436438
self.config['CFA_PATTERN'] = self.config['CCD_INFO']['CCD_CFA']['CFA_TYPE'].get('text')
437439

438440
logger.info('CCD CFA: {0:s}'.format(str(self.config['CFA_PATTERN'])))

indi_allsky/darks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ def stack(self, tmp_fit_dir_p, filename_p, exposure, image_bitpix):
866866

867867
dark_images = ccdproc.ImageFileCollection(tmp_fit_dir_p)
868868

869-
cal_darks = dark_images.files_filtered(imagetyp='Dark Frame', exptime=exposure, include_path=True)
869+
cal_darks = dark_images.files_filtered(exptime=exposure, include_path=True)
870870

871871

872872
start = time.time()

indi_allsky/image.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,24 +229,24 @@ def saferun(self):
229229
hdulist = fits.open(filename_p)
230230

231231
#logger.info('HDU Header = %s', pformat(hdulist[0].header))
232-
image_type = hdulist[0].header['IMAGETYP']
233232
image_bitpix = hdulist[0].header['BITPIX']
233+
image_bayerpat = hdulist[0].header.get('BAYERPAT')
234234

235235
scidata = hdulist[0].data
236236
elif filename_p.suffix in ['.jpg', '.jpeg']:
237237
self.indi_rgb = False
238238

239239
scidata = cv2.imread(str(filename_p), cv2.IMREAD_UNCHANGED)
240240

241-
image_type = 'Light Frame'
242241
image_bitpix = 8
242+
image_bayerpat = None
243243
elif filename_p.suffix in ['.png']:
244244
self.indi_rgb = False
245245

246246
scidata = cv2.imread(str(filename_p), cv2.IMREAD_UNCHANGED)
247247

248-
image_type = 'Light Frame'
249248
image_bitpix = 8
249+
image_bayerpat = None
250250
elif filename_p.suffix in ['.dng']:
251251
if not rawpy:
252252
filename_p.unlink()
@@ -260,7 +260,6 @@ def saferun(self):
260260
hdu = fits.PrimaryHDU(scidata)
261261
hdulist = fits.HDUList([hdu])
262262

263-
hdulist[0].header['IMAGETYP'] = 'Light Frame'
264263
hdulist[0].header['EXPTIME'] = float(exposure)
265264
#hdulist[0].header['XBINNING'] = 1
266265
#hdulist[0].header['YBINNING'] = 1
@@ -270,13 +269,13 @@ def saferun(self):
270269
hdulist[0].header['XBAYROFF'] = 0
271270
hdulist[0].header['YBAYROFF'] = 0
272271

273-
image_type = hdulist[0].header['IMAGETYP']
274272
image_bitpix = hdulist[0].header['BITPIX']
273+
image_bayerpat = hdulist[0].header.get('BAYERPAT')
275274

276275

277276

278277
filename_p.unlink() # no longer need the original file
279-
logger.info('Detected image type: %s, bits: %d', image_type, image_bitpix)
278+
logger.info('Detected image bits: %d, cfa: %s', image_bitpix, str(image_bayerpat))
280279

281280

282281

@@ -306,7 +305,7 @@ def saferun(self):
306305
self.sqm_value = self.calculateSqm(scidata, exposure)
307306

308307
# debayer
309-
scidata = self.debayer(scidata)
308+
scidata = self.debayer(scidata, image_bayerpat)
310309

311310
else:
312311
# data is probably RGB
@@ -1025,16 +1024,22 @@ def calibrate(self, scidata_uncalibrated, exposure, camera_id, image_bitpix):
10251024
return scidata_calibrated
10261025

10271026

1028-
def debayer(self, scidata):
1029-
if not self.config['CFA_PATTERN']:
1027+
def debayer(self, scidata, image_bayerpat):
1028+
# sanity check
1029+
if not len(scidata.shape) == 2:
1030+
# color, already debayered
10301031
return scidata
10311032

1033+
if not image_bayerpat:
1034+
return scidata
1035+
1036+
10321037
if self.config.get('NIGHT_GRAYSCALE') and self.night_v.value:
1033-
debayer_algorithm = self.__cfa_gray_map[self.config['CFA_PATTERN']]
1038+
debayer_algorithm = self.__cfa_gray_map[image_bayerpat]
10341039
elif self.config.get('DAYTIME_GRAYSCALE') and not self.night_v.value:
1035-
debayer_algorithm = self.__cfa_gray_map[self.config['CFA_PATTERN']]
1040+
debayer_algorithm = self.__cfa_gray_map[image_bayerpat]
10361041
else:
1037-
debayer_algorithm = self.__cfa_bgr_map[self.config['CFA_PATTERN']]
1042+
debayer_algorithm = self.__cfa_bgr_map[image_bayerpat]
10381043

10391044
scidata_bgr = cv2.cvtColor(scidata, debayer_algorithm)
10401045

indi_allsky/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = "5.4"
1+
__version__ = "5.5"
22
__config_version__ = 20221023.0
33

0 commit comments

Comments
 (0)