Welcome to genie_python’s documentation!¶
Commands¶
- class genie.GetSampleParsReturnMEAS¶
- class genie.GetSampleParsReturnSCRIPT¶
- genie.abort(verbose: bool = False, prepost: bool = True) None ¶
Abort the current run.
- Parameters:
verbose (bool, optional) – show the messages from the DAE
prepost (bool, optional) – run pre and post commands (default: True)
- genie.begin(period: int = 1, meas_id: str | None = None, meas_type: str = '', meas_subid: str = '', sample_id: str = '', delayed: bool = False, quiet: bool = False, paused: bool = False, verbose: bool = False, prepost: bool = True) None ¶
Starts a data collection run.
- Parameters:
period (int, optional) – the period to begin data collection in
meas_id (string, optional) – the measurement id
meas_type (string, optional) – the type of measurement
meas_subid (string, optional) – the measurement sub-id
sample_id (string, optional) – the sample id
delayed (bool, optional) – puts the period card to into delayed start mode
quiet (bool, optional) – suppress the output to the screen
paused (bool, optional) – begin in the paused state
verbose (bool, optional) – show the messages from the DAE
prepost (bool, optional) – run pre and post commands (default: True)
- Returns:
return what the begin_postcmd method returns
- Return type:
Any
- genie.cget(block: str) _CgetReturn ¶
Gets the useful values associated with a block.
The value will be None if the block is not “connected”.
- Parameters:
block (string) – the name of the block
- Returns
- dict: details about about the block. Contains:
name - name of the block value - value of the block unit - physical units of the block connected - True if connected; False otherwise runcontrol - NO not in runcontrol, YES otherwise lowlimit - run control low limit set highlimit - run control high limit set alarm - the alarm status of the block
- genie.change(**params: str | int) None ¶
Change experiment parameters.
Note: it is possible to change more than one item at a time.
- Parameters:
title (string, optional) – the new title
period (int, optional) – the new period (must be in a non-running state)
nperiods (int, optional) – the new number of software periods (must be in a non-running state)
user (string, optional) – the new user(s) as a comma-separated list
rb (int, optional) – the new RB number
Examples
Change the title:
>>> change(title="The new title")
Change the user:
>>> change(user="Instrument Team")
Set multiple users:
>>> change(user="Thouless, Haldane, Kosterlitz")
Change the RB number and the users:
>>> change(rb=123456, user="Smith, Jones")
- genie.change_beamline_par(name: str, value: bool | int | float | str | None) None ¶
Set a new value for a beamline parameter
- Parameters:
name (string) – the name of the parameter to change
value – the new value
- genie.change_fermi_veto(enable: bool | None = None, delay: float = 1.0, width: float = 1.0) None ¶
Configure the fermi chopper veto.
- Parameters:
enable (bool, optional) – enable the fermi veto
delay (float, optional) – the veto delay
width (float, optional) – the veto width
- genie.change_finish() None ¶
End a change operation.
The operation is begun when change_start is called.
Between these two calls a sequence of other change commands can be called. For example: change_tables, change_tcb etc.
- genie.change_monitor(spec: int, low: float, high: float) None ¶
Change the monitor to a specified spectrum and range.
- Parameters:
spec (int) – the spectrum number
low (float) – the low end of the integral
high (float) – the high end of the integral
- genie.change_number_soft_periods(number: int, enable: bool = False) None ¶
Sets the number of software periods for the DAE.
- Parameters:
number (int) – the number of periods to create
enable (bool, optional) – switch to soft period mode
- genie.change_period(period: int) None ¶
Changes the current period number.
- Parameters:
period (int) – the period to switch to
- genie.change_rb(rb: int | str) None ¶
Changes the RB number.
- Parameters:
rb (int or string) – the new RB number
- genie.change_sample_par(name: str, value: bool | int | float | str | None) None ¶
Set a new value for a sample parameter.
- Parameters:
name (string) – the name of the parameter to change
value – the new value
- genie.change_script_dir(*directory: str) None ¶
Set the directory for loading user scripts from.
- Parameters:
directory (string|List(string)) – the directory to load user scripts from, either as a single entry or as multiple arguments
Example
g.change_script_dir(r”c/scrips/mydir”) g.change_script_dir(r”c/scrips”, “mydir”)
- genie.change_start() None ¶
Start a change operation.
The operation is finished when change_finish is called.
Between these two calls a sequence of other change commands can be called. For example: change_tables, change_tcb etc.
- genie.change_sync(source: str) None ¶
Change the source the DAE using for synchronisation.
- Parameters:
source (string) – the source to use ( ‘isis’, ‘internal’, ‘smp’, ‘muon cerenkov’, ‘muon ms’, ‘isis (first ts1)’
)
- genie.change_tables(wiring: str | None = None, detector: str | None = None, spectra: str | None = None) None ¶
Load the wiring, detector and/or spectra tables. Checks that the file paths are valid, throws exception if not. :param wiring: the filename of the wiring table file :type wiring: string, optional :param detector: the filename of the detector table file :type detector: string, optional :param spectra: the filename of the spectra table file :type spectra: string, optional
- genie.change_tcb(low: float | None = None, high: float | None = None, step: float | None = None, trange: int = 1, log: bool = False, regime: int = 1) None ¶
Change the time channel boundaries. If None is specified for low, high or step then the values are left unchanged.
- Args
low (float, optional): the lower limit. Default is no change from the current value. high (float, optional): the upper limit. Default is no change from the current value. step (float,optional): the step size. Default is no change from the current value. trange (int, optional): the time range (1 to 5). Default is 1. log (bool, optional): whether to use LOG binning. Default is no. regime (int, optional): the time regime to set (1 to 6). Default is 1.
Examples
Changes the from, to and step of the 1st range to 0, 10 and 5 respectively.
>>> change_tcb(0, 10, 5)
Changes the step size of the 2nd range to 2, leaving other parameters unchanged.
>>> change_tcb(step=2, trange=2)
- genie.change_tcb_file(tcbfile: str | None = None, default: bool = False) None ¶
Change the time channel boundaries.
- Parameters:
tcbfile (string, optional) – the file to load
default (bool, optional) – load the default file
- genie.change_title(title: str) None ¶
Sets the current title.
- Parameters:
title – the new title
- genie.change_users(users: str) None ¶
Changes the users.
- Parameters:
users – a string containing the user name(s)
Example
>>> change_users("Emerson, Lake, Palmer")
- genie.change_vetos(**params: bool | None) None ¶
Change the DAE veto settings.
- Parameters:
clearall (bool, optional) – remove all vetos
smp (bool, optional) – set SMP veto
ts2 (bool, optional) – set TS2 veto
hz50 (bool, optional) – set 50 hz veto
ext0 (bool, optional) – set external veto 0
ext1 (bool, optional) – set external veto 1
ext2 (bool, optional) – set external veto 2
ext3 (bool, optional) – set external veto 3
fifo (bool, optional) – set FIFO veto
Note: If clearall is specified then all vetos (excluding the FIFO veto) are turned off, but it is possible to turn other vetoes back on at the same time.
Note: FIFO veto is automatically enabled on run begin, but can be changed whilst running.
Examples
Turns all vetoes off then turns the SMP veto back on:
>>> change_vetos(clearall=True, smp=True)
Turn off FIFO:
>>> change_vetos(fifo=False)
- genie.check_alarms(*blocks: str) tuple[list[str], list[str], list[str]] ¶
Checks whether the specified blocks are in alarm.
- Parameters:
blocks (string, multiple) – the block(s) to check
- Returns:
the blocks in minor alarm and major alarm respectively
- Return type:
list, list
Example
Check alarm state for block1 and block2:
>>> check_alarms("block1", "block2")
- genie.check_limit_violations(*blocks: str) list[str] ¶
Checks whether the specified blocks have soft limit violations.
- Parameters:
blocks (string, multiple) – the block(s) to check
- Returns:
the blocks that have soft limit violations
- Return type:
list
Example
Check soft limit violations for block1 and block2:
>>> check_limit_violations("block1", "block2")
- genie.configure_internal_periods(sequences: int | None = None, output_delay: int | None = None, period: int | None = None, daq: bool = False, dwell: bool = False, unused: bool = False, frames: int | None = None, output: int | None = None, label: str | None = None) None ¶
Configure the internal periods without switching to internal period mode.
- Parameters:
sequences (int, optional) – the number of times to repeat the period loop (0 = infinite loop)
output_delay (int, optional) – the output delay in microseconds
period (int, optional) – the number of the period to set the following parameters for
daq (bool, optional) – the specified period is a acquisition period
dwell (bool, optional) – the specified period is a dwell period
unused (bool, optional) – the specified period is a unused period
frames (int, optional) – the number of frames to count for the specified period
output (int, optional) – the binary output the specified period
label (string, optional) – the label for the period the specified period
Note: if the period number is unspecified then the settings will be applied to all periods
- genie.connected_pvs_in_list(pv_list: list[str], is_local: bool = False) list[str] ¶
Check if the specified PVs are connected.
- Parameters:
pv_list (list) – the PV names
is_local (bool, optional) – whether to automatically prepend the local inst prefix to the PV names
- Returns:
the PV names that are connected
- Return type:
list
- genie.cset(*args: str, runcontrol: bool | None = None, lowlimit: float | None = None, highlimit: float | None = None, wait: bool | None = None, verbose: bool | None = None, **kwargs: bool | int | float | str | None) None ¶
Sets the setpoint and runcontrol settings for blocks.
- Parameters:
runcontrol (bool, optional) – whether to set runcontrol for this block
wait (bool, optional) – pause execution until setpoint is reached (one block only)
lowlimit (float, optional) – the lower limit for runcontrol or waiting
highlimit (float, optional) – the upper limit for runcontrol or waiting
verbose (bool, optional) – report what the new block state is as a result of the command
Note: cannot use wait and runcontrol in the same command
Examples
Setting a value for a block:
>>> cset(block1=100)
Or:
>>> cset("block1", 100)
Setting values for more than one block:
>>> cset(block1=100, block2=200, block3=300)
NOTE: the order in which the values are set is random, e.g. block1 may or may not be set before block2 and block3
Setting runcontrol values for a block:
>>> cset(block1=100, runcontrol=True, lowlimit=99, highlimit=101)
Changing runcontrol settings for a block without changing the setpoint:
>>> cset("block1", runcontrol=False) >>> cset(block1=None, runcontrol=False)
Wait for setpoint to be reached (one block only):
>>> cset(block1=100, wait=True)
Wait for limits to be reached - this does NOT change the runcontrol limits:
>>> cset(block1=100, wait=True, lowlimit=99, highlimit=101)
- genie.cshow(block: str | None = None) None ¶
Show the current settings for one block or for all blocks.
- Parameters:
block (string, optional) – the name of the block
Examples
Showing all block values:
>>> cshow()
Showing values for one block only (name must be quoted):
>>> cshow("block1")
- genie.define_hard_period(period: int | None = None, daq: bool = False, dwell: bool = False, unused: bool = False, frames: int | None = None, output: int | None = None, label: str | None = None) None ¶
Define the internal hardware periods.
- Parameters:
period (int, optional) – the number of the period to set the following parameters for
daq (bool, optional) – the specified period is a acquisition period
dwell (bool, optional) – the specified period is a dwell period
unused (bool, optional) – the specified period is a unused period
frames (int, optional) – the number of frames to count for the specified period
output (int, optional) – the binary output the specified period
label (string, optional) – the label for the period the specified period
Note: if the period number is unspecified then the settings will be applied to all periods
- genie.enable_hard_periods(mode: str, period_file: str | None = None, sequences: int | None = None, output_delay: int | None = None, period: int | None = None, daq: bool = False, dwell: bool = False, unused: bool = False, frames: int | None = None, output: int | None = None, label: str | None = None) None ¶
Sets the DAE to use hardware periods.
- Parameters:
mode (string) – set the mode to internal (‘int’) or external (‘ext’)
period_file (string, optional) – the file containing the internal period settings (ignores any other settings)
sequences (int, optional) – the number of times to repeat the period loop (0 = infinite loop)
output_delay (int, optional) – the output delay in microseconds
period (int, optional) – the number of the period to set the following parameters for
daq (bool, optional) – the specified period is a acquisition period
dwell (bool, optional) – the specified period is a dwell period
unused (bool, optional) – the specified period is a unused period
frames (int, optional) – the number of frames to count for the specified period
output (int, optional) – the binary output the specified period
label (string, optional) – the label for the period the specified period
Note: if the period number is unspecified then the settings will be applied to all periods
Examples
Setting external periods:
>>> enable_hard_periods("ext")
Setting internal periods from a file:
>>> enable_hard_periods("int", "c:\myperiods.txt")
- genie.enable_soft_periods(nperiods: int | None = None) None ¶
Switch the DAE to software periods mode.
- Parameters:
nperiods (int, optional) – the number of software periods
- genie.end(verbose: bool = False, quiet: bool = False, immediate: bool = False, prepost: bool = False) None ¶
End the current run.
- Parameters:
verbose (bool, optional) – show the messages from the DAE
quiet (bool, optional) – suppress the end_precmd output to the screen
immediate (bool, optional) – end immediately, without waiting for a period sequence to complete
prepost (bool, optional) – run pre and post commands (default: True)
- genie.get_beamline_pars() _GetbeamlineparsReturn ¶
Get the current beamline parameter values.
- Returns:
the beamline parameters
- Return type:
dict
- genie.get_block_units(block_name: str) str | dict | None ¶
Get the physical measurement units associated with a block name.
- Parameters:
block_name – name of the block
- Returns
string: units of the block
- genie.get_blocks() list[str] ¶
Get the names of the blocks.
- Returns:
the blocknames
- Return type:
list
- genie.get_dae_simulation_mode() bool ¶
Gets the DAE simulation mode. :returns: True if the DAE is in simulation mode, False otherwise.
- genie.get_dashboard() _GetdashboardReturn ¶
Get the current experiment values.
- Returns:
the experiment values
- Return type:
dict
- genie.get_detector_table() str | None ¶
Gets the current detector table path”
- Returns:
The file path of the current detector table.
- genie.get_detector_tables() list[str] ¶
Gets a list of possible detector table choices.
- Returns:
the files
- Return type:
list
- genie.get_display_title() bool ¶
Returns the current display title status.
- Returns:
the display title status
- Return type:
boolean
- genie.get_events() int ¶
Gets the total events for all the detectors.
- Returns:
the number of events
- Return type:
int
- genie.get_frames(period: bool = False) int ¶
Gets the current number of good frames.
- Parameters:
period (bool, optional) – whether to return the value for the current period only
- Returns:
the number of frames
- Return type:
int
- genie.get_mevents() float ¶
Gets the total millions of events for all the detectors.
- Returns:
the number of millions of events
- Return type:
float
- genie.get_number_periods() int ¶
Get the number of software periods.
- Returns:
the number of periods
- Return type:
int
- genie.get_number_spectra() int ¶
Get the number of spectra. The diagnostic spectrum zero is not included in the count, so valid spectrum numbers are 0 to get_number_spectra()
- Returns:
the number of spectra
- Return type:
int
- genie.get_number_timechannels() int ¶
Get the number of time channels. This is the number of bins used to map the time region of interest, it does not include the special diagnostic “bin zero” in this count but this fact is not normally of interest to most users.
- Returns:
the number of time channels
- Return type:
int
- genie.get_period() int ¶
Gets the current period number.
- Returns:
the current period
- Return type:
int
- genie.get_period_files() list[str] ¶
Gets a list of possible period file choices.
- Returns:
the files
- Return type:
list
- genie.get_pv(name: str, to_string: bool = False, is_local: bool = False, use_numpy: bool = False) bool | int | float | str | list[bool | int | float | str] | ndarray[Any, dtype[_ScalarType_co]] | None ¶
Get the value for the specified PV.
- Parameters:
name (string) – the name of the PV to get the value for
to_string (bool, optional) – whether to get the value as a string
is_local (bool, optional) – whether to automatically prepend the local inst prefix to the PV name
use_numpy (bool, optional) – True use numpy to return arrays, False return a list; None for use the default
- Returns:
the current PV value
- genie.get_raw_frames(period: bool = False) int ¶
Gets the current number of raw frames.
- Parameters:
period (bool, optional) – whether to return the value for the current period only
- Returns:
the number of raw frames
- Return type:
int
- genie.get_rb() str ¶
Returns the current RB number.
- Returns:
the RB number
- Return type:
string
- genie.get_runnumber() str ¶
Get the current run-number.
- Returns:
the run-number
- Return type:
string
- genie.get_runstate() str ¶
Get the current status of the instrument as a string.
Note: this value can take a few seconds to update after a change of state.
- Returns:
the current run state
- Return type:
string
- genie.get_sample_pars() _GetSampleParsReturn ¶
Get the current sample parameter values.
- Returns:
the sample parameters
- Return type:
dict
- genie.get_script_dir() str ¶
Get the current script directory.
- Returns:
the directory
- Return type:
string
- genie.get_spectra_table() str | None ¶
Gets the current spectra table path”
- Returns:
The file path of the current spectra table.
- genie.get_spectra_tables() list[str] ¶
Gets a list of possible spectra table choices.
- Returns:
the files
- Return type:
list
- genie.get_spectrum(spectrum: int, period: int = 1, dist: bool = True) _GetspectrumReturn ¶
Get the specified spectrum from the DAE.
- Parameters:
spectrum (int) – the spectrum number
period (int, optional) – the period
dist (bool, optional) – whether to get the spectrum as a distribution. Default is True.
- Returns:
dictionary of values
- Return type:
dict
- genie.get_spectrum_data(with_spec_zero: bool = True) ndarray[Any, dtype[_ScalarType_co]] ¶
Get the event mode spectrum data as numpy ND array.
- Parameters:
with_spec_zero (bool, optional) – Include or exclude diagnostic spectrum 0 if you have 10 spectra and include spectrum zero, you array will be of size 11 and spectrum 5 will be at array[5]. If you exclude spectrum zero then spectrum 5 would be at array[4]
- Returns:
- spectrum data ND array
this is of dimensions [periods, spectra, time_bins]
- Return type:
numpy int array
- genie.get_spectrum_integrals(with_spec_zero: bool = True) ndarray[Any, dtype[_ScalarType_co]] ¶
Get the event mode spectrum integrals as numpy ND array.
- Parameters:
with_spec_zero (bool, optional) – Include or exclude diagnostic spectrum 0 if you have 10 spectra and include spectrum zero, your array will be of size 11 and spectrum 5 will be at array[5]. If you exclude spectrum zero then spectrum 5 would be at array[4]
- Returns:
- spectrum integrals numpy ND array
this is of dimensions [periods, spectra]
- Return type:
numpy int array
- genie.get_tcb_settings(trange: int, regime: int = 1) dict[str, int] ¶
Gets a dictionary of the time channel settings.
- Parameters:
trange (int) – the time range to read (1 to 5)
regime (int, optional) – the regime to read (1 to 6). Default is 1.
- Returns:
the low, high and step for the supplied range and regime
- Return type:
dict
Examples
Get the step size for the 2nd range in the 3rd regime:
>>> get_tcb_settings(2, 3)["Steps"]
Get the step size for the 2nd range in the 3rd regime:
>>> get_tcb_settings(2, 3)["Steps"]
- genie.get_time_since_begin(get_timedelta: bool = False) float | timedelta ¶
Gets the time since start of the current run in seconds or in datetime
- Parameters:
get_timedelta (bool) – If true return the value as a datetime object, otherwise return seconds (defaults to false)
- Returns
- integer: the time since start in seconds if get_datetime is False,
or timedelta, the time since begin as a datetime.timedelta object (Year-Month-Day Hour:Minute:Second) if get_datetime is True
- genie.get_title() str ¶
Returns the current title.
- Returns:
the title
- Return type:
string
- genie.get_totalcounts() int ¶
Get the total counts for the current run.
- Returns:
the total counts
- Return type:
int
- genie.get_uamps(period: bool = False) float ¶
Get the current number of micro-amp hours.
- Parameters:
period (bool, optional) – whether to return the value for the current period only
- Returns:
the number of uamps
- Return type:
float
- genie.get_users() str ¶
Get the users.
- Returns:
the users.
- Return type:
str
- genie.get_version() str ¶
Tells you the version of genie_python that is used.
- Returns:
The current version number of genie python
- Return type:
string
- genie.get_wiring_table() str | None ¶
Gets the current wiring table path”
- Returns:
The file path of the current wiring table.
- genie.get_wiring_tables() list[str] ¶
Gets a list of possible wiring table choices.
- Returns:
the files
- Return type:
list
- genie.integrate_spectrum(spectrum: int, period: int = 1, t_min: float | None = None, t_max: float | None = None) float | None ¶
Integrates the spectrum within the time period and returns neutron counts.
The underlying algorithm sums the counts from each bin, if a bin is split by the time region then a proportional fraction of the count for that bin is used.
- Parameters:
spectrum (int) – the spectrum number
period (int, optional) – the period
t_min (float, optional) – time of flight to start from
t_max (float, optional) – time of flight to finish at
- Returns:
integral of the spectrum (neutron counts); None spectrum can not be read
- Return type:
float
- genie.load(name: str) None ¶
Informs the user that load may not be the function they want. Prints a message telling the user about g.loadscript and numpy.load.
- Parameters:
name (string) – The script the user is trying to load.
- genie.load_script(name: str, check_script: bool = True, warnings_as_error: bool = False) None ¶
Loads a user script.
- Parameters:
name (string) – the name of the file to load. If this is not a full path the file is assumed to be in C:scripts
check_script – When True run the script checker on the script; False otherwise (default True)
warnings_as_error – When true throw an exception on a warning; False otherwise (default False)
- genie.pause(verbose: bool = False, immediate: bool = False, prepost: bool = True) None ¶
Pause the current run.
- Parameters:
verbose (bool, optional) – show the messages from the DAE
immediate (bool, optional) – pause immediately, without waiting for a period sequence to complete
prepost (bool, optional) – run pre and post commands (default: True)
- genie.plot_spectrum(spectrum: int, period: int = 1, dist: bool = True) object ¶
Get the specified spectrum from the DAE and plot it. Returns the plot that was created.
Note: this will replace any other plots which are open.
- Parameters:
spectrum (int) – the spectrum number
period (int, optional) – the period. Default is 1
dist (bool, optional) – whether to get the spectrum as a distribution. Default is True
- Returns:
The created plot
- genie.prefix_pv_name(name: str) str ¶
Prepends the instrument PV prefix on to the supplied PV name
- Parameters:
name (string) – The PV without the prefix.
- Returns:
The PV with the instrument prefix prepended
- Return type:
string
- genie.recover(verbose: bool = False) None ¶
Recovers the run if it has been aborted. The command should be run before the next run is started.
Note: the run will be recovered in the paused state.
- Parameters:
verbose (bool, optional) – show the messages from the DAE
- genie.reload_current_config() None ¶
Reload the current configuration.
- genie.resume(verbose: bool = False, prepost: bool = False) None ¶
Resume the current run after it has been paused.
- Parameters:
verbose (bool, optional) – show the messages from the DAE
prepost (bool, optional) – run pre and post commands (default: True)
- genie.send_alert(message: str, inst: str | None = None) None ¶
Sends an alert message for the specified instrument.
- Parameters:
message (string) – the message to send
inst (string, optional) – the instrument to generate the alert for. Defaults to current instrument.
- genie.send_email(address: str, message: str) None ¶
Sends a message to an email address.
- Parameters:
address (string) – the email address to use
message (string) – the message to send
- genie.send_sms(phone_num: str, message: str) None ¶
Sends an SMS message to a phone number. If you are sending to messages to the same number often consider using g.alerts.send()
- Parameters:
phone_num (string) – the phone number to send the SMS to
message (string) – the message to send
- genie.set_dae_simulation_mode(mode: bool, skip_required_runstates: bool = False) None ¶
Sets the DAE into simulation mode.
- Parameters:
mode – True to set the DAE into simulated mode, False to set the DAE into non-simulated (hardware) mode
skip_required_runstates – Ignore all checks, use with caution
- genie.set_display_title(display_title: bool) None ¶
Sets the current display title status.
- Parameters:
display_title – the new display title status
- genie.set_instrument(pv_prefix: str, import_instrument_init: bool = True) None ¶
Sets the instrument this session is communicating with. Used for remote access - do not delete.
- Parameters:
pv_prefix (string) – the PV prefix
import_instrument_init (bool) – if True import the instrument init
don't (from the config area; otherwise)
- genie.set_pv(name: str, value: bool | int | float | str | list[bool | int | float | str] | ndarray[Any, dtype[_ScalarType_co]] | None, wait: bool = False, is_local: bool = False) None ¶
Set the value for the specified PV.
- Parameters:
name (string) – the PV name
value – the new value to set
wait (bool, optional) – whether to wait until the value has been received by the hardware
is_local (bool, optional) – whether to automatically prepend the local inst prefix to the PV name
- genie.snapshot_crpt(filename: str = 'c:\\Data\\snapshot_crpt.tmp', verbose: bool = False) None ¶
Create a snapshot of the current data.
- Parameters:
filename (string, optional) – where to write the data file(s)
verbose (bool, optional) – show the messages from the DAE
Examples
Snapshot to a file called my_snapshot:
>>> snapshot_crpt("c:\Data\my_snapshot")
- genie.store(verbose: bool = False) None ¶
Data loaded into memory by a previous update command is now written to disk.
- Parameters:
verbose (bool, optional) – show the messages from the DAE
- genie.update(pause_run: bool = True, verbose: bool = False) None ¶
Data is loaded from the DAE into the computer memory, but is not written to disk.
- Parameters:
pause_run (bool, optional) – whether to pause data collection first [optional]
verbose (bool, optional) – show the messages from the DAE
- genie.updatestore(verbose: bool = False) None ¶
Performs an update and a store operation in a combined operation. This is more efficient than doing the commands separately.
- Parameters:
verbose (bool, optional) – show the messages from the DAE
- genie.waitfor(block: str | None = None, value: float | None = None, lowlimit: float | None = None, highlimit: float | None = None, maxwait: float | None = None, wait_all: bool = False, seconds: float | None = None, minutes: float | None = None, hours: float | None = None, time: str | None = None, frames: int | None = None, raw_frames: int | None = None, uamps: float | None = None, mevents: float | None = None, early_exit: ~typing.Callable[[], bool] = <function <lambda>>, quiet: bool = False, **pars: bool | int | float | str | ~typing.Callable[[None], bool] | None) None ¶
Interrupts execution until certain conditions are met.
- Parameters:
block (string, optional) – the name of the block to wait for
value (float, optional) – the block value to wait for
lowlimit (float, optional) – wait for the block to be >= this value (numeric only)
highlimit (float, optional) – wait for the block to be <= this value (numeric only)
maxwait (float, optional) – wait no longer that the specified number of seconds
wait_all (bool, optional) – wait for all conditions to be met (e.g. a number of frames and an amount of uamps)
seconds (float, optional) – wait for a specified number of seconds
minutes (float, optional) – wait for a specified number of minutes
hours (float, optional) – wait for a specified number of hours
time (string, optional) – a quicker way of setting hours, minutes and seconds (must be of format “HH:MM:SS”)
frames (int, optional) – wait for a total number of good frames to be collected
raw_frames (int, optional) – wait for a total number of raw frames to be collected
uamps (float, optional) – wait for a total number of uamps to be received
mevents (float, optional) – wait for a total number of millions of events to be collected
early_exit (lambda, optional) – stop waiting if the function evaluates to True
quiet (bool, optional) – suppress normal output messages to the console
Examples
Wait for a block to reach a specific value:
>>> waitfor(myblock=123) >>> waitfor("myblock", 123) >>> waitfor("myblock", True) >>> waitfor("myblock", "OPEN")
Wait for a block to be between limits:
>>> waitfor("myblock", lowlimit=100, highlimit=110)
Wait for a block to reach a specific value, but no longer than 60 seconds:
>>> waitfor(myblock=123, maxwait=60)
Wait for a specified time interval:
>>> waitfor(seconds=10) >>> waitfor(hours=1, minutes=30, seconds=15) >>> waitfor(time="1:30:15")
Wait for a data collection condition:
>>> waitfor(frames=5000) >>> waitfor(uamps=200)
Wait for either a number of frames OR a time interval to occur:
>>> waitfor(frames=5000, hours=2)
Wait for a number of frames AND a time interval to occur:
>>> waitfor(frames=5000, hours=2, wait_all=True)
Wait for either the block to reach a value or a condition to be met:
>>> waitfor(myblock=123, early_exit=lambda: some_function(cget("another_block")["value"]) > 123)
- genie.waitfor_block(block: str, value: bool | int | float | str | None = None, lowlimit: float | None = None, highlimit: float | None = None, maxwait: float | None = None, early_exit: ~typing.Callable[[], bool] = <function <lambda>>, quiet: bool = False) None ¶
Interrupts execution until block reaches specific value
- Parameters:
block – the name of the block to wait for
value – the target block value
lowlimit – waits for the block to be >= this value (numeric only)
highlimit – waits for the block to be <= this value (numeric only)
maxwait – wait no longer that the specified number of seconds
early_exit – stop waiting if the exception evaluates to True
quiet (bool, optional) – suppress normal output messages to the console
Examples
>>> waitfor_block("myblock", value=123) >>> waitfor_block("myblock", value=True, maxwait=15) >>> waitfor_block("myblock", lowlimit=100, highlimit=110) >>> waitfor_block("myblock", highlimit=1.0, maxwait=60) >>> waitfor_block( ... "myblock", value=123, early_exit=lambda: cget("myblock_limit_reached")["value"] != 0 ... )
- genie.waitfor_frames(frames: int, quiet: bool = False) None ¶
Interrupts execution to wait for number of total good frames to reach parameter value
- Parameters:
frames (int) – the number of frames to wait for
quiet (bool, optional) – suppress normal output messages to the console
Example
>>> waitfor_frames(4000)
- genie.waitfor_mevents(mevents: float, quiet: bool = False) None ¶
Interrupts execution to wait for number of millions of events to reach parameter value
- Parameters:
mevents (float) – the number of millions of events to wait for
quiet (bool, optional) – suppress normal output messages to the console
Example
>>> waitfor_mevents(0.0004)
- genie.waitfor_move(*blocks: str | None, **kwargs: int | None) None ¶
Wait for all motion or specific motion to complete.
If block names are supplied then it will only wait for those to stop moving. Otherwise, it will wait for all motion to stop.
- Parameters:
blocks (string, multiple, optional) – the names of specific blocks to wait for
start_timeout (int, optional) – the number of seconds to wait for the movement to begin (default = 2 seconds)
move_timeout (int, optional) – the maximum number of seconds to wait for motion to stop
Examples
Wait for all motors to stop moving:
>>> waitfor_move()
Wait for all motors to stop moving with a timeout of 30 seconds:
>>> waitfor_move(move_timeout=30)
Wait for only slit1 and slit2 motors to stop moving:
>>> waitfor_move("slit1", "slit2")
- genie.waitfor_raw_frames(raw_frames: int, quiet: bool = False) None ¶
Interrupts execution to wait for number of total raw frames to reach parameter value
- Parameters:
frames (raw) – the number of raw frames to wait for
quiet (bool, optional) – suppress normal output messages to the console
Example
>>> waitfor_raw_frames(4000)
- genie.waitfor_runstate(state: str, maxwaitsecs: int = 3600, onexit: bool = False, quiet: bool = False) None ¶
Wait for a particular instrument run state.
- Parameters:
state (string) – the state to wait for (e.g. “paused”)
maxwaitsecs (int, optional) – the maximum time to wait for the state before carrying on
onexit (bool, optional) – wait for runstate to change from the specified state
quiet (bool, optional) – suppress normal output messages to the console
Examples
Wait for a run to enter the paused state:
>>> waitfor_runstate("paused")
Wait for a run to exit the paused state:
>>> waitfor_runstate("paused", onexit=True)
- genie.waitfor_time(seconds: float | None = None, minutes: float | None = None, hours: float | None = None, time: str | None = None, quiet: bool = False) None ¶
Interrupts execution for a specified amount of time
- Parameters:
seconds (float, optional) – wait for a specified number of seconds
minutes (float, optional) – wait for a specified number of minutes
hours (float, optional) – wait for a specified number of hours
time (string, optional) – a quicker way of setting hours, minutes and seconds (must be of format “HH:MM:SS”)
quiet (bool, optional) – suppress normal output messages to the console
Examples
>>> waitfor_time(seconds=10) >>> waitfor_time(hours=1, minutes=30, seconds=15) >>> waitfor_time(time="1:30:15")
- genie.waitfor_uamps(uamps: float, quiet: bool = False) None ¶
Interrupts execution to wait for a specific total charge
- Parameters:
uamps – the charge to wait for
quiet (bool, optional) – suppress normal output messages to the console
Example
>>> waitfor_uamps(115.5)
Genie Advanced module:
This module is used for advanced commands that are for expert users.
- genie_advanced.assert_in_manager_mode() None ¶
Checks that the user is in manager mode so can use advanced functions.
Args:
Returns:
- genie_advanced.get_exp_data(rb: int | str = '%', user: str = '%', role: str = '%', verbose: bool = False) list[_GetExpDataReturn] ¶
Returns the data of experiments that match the given criteria, or all if none is given, from the exp_data database. If verbose is enabled, only pretty-print the data.
- Parameters:
rb (int, optional) – The RB number of the experiment to look for, Defaults to Any.
user (str, optional) – The name of the user who is running/has run the experiment, Defaults to Any.
role (str, optional) – The user role, Defaults to Any.
verbose (bool, optional) – Pretty-print the data, Defaults to False.
- Returns:
The experiment(s) data as a list of dicts.
- Return type:
exp_data (list)
- Raises:
NotFoundError – Thrown if a parameter’s value was not found in the database.
- genie_advanced.get_instrument() str | None ¶
Gets the name of the local instrument (e.g. NDW1234, DEMO, EMMA-A)
- Returns:
the name of the local instrument
- genie_advanced.get_manager_mode() bool ¶
Returns whether you are in manager mode or not.
- Returns:
Manager mode on or off.
- Return type:
manager_mode (Bool)
- genie_advanced.get_pv_from_block(block: str) str ¶
Get the full PV name for a given block. This is an advanced function because of the need to use the pv name correctly.
- Parameters:
block (str) – A block object
- Returns:
The pv name as a string
- Return type:
pv_name (Str)
- genie_advanced.get_spectrum_data(with_spec_zero: bool = True, with_time_bin_zero: bool = False) ndarray[Any, dtype[_ScalarType_co]] ¶
Get the event mode spectrum data as ND array.
- Parameters:
with_spec_zero (bool, optional) – Include or exclude diagnostic spectrum 0 if you have 10 spectra and include spectrum zero, your array will be of size 11 and spectrum 5 will be at array[5]. If you exclude spectrum zero then spectrum 5 would be at array[4]
with_time_bin_zero (bool, optional) – Include or exclude diagnostic bin 0 if you have 1000 time channels and include time bin 0, your array will be of size 1001 and data for your defined time bins will start at array[1] rather than array[0]. This bin contents is only of use for diagnostic issues, it contains data that does not fit into the defined time range
- Returns:
- spectrum data ND array
this is of dimensions [periods, spectra, time_bins]
- Return type:
numpy int array
- genie_advanced.motor_in_set_mode(pv_name: str) Iterator ¶
Uses a context to place motor into set mode and ensure that it leaves set mode after context has ended. If it can not set the mode correctly will not run the yield.
- Parameters:
pv_name – pv of motor on which to set the mode
Returns:
- genie_advanced.open_plot_window(is_primary: bool = True, host: str | int | None = None, figures: list[int] | None = None) None ¶
Open the plot window in a locally running client (even if this is called in a standalone genie_python) :param is_primary: True to open primary plotting window; False open secondaty window :param host: host to open plot from; Default None is localhost :param figures: List of figures to open; Default opens all figures
- genie_advanced.pv_exists(pv: str, is_local: bool = False) None ¶
Check if PV exists.
- Params:
pv (str): The address of the PV is_local (bool, optional): is it a local PV i.e. needs prefix adding
- genie_advanced.redefine_motor_position(name: str, value: float | int) None ¶
Change the motor Move Abs value.
- Parameters:
name – Name of the motor. e.g MTR0101
value – The new value of Move Abs.
Returns:
- genie_advanced.set_abort_postcmd(abort_postcmd: Callable[[Any], str | None]) None ¶
Set the function to call after the abort command.
- Parameters:
abort_postcmd (function) – The function to call.
- genie_advanced.set_abort_precmd(abort_precmd: Callable[[Any], str | None]) None ¶
Set the function to call before the abort command.
- Parameters:
abort_precmd (function) – The function to call.
- genie_advanced.set_begin_postcmd(begin_postcmd: Callable[[Any], str | None]) None ¶
Set the function to call after the begin command.
- Parameters:
begin_postcmd (function) – The function to call.
- genie_advanced.set_begin_precmd(begin_precmd: Callable[[Any], str | None]) None ¶
Set the function to call before the begin command.
- Parameters:
begin_precmd (function) – The function to call (which should return
start (None if it wants the run to)
run). (or a string with the reason why not to start)
- genie_advanced.set_dae_message_verbosity(verbose: bool) None ¶
Set the verbosity of messages coming from the DAE.
- Parameters:
verbose (bool) – set the verbosity, True to be more verbose
- genie_advanced.set_end_postcmd(end_postcmd: Callable[[Any], str | None]) None ¶
Set the function to call after the end command.
- Parameters:
end_postcmd (function) – The function to call.
- genie_advanced.set_end_precmd(end_precmd: Callable[[Any], str | None]) None ¶
Set the function to call before the end command.
- Parameters:
end_precmd (function) – The function to call.
- genie_advanced.set_pause_postcmd(pause_postcmd: Callable[[Any], str | None]) None ¶
Set the function to call after the pause command.
- Parameters:
pause_postcmd (function) – The function to call.
- genie_advanced.set_pause_precmd(pause_precmd: Callable[[Any], str | None]) None ¶
Set the function to call before the pause command.
- Parameters:
pause_precmd (function) – The function to call.
- genie_advanced.set_resume_postcmd(resume_postcmd: Callable[[Any], str | None]) None ¶
Set the function to call after the resume command.
- Parameters:
resume_postcmd (function) – The function to call.
- genie_advanced.set_resume_precmd(resume_precmd: Callable[[Any], str | None]) None ¶
Set the function to call before the resume command.
- Parameters:
resume_precmd (function) – The function to call.
- genie_advanced.wait_for_pv(pv: str, value: bool | int | float | str | None, maxwait: int | None = None) None ¶
Wait until a PV has reached a given value.
- Params:
pv (str): The address of the PV value: The value to wait for maxwait (int, optional): The maximum time to wait for in seconds