contrast.environment package

Module contents

This module contains the “environment” – the set of objects that define how and when data acquisition is done, what is seen, where data is written, etc. It also provides and keeps track of macros.

The module provides a central instance of the Environment class, env.

class contrast.environment.Env[source]

Bases: object

Container for a number of global environment variables.

contrast.environment.runCommand(line)[source]

Function for running magics from scripts.

contrast.environment.macro(cls)[source]

Decorator which turn a class into a macro. This means that it will be callable from the ipython prompt with command line syntax.

  • Take all arguments in the constructor. The arguments can be Gadget objects and this decorator will find the objects from their names as entered on the command line. They can also be python expressions like 1+1 or 1./20, and are converted to strings otherwise.
  • Provide a run method which takes no arguments and executes the scan or whatever.

The name of the class converted to lower case will be used for the magic command used to launch the macro.

contrast.environment.register_shortcut(name, command)[source]

Factory function which takes two strings name and command, and creates a shortcut macro from the former to the latter.

class contrast.environment.LsMac[source]

Bases: object

This class generates the macro `lsmac`

List available macros. Do <macro-name>? (without <>) for more information.

class contrast.environment.UserLevel(level=None)[source]

Bases: object

This class generates the macro `userlevel`

Get or set the current user level.

userlevel [<level>]
class contrast.environment.Path[source]

Bases: object

This class generates the macro `path`

Print the current data path.

Submodules

contrast.environment.data module

class contrast.environment.data.PathFixer[source]

Bases: object

Basic pathfixer which takes a path manually.

class contrast.environment.data.SdmPathFixer(sdm_device)[source]

Bases: object

MAX IV pathfixer which takes a path from a Tango device.

contrast.environment.scheduling module

Module which provides Scheduler classes, which help the acquisition system determine whether the instrument is ready to acquire, and if there are any deadlines coming up that have to be avoided.

class contrast.environment.scheduling.DummyScheduler[source]

Bases: object

Dummy base class to define the API.

ready

Whether or not the system is available now.

limit

Time left (in seconds) until the next deadline, None for no deadline.

class contrast.environment.scheduling.DummyInjectionScheduler[source]

Bases: contrast.environment.scheduling.DummyScheduler

Dummy that does injection for one minute every five minutes.

class contrast.environment.scheduling.TangoShutterChecker(*shutter_devs)[source]

Bases: threading.Thread

Helper class which asynchronously checks the status of a number of shutters and keeps their last statuses in a GIL-protected list, which can be accessed at any time.

class contrast.environment.scheduling.MaxivScheduler(proxy_device, shutter_list, avoid_injections=True, respect_countdown=True)[source]

Bases: contrast.environment.scheduling.DummyScheduler

Scheduler to keep track of shutter status and the MAX IV injection system.

NOTE: Using threaded status checkers here to avoid polling a large number of potentially slow shutter devices on a different control system.

At MAX IV, there is a local proxy device with countdown and ring current attributes.

contrast.environment.snapshots module

Module which contains classes that gather information which needs to be dumped to every scan.

class contrast.environment.snapshots.EmptySnapshot[source]

Bases: object

Define the API.

capture()[source]

Returns a dict of label-value pairs.

class contrast.environment.snapshots.MotorSnapshot[source]

Bases: contrast.environment.snapshots.EmptySnapshot

Snapshot which consists of all motor values.