Skip to content

Commit

Permalink
Better compatibility with qserver (fixing docstings format)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrakitin authored and XPD_Operator committed May 17, 2024
1 parent a054a3f commit 2fe109a
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 68 deletions.
48 changes: 28 additions & 20 deletions startup/1001-remoteplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,23 @@ def xpd_mscan_flt(sample_list, pos_list, ht_list, scanplan, motor=sample_x, dela
# -----start temperature scan plans ------------------

def xpd_temp_list(smpl, Temp_list, exp_time, delay=1, dets=[]):
'''
example
xpd_temp_list(1, [300, 350, 400], 5, delay=1)
sample 1, at temperature 300, 350 and 400, exposure time 5sec, wait 1 second after each temperature.
'''The plan to perform a scan over temperature list.
Parameters
----------
smpl: sample index ID in sample list
Temp_list: temperature list
exp_time : total exposure time for each sample, in seconds
delay: sleep time after each temperature changes, for temperature controller to stable
dets: list of motors, temperatures controllers, which will be recorded in table.
Examples
--------
parameters:
smpl: sample index ID in sample list
Temp_list: temperature list
exp_time : total exposure time for each sample, in seconds
delay: sleep time after each temperature changes, for temperature controller to stable
dets: list of motors, temperatures controllers, which will be recorded in table.
>>> xpd_temp_list(1, [300, 350, 400], 5, delay=1)
sample 1, at temperature 300, 350 and 400, exposure time 5sec, wait 1 second after each temperature.
'''
#RE(_configure_area_det(exp_time))
T_controller = xpd_configuration["temp_controller"]
Expand All @@ -193,16 +198,19 @@ def xpd_temp_list(smpl, Temp_list, exp_time, delay=1, dets=[]):

def xpd_temp_ramp(smpl, Tstart, Tstop, Tstep, exp_time, delay = 1, dets=[]):
'''
example:
xpd_temp_ramp(1, 300, 400, 10, 5, delay=1)
sample 1, from 300K to 400K, 10K steps, exposure time 5sec, wait 1 second after each temperature.
parameters:
smpl: sample index ID in sample list
Tstart, Tstop, Tstep: temperature range(Tstart, Tend), step size: Tstep
scanplan : scanplan index ID in scanplan list
delay: sleep time after each temperature changes, for temperature controller to stable
dets: list of motors, temperatures controllers, which will be recorded in table.
Parameters
----------
smpl: sample index ID in sample list
Tstart, Tstop, Tstep: temperature range(Tstart, Tend), step size: Tstep
scanplan : scanplan index ID in scanplan list
delay: sleep time after each temperature changes, for temperature controller to stable
dets: list of motors, temperatures controllers, which will be recorded in table.
Examples
--------
>>> xpd_temp_ramp(1, 300, 400, 10, 5, delay=1)
sample 1, from 300K to 400K, 10K steps, exposure time 5sec, wait 1 second after each temperature.
'''
#RE(_configure_area_det(exp_time))
T_controller = xpd_configuration["temp_controller"]
Expand Down
8 changes: 5 additions & 3 deletions startup/42-energy-calib.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ def get_wavelength_from_std_tth(x, y, d_spacings, ns, plot=False):


class ComputeWavelength(CollectThenCompute):
"""
Example
-------
"""The class to compute the length.
Examples
--------
>>> cw = ComputeWavelgnth('tth_cal', 'some_detector', d_spacings, ns)
>>> RE(scan(...), cw)
"""
Expand Down
13 changes: 9 additions & 4 deletions startup/85-robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ def robot_wrapper(plan, sample):
sample : dict
must contain 'position'; optionally also 'geometry'
Example
-------
Examples
--------
>>> plan = count([pe1c])
>>> new_plan = robot_wrapper(plan, {'position': 1})
"""
Expand Down Expand Up @@ -219,8 +220,12 @@ def example():


def excel_example(filename, geometry=None):
"""
Example: RE(excel_example('/XF28IDC/XF28ID2/pe2_data/xpdUser/Import/example-with-dan.xlsx'))
"""Excel example plan.
Examples
--------
>>> RE(excel_example('/XF28IDC/XF28ID2/pe2_data/xpdUser/Import/example-with-dan.xlsx'))
"""
import pandas as pd
f = pd.ExcelFile(filename)
Expand Down
4 changes: 2 additions & 2 deletions startup/90-plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def MED(init_gas, other_gas, minT, maxT, num_steps, num_steady, num_trans, num_l
5. Switch the gas to `other_gas` and take `num_trans` acquisitions.
6. Switch it back and take another `num_trans` acquisitions.
Example
-------
Examples
--------
Set the gasses. They can be in any other, nothing to do with
the order they are used in the plan.
>>> gas.gas_list = ['O2', 'CO2']
Expand Down
4 changes: 0 additions & 4 deletions startup/91-plans-ecal.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ def Ecal(wguess, detectors=None, motor=None, coarse_step=.0012, coarse_nsteps=12
the coarse scan
motor_type : str, optional
the type of motor used, ether "th" (theta) or "tth"(two-theta)
Example
-------
'''
if detectors is None:
detectors = [sc]
Expand Down
28 changes: 8 additions & 20 deletions startup/970-load.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
# import necessary modules
from xpdacq.xpdacq import *
from xpdacq.beamtime import *
del Tlist
del Tramp
from xpdacq.utils import import_sample_info

# instantiate xrun without beamtime, like bluesky setup
Expand All @@ -58,14 +56,15 @@
xrun.md['group'] = glbl['group']
xrun.md['facility'] = glbl['facility']

# TODO: fix for queueserver - need to exclude interaction:
# /opt/bluesky/queueserver/queueserver-config.yml - check for existence of this file and load silently...


print("loading beamline config")

# removing human input for automating queueserver setup by setting test=True
beamline_config = _load_beamline_config(glbl['blconfig_path'], test=True)
if is_re_worker_active(): # running in queueserver
del Tlist
del Tramp
# removing human input for automating queueserver setup by setting test=True
beamline_config = _load_beamline_config(glbl['blconfig_path'], test=True)
else:
beamline_config = _load_beamline_config(glbl['blconfig_path'])

print("loaded beamline config")

Expand Down Expand Up @@ -100,12 +99,6 @@

print('OK, ready to go. To continue, follow the steps in the xpdAcq')
print('documentation at http://xpdacq.github.io/xpdacq\n')
'''
bt = start_xpdacq()
if bt is not None:
print("INFO: Reload beamtime objects:\n{}\n".format(bt))
if reload_glbl_dict is not None:
_set_glbl(glbl, reload_glbl_dict)


class MoreCustomizedRunEngine(CustomizedRunEngine):
Expand All @@ -116,7 +109,7 @@ def __call__(self, plan, *args, **kwargs):
from nslsii import configure_kafka_publisher
from bluesky.utils import ts_msg_hook

RE = MoreCustomizedRunEngine(None)
RE = MoreCustomizedRunEngine(None) # This object is like 'xrun', but with the RE API.
# RE.msg_hook = ts_msg_hook

configure_kafka_publisher(RE, beamline_name='xpd')
Expand All @@ -126,8 +119,3 @@ def __call__(self, plan, *args, **kwargs):
RE.subscribe(db.insert, "all")
RE.beamtime = bt
RE.clear_suspenders()
'''

22 changes: 12 additions & 10 deletions startup/972-acq-plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@


def gas_plan(gas_in, rga_masses=['mass1', 'mass2', 'mass3', 'mass4', 'mass5', 'mass6']):
"""
Example:
>>> RE(gas_plan(gas_in='He', masses_to_plot=['mass4', 'mass6']))
----------
"""The plan to switch gases.
Parameters
----------
Expand All @@ -33,6 +29,11 @@ def gas_plan(gas_in, rga_masses=['mass1', 'mass2', 'mass3', 'mass4', 'mass5', 'm
These gas must be in `gas.gas_list` but they may be in any order.
rga_masses: list, optional
a list of rga masses appearing in a live table
Examples
--------
>>> RE(gas_plan(gas_in='He', rga_masses=['mass4', 'mass6']))
"""
print('Warning: check the gas list!')

Expand All @@ -50,11 +51,7 @@ def gas_plan(gas_in, rga_masses=['mass1', 'mass2', 'mass3', 'mass4', 'mass5', 'm


def gas_plan_with_detector(gas_in, rga_masses=['mass1', 'mass2', 'mass3', 'mass4', 'mass5', 'mass6'], det=None, exp_time=5, num_exp=1, delay=1):
"""
Example:
>>> RE(gas_plan(gas_in='He', masses_to_plot=['mass4', 'mass6']))
----------
"""The plan to switch gases with a detector.
Parameters
----------
Expand All @@ -71,6 +68,11 @@ def gas_plan_with_detector(gas_in, rga_masses=['mass1', 'mass2', 'mass3', 'mass4
number of exposures
delay : float, optional
delay between exposures in seconds
Examples
--------
>>> RE(gas_plan_with_detector(gas_in='He', rga_masses=['mass4', 'mass6']))
"""
if det is None:
det = pe1c
Expand Down
6 changes: 4 additions & 2 deletions startup/973-gas-plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def Tramp_gas_plan(detectors, gas_in, exp_time, Tstart, Tstop, Tstep,
rga_masses: list, optional
a list of rga masses will be appearing in a live table
Example:
Examples
--------
>>> plan = Tramp_gas_plan([pe1c, rga], 'He', 5, 300, 350, 5)
>>> xrun(<sample ind>, plan)
Expand Down Expand Up @@ -108,7 +108,9 @@ def tseries_gas_plan(detectors, gas_in, exp_time, delay=1, num_exp=1,
rga_masses: list, optional
a list of rga masses appearing in a live table
Example:
Examples
--------
>>> plan = tseries_gas_plan([pe1c, rga], 'He', 5, 10, 2)
>>> xrun(<sample ind>, plan)
"""
Expand Down
55 changes: 52 additions & 3 deletions startup/existing_plans_and_devices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5408,6 +5408,49 @@ existing_devices:
is_movable: true
is_readable: true
module: ophyd.mixins
setread:
classname: EpicsSignalPositioner
is_flyable: false
is_movable: true
is_readable: true
module: ophyd.mixins
temperature:
classname: EpicsSignalPositioner
is_flyable: false
is_movable: true
is_readable: true
module: ophyd.mixins
is_flyable: false
is_movable: false
is_readable: true
module: __main__
eurotherm2:
classname: Eurotherm
components:
mode:
classname: EpicsSignal
is_flyable: false
is_movable: true
is_readable: true
module: ophyd.signal
power:
classname: EpicsSignalPositioner
is_flyable: false
is_movable: true
is_readable: true
module: ophyd.mixins
ramprate:
classname: EpicsSignalPositioner
is_flyable: false
is_movable: true
is_readable: true
module: ophyd.mixins
setread:
classname: EpicsSignalPositioner
is_flyable: false
is_movable: true
is_readable: true
module: ophyd.mixins
temperature:
classname: EpicsSignalPositioner
is_flyable: false
Expand Down Expand Up @@ -6246,6 +6289,12 @@ existing_devices:
is_movable: true
is_readable: true
module: ophyd.mixins
setread:
classname: EpicsSignalPositioner
is_flyable: false
is_movable: true
is_readable: true
module: ophyd.mixins
temperature:
classname: EpicsSignalPositioner
is_flyable: false
Expand Down Expand Up @@ -14987,7 +15036,7 @@ existing_plans:
properties:
is_generator: true
excel_example:
description: 'Example: RE(excel_example(''/XF28IDC/XF28ID2/pe2_data/xpdUser/Import/example-with-dan.xlsx''))'
description: Excel example plan.
module: __main__
name: excel_example
parameters:
Expand Down Expand Up @@ -15285,7 +15334,7 @@ existing_plans:
properties:
is_generator: true
gas_plan:
description: 'Example:'
description: The plan to switch gases.
module: __main__
name: gas_plan
parameters:
Expand All @@ -15305,7 +15354,7 @@ existing_plans:
properties:
is_generator: true
gas_plan_with_detector:
description: 'Example:'
description: The plan to switch gases with a detector.
module: __main__
name: gas_plan_with_detector
parameters:
Expand Down

0 comments on commit 2fe109a

Please sign in to comment.