IB package

Submodules

IB.CamIB module

CamIB.py

This is the DESI Image Builder for camera application. It works in conjunction with manager applications such as CameraMan or FocusMan

Basic functionality: Wait for a trigger from Manager

parse the ib_instructions block for sources, expid and frame numbers setup a get_image multiOps call with a response_handler hook the response_handler sorts the received image data into the Exposures structure
When a complete, add an entry to the build queue
this entry includes distribution and processing information from ib_instructions as well as expid and frame number add primary extension to exposure if requested
Distribution and processing options
write_image locally (submit to write queue, _savings call from Exposures in separate thread) send_to as requested (submit to send_to queue, send_image from Exposures in separate thread) process as requested (e.q. guider postage stamps
Archive

Archive functionality is implemented to save a complete exposure as a data cube The basis structure of the archive data cube is

primary extension N 3D (numpy) arrays, one for each source with the frame number as the 3rd coordinate N ascii tables, one for each source with the frame number as the 3rd coordinate and the header keywords as columns
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 assign to instruct the IB to collect image data and to start the build process set_primary to write the primary extension for an exposure/frame write_image to write a complete image data to local disk get_image to return a complete image via PML send_image to send a complete image via PML clear_image to clear the image from the exposures structure finalize_exposure to signal that an exposure is complete archive_exposure to archive all images from an exposure (possibly add write_archive, send_archive, get_archive) accept_extension to push an extension to the IB (normally we pull)
Several shared variables published by this application:
STATUS reflects the application’s status EXPOSURE_READY indicates that an exposure is ready ARCHIVE_READY indicates that an archive is ready <role>_DISKSPACE shows the available disk space

Version History 3/19/2018 KH Initial framework 4/17/2018 KH separate ImageBuilder and ImagePlotter classes

class IB.CamIB.CamIB(device_mode=False, noSVE=None, **extra_args)

Bases: DOSlib.application.Application

tag = 'IB'
commands = ['configure', 'get', 'set', 'assign', 'build', 'write_image', 'get_image', 'send_image', 'clear_image', 'finalize_exposure', 'archive_exposure', 'accept_extension']
defaults = {'add_frame': True, 'add_on': None, 'archive_dir': None, 'archive_metadata': None, 'archive_primary': None, 'archive_secondary': None, 'camib_version': 'trunk', 'compress': False, 'constants_version': 'DEFAULT', 'exclude': [], 'exposure_ready_mode': 'memory', 'file_purge': False, 'file_purge_threshold': 2, 'frame_purge_threshold': 4, 'image_dir': '${DOS_IMAGEDIR}', 'image_name': None, 'local_copy': False, 'mem_purge': True, 'mem_purge_threshold': 4, 'mode': None, 'plot_mark_center': False, 'plot_save': False, 'plot_save_ext': 'ALL', 'plot_save_mode': 'EXTENSIONS', 'plot_show': False, 'plot_show_ext': 'CIN', 'plot_show_mode': 'CI', 'plot_subtitle': True, 'plot_title': True, 'png_dir': None, 'primary': None, 'send_to': [], 'sources': [], 'sub_dir': None, 'use_exp_dir': True, 'use_obs_day': True, 'use_plotter': True, 'watch': []}
CAMERA_HEADERS = ['local_copy', 'expid', 'image_dir', 'archive_dir', 'sub_dir', 'image_name', 'mem_purge_threshold', 'frame_purge_threshold', 'file_purge_threshold', 'send_to', 'mem_purge', 'compress', 'file_purge', 'cb_function', 'cb_args', 'ib_send_to', 'ib_local_copy', 'archive_primary', 'archive_secondary', 'archive_metadata', 'send_command', 'send_argsframe', 'autotrieddark', 'autotriedbias']
OBSERVATORY = {'OBS-ELEV': 2097.0, 'OBS-LAT': '31.96403', 'OBS-LONG': '-111.59989', 'OBSERVAT': 'KPNO', 'TELESCOP': 'KPNO 4.0-m telescope'}
HEADER_CONSTANTS = {'SOFTVER': 'trunk', 'TIMESYS': 'UTC'}
init()

Initialize image builder application. Set up variables, discovery

configure(constants='DEFAULT')
Configure the camera image builder application
Loads constants from DB when applicable Resets the exposures management structure Repeats the initial configuration (_initial_configuration()) When successful, the application state is set to READY
get(what, **options)

Retrieve parameters dynamically. Options include: status Returns the application status hostname Returns hostname mode returns IB mode (CI, GUIDE, FOCUS….) myURI Returns Pyro URI exclude Returns list of [‘frame’] keywords excluding from image distribution image_name Returns image basename sub_dir Returns subdirectory for local images image_dir Returns directory for local images png_dir Returns directory for local png images archive_dir, archive_primary, archive_secondary, archive_metadata returns archive settings primary Returns name of primary extensions compress Returns True if images are written rice-compressed add_on Returns any addition to the filename add_frame Returns True/False if adding/suppressing frame number in filename local_copy Returns state of local copy flag send_to Returns default list of receivers 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 Returns when exposure readiness is announced exposure_status Returns dictionary with expid and frame numbers for the different processing stages for the current exposure or expid if given processing_times Returns timing information from the current exposure or expid if given 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 extheader = extname returns extension header (expid, frame required) extdata = extname returns extension data (expid, frame required) expid=n returns information for exposure n expid=n, frame=m returns information for exposure n, frame m

ib_instructions returns dictionary with IB instructions for the current exposure or expid if given exp_ready, image_ready, archive_ready returns current value of these SVs plot_options returns ib plotter options

set(**kwargs)
Set key/value pairs to set parameters dynamically. Options include:
image_name Sets the image basename sub_dir Sets the output subdirectory for image data image_dir Sets the output directory for image data png_dir Sets the output directory for png image data archive_dir Sets the output directory for image archive 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 primary Sets name of primary extension (upper case) local_copy Sets the local_copy flag add_send_to Adds entry to the default receiver list remove_send_to Removes entry from the default receiver list 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 expsure_ready_mode Sets when exposure readiness is announced (memory, fits, png) add_exclude add a <frame> keyword to be excluded from image distribution remove_exclude remove a <frame> keyword from being excluded from image distribution plot_<option> set option for plot command
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

accept_extension(expid, frame, extname, source=None, clobber=False, header={}, data=None)

Accept an extension for the given expid/frame if part of assignment, remove extension from list (if source is given) and trigger the image_builder thread if necessary Raises an exception if the exposure/frame doesn’t exist or is already complete If the extension exists and clobber is True, the data is overwritten and the header is updated. If clobber is False and exception is raised. if extname is PRIMARY, the actual extname will be taken from self.exposures.primary (in this case the header will be updated, not overwritten

assign(expid, frame, **kwargs)

submit an assignment and trigger the collection process. returns right away (build on the other hand waits for image collection to complete)

build(expid, frame, **kwargs)

accept an assignment and call the ImageBuilder build function to start collecting data

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

archive_exposure(expid, add2primary={}, add2metadata=[], add2secondary={}, compress=True)

trigger the _image_archiver thread to archive this exposure. could use kwargs to pass additionas to the primary or extension headers the add2xxx keywords allow to add extra keywords to the primary/metadata/extension dictionaries in the exposures structures. Note that the corresponding values are taken from the image data (ie it must exist in the data)

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

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 exclude List of <frame> keywords to be omitted
get_image(expid, frame=None, dark_subtract=False, extra_headers=None, clobber=False, exclude=None, all_fields=False)

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) exclude List of <frame> keywords to be omitted

write_image(expid, frame=None, image_dir=None, image_name=None, 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 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) overwrite If True, an existing file with the same name will be overwritten. exclude List of <frame> keywords to be omitted compress If true write rice-compressed images add_on is added at the end (before .fits) add_frame True/False forces/suppressed inclusion of the frame number in the filename
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 Image Builder Application. Wait for shutdown flag

IB.FVCIB module

IB.FocusIB module

FocusIB.py

This is based on the CamIB application Differences to CamIB:

use_donut - [config] controls if the donut system is used

tag remains IB The donut app should be added to the watch list (config, processed by CamIB) for (dos-) connection management. The name of the donut app is passed in the donutApp config variable

ToDo: add mem purge for postage stamps (should be moved to exposures) Version History 02/14/2018 v0.5.0 KH Inherit from CamIB.py

class IB.FocusIB.FocusIB(device_mode=False, noSVE=None, **extra_args)

Bases: IB.CamIB.CamIB

init()

Initialization (called directly by the application framework)

configure(constants='DEFAULT')

Configure the focus image builder application

set(**options)

do focus ib specific set operations, then call CamIB

get(what, **options)

do focus ib specific get operations, then call CamIB

IB.GuiderIB module

GuiderIB.py

This is based on the CamIB application Differences to CamIB:

stamper - functions to extract rois and to send the image to the Guider accept_rois - rois are passed as part of the trigger IB block and we allow defaults to be set with this call

use_guider - [config] controls if the guider is used

tag remains IB The guider app should be added to the watch list (config, processed by CamIB) for (dos-) connection management. The name of the guider app is passed in the guiderApp config variable

ToDo: add mem purge for postage stamps (should be moved to exposures) Version History 02/14/2018 v0.5.0 KH Inherit from CamIB.py

class IB.GuiderIB.GuiderIB(device_mode=False, noSVE=None, **extra_args)

Bases: IB.CamIB.CamIB

init()

Initialization (called directly by the application framework)

configure(constants='DEFAULT')

Configure the guider image builder application

set(**options)

do guider ib specific set operations, then call CamIB

get(what, **options)

do guider ib specific set operations, then call CamIB

accept_rois(roi_list)

Accept (default) roi list. This is used if rois are not passed from the manager app during assign()

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

Clear the postage stamps 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

finalize_rois(expid, *args, **kwargs)

Finalize rois by setting the status field in self.postage_stamps to ‘COMPLETE’ args, kwargs are for future extension to send notifications maybe to the Archiver

archive_rois(expid, add2primary={}, add2metadata=[], add2secondary={}, compress=True)

trigger the _image_archiver thread to archive this exposure. could use kwargs to pass additionas to the primary or extension headers the add2xxx keywords allow to add extra keywords to the primary/metadata/extension dictionaries in the exposures structures.

send_rois(expid, frame=None, send_to=None, send_command=None, extra_headers=None, clobber=False, exclude=None, all_fields=False)

Send postage stamps 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 exclude List of <frame> keywords to be omitted
get_rois(expid, frame=None, dark_subtract=False, extra_headers=None, clobber=False, exclude=None, all_fields=False)

Returns postage stamps (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) exclude List of <frame> keywords to be omitted

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

Save postage stamps 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 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) overwrite If True, an existing file with the same name will be overwritten. exclude List of <frame> keywords to be omitted compress If true write rice-compressed images add_on is added at the end (before .fits) add_frame True/False forces/suppressed inclusion of the frame number in the filename

