The Camera Class

camera.py

This is the DESI camera application. It is used for the focus and guide GFA modules as well as skycamera and the commissioning instrument SBIG cameras

All camera controller specifics are moved to device specific modules (e.g. device_gfa.py) A simulated camera controller is also available. The configuration variable controller selects between these options. The interface to the GFA controller firmware and the Barcelona software is done in device_gfa.py using the gfaaccesslib module.

Two options are available to run in simulation mode. The standard is to set controller == simulator, which forces the simulated camera controller (device_sim.py) is loaded. For the GFA cameras a low level hardware simulator that emulated the GFA device is also available. To use this set controller = GFA and camcon_mode = sim

The following commands are implmented:

configure to configure the application and the controller get to read status and configuration information set to update select variables at run time prepare_for_exposure to prepare the CCD for the next exposure expose to take the exposure you prepared for with the previous prepare_for_exposure call send_camcon_cmd to send commands directly to the camera controller

this is used as a replacement for the gfa specific commands: gfa_set_voltages_config sets all the voltage levels for GFA gfa_get_voltages_config gets all the voltage settings for GFA gfa_bias_powerup turn on ccd bias voltage gfa_bias_powerdown turn off ccd bias voltage

finalize_exposure Called after a guider or similar sequence to close exposures management structure expose_loop Convenience function to call expose() multiple times start_sequence Called to start a guider, donut or sky camera sequence stop_sequence Called to stop a running sequence clear_ccd write_image Write image data to local disk get_image Return an image via PML send_image Send an image via PML clear_image Clear the image from the exposures structure calibrate Sequence of bias and dark exposures to create master bias and dark frames set_guide_stars In simulation mode only, set positions for (guide) stars, set fixed_positions to True clear_guide_stars Remove (guide) star list and set simulation parameter fixed_positions to False go_test Convenience function to test functionality

Role name convention:
GFA<unit> with unit being a number between 0 and 9.
if unit is in [1, 4, 6, 9] the camera is configured as FOCUS (alignment) camera. For all other values the camera is configured as a GUIDE camera.

SKYCAMERA CI<unit> the CI cameras use letters like E, W etc to distinguish the devices

Several shared variables published by this application:
STATUS reflects the application’s status CONNECTED is True when the controller is connected and alive (ie responds to version command) CONTROLLER_STATUS is reflects the controller hardware status INFOC is the controller telemetry VSUB is the status of the controller bias voltage EXPOSURE_READY indicates that an exposure is complete and ready to retrieve the data

Status information is polled periodically from the camera controller. At this point no asynchronous link is provided between the controller and the camera application to send alarms or event information (e.g. digitized) but this can be added in the future.

About GFAStatus: some of the states are transition states (exposing, powerup, powerdown, telemetry)
To check if the bias voltages are on use the is_powered function Different from the ccd controller there is no separate power on/off function
Changelog:
removed ccd_simulator and ccd_controller changed gfa.py to api.py changed get exposure stack to use gfaapi functions removed mode from defaults added DOSlib util, mjd changed from pyfits to astropy.io added OrderedDict for header added camera_headers changed to gfa_ip, fixed some typos import GFAStatusType added gfa update status to init added gfa.close and bias removed erase function, added clear_ccd to commands cleaned up gfa voltage functions added telemetry and status updates to main removed abort, digitize, build (some might come back later) renamed self.gfa and related to self.camcon and related to indicate that multiple controllers are supported

Version History 1/21/2015 KH Initial framework 1/1/2016 KAR Make it happen 7/6/2016 KH Added DOS support, standard functions and shared variables 1/6/2017 DLR created GFA_camera class, moved all GFA function into it.

Also moved function definitions into separate files. camera.py is now 1000 lines shorter.

12/1/2017 KH cleaned camera.py - camera controller interface 9/3/2018 KH exposures class added , roi support removed

just import DOSlib.logger as Log to get this functionality DLR: THe new GFA_camera class and the previous SBIG_camera and FakeSBIG classes support logging through the DOSlib logger as long as you add configure these objects to use the loggers using “gfa.add_loggers”.

