Reference

This is the auto-generated reference from the doc strings in the source code.

Instrument

The baseline for loading a scanning instrument

Each instrument will have its own module that declares a class inheriting from ScanningInstrument. The abstract base class is used to ensure that the derived classes define the necessary methods to run any generic scripts.

class src.Instrument.ScanningInstrument[source]

The base class for scanning measurement instruments.

TIMINGS

The list of valid waitfor keywords.

begin(*args, **kwargs)[source]

Start a measurement.

check_move_pos(pos)[source]

Check whether the position is valid and return True or False

Parameters:pos (str) – The sample changer position
configure_sans(size='')[source]

Setup to the instrument for a SANS measurement

Parameters:size (str) – The aperature size. e.g. “Small” or “Medium” A blank string (the default value) results in the aperature not being changed
configure_trans(size='')[source]

Setup the instrument for a transmission measurement

Parameters:size (str) – The aperature size. e.g. “Small” or “Medium” A blank string (the default value) results in the aperature not being changed
detector_on(powered=None, delay=True)[source]

Query and set the detector’s electrical state.

Parameters:
  • on (bool or None) – If None, then return the detector’s current state. If True, turn the detector on. If False, turn the detector off.
  • delay (bool) – If changing the detector state, whether to wait for the detector to finish warming up or powering down before continuing the script.
  • Returns
  • bool – If the detector is currently on
end()[source]

End a measurement.

measure(title, pos=None, thickness=1.0, trans=False, dae=None, aperature='', **kwargs)[source]

Take a sample measurement.

Parameters:
  • title (str) – The title for the measurement. This is the only required parameter.
  • pos – The sample position. This can be a string with the name of a sample position or it can be a function which moves the detector into the desired position. If left undefined, the instrument will take the measurement in its current position.
  • thickness (float) – The thickness of the sample in millimeters. The default is 1mm.
  • trans (bool) – Whether to perform a transmission run instead of a sans run.
  • dae (str or func) – This option allows setting the default dae mode. It takes a string that contains the name of the DAE mode to be used as the new default. For example, >>> measure(“Test”, frames=10, dae=”event”) Is equivalent to >>> set_default_dae(setup_dae_event) >>> measure(“Test”, frames=10) If dae is a function, then the function is set to the default >>> measure(“Test”, frames=10, dae=foo) Is equivalent to >>> set_default_dae(foo) >>> measure(“Test”, frames=10)
  • aperature (str) – The aperature size. e.g. “Small” or “Medium” A blank string (the default value) results in the aperature not being changed.
  • **kwargs – This function takes two kinds of keyword arguments. If given a block name, it will move that block to the given position. If given a time duration, then that will be the duration of the run.

Examples

>>> measure("H2O", frames=900)

Perform a SANS measurment in the current position on a 1 mm thick water sample until the proton beam has released 900 proton pulses (approx 15 minutes).

>>> measure("D2O", "LT", thickness=2.0, trans=True, Phi=3, uamps=10)

Move to sample changer position LT, then adjust the CoarseZ motor to 38 mm. Finally, take a transmission measurement on a 2 mm thick deuterium sample for 10 µA hours of proton current. (approx 15 minutes).

measure_file(file_path, forever=False)[source]

Perform a series of measurements based on a spreadsheet

The file should contain comma separated values. Excel can easily produce files of this sort. The first line of the file is the header with each field giving the name of a parameter to the measure function. As always, the title parameter is mandatory. Each subsequent line of the file represents a single measurement with the fields indicating that values to pass to their corresponding keywords. If a cell is blank, the keyword’s default parameter it used. Boolean values are represented by True and False and are not case sensitive.

The script is run through the simulator to check for errors before attempting a real run.

Parameters:
  • file_path (str) – The location of the script file
  • forever (bool) – If set to True, the instrument will repeatedly run the script manually stopped. This can be useful for an overnight run where you want to keep measureing until the users return.
static printsamplepars()[source]

Display the basic sample parameters on the console.

sanitised_timings(kwargs)[source]

Include only the keyword arguments for run timings.

Parameters:
  • kwargs (dict) –
  • dictionary of keyword arguments (A) –
Returns:

  • dict
  • Keyword arguments accepted by gen.waitfor

static set_aperature(size)[source]

Set the beam aperature to the desired size

Parameters:size (str) – The aperature size. e.g. “Small” or “Medium” A blank string (the default value) results in the aperature not being changed.
set_default_dae(mode=None, trans=False)[source]

Set the default DAE mode for SANS or TRANS measuremnts.

Parameters:
  • mode (str or function) – If the mode is a function, call that function to set the DAE mode. If the mode is a string, call the function whose name is “setup_dae_” followed by that string.
  • trans (bool) – If true, set the default transmission instead of the default SANS mode.
setup_dae_bsalignment()[source]

Configure wiring tables for beamstop alignment.

setup_dae_event()[source]

Set the wiring tables for event mode

setup_dae_event_fastsave()[source]

