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.
-
check_move_pos(pos)[source]¶ Check whether the position is valid and return True or False
Parameters: pos (str) – The sample changer position
-
static
convert_file(file_path)[source]¶ Turn a CSV run list into a full python script
This function allows the user to create simple scripts with Excel, then turn them into full Python scripts that can be edited and customised as needed.
-
detector_lock(state=None)[source]¶ Query or activate the detector lock
Parameters: state (bool or None) – If None, return the current lock state. Otherwise, set the new lock state Returns: - The current lock state as a bool
- Locking the detector prevents turning the detector on or off
- and bypasses the detector checks.
-
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
-
do_sans(title, pos=None, thickness=1.0, dae=None, blank=False, aperature='', **kwargs)[source]¶ A wrapper around
measurewhich ensures that the instrument is not in transmission modeLook at the documentation for
measureto see the full set of parameters accepted.
-
do_trans(title, pos=None, thickness=1.0, dae=None, blank=False, aperature='', **kwargs)[source]¶ A wrapper around
measurewhich ensures that the instrument is not in transmission mode.Look at the documentation for
measureto see the full set of parameters accepted.
-
measure(title, pos=None, thickness=1.0, trans=False, dae=None, blank=False, 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) To get a full list of the supported dae modes, run >>> enumerate_dae()
- aperature (str) – The aperature size. e.g. “Small” or “Medium” A blank string (the default value) results in the aperature not being changed.
- blank (bool) – If this sample should be considered a blank/can/solvent measurement
- **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
titleparameter 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:
-
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.
-
reduction¶
This module automates the creation of reduction scripts from the run log.
-
src.reduction.connect_samples(runs, test)[source]¶ Group runs with the same sample
Parameters: - run (list) – A list of XML nodes for the run numbers to investigate
- test (function) – A boolean to check if the run should be included
Returns: Return type: A dictionary of runs with their samples as the key.
-
src.reduction.console_oracle(sample, blanks)[source]¶ Have the use identify the blank for a sample
The list of possible blanks will be enumerated and displayed to the user. The user can then pick an iterm off the list from the keyboard.
Parameters:
-
src.reduction.identify_pairs(data, oracle=<function console_oracle>)[source]¶ Find the exact blanks for a set of sample runs
Parameters: - data (dict) – The dictionary of possible sample/blank setups extracted from the log file.
- oracle (function) – A function that takes a sample name and a list of possible blanks and returns the name of the correct blank. The default value will print the blanks to the console and as the user to chose the correct blank.
-
src.reduction.is_blank_transmission(run)[source]¶ Was the measurement in transmission mode and on a blank?
-
src.reduction.is_transmission(run)[source]¶ Was the measurement in transmission mode and on a sample?
-
src.reduction.sans_connection(start, end, path)[source]¶ Connect the runs for a series of sesans measurements
-
src.reduction.sans_reduction(outfile, data, pairs, mask, direct)[source]¶ Create a reduction script for sans data
Parameters: - outfile (str) – The path where the script should be saved
- data (dict) – The sample dictionary extracted from the sample log
- pairs (dict) – A dictionary with sample names as the keys and the corresponding blank samples as the values
- mask (str) – The mask file for the reduction
- direct (int) – The run number for the direct run
-
src.reduction.sesans_connection(start, end, path)[source]¶ Connect the runs for a series of sesans measurements
Util¶
Useful utilities for scriping
-
src.Util.dae_setter(suffix, measurement_type)[source]¶ Declare that a method sets the DAE wiring table
Parameters: Returns: - A decorator for setting the dae mode
- This decorator was designed to work on subclasses of the
src.Instrument.ScanningInstrumentclass. 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
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
setup_dae_diffraction(self, *args, **kwargs)[source]¶ Set the wiring tables for a diffraction measurement
-
setup_dae_event_fastsave(*args, **kwargs)[source]¶ Event mode with reduced detector histogram binning to decrease filesize.
-
static
setup_dae_monitorsonly(self, *args, **kwargs)[source]¶ Set the wiring tables to record only the monitors.
-
setup_dae_nrscanning(*args, **kwargs)[source]¶ Set the wiring tables for performing scans during neutron reflectivity
-
static
setup_dae_polarised(self, *args, **kwargs)[source]¶ Set the wiring tables for a polarisation measurement.
-
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_transmission(*args, **kwargs)[source]¶ Set the wiring tables for a transmission measurement
-
static