PyScripts

PyScripts are used to automate various processes, such as extraction of gas and measurement of isotopes.

PyScript

class pychron.pyscripts.pyscript.PyScript(*args, **kw)[source]
calculate_estimated_duration(ctx=None, force=False)[source]

maintain a dictionary of previous calculated durations. key=hash(ctx), value=duration

ValvePyScript

class pychron.pyscripts.valve_pyscript.ValvePyScript(*args, **kw)[source]

Ramper

class pychron.pyscripts.extraction_line_pyscript.Ramper[source]
ramp(func, start, end, duration, rate=0, period=1)[source]

rate = units/s duration= s

use rate if specified

ExtractionPyScript

class pychron.pyscripts.extraction_line_pyscript.ExtractionPyScript(*args, **kw)[source]

The ExtractionPyScript is used to program the extraction and gettering of sample gas.

extract_pipette(identifier='', timeout=300)[source]

this is an atomic command. use the apis_controller config file to define the isolation procedures.

get_extraction_positions(clear=True)[source]

Returns a list of x,y,z tuples each tuple represents where the extraction occurred

if clear is True (default) self._extraction_positions set to an empty list

Returns

list of x,y,z tuples

Return type

list of tuples

get_output_blob()[source]

Get the extraction device’s output blob

Returns

output blob: binary string representing time v percent output

Return type

str

get_response_blob()[source]

Get the extraction device’s response blob

Returns

response blob. binary string representing time v measured output

Return type

str

get_setpoint_blob()[source]

Get the extraction device’s setpoint blob

Returns

setpoint blob: binary string representing time v requested setpoint

Return type

str

load_pipette(identifier, timeout=300)[source]

this is a non blocking command. it simply sends a command to apis to start one of its runscripts.

it is the ExtractionPyScripts responsiblity to handle the waiting. use the waitfor command to wait for signals from apis.

output_achieved()[source]

Return a formated string with the extraction “heating” results:

Requested Output= 100.000
Achieved Output= 99.012
Returns

Formatted string with results

Return type

str

position

if position is 0 return None

set_default_context(**kw)[source]

provide default values for all the properties exposed in the script

snapshot(name='', prefix='', view_snapshot=False, pic_format='.jpg')[source]

if name not specified use RID_Position e.g 12345-01A_3

waitfor(func_or_tuple, start_message='', end_message='', check_period=1, timeout=0, func_kw=None)[source]

tuple format: (device_name, function_name, comparison, …) addition tuple elements are passed to function_name

comparison

x<10
10<x<20

callable can of form func() or func(ti) or func(ti, i) where ti is the current relative time (relative to start of waitfor) and i is a counter

Parameters
  • func_or_tuple (callable, tuple) – wait for function to return True

  • start_message (str) – Message to display at start

  • end_message (str) – Message to display at end

  • check_period (int, float) – Delay between checks in seconds

  • timeout (int, float) – Cancel waiting after timeout seconds

MeasurementPyScript

class pychron.pyscripts.measurement_pyscript.MeasurementPyScript(*args, **kw)[source]

MeasurementPyScripts are used to collect isotopic data

activate_detectors(*dets, **kw)[source]

set the active detectors

Parameters

dets – list

coincidence()[source]

Do a coincidence scan. Peak center all active detectors simulatenously. calculate required deflection corrections to bring all detectors into coincidence

eqtime

Property. Equilibration time. Get value from AutomatedRun.

Returns

float, int

equilibrate(eqtime=20, inlet=None, outlet=None, do_post_equilibration=True, close_inlet=True, delay=3)[source]

equilibrate the extraction line with the mass spectrometer

inlet or outlet can be a single valve name or a list of valve names.

'A', ('A','B'), ['A','B'], 'A,B'
Parameters
  • eqtime – int, equilibration duration in seconds

  • inlet – str, tuple or list, inlet valve

  • outlet – str, tuple or list, ion pump valve

  • do_post_equilibration – bool

  • close_inlet – bool

  • delay – int, delay in seconds between close of outlet and open of inlet

generate_ic_mftable(detectors, refiso='Ar40', peak_center_config='', n=1, calc_time=False)[source]

Generate an IC MFTable. Use this when doing a Detector Intercalibration. peak centers the refiso on a list of detectors. MFTable saved as ic_mftable

cancel script if generating mftable fails

Parameters
  • detectors (list) – list of detectors to peak center

  • refiso (str) – isotope to peak center

peak_center(detector='', isotope='', integration_time=1.04, save=True, calc_time=False, directions='Increase', config_name='default')[source]

Calculate the peak center for isotope on detector.

Parameters
  • detector – str

  • isotope – str

  • integration_time – float

  • save – bool

position_magnet(pos, detector='AX', use_dac=False, for_collection=True)[source]
Parameters
  • pos (str) – location to set magnetic field

  • detector – detector to position pos

  • use_dac (bool) – is the pos a DAC voltage

examples:

position_magnet(4.54312, use_dac=True) # detector is not relevant
position_magnet(39.962, detector='AX')
position_magnet('Ar40', detector='AX') #Ar40 will be converted to 39.962 use mole weight dict
post_equilibration(block=False)[source]

Run the post equilibration script.

reset(arun)[source]

Reset the script with a new automated run

Parameters

arun (AutomatedRun) – A new AutomatedRun

set_baseline_fits(*fits)[source]

set baseline fits for detectors

Parameters

fits

set_fits(*fits)[source]

set time vs intensity regression fits for isotopes

Parameters

fits – str, list, or tuple

set_integration_time(v)[source]

Set the integration time

Parameters

v (float) – integration time in seconds

set_time_zero(offset=0)[source]

set the time_zero value. add offset to time_zero

T_o= ion pump closes
offset seconds after T_o. define time_zero

T_eq= inlet closes
time_zero_offset

Property. Substract time_zero_offset from time value for all data points

Returns

float, int

truncated

Property. True if run was truncated otherwise False

Returns

bool

use_cdd_warming

Property. Use CDD Warming. Get value from AutomatedRunSpec

Returns

bool

whiff(ncounts=0, conditionals=None)[source]

Do a whiff measurement.

Whiff’s are quick measurements with conditionals. use them to take action at the beginning of a measurement. For example do a whiff to determine if intensity to great.

Parameters
  • ncounts – int

  • conditionals – list of dicts