Also, to initialize ccd_geometry, use camcon.init_geometry, and assign the result to self.ccd_geometry in the Camera object. When changing the geometry, use self.update_geometry and update the ccd_geometry dictionary.
class Camera.camera.Camera(device_mode=False, noSVE=None, **extra_args)
init()

Initialize camera application. Set up variables, connect camera controller, discovery

next(*args, **kwargs)

Set synchronized flag to indicate that the next exposure in a sequence can start Optional arguments can be used for further synchronization (e.g. expid, frame number)

configure(constants='DEFAULT')
Configure the camera application
Loads constants from DB when applicable Resets exposure id and the exposures management structure Repeats the initial configuration (_initial_configuration()) When successful, the application state is set to READY
register_camman(uri)

this needs some more work when CamMan is more complete

get(what, **options)

Retrieve parameters dynamically. Options include: status Returns the application status unit Returns the camera unit number vsub, vccd Returns True is bias voltages are applied camcon_connected Returns True if the camera is connected controller Returns version information about the controller model Returns the camera model mode Returns the camera mode wcs Returns the camera wcs lookup value rate Returns the update rate for the telemetry loop unittype Returns STX, GUIDE or FOCUS image_name Returns image basename image_dir Returns directory for local images png_dir, archive_dir, sub_dir use_obs_day use_exp_dir compress Returns True if images are compressed add_on Returns any addition to the filename add_frames Returns True/False if adding/suppressing frame number in filename synchronized Returns True is synchronized flag (event) is set local_copy Returns state of local copy flag mem_purge Returns state of mem purge flag file_purge Returns state of file purge flag mem_purge_threshold Returns threshold for mem purge frame_purge_threshold Returns threshold for frame purge file_purge_threshold Returns threshold for file purge exposure_ready_mode, trim_full_image Returns state of the trim_full_image flag save_raw_image Returns state of the save_raw_image flag subtract_bias Returns True if bias should be subtracted subtract_dark Returns True if a (scaled) dark frame should be subtracted bias_frame Returns filename of bias frame (or “Internal” if self calibrated) dark_frame Returns filename of dark frame (or “Internal” if self calibrated) size Returns information about the CCD geometry temp_regulation Returns regulation modes (SBIG only) temp_setpoint Returns temperature setpoint (SBIG only) usb_info Returns results from usb query call camcon_status Returns status information from the controller camcon_tele Returns telemetry information from the controller camcon_info Returns general information from the controller camcon_ip Returns camera controller IP address camcon_port Returns camera controller IP port camcon_aport Returns camera controller IP async port camcon_mode Returns camera controller mode binning camcon_binning Returns camera controller binning mode sequence Returns the state of the run_sequence flag last_expid Returns the last exposure id used (in test/debug mode) exposure_times Returns timing information from last exposure if available exposure Returns information about an exposure

Options: mode=all returns full exposure structure mode=list returns list of exposures mode=detail returns more details about the exposure expid=n returns information for exposure n expid=n,full_frame=m returns information for exposure n, full frame m
set(**kwargs)

Set key/value pairs to set parameters dynamically. Options include: Not all options are supported by all camera controllers