IB.ImageBuilder module

Image Builder Class

build
image_collector thread/queue image_builder thread/queue image_writer thread/queue image_sender thread/queue
provides hooks for user routines at these steps in the image pipeline
image_built - at the end of the image building step. (includes collection and building) image_saved - once image is written to disk image_sent - after all send_to requests have been processed image_archived - after the exposure has been archived
an additional callout function is provided ro be used as option for send_to
distribute

build uses multiOps to call the get_image() method of the source apps. A response handler is used to insert the received data into the exposures structure. When data from all sources has been collected, an entry is posted to the image_builder queue to trigger further processing.

class IB.ImageBuilder.ImageBuilder(role, mode, exposures, abort_event, shutdown_event, exp_ready, image_ready, archive_ready)

Bases: object

set_exposures(exposures)
restart_threads()

Restart a thread

assign(expid, frame, **options)

accept an assignment from the manager and to the collecter queue to start collecting image data

collect(expid, frame, **options)

accept an assignment from the manager and start collecting image data when complete, place a notifier in the build queue to trigger the image builder thread

archive_exposure(expid, add2primary={}, add2metadata=[], add2secondary={}, compress=True)

trigger the _image_archiver thread to archive this exposure. could use kwargs to pass additionas to the primary or extension headers the add2xxx keywords allow to add extra keywords to the primary/metadata/extension dictionaries in the exposures structures.

