Pyscript API - NMGRL/pychron GitHub Wiki

Pyscript API

Commands

Below are all the available functions that may be used within a PyScript. Python builtins are also available and additional modules may be imported similar to any normal python script.

classmethod abort

abort()

Abort the current script. :return:

method acquire

acquire(name=None, clear=False)

method acquire_grain_polygon_blob

acquire_grain_polygon_blob()

method autofocus

autofocus(set_zoom=True)

method begin_heating_interval

begin_heating_interval(
    duration,
    min_rise_rate=None,
    check_time=60,
    check_delay=60,
    check_period=1,
    temperature=None,
    timeout=300,
    tol=10,
    name=None,
    calc_time=False
)

method begin_interval

begin_interval(duration, name=None, calc_time=False)

Args:

  • duration (float, int): Duration of interval in seconds
  • name (str, optional): Optional name of this interval. Useful for logging

Returns: None

classmethod cancel

cancel(**kw)

Cancel the current script

:return:

method check_reached_setpoint

check_reached_setpoint()

method close

close(name=None, description='', cancel_on_failed_actuation=True, ntries=100)

classmethod complete_interval

complete_interval()

method delay

delay(duration=0, message=None, calc_time=False)

method disable

disable()

method drop_sample

drop_sample(position='')

method dump_sample

dump_sample()

method enable

enable()

method end_extract

end_extract()

method execute_pattern

execute_pattern(pattern='', block=True, duration=None)

method exit

exit()

method extract

extract(power='', units='', block=None)

method extract_pipette

extract_pipette(identifier='', timeout=300)

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

method fire_laser

fire_laser()

method get_cryo_temp

get_cryo_temp(value=1)

method get_device

get_device(name)

method get_manometer_pressure

get_manometer_pressure(idx=0)

method get_pressure

get_pressure(controller, gauge)

method get_resource_value

get_resource_value(name=None)

method get_value

get_value(name)

classmethod grain_polygon

grain_polygon()

method _m_info

_m_info(message=None)

classmethod interval

interval(dur)

:type dur: float, int

method is_closed

is_closed(name=None, description='')

method is_open

is_open(name=None, description='')

classmethod lighting

lighting(value=75)

method load_and_execute_lascon_script

load_and_execute_lascon_script(scriptnumber, block=True)

method load_pipette

load_pipette(identifier, timeout=300)

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.

method lock

lock(name=None, description='')

method move_to_position

move_to_position(position='', autocenter=True, block=True)

method _m_open

_m_open(name=None, description='', cancel_on_failed_actuation=True, ntries=100)

method pause

pause(delay=2)

method power_map

power_map(cx, cy, padding, bd, power)

method prepare

prepare()

method ramp

ramp(start=0, setpoint=0, duration=0, rate=0, period=1)

method release

release(name=None)

classmethod safe_while

safe_while(func, timeout=60, period=1, calc_time=False)

method set_cryo

set_cryo(value, device_name=None, block=False, delay=1)

Set the cryotrap to setpoint value in degrees K.

Args:

  • value (float,int): Setpoint in degrees K
  • block (bool,float,int, optional): If True command is blocking, i.e. the command will not return until setpoint reached. If block is a number than block until block>abs(current_temp-setpoint)
  • delay (float,int): Delay in seconds between each check to determine if blocking is complete.

method set_intensity_scalar

set_intensity_scalar(v)

method set_light

set_light(value='')

method set_motor

set_motor(name='', value='')

method set_motor_lock

set_motor_lock(name='', value='')

method set_pid_parameters

set_pid_parameters(v)

method set_resource

set_resource(name=None, value=1)

method set_response_recorder_period

set_response_recorder_period(p)

method set_tray

set_tray(tray='')

method set_x

set_x(value, velocity='')

method set_xy

set_xy(value, velocity='')

method set_y

set_y(value, velocity='')

method set_z

set_z(value, velocity='')

method sleep

sleep(duration=0, message=None, calc_time=False)

method snapshot

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

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

method start_cryo_recorder

start_cryo_recorder()

method start_grain_polygon

start_grain_polygon()

method start_response_recorder

start_response_recorder()

method start_video_recording

start_video_recording(name='video')

method stop_cryo_recorder

stop_cryo_recorder()

method stop_grain_polygon

stop_grain_polygon()

method stop_response_recorder

stop_response_recorder()

method stop_video_recording

stop_video_recording(save_db=True)

method store_manometer_pressure

store_manometer_pressure(idx=0)

method unlock

unlock(name=None, description='')

classmethod video_recording

video_recording(name='video')

method wait

wait(name=None, criterion=0)

method waitfor

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

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

:param func_or_tuple: wait for function to return True :type func_or_tuple: callable, tuple :param start_message: Message to display at start :type start_message: str :param end_message: Message to display at end :type end_message: str :param check_period: Delay between checks in seconds :type check_period: int, float :param timeout: Cancel waiting after timeout seconds :type timeout: int, float

method wake

wake()

method warmup

warmup(block=False)

Context

Below are all the "contextual" values availiable to a PyScript. These contextual values are typically set by the Experiment Editor and used when running an Automated Analysis

analysis_type

Type: str

beam_diameter

Type: NoneType

cleanup

Type: int

cryo_temperature

Type: int

delay_after

Type: int

duration

Type: int

extract_device

Type: str

extract_units

Type: str

extract_value

Type: int

light_value

Type: int

load_identifier

Type: str

next_position

Type: str

pattern

Type: str

position

Type: str

post_cleanup

Type: int

pre_cleanup

Type: int

ramp_duration

Type: int

ramp_rate

Type: int

run_identifier

Type: str

tray

Type: str
⚠️ **GitHub.com Fallback** ⚠️