Skip to content

Commit

Permalink
Add Birger focuser info to SBIG camera FITS headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Horton committed Feb 14, 2017
1 parent 0a7ea11 commit 43838be
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 4 deletions.
12 changes: 11 additions & 1 deletion pocs/camera/sbig.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from astropy.io import fits

from .camera import AbstractCamera
from .focuser.birger import Focuser as BirgerFocuser
from .sbigudrv import SBIGDriver, INVALID_HANDLE_VALUE
from ..utils import error, current_time, images

Expand Down Expand Up @@ -190,9 +191,18 @@ def take_exposure(self, seconds=1.0 * u.second, filename=None, dark=False, block

assert filename is not None, self.logger.warning("Must pass filename for take_exposure")

if self.focuser and isinstance(self.focuser, BirgerFocuser):
# Add Birger focuser info to FITS headers
extra_headers = (('BIRG-ID', self.focuser.uid, 'Focuser serial number'),
('BIRGLENS', self.focuser.lens_info, 'Attached lens'),
('BIRGFIRM', self.focuser.library_version, 'Focuser firmware version'),
('BIRGHARD', self.focuser.hardware_version, 'Focuser hardware version'))
else:
extra_headers = None

self.logger.debug('Taking {} second exposure on {}: {}'.format(seconds, self.name, filename))
exposure_event = Event()
self._SBIGDriver.take_exposure(self._handle, seconds, filename, exposure_event, dark)
self._SBIGDriver.take_exposure(self._handle, seconds, filename, exposure_event, dark, extra_headers)

if blocking:
exposure_event.wait()
Expand Down
8 changes: 6 additions & 2 deletions pocs/camera/sbigudrv.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def set_temp_regulation(self, handle, set_point):
self._send_command('CC_SET_TEMPERATURE_REGULATION2', params=set_temp_params)
self._send_command('CC_SET_TEMPERATURE_REGULATION2', params=set_freeze_params)

def take_exposure(self, handle, seconds, filename, exposure_event=None, dark=False):
def take_exposure(self, handle, seconds, filename, exposure_event=None, dark=False, extra_headers=None):
"""
Starts an exposure and spawns thread that will perform readout and write
to file when the exposure is complete.
Expand Down Expand Up @@ -276,7 +276,7 @@ def take_exposure(self, handle, seconds, filename, exposure_event=None, dark=Fal
params=query_status_params,
results=query_status_results)

# Assemble basic FITS header
# Assemble FITS header with all the relevant info from the camera itself
temp_status = self.query_temp_status(handle)
if temp_status.coolingEnabled:
if abs(temp_status.imagingCCDTemperature - temp_status.ccdSetpoint) > 0.5 or \
Expand Down Expand Up @@ -304,6 +304,10 @@ def take_exposure(self, handle, seconds, filename, exposure_event=None, dark=Fal
else:
header.set('IMAGETYP', 'Light Frame')

if extra_headers:
for entry in extra_headers:
header.set(*entry)

# Start exposure
self.logger.debug('Starting {} second exposure on {}'.format(seconds, handle))
with self._command_lock:
Expand Down
47 changes: 46 additions & 1 deletion pocs/focuser/birger.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ def max_position(self):
"""
return self._max_position

@property
def lens_info(self):
"""
Return basic lens info (e.g. '400mm,f28' for a 400 mm f/2.8 lens)
"""
return self._lens_info

@property
def library_version(self):
"""
Returns the version string of the Birger adaptor library (firmware).
"""
return self._library_version

@property
def hardware_version(self):
"""
Returns the hardware version of the Birger adaptor
"""
return self._hardware_version

##################################################################################################
# Public Methods
##################################################################################################
Expand Down Expand Up @@ -103,9 +124,18 @@ def connect(self):
raise err

# Get serial number. Note, this is the serial number of the Birger adaptor,
# *not* the attached lens (which would be more useful).
# *not* the attached lens (which would be more useful). Accessible as self.uid
self._get_serial_number()

# Get the version string of the adaptor software libray. Accessible as self.library_version
self._get_libary_version()

# Get the hardware version of the adaptor. Accessible as self.hardware_version
self._get_hardware_version()

# Get basic lens info (e.g. '400mm,f28' for a 400 mm, f/2.8 lens). Accessible as self.lens_info
self._get_lens_info()

# Initialise the aperture motor. This also has the side effect of fully opening the iris.
self._initialise_aperture()

Expand Down Expand Up @@ -233,6 +263,21 @@ def _get_serial_number(self):
self._serial_number = response[0].rstrip()
self.logger.debug("Got serial number {} for {} on {}".format(self.uid, self.name, self.port))

def _get_library_version(self):
response = self._send_command('lv', response_length=1)
self._library_version = response[0].rstrip()
self.logger.debug("Got library version '{}' for {} on {}".format(self.library_version, self.name, self.port))

def _get_hardware_version(self):
response = self._send_command('hv', response_length=1)
self._hardware_version = response[0].rstrip[]
self.logger.debug("Got hardware version {} for {} on {}".format(self.hardware_version, self.name,, self.port))

def _get_lens_info(self):
response = self._send_command('if', response_length=1)
self._lens_info = response[0].rstrip()
self.logger.debug("Got lens info '{}' for {} on {}".format(self.lens_info, self.name, self.port))

def _initialise_aperture(self):
self.logger.debug('Initialising aperture motor')
response = self._send_command('in', response_length=1)
Expand Down

0 comments on commit 43838be

Please sign in to comment.