accept_extension(expid, frame, extname, source=None, clobber=False, header={}, data=None)

Accept an extension for the given expid/frame if part of assignment, remove extension from list (if source is given) and trigger the image_builder thread if necessary Raises an exception if the exposure/frame doesn’t exist or is already complete If the extension exists and clobber is True, the data is overwritten and the header is updated. If clobber is False and exception is raised. if extname is PRIMARY, the actual extname will be taken from self.primary (in this case the header will be updated, not overwritten

distribute(*args, **kwargs)
image_built(expid, frame, **options)
image_saved(expid, frame, **options)
image_sent(expid, frame, **options)
image_archived(expid, frame, **options)

IB.ImagePlotter module

ImagePlotter class as part of the ImageBuilder allows to plot individual extensions or more complex assemblies like all guider GFAs images can be saved in png format (and from there get picked up by the image server)

more detailed description to be added

class IB.ImagePlotter.ImagePlotter(mode, when_done=None)

Bases: object

plot(expid, frame, exposures, **options)

IB.SkyIB module

SkyIB.py

This is based on the CamIB application Differences to CamIB:

primary, secondary and metadata archive defaults

tag remains IB

Version History 02/14/2018 v0.5.0 KH Inherit from CamIB.py

class IB.SkyIB.SkyIB(device_mode=False, noSVE=None, **extra_args)

Bases: IB.CamIB.CamIB

init()

Initialization (called directly by the application framework)

IB.SpecIB module

SpecIB.py

This is the DESI Image Builder for the spectrographs. It works in conjunction with the SpecMan applications

Basic functionality: Wait for a trigger from Manager

parse the ib_instructions block for sources, expid and frame numbers setup a get_image multiOps call with a response_handler hook the response_handler sorts the received image data into the Exposures structure
When a complete, add an entry to the build queue
this entry includes distribution and processing information from ib_instructions as well as expid and frame number add primary extension to exposure if requested
Distribution and processing options
write_image locally (submit to write queue, _savings call from Exposures in separate thread) send_to as requested (submit to send_to queue, send_image from Exposures in separate thread) process as requested (e.q. guider postage stamps
Archive

Archive functionality is implemented to save a complete exposure as a data cube The basis structure of the archive data cube is

primary extension N 3D (numpy) arrays, one for each source with the frame number as the 3rd coordinate N ascii tables, one for each source with the frame number as the 3rd coordinate and the header keywords as columns
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 assign to instruct the IB to collect image data and to start the build process set_primary to write the primary extension for an exposure/frame write_image to write a complete image data to local disk get_image to return a complete image via PML send_image to send a complete image via PML clear_image to clear the image from the exposures structure finalize_exposure to signal that an exposure is complete archive_exposure to archive all images from an exposure (possibly add write_archive, send_archive, get_archive) accept_extension to push an extension to the IB (normally we pull)
Several shared variables published by this application:
STATUS reflects the application’s status EXPOSURE_READY indicates that an exposure is ready ARCHIVE_READY indicates that an archive is ready <role>_DISKSPACE shows the available disk space

Version History 3/19/2018 KH Initial framework 4/17/2018 KH separate ImageBuilder and ImagePlotter classes 4/23/2018 KH spectrograph version

class IB.SpecIB.CamIB(device_mode=False, noSVE=None, **extra_args)

Bases: DOSlib.application.Application

tag = 'IB'
commands = ['configure', 'get', 'set', 'assign', 'build', 'write_image', 'get_image', 'send_image', 'clear_image', 'finalize_exposure', 'archive_exposure', 'accept_extension', 'register_callback', 'clear_callback']
defaults = {'add_frame': None, 'add_on': None, 'archive_dir': '${DOS_IMAGEDIR}', 'archive_metadata': None, 'archive_primary': None, 'archive_secondary': None, 'camib_version': 'trunk', 'compress': True, 'constants_version': 'DEFAULT', 'exclude': [], 'exposure_ready_mode': 'built', 'file_purge': False, 'file_purge_threshold': 2, 'frame_purge_threshold': 4, 'image_dir': '${DOS_IMAGEDIR}', 'image_name': None, 'local_copy': True, 'mem_purge': True, 'mem_purge_threshold': 4, 'mode': None, 'plot_mark_center': False, 'plot_save': False, 'plot_save_ext': 'ALL', 'plot_save_mode': 'EXTENSIONS', 'plot_show': False, 'plot_show_ext': 'CCDS0Z', 'plot_show_mode': 'EXTENSIONS', 'plot_subtitle': False, 'plot_title': True, 'png_dir': None, 'primary': None, 'send_to': [], 'sources': [], 'specib_version': 'trunk', 'sub_dir': None, 'use_built_callback': False, 'use_exp_dir': True, 'use_obs_day': True, 'use_plotter': True, 'use_saved_callback': False, 'use_sent_callback': False}
CAMERA_HEADERS = ['local_copy', 'expid', 'image_dir', 'image_name', 'mem_purge_threshold', 'frame_purge_threshold', 'file_purge_threshold', 'send_to', 'mem_purge', 'compress', 'file_purge', 'cb_function', 'cb_args', 'ib_send_to', 'ib_local_copy', 'archive_primary', 'archive_secondary', 'archive_metadata', 'send_command', 'send_argsframe', 'autotrieddark', 'autotriedbias']
OBSERVATORY = {'OBS-ELEV': 2097.0, 'OBS-LAT': '31.96403', 'OBS-LONG': '-111.59989', 'OBSERVAT': 'KPNO', 'TELESCOP': 'KPNO 4.0-m telescope'}
HEADER_CONSTANTS = {'SOFTVER': 'trunk', 'TIMESYS': 'UTC'}
init()

Initialize image builder application. Set up variables, discovery

register_callback(operation, interface=None, function=None, cb_args=None, enable=None)

register a PML interface (server) and function to be called at the end of accummulation or digitization. Only one callback can be registered per function (built, saved, sent) meaning that earlier values will be overwritten by subsequent calls. The named arguments dictionary (kwargs) must include values for the interface and function to be called. When given, the value of cb_args is passed to the callback function. operation has to be either expose or digitize Supports both PML callbacks and Pyro URIs. If interface is None and function is callable, a local function call is executed (instead of a PML command)

clear_callback(callback)

clear the callback variables

configure(constants='DEFAULT')
Configure the camera image builder application
Loads constants from DB when applicable Resets the exposures management structure Repeats the initial configuration (_initial_configuration()) When successful, the application state is set to READY
get(what, **options)

Retrieve parameters dynamically. Options include: status Returns the application status hostname Returns hostname mode returns IB mode (CI, GUIDE, FOCUS….) myURI Returns Pyro URI exclude Returns list of [‘frame’] keywords excluding from image distribution image_name Returns image basename image_dir Returns directory for local images png_dir Returns directory for local png images archive_dir, archive_primary, archive_secondary, archive_metadata returns archive settings primary Returns name of primary extensions compress Returns True if images are written rice-compressed add_on Returns any addition to the filename add_frames Returns True/False if adding/suppressing frame number in filename local_copy Returns state of local copy flag send_to Returns default list of receivers 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 Returns when exposure readiness is announced exposure_status Returns dictionary with expid and frame numbers for the different processing stages for the current exposure or expid if given processing_times Returns timing information from the current exposure or expid if given 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 extheader = extname returns extension header (expid, frame required) extdata = extname returns extension data (expid, frame required) expid=n returns information for exposure n expid=n, frame=m returns information for exposure n, frame m

ib_instructions returns dictionary with IB instructions for the current exposure or expid if given use_built_callback use_saved_callback use_sent_callback builtCB exp_ready, image_ready, archive_ready returns current value of these SVs plot_options returns ib plotter options

set(**kwargs)
Set key/value pairs to set parameters dynamically. Options include:
image_name Sets the image basename image_dir Sets the output directory for image data png_dir Sets the output directory for png image data archive_dir Sets the output directory for image archive sub_dir 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 primary Sets name of primary extension (upper case) use_obs_day use_exp_dir local_copy Sets the local_copy flag add_send_to Adds entry to the default receiver list remove_send_to Removes entry from the default receiver list mem_purge Sets the mem_purge flag file_purge Sets the file_purge flag use_built_callback mem_purge_threshold Sets the mem_purge threshold frame_purge_threshold Sets the frame_purge threshold file_purge_threshold Sets the file_purge threshold expsure_ready_mode Sets when exposure readiness is announced (memory, fits, png) add_exclude add a <frame> keyword to be excluded from image distribution remove_exclude remove a <frame> keyword from being excluded from image distribution plot_<option> set option for plot command
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

accept_extension(expid, frame, extname, source=None, clobber=False, header={}, data=None)

Accept an extension for the given expid/frame if part of assignment, remove extension from list (if source is given) and trigger the image_builder thread if necessary Raises an exception if the exposure/frame doesn’t exist or is already complete If the extension exists and clobber is True, the data is overwritten and the header is updated. If clobber is False and exception is raised. if extname is PRIMARY, the actual extname will be taken from self.exposures.primary (in this case the header will be updated, not overwritten

assign(expid, frame, **kwargs)

submit an assignment and trigger the collection process. returns right away (build on the other hand waits for image collection to complete)

build(expid, frame, **kwargs)

accept an assignment and call the ImageBuilder build function to start collecting data

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

archive_exposure(expid, add2primary={}, add2metadata=[], add2secondary={}, compress=True)

trigger the _image_archiver thread to archive this exposure. could use kwargs to pass additionas to the primary or extension headers the add2xxx keywords allow to add extra keywords to the primary/metadata/extension dictionaries in the exposures structures.

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

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 exclude List of <frame> keywords to be omitted
get_image(expid, frame=None, dark_subtract=False, extra_headers=None, clobber=False, exclude=None, all_fields=False)

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) exclude List of <frame> keywords to be omitted

write_image(expid, frame=None, image_dir=None, image_name=None, 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 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) overwrite If True, an existing file with the same name will be overwritten. exclude List of <frame> keywords to be omitted add_on is added at the end (before .fits) add_frame True/False forces/suppressed inclusion of the frame number in the filename compress If true write rice-compressed images
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 Image Builder Application. Wait for shutdown flag

Module contents