APF Python library

The APF Python module is intended to provide high-level access to basic functionality of the APF dome and telescope. In many cases, functions are wrappers to other software; in others, the core functionality is implemented directly.

The APF module is not complete. Functions have been added strictly on an as-needed basis, as needs emerged elsewhere in the APF software ecosystem.

APF systems are grouped into submodules within the APF module. None of the systems break out as individual classes; users of the APF module are expected to use the APF module directly, almost as if it were a global class instance.

Programming infrastructure

The APF module also implements common infrastructure used by many Python tools associated with the APF.

APF.log(text, level=None, echo=False)

Log text via the external apflogger application. If level is specified, it should be one of the log levels accepted by apflogger on the command line, such as ‘error’, ‘warn’, or ‘notice’. If not specified, no level will be provided on the command line, and the apflogger default will be used. If echo is set to True, apflogger will echo the text on standard output, prefixed with the date.

APF.service(service, heartbeat=True)

Retrieve a cached ktl.Service instance. By default, the cached instance will be configured to be aware of the appropriate heartbeat keyword(s) for that service. Set heartbeat to False to avoid the automatic heartbeat functionality; ignoring heartbeats should only be considered for transient client applications.

APF.write(keyword, value, wait=True, binary=False, timeout=None)

Wrapper to ktl.Keyword.write() that ensures restricted keywords are only modified in appropriate circumstances. keyword is either a ktl.Keyword instance, or a keyword name in service.KEYWORD form. The remainder of the arguments will be passed directly to ktl.Keyword.write().

Telescope control

Many of the functions defined here are thin wrappers to the slew script.

APF.Telescope.disable(wait=True)

Command the telescope to disable itself. If wait is False, disable() will not check to see whether the command succeeds, and will return None. If wait is True and the command does succeed, disable() will return True; if the command fails, it will return False.

APF.Telescope.home()

Home the telescope. This function is a thin wrapper to the home_telescope script.

APF.Telescope.park()

Park the telescope. This function is a thin wrapper to the park_telescope script.

APF.Telescope.slew(az=None, el=None, ra=None, dec=None, wait=True)

At least one position argument must be specified. If only one of azimuth or elevation is supplied, it is assumed that the unspecified position parameter will remain the same; likewise for right ascension and declination.

At the end of a successful slew, the telescope will be left tracking that position.

This function is a thin wrapper to the slew script.

Dome shutter control

Many of the functions defined here are thin wrappers to the shutters script.

APF.Shutters.close(wait=True)

Close the dome shutters.

APF.Shutters.closed()

Return a boolean indicating whether the dome shutters are presently closed.

APF.Shutters.crack(wait=True)

If closed, barely crack open the dome shutters.

APF.Shutters.move(front=None, rear=None, wait=True)

At least one position argument must be specified. If only one of front or rear is supplied, it is assumed that the unspecified position parameter will remain the same.

APF.Shutters.open(wait=True)

Open the dome shutters in the up-and-over position.

APF.Shutters.opened()

Return a boolean indicating whether the dome shutters are presently open.

Dome vent control

APF.Vents.close(wait=True)

Close all operable vent doors. If wait is True, this function will block until the vent doors are done closing. In the event of a permission failure or other runtime error, an exception will be raised.

APF.Vents.closed()

Return a boolean indicating whether all vent doors are presently closed.

APF.Vents.open(wait=True)

Open all operable vent doors. If wait is True, this function will block until the vent doors are done opening. In the event of a permission failure or other runtime error, an exception will be raised.

APF.Vents.opened()

Return a boolean indicating whether all vent doors not in a manual override are presently open. If all vent doors are in a manual override, all vent doors will be inspected.

Exceptions

class APF.EmergencyStop

Raised if the emergency stop is engaged, and cannot be disengaged.

class APF.PermissionError

The caller made a KTL modify request that is not permitted due to one or more active checkapf restrictions.

class APF.PhysicalEmergencyStop

Raised if a physical emergency stop is engaged.

class APF.SoftwareEmergencyStop

Raised if the software emergency stop is engaged.

Table Of Contents

Previous topic

Software Interface

Next topic

apftask - task coordination service

This Page