Skip to content

API Class

The following methods represent the azcam API. Examples of commands are below.

Python:
api.command(args)
Example: api.set_exposuretime(32.2)
CommandServer:
"api.command arg1 arg2"
Examples:
"api.set_exposuretime 32.2"
"set_exposuretime 32.2"

For the CommandServer the "api." may be omitted.

azcam.api.API

Bases: object

AzCam API class.

mock = 0 instance-attribute

True for mock mode which uses no hardware

abort()

Abort an operation in progress.

expose(exposure_time, imagetype='', title='')

Make a complete exposure.

Parameters:

Name Type Description Default
exposure_time float

exposure time in seconds

required
imagetype str

type of exposure ('zero', 'object', 'flat', ...)

''
title str

image title.

''

expose1(exposure_time, image_type='', image_title='')

Make a complete exposure with immediate return to caller.

Parameters:

Name Type Description Default
exposure_time float

exposure time in seconds

required
image_type str

type of exposure ('zero', 'object', 'flat', ...)

''
image_title str

image title, usually surrounded by double quotes

''

flush(cycles=1)

Flush/clear sensor.

Parameters:

Name Type Description Default
cycles int

number of times to flush the sensor

1

focus_abort()

Abort focus exposure.

focus_initalize()

Initialize focus routine.

focus_run(exposure_time, number_exposures, focus_step, detector_shift)

Execute the focus sequence. If focus.set_pars() was previously called then those values are used and input here is ignored. Args: exposure_time: Exposure time in seconds. number_exposures: Number of exposures in focus sequence. focus_step: Number of focus steps between each exposure in a frame. detector_shift: Number of rows to shift detector for each focus step.

focus_set_pars(exposure_time, number_exposures=7, focus_step=30, detector_shift=10)

Set focus related parameters. Args: number_exposures: Number of exposures in focus sequence. focus_step: Number of focus steps between each exposure in a frame. detector_shift: Number of rows to shift detector for each focus step. exposuretime: Exposure time i seconds.

get_control_temperature(temperature_id=-1)

Get the control temperature (set point).

Parameters:

Name Type Description Default
temperature_id int

temperature sensor identifier

-1

Returns:

Name Type Description
control_temperature float

control temperature

get_exposuretime()

Return current exposure time in seconds.

Returns:

Name Type Description
exposure_time float

exposure time in seconds.

get_exposuretime_remaining()

Return remaining exposure time in seconds.

Returns:

Name Type Description
exposure_time_remaining float

exposure time remaining in seconds.

get_filter(filter_id=0)

Return the current/loaded filter, typically the filter in the beam. Args: filter_id: filter mechanism ID

get_filters(filter_id=0)

Return a list of all available/loaded filters. Args: filter_id: filter mechanism ID

get_format()

Return the current detector format parameters.

get_image_title()

Return the image title.

get_image_type()

Get current image type for an exposure. imagetype is system defined, and typically includes: zero, object, dark, flat.

Returns:

Name Type Description
image_type str

image type string

get_image_types()

Return a list of valid imagetypes.

Returns:

Name Type Description
image_types list[str]

list of valid iamge types

get_par(parameter, subdict=None)

Return the current attribute value of a parameter in the parameters dictionary. If subdict is not specified then the default sub-dictionary is used.

Parameters:

Name Type Description Default
parameter str

name of the parameter

required
subdict str | None

name of the sub-dictionary containing the parameter

None

Returns:

Name Type Description
value Any

value of the parameter

get_pixels_remaining()

Return number of remaining pixels to be read (counts down).

Returns:

Name Type Description
pixels_remaining int

number of pixels remaining to be readout.

get_roi(roi_num=0)

Returns a list of the ROI parameters for the roi_num specified. Currently only one ROI (0) is supported.

Parameters:

Name Type Description Default
roi_num int

ROI number to return

0

Returns: list format is (first_col,last_col,first_row,last_row,col_bin,row_bin).

get_status()

Return a variety of system status data in one dictionary.

Returns:

Name Type Description
data dict

dictionary of exposure related data

get_temperatures()

Return all system temperatures.

Returns:

Name Type Description
temperatures list[float]

list of temperatures read

get_wavelength(wavelength_id=0)

Returns the current wavelength. Args: wavelength_id: wavelength mechanism ID

get_wavelengths(wavelength_id=0)

Returns a list of valid wavelengths. Used for filter and LED based systems. Args: wavelength_id: wavelength mechanism ID

initialize(mock=0)

Initialize the API.

Parameters:

Name Type Description Default
mock int

flag set true for development with no hardware

0

initialize_exposure()