Event mode with reduced detector histogram binning to decrease filesize.

setup_dae_histogram()[source]

Set the wiring tables for histogram mode

setup_dae_monitorsonly()[source]

Set the wiring tables to record only the monitors

setup_dae_nr()[source]

Set the wiring tables for a neutron reflectivity measurement

setup_dae_nrscanning()[source]

Set the wiring tables for performing scans during neutron reflectivity

setup_dae_polarised()[source]

Set the wiring tables for a polarisation measurement

setup_dae_scanning()[source]

Set the wiring tables for a scan

setup_dae_transmission()[source]

Set the wiring tables for a transmission measurement

waitfor(**kwargs)[source]

Await the user’s desired statistics.

Util

Useful utilities for scriping

src.Util.dae_setter(inner)[source]

Declare that a method sets the DAE wiring table

This decorator was designed to work on subclasses of the src.Instrument.ScanningInstrument class. The following functionality is added into the class

  1. If the wiring tables are already in the correct state, the function returns immediately without taking any other actions
  2. If the wiring tables are in a different state, the change to the wiring tables is printed to the prompt before performing the actual change

#1 of the above is the most important, as it allows the wiring tables to be set on any function call without worrying about wasting time reloading an existing configuration

Please note that this decorator assumes that the title of the method begins with “setup_dae”, followed by the new of the state of the wiring table.

src.Util.pretty_print_time(seconds)[source]

Given a number of seconds, generate a human readable time string.

Parameters:seconds (float) – The time in seconds that the script will require.
Returns:A string giving the time needed in hours and an approximate ETA.
Return type:str
src.Util.user_script(script)[source]

A decorator to perform some sanity checking on a user script before it is run

src.Util.wait_time(call)[source]

Calculate the time spent waiting by a mock wait call.

Parameters:call (mock.Call) – A mock call that might be a waitfor command
Returns:The approximate time in seconds needed for this command.
Return type:float

Larmor

This is the instrument implementation for the Larmor beamline.

class src.Larmor.Larmor[source]

This class handles the Larmor beamline

static BSInOut(In=True)[source]

Move the Beam Stop in and out of the beam.

Parameters:In (bool) – Whether to move the beam stop in or out
static FOMin()[source]

Put the frame overload mirror into the beam.

static LongPolariserin()[source]

Put the long polariser for short wavelengths into the beam.

static ShortPolariserin()[source]

Put the short polariser for long wavelength into the beam.

get_lrange()[source]

Return the current wavelength range

get_tof_step()[source]

Get the current TOF step for the tcb

static home_pi_rotation()[source]

Calibrate the pi flipper.

static homea1()[source]

Rehome aperature 1.

static homecoarsejaws()[source]

Rehome coarse jaws.

static homes1()[source]

Rehome slit1.

static homes2()[source]

Rehome slit2. This is currentl a no-op.

movebench(angle=0.0, delaydet=True)[source]

Safely move the downstream arm

rotatebench(angle=0.0)[source]

Move the downstream arm

set_lrange(lrange)[source]

Set the current wavelength range

set_tof_step(step)[source]

Set the current TOF step for the tcb

static setup_dae_4periods(self, *args, **kwargs)[source]

Setup the instrument with four periods.

setup_dae_bsalignment(*args, **kwargs)[source]

Configure wiring tables for beamstop alignment.

static setup_dae_diffraction(self, *args, **kwargs)[source]

Set the wiring tables for a diffraction measurement

setup_dae_event(*args, **kwargs)[source]

Set the wiring tables for event mode

setup_dae_event_fastsave(*args, **kwargs)[source]

Event mode with reduced detector histogram binning to decrease filesize.

setup_dae_histogram(*args, **kwargs)[source]

Set the wiring tables for histogram mode

static setup_dae_monotest(self, *args, **kwargs)[source]

Setup with a mono test?

setup_dae_nr(*args, **kwargs)[source]

Set the wiring tables for a neutron reflectivity measurement

setup_dae_nrscanning(*args, **kwargs)[source]

Set the wiring tables for performing scans during neutron reflectivity

static setup_dae_resonantimaging(self, *args, **kwargs)[source]

Set the wiring table for resonant imaging

static setup_dae_resonantimaging_choppers(self, *args, **kwargs)[source]

Set the wiring thable for resonant imaging choppers

setup_dae_scanning(*args, **kwargs)[source]

Set the wiring tables for a scan

setup_dae_sesans(*args, **kwargs)[source]

Setup the instrument for SESANS measurements.

setup_dae_transmission(*args, **kwargs)[source]

Set the wiring tables for a transmission measurement

static setup_dae_tshift(self, *args, **kwargs)[source]

Allow m1 to count as normal but to shift the rest of the detectors in order to allow counting over the frame.

static setup_pi_rotation()[source]

Initialise the pi flipper.

src.Larmor.sleep(seconds)[source]

Override the sleep function to use genie.

We need this override to ensure that simularted runs are forced to wait for real sleeps.