Experiment

Automated Run

class pychron.experiment.automated_run.automated_run.AutomatedRun(*args, **kw)[source]

The AutomatedRun object is used to execute automated analyses.

It mostly delegates responisbility to other objects. It provides an interface for MeasurementPyscripts. All measurement script commands have a corresponding function defined here. A commands corresponding function is defined as py_{function_name}

for example position_magnet calls AutomatedRun.py_position_magnet

data collection is handled by either MultiCollector or PeakHopCollector

persistence (saving to file and database) is handled by AutomatedRunPersister

An automated run is executed in four steps by the ExperimentExecutor.

  1. start

  2. extraction

  3. measurement

    1. equilibration

    2. post_equilibration

  4. post_measurement

equilibration and post_equilibration are executed concurrently with the measurement script this way equilibration gas can be measured.

four pyscripts (all optional) are used to program analysis execution

  1. extraction

  2. measurement

  3. post_equilibration

  4. post_measurement

four types of conditionals are available

  1. termination_conditionals

  2. truncation_conditionals

  3. action_conditionals

  4. cancelation_conditionals

cancel_run(state='canceled', do_post_equilibration=True)[source]

terminate the measurement script immediately

do post termination

post_eq and post_meas

don’t save run

get_interpolation_value(value)[source]

value is a string in the format of $VALUE. Search for VALUE first in the options file then in the extraction scripts metadata

Parameters

value

Returns

info(msg, color=None, *args, **kw)[source]
py_add_action(**kw)[source]

attr must be an attribute of arar_age

perform a specified action if teststr evaluates to true

py_add_cancelation(**kw)[source]

cancel experiment if teststr evaluates to true

py_add_termination(**kw)[source]

attr must be an attribute of arar_age

terminate run and continue experiment if teststr evaluates to true

py_add_truncation(**kw)[source]

attr must be an attribute of arar_age

truncate measurement and continue run if teststr evaluates to true default kw: attr=’‘, comp=’‘,start_count=50, frequency=5, abbreviated_count_ratio=1.0

py_define_hops(hopstr)[source]

set the detector each isotope add additional isotopes and associated plots if necessary

truncate_run(style='normal')[source]

truncate the measurement script

style:

normal- truncate current measure iteration and continue quick- truncate current measure iteration use truncated_counts for following

measure iterations

wait_for_overlap()[source]

by default overlap_evt is set after equilibration finished

Collectors

class pychron.experiment.automated_run.data_collector.DataCollector(*args, **kw)[source]

Base class for Collector objects. Provides logic for iterative measurement.

class pychron.experiment.automated_run.multi_collector.MultiCollector(*args, **kw)[source]

Collector class for doing multi-collection, i.e. measuring multiple intensities simultaneously.

MulticCollector and PeakHopCollector conceptually very similar and potentially could be merged and simplified. MultiCollection is a simple case of PeakHopCollection in which only one peak hop is made at the beginning.

class pychron.experiment.automated_run.peak_hop_collector.PeakHopCollector(*args, **kw)[source]

Collector class for doing a peak hop measurement. Measure one or more intensities at given mass for ncounts then jump magnet to next new mass.

Persistence

class pychron.experiment.automated_run.persistence.AutomatedRunPersister(*args, **kw)[source]

Save automated run data to file and database(s)

  1. save meta data to the local_lab database. This keeps are local record of all analyses run on the local system

  2. save data to an HDF5 file using a H5DataManager

  3. use the Datahub to save data to databases

build_peak_hop_tables(grpname, hops)[source]

construct the table structure for a peak hop hops needs to be a str parsable by parse_hops

Parameters
  • grpname – str

  • hops – str

build_tables(grpname, detectors, n)[source]

construct the hdf5 table structure

Parameters
  • grpname – str

  • detectors – list

get_data_writer(grpname)[source]

grpname should be a str such as “signal”, “baseline”,etc return a closure for writing the data

Parameters

grpname – str

Returns

function

post_extraction_save()[source]

save extraction blobs, loadtable, and snapshots to the primary db

post_measurement_save(save_local=True)[source]

check for runid conflicts. automatically update runid if conflict

  1. save to primary database (aka mainstore)

  2. save detector_ic to csv if applicable

  3. save to secondary database

pre_measurement_save()[source]

setup hdf5 file

save_peak_center_to_file(pc)[source]

save a peak center to file

Parameters

pcPeakCenter

set_preferences(preferences)[source]

bind to application preferences

Conditional

class pychron.experiment.conditional.conditional.BaseConditional(*args, **kw)[source]
check(run, data, cnt)[source]

check conditional if cnt is greater than start count cnt-start count is greater than 0 and cnt-start count is divisable by frequency

returns True if check passes. e.i. Write checks to trip on success. To terminate if Ar36 intensity is less than x use Ar36<x

Parameters
  • runAutomatedRun

  • data – 2-tuple. (keys, signals) where keys==detector names, signals== measured intensities

  • cnt – int

Returns

True if check passes. e.i. Write checks to trip on success.

class pychron.experiment.conditional.conditional.AutomatedRunConditional(teststr, start_count=0, frequency=1, *args, **kw)[source]
class pychron.experiment.conditional.conditional.TruncationConditional(teststr, start_count=0, frequency=1, *args, **kw)[source]

stops the current measurement and continues to next step in pyscript. If more measure calls are main use abbreviated_count_ratio to reduce the number of counts. for example of abbreviated_count_ratio = 0.5 and the original baseline counts = 100, only 50 counts will be made for a truncated run.

class pychron.experiment.conditional.conditional.TerminationConditional(teststr, start_count=0, frequency=1, *args, **kw)[source]

Stop the current analysis immediately. Don’t save to database. Continue to next run in experiment queue

class pychron.experiment.conditional.conditional.CancelationConditional(teststr, start_count=0, frequency=1, *args, **kw)[source]

Stop the current analysis immediately then stop the experiment.

class pychron.experiment.conditional.conditional.ActionConditional(teststr, start_count=0, frequency=1, *args, **kw)[source]

Executes a specified action. The action string is executed as pyscript snippet. actions therefore may be any valid measuremnt pyscript code. for example:

# call a gosub
gosub("someGoSub")

# open a valve
open("V")
perform(script)[source]

perform the specified action.

use MeasurementPyScript.execute_snippet to perform desired action

Parameters

script – MeasurementPyScript