Initialize exposure.

pause()

Pause an exposure inegration (only) in progress.

read_header_file(filename)

Read header file located on the server machine.

reset_exposure()

Reset exposure.

resume()

Resume a paused exposure.

roi_reset()

Resets detector ROI values to full frame, current binning.

save_pars()

Writes the par_dict to the par_file using current values.

sequence(number_exposures=1, flush_array_flag=-1, delay=-1)

Take an exposure sequence. Uses pre-set exposure time, image type and image title.

Parameters:

Name Type Description Default
number_exposures int

number of exposures to make.

1
flush_array_flag int

defines detector flushing: -1 => current value defined by exposure.exposure_sequence_flush [default] 0 => flush for each exposure 1 => flush after first exposure only 2 => no flush

-1
delay float

delay between exposures in seconds -1 => no change

-1

sequence1(number_exposures=1, flush_array_flag=-1, delay=-1)

Take an exposure sequence. Uses pre-set exposure time, image type and image title.

Parameters:

Name Type Description Default
number_exposures int

number of exposures to make.

1
flush_array_flag int

defines detector flushing: -1 => current value defined by exposure.exposure_sequence_flush [default] 0 => flush for each exposure 1 => flush after first exposure only 2 => no flush

-1
delay float

delay between exposures in seconds -1 => no change

-1

set_control_temperature(temperature=None, temperature_id=-1)

Set the control temperature (set point).

Parameters:

Name Type Description Default
temperature float | None

control temperature in Celsius. If not specified, use saved value

None
temperature_id int

control temperature sensor number

-1

set_exposuretime(exposure_time)

Set current exposure time.

Parameters:

Name Type Description Default
exposure_time float

exposure time in seconds.

required

set_filename(filename)

Set the filename components based on a simple filename.

Parameters:

Name Type Description Default
filename str

complete filename to be set

required

set_filter(filter_name, filter_id=0)

Set the current/loaded filter, typically the filter in the beam. Args: filter_name: filter name to set. Could be a number or filter name. filter_id: filter mechanism ID

set_format(ns_total, ns_predark, ns_underscan, ns_overscan, np_total, np_predark, np_underscan, np_overscan, np_frametransfer)

Set the sensor format for subsequent exposures. Must call set_roi() after using this command and before starting exposure.

Parameters:

Name Type Description Default
ns_total int

number of visible columns.

required
ns_predark int

number of physical dark underscan columns.

required
ns_underscan int

desired number of desired dark underscan columns.

required
ns_overscan int

number of dark overscan columns.

required
np_total int

number of visible rows.

required
np_predark int

number of physical dark underscan rows.

required
np_underscan int

number of desired dark underscan rows.

required
np_overscan int

number of desired dark overscan rows.

required
np_frametransfer int

number rows to frame transfer shift.

required

set_image_title(title)

Set the image title.

Parameters:

Name Type Description Default
title str

image title

required

set_image_type(imagetype='zero')

Set image type for an exposure.

Parameters:

Name Type Description Default
imagetype str

system defined, and typically includes: zero, object, dark, flat.

'zero'

set_par(parameter, value='None', subdict=None)

Set the value of a parameter in a parameters dictionary. Also attempts to set actual attribute value.

Parameters:

Name Type Description Default
parameter str

name of the parameter

required
value Any

value of the parameter. Defaults to None.

'None'
subdict str | None

name of sub-dictionary in which to set paramater

None

set_roi(first_col=-1, last_col=-1, first_row=-1, last_row=-1, col_bin=-1, row_bin=-1, roi_num=0)

Sets the ROI values for subsequent exposures. Currently only one ROI [0] is supported. These values are for the entire focal plane, not just one detector. All values are in unbinned coordinates.

Parameters:

Name Type Description Default
first_col int

first column

-1
last_col int

last column

-1
first_row int

first row

-1
last_row int

last row

-1
col_bin int

: column binning

-1
row_bin int

row binning

-1
roi_num int

ROI number [0]

0

set_shutter(state=0, shutter_id=0)

Open or close a shutter.

:param state: :param shutter_id: Shutter ID flag

  • 0 => controller default shutter.
  • 1 => instrument default shutter.

set_wavelength(wavelength, wavelength_id=0)

Set the current wavelength, typically for a filter or grating. Args: wavelength: wavelength value to set. Could be a number or filter name. wavelength_id: wavelength mechanism ID

test(exposure_time=0.0, shutter=0)

Make a test exposure.

Parameters:

Name Type Description Default
exposure_time float

exposure time in seconds

0.0
shutter int

0 for closed and 1 for open

0