update_rate Sets the update rate vsub/vccd Turns on/off bias voltages. Syntax: set vsub=ON/OFF image_name Sets the image basename image_dir Sets the output directory for image data png_dir, archive_dir, sub_dir binning Sets pixel array binning (tuple like (2,2) compress Sets the compress flag (True/False) add_on Sets string to add to filename (before .fits) add_frame If True/False adds/suppresses frame number in filename local_copy Sets the local_copy flag trim_full_image Sets the trim_full_image flag save_raw_image Sets the save_raw_image flag mem_purge Sets the mem_purge flag file_purge Sets the file_purge flag mem_purge_threshold Sets the mem_purge threshold frame_purge_threshold Sets the frame_purge threshold file_purge_threshold Sets the file_purge threshold subtract_dark Sets the subtract dark flag subtract_bias Sets the subtract bias flag last_expid Sets the last expid (used in test/debug mode) fan Turns on/off fan (SBIG only) temp_regulation Sets temperature control mode (list), e.g.

[on, enable_autofreeze]

synchronized Sets/resets the next exposure/synchronized flag wcs Sets WCS for this camera

set_guide_stars(positions, fixed_positions=True, deviations=4)
Add stars at the given “positions” to the simulation
Format: {<camera> : [{x:<…>, y:<…>, other properties},{…}], <camera>…}

deviations sets how far star positions can jitter (in pixels)

clear_guide_stars()

remove roi list from sim_params and set fixed_positions flag to False

clear_image(expid=None, frame=None, extension=None)

Clear the exposures dictionary and thereby release the image memory buffers Arguments: expid: exposure number or all (careful!) if specific exposure is given: frame: frame number or all if a specific frame is given: extension: extename or all

prepare_for_exposure(expid, flavor=None, **options)
Prepare camera for an exposure
set exposure number (expid) set exposure type set exposure time (if given) prepare the camera controller prepare_for_exposure function
Arguments
expid Exposure number (int, required)
Can be set to next in test/debug mode

flavor Exposure type (zero, dark etc) (required)

Keyword arguments

exptime Exposure time in seconds details A dictionary with additional exposure info (for example tel_ra, tel_dec for the CI WCS) Simulation mode only: fixed_positions If true, simulated positions of stars in roi list (if given) vary around

roi_list position

fixed_positions_deviation Mean jitter (in pixels (before binning)) if fixed_positions is True

If expid already exists in Exposures() the next frame is prepared

expose(expid, **options)

Expose ccd and read out by calling the camera controller expose function For these cameras, the digitize functionality is included and not a separate call Generate header and store it together with image data in the exposures structure Optionally write image in FITS format to file. exposure time must be given in options if not previously set by prepare_for_exposure() Prepare for exposure must have been called before calling expose However, if the exposures structure indicates that this exposure is in use but that the new frame has not been prepared, prepare_for_exposure is called. exptime and flavor are taken from the last frame that was taken for this exposure id. expose() will use the frame indicated by the prepare_for dictionay in self.exposures[expid] Positional arguments

expid exposure number (required, int or ‘next’ if self.expid has been set)
Named arguments:

local_copy write a local copy in FITS format if True mem_purge delete old image data in memory file_purge delete old image data on disk if local_copy is true send_to pml proxy or pml interface/command tuples (or a list of these)

command: function to be called on receiver If not given or set to None, the image data is not sent

send_command Command to be used when sending image (send_to and send_command are both required) extra_headers Dictionary with extra header keywords/values that will be added to the image header bias_subtract Subtract bias frame for local_copy or send option dark_subtract Subtract dark frame for local_copy or send option exptime Exposure time in seconds (overwrites prepare_for_exposure value) flavor Exposure type (overwrites prepare_for_exposure value) compress If True (and local_copy == True), images are writted rice-compressed

The rest of the named arguments passed to the routine but not listed in CAMERA_HEADERS will be added to the header. (expid will be renamed to OBSNUM) Returns a dictionary with status information on completion

process_image(status, frame=None)

called by expose() with the complete image frame to be overloaded by the user (e.g SkyCam)

start_sequence(expid, exptime=None, flavor=None, **options)

Start the sequence and call expose repeatedly Required Arguments

expid Exposure number (int, required) exptime Exposure time in seconds flavor Exposure type
Optional Arguments:

count max. number of exposures in sequence(can be stopped with stop_sequence) delay delay in seconds between sequence exposures (for latency adjustments)

Note that delay and exptime combined define the sequence update rate

latency time between cycles (== exposure + readout + possible delay) synchronized requires next_exposure flag to be set before starting next exposure

The remaining arguments such as local_copy, mem_purge send_to… will be passed to the expose command

stop_sequence(*args, **kwargs)

Set a flag to stop the exposure sequence loop args, kwargs are for future extension to send notifications maybe to the Archiver

finalize_exposure(expid, *args, **kwargs)

Finalize an exposure by setting the status field in the exposures to ‘COMPLETE’ args, kwargs are for future extension to send notifications maybe to the Archiver

calibrate(bias=True, nbias=5, dark=True, ndark=5, darktime=2.0, bias_outfile=None, dark_outfile=None)

Generate master bias and dark frames Images are stacked and median combined The master dark frame is scaled to 1 second. darktime is the exposure time used for darks This call clears the exposures structure to have enough memory space, mem_purge is False and after the call, the exposures structure is cleared again.

expose_loop(expid, flavor='zero', count=1, delay=0, **options)

convenience function to run multiple exposures using expose command :param expid - initial expid: :param flavor: :param count - number of exposures: :param delay - delay between exposures in seconds:

options:

send_image(expid, frame=None, send_to=None, send_command=None, bias_subtract=False, dark_subtract=False, extra_headers=None, clobber=False, exclude=None)

Send data for exposure = expid to an PML interface (name or proxy) Required arguments: expid (required) Optional arguments:

frame frame number (default is None which means send all frames) to (proxy or name of receiving PML interface (or list)) command (function of receiving PML interface to be called) extra_headers will be added to the FITS header clobber if true existing header keywords will be overwritten dark_subtract a scaled dark frame and a bias frame will be subtracted (overwrites bias_subtract setting) bias_subtract a bias frame will be subtracted exclude list of frame keywords to omit from image data
get_image(expid, frame=None, bias_subtract=False, dark_subtract=False, extra_headers=None, clobber=False, exclude=None)

Returns an image (single or all frames) Required arguments: expid (int) The requested image must be in the internal exposure status structure. If frame == None, all frames for this exposure will be returned key/value pairs given in extra_headers will be added to the header of each frame’s primary extension (if it exists). If clobber == True, existing header keys will be overwritten (if same name) Images will be bias subtracted if the flag is true, they will be dark and bias subtracted when dark_subtract is true (overwrites bias_subtract setting) exclude is used to omit <frame> keywords

write_image(expid, frame=None, image_dir=None, image_name=None, bias_subtract=False, dark_subtract=False, extra_headers=None, clobber=False, overwrite=True, exclude=None, compress=False, add_on=None, add_frame=None)

Save image to disk Required arguments: expid (int) Optional arguments: frame (int) frame to write (if None all frames are written to disk)

image_name Overwrites default image base name image_dir Overwrites default image directory overwrite If True, an existing file with the same name will be overwritten. dark_subtract a scaled dark frame and a bias frame will be subtracted bias_subtract a bias frame will be subtracted extra_headers key/value pairs to be added to the header of each frame’s primary extension (if it exists). clobber If true, existing header keys will be overwritten (if same name) exclude list of frame keywords to omit from image data compress if True, image data will be saved rice-compressed (locally) add_on Optional addition to filename (before .fits) add_frame Force/suppress inclusion of frame number
detrend_image(expid, frame=None, bias_subtract=False, dark_subtract=False)

perfrom image detrending on single frame or entire exposures (if frame == None) bias and dark master frames must be available or an exception is raised will check if image was previously detrended detrended pixel data will overwrite raw pixel array!!!!

send_camcon_cmd(cmd, *args, **kwargs)

Send command “cmd” plus any additional arguments to the camera controller This replaces these commands:

gfa_set_voltages_config gfa_get_voltages_config gfa_bias_powerup gfa_bias_powerdown gfa_shutdown gfa_get_telemetry gfa_set_exposure_configuration gfa_get_exposure_configuration
clear_ccd()

Call the controller clear function

about_to_connect_to_instance(*args, **kwargs)

To be overridden by the user so that any actions can be taken when the device application is about to connect to an instance

did_connect_to_instance(*args, **kwargs)

To be overridden by the user so that any actions can be taken when the device application connects to an instance

about_to_disconnect_from_instance(*args, **kwargs)

To be overridden by the user so that any actions can be taken when the device application is about to disconnect from an instance

did_disconnect_from_instance(*args, **kwargs)

To be overridden by the user so that any actions can be taken when the device application disconnects from an instance

main()

Main routine of the Camera Application. Wait for shutdown flag while periodically updating controller status.

class Camera.camera.Camera(device_mode=False, noSVE=None, **extra_args)
init()

Initialize camera application. Set up variables, connect camera controller, discovery

next(*args, **kwargs)

Set synchronized flag to indicate that the next exposure in a sequence can start Optional arguments can be used for further synchronization (e.g. expid, frame number)

configure(constants='DEFAULT')
Configure the camera application
Loads constants from DB when applicable Resets exposure id and the exposures management structure Repeats the initial configuration (_initial_configuration()) When successful, the application state is set to READY
register_camman(uri)

this needs some more work when CamMan is more complete

get(what, **options)

Retrieve parameters dynamically. Options include: status Returns the application status unit Returns the camera unit number vsub, vccd Returns True is bias voltages are applied camcon_connected Returns True if the camera is connected controller Returns version information about the controller model Returns the camera model mode Returns the camera mode wcs Returns the camera wcs lookup value rate Returns the update rate for the telemetry loop unittype Returns STX, GUIDE or FOCUS image_name Returns image basename image_dir Returns directory for local images png_dir, archive_dir, sub_dir use_obs_day use_exp_dir compress Returns True if images are compressed add_on Returns any addition to the filename add_frames Returns True/False if adding/suppressing frame number in filename synchronized Returns True is synchronized flag (event) is set local_copy Returns state of local copy flag mem_purge Returns state of mem purge flag file_purge Returns state of file purge flag mem_purge_threshold Returns threshold for mem purge frame_purge_threshold Returns threshold for frame purge file_purge_threshold Returns threshold for file purge exposure_ready_mode, trim_full_image Returns state of the trim_full_image flag save_raw_image Returns state of the save_raw_image flag subtract_bias Returns True if bias should be subtracted subtract_dark Returns True if a (scaled) dark frame should be subtracted bias_frame Returns filename of bias frame (or “Internal” if self calibrated) dark_frame Returns filename of dark frame (or “Internal” if self calibrated) size Returns information about the CCD geometry temp_regulation Returns regulation modes (SBIG only) temp_setpoint Returns temperature setpoint (SBIG only) usb_info Returns results from usb query call camcon_status Returns status information from the controller camcon_tele Returns telemetry information from the controller camcon_info Returns general information from the controller camcon_ip Returns camera controller IP address camcon_port Returns camera controller IP port camcon_aport Returns camera controller IP async port camcon_mode Returns camera controller mode binning camcon_binning Returns camera controller binning mode sequence Returns the state of the run_sequence flag last_expid Returns the last exposure id used (in test/debug mode) exposure_times Returns timing information from last exposure if available exposure Returns information about an exposure

Options: mode=all returns full exposure structure mode=list returns list of exposures mode=detail returns more details about the exposure expid=n returns information for exposure n expid=n,full_frame=m returns information for exposure n, full frame m
set(**kwargs)

Set key/value pairs to set parameters dynamically. Options include: Not all options are supported by all camera controllers

update_rate Sets the update rate vsub/vccd Turns on/off bias voltages. Syntax: set vsub=ON/OFF image_name Sets the image basename image_dir Sets the output directory for image data png_dir, archive_dir, sub_dir binning Sets pixel array binning (tuple like (2,2) compress Sets the compress flag (True/False) add_on Sets string to add to filename (before .fits) add_frame If True/False adds/suppresses frame number in filename local_copy Sets the local_copy flag trim_full_image Sets the trim_full_image flag save_raw_image Sets the save_raw_image flag mem_purge Sets the mem_purge flag file_purge Sets the file_purge flag mem_purge_threshold Sets the mem_purge threshold frame_purge_threshold Sets the frame_purge threshold file_purge_threshold Sets the file_purge threshold subtract_dark Sets the subtract dark flag subtract_bias Sets the subtract bias flag last_expid Sets the last expid (used in test/debug mode) fan Turns on/off fan (SBIG only) temp_regulation Sets temperature control mode (list), e.g.

[on, enable_autofreeze]

synchronized Sets/resets the next exposure/synchronized flag wcs Sets WCS for this camera

set_guide_stars(positions, fixed_positions=True, deviations=4)
Add stars at the given “positions” to the simulation
Format: {<camera> : [{x:<…>, y:<…>, other properties},{…}], <camera>…}

deviations sets how far star positions can jitter (in pixels)

clear_guide_stars()

remove roi list from sim_params and set fixed_positions flag to False

clear_image(expid=None, frame=None, extension=None)

Clear the exposures dictionary and thereby release the image memory buffers Arguments: expid: exposure number or all (careful!) if specific exposure is given: frame: frame number or all if a specific frame is given: extension: extename or all

prepare_for_exposure(expid, flavor=None, **options)
Prepare camera for an exposure
set exposure number (expid) set exposure type set exposure time (if given) prepare the camera controller prepare_for_exposure function
Arguments
expid Exposure number (int, required)
Can be set to next in test/debug mode

flavor Exposure type (zero, dark etc) (required)

Keyword arguments

exptime Exposure time in seconds details A dictionary with additional exposure info (for example tel_ra, tel_dec for the CI WCS) Simulation mode only: fixed_positions If true, simulated positions of stars in roi list (if given) vary around

roi_list position

fixed_positions_deviation Mean jitter (in pixels (before binning)) if fixed_positions is True

If expid already exists in Exposures() the next frame is prepared

expose(expid, **options)

Expose ccd and read out by calling the camera controller expose function For these cameras, the digitize functionality is included and not a separate call Generate header and store it together with image data in the exposures structure Optionally write image in FITS format to file. exposure time must be given in options if not previously set by prepare_for_exposure() Prepare for exposure must have been called before calling expose However, if the exposures structure indicates that this exposure is in use but that the new frame has not been prepared, prepare_for_exposure is called. exptime and flavor are taken from the last frame that was taken for this exposure id. expose() will use the frame indicated by the prepare_for dictionay in self.exposures[expid] Positional arguments

expid exposure number (required, int or ‘next’ if self.expid has been set)
Named arguments:

local_copy write a local copy in FITS format if True mem_purge delete old image data in memory file_purge delete old image data on disk if local_copy is true send_to pml proxy or pml interface/command tuples (or a list of these)

command: function to be called on receiver If not given or set to None, the image data is not sent

send_command Command to be used when sending image (send_to and send_command are both required) extra_headers Dictionary with extra header keywords/values that will be added to the image header bias_subtract Subtract bias frame for local_copy or send option dark_subtract Subtract dark frame for local_copy or send option exptime Exposure time in seconds (overwrites prepare_for_exposure value) flavor Exposure type (overwrites prepare_for_exposure value) compress If True (and local_copy == True), images are writted rice-compressed

The rest of the named arguments passed to the routine but not listed in CAMERA_HEADERS will be added to the header. (expid will be renamed to OBSNUM) Returns a dictionary with status information on completion

process_image(status, frame=None)

called by expose() with the complete image frame to be overloaded by the user (e.g SkyCam)

start_sequence(expid, exptime=None, flavor=None, **options)

Start the sequence and call expose repeatedly Required Arguments

expid Exposure number (int, required) exptime Exposure time in seconds flavor Exposure type
Optional Arguments:

count max. number of exposures in sequence(can be stopped with stop_sequence) delay delay in seconds between sequence exposures (for latency adjustments)

Note that delay and exptime combined define the sequence update rate

latency time between cycles (== exposure + readout + possible delay) synchronized requires next_exposure flag to be set before starting next exposure

The remaining arguments such as local_copy, mem_purge send_to… will be passed to the expose command

stop_sequence(*args, **kwargs)

Set a flag to stop the exposure sequence loop args, kwargs are for future extension to send notifications maybe to the Archiver

finalize_exposure(expid, *args, **kwargs)

Finalize an exposure by setting the status field in the exposures to ‘COMPLETE’ args, kwargs are for future extension to send notifications maybe to the Archiver

calibrate(bias=True, nbias=5, dark=True, ndark=5, darktime=2.0, bias_outfile=None, dark_outfile=None)

Generate master bias and dark frames Images are stacked and median combined The master dark frame is scaled to 1 second. darktime is the exposure time used for darks This call clears the exposures structure to have enough memory space, mem_purge is False and after the call, the exposures structure is cleared again.

expose_loop(expid, flavor='zero', count=1, delay=0, **options)

convenience function to run multiple exposures using expose command :param expid - initial expid: :param flavor: :param count - number of exposures: :param delay - delay between exposures in seconds:

options:

send_image(expid, frame=None, send_to=None, send_command=None, bias_subtract=False, dark_subtract=False, extra_headers=None, clobber=False, exclude=None)

Send data for exposure = expid to an PML interface (name or proxy) Required arguments: expid (required) Optional arguments:

frame frame number (default is None which means send all frames) to (proxy or name of receiving PML interface (or list)) command (function of receiving PML interface to be called) extra_headers will be added to the FITS header clobber if true existing header keywords will be overwritten dark_subtract a scaled dark frame and a bias frame will be subtracted (overwrites bias_subtract setting) bias_subtract a bias frame will be subtracted exclude list of frame keywords to omit from image data
get_image(expid, frame=None, bias_subtract=False, dark_subtract=False, extra_headers=None, clobber=False, exclude=None)

Returns an image (single or all frames) Required arguments: expid (int) The requested image must be in the internal exposure status structure. If frame == None, all frames for this exposure will be returned key/value pairs given in extra_headers will be added to the header of each frame’s primary extension (if it exists). If clobber == True, existing header keys will be overwritten (if same name) Images will be bias subtracted if the flag is true, they will be dark and bias subtracted when dark_subtract is true (overwrites bias_subtract setting) exclude is used to omit <frame> keywords

write_image(expid, frame=None, image_dir=None, image_name=None, bias_subtract=False, dark_subtract=False, extra_headers=None, clobber=False, overwrite=True, exclude=None, compress=False, add_on=None, add_frame=None)

Save image to disk Required arguments: expid (int) Optional arguments: frame (int) frame to write (if None all frames are written to disk)

image_name Overwrites default image base name image_dir Overwrites default image directory overwrite If True, an existing file with the same name will be overwritten. dark_subtract a scaled dark frame and a bias frame will be subtracted bias_subtract a bias frame will be subtracted extra_headers key/value pairs to be added to the header of each frame’s primary extension (if it exists). clobber If true, existing header keys will be overwritten (if same name) exclude list of frame keywords to omit from image data compress if True, image data will be saved rice-compressed (locally) add_on Optional addition to filename (before .fits) add_frame Force/suppress inclusion of frame number
detrend_image(expid, frame=None, bias_subtract=False, dark_subtract=False)

perfrom image detrending on single frame or entire exposures (if frame == None) bias and dark master frames must be available or an exception is raised will check if image was previously detrended detrended pixel data will overwrite raw pixel array!!!!

send_camcon_cmd(cmd, *args, **kwargs)

Send command “cmd” plus any additional arguments to the camera controller This replaces these commands:

gfa_set_voltages_config gfa_get_voltages_config gfa_bias_powerup gfa_bias_powerdown gfa_shutdown gfa_get_telemetry gfa_set_exposure_configuration gfa_get_exposure_configuration
clear_ccd()

Call the controller clear function

about_to_connect_to_instance(*args, **kwargs)

To be overridden by the user so that any actions can be taken when the device application is about to connect to an instance

did_connect_to_instance(*args, **kwargs)

To be overridden by the user so that any actions can be taken when the device application connects to an instance

about_to_disconnect_from_instance(*args, **kwargs)

To be overridden by the user so that any actions can be taken when the device application is about to disconnect from an instance

did_disconnect_from_instance(*args, **kwargs)

To be overridden by the user so that any actions can be taken when the device application disconnects from an instance

main()

Main routine of the Camera Application. Wait for shutdown flag while periodically updating controller status.