apply forwards_to decorator and added docstrings to all scan methods; better repr
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
|
||||
from slic.core.adjustable import DummyAdjustable
|
||||
from slic.utils import typename, nice_linspace, nice_arange
|
||||
from slic.utils import typename, nice_linspace, nice_arange, forwards_to
|
||||
|
||||
from .scanbackend import ScanBackend
|
||||
|
||||
@@ -23,7 +23,7 @@ class Scanner:
|
||||
scan_info_dir (string, optional): Folder to store ScanInfo.
|
||||
default_acquisitions (sequence of BaseAcquisitions, optional): List of default acquisition objects to acquire from.
|
||||
condition (BaseCondition): Condition that needs to be fullfilled to accept a recorded step of the scan.
|
||||
make_scan_sub_dir (bool): If True (default), create a sub folder in data_base_dir in the acquisition's default_dir for each scan: scanname/scanname_step00001.h5. If False, the per-step files will be saved directly to data_base_dir in the acquisition's default_dir
|
||||
make_scan_sub_dir (bool): If True (default), create a sub folder in data_base_dir in the acquisition's default_dir for each scan: scanname/scanname_step00001.h5. If False, the per-step files will be saved directly to data_base_dir in the acquisition's default_dir.
|
||||
"""
|
||||
self.data_base_dir = data_base_dir
|
||||
self.scan_info_dir = scan_info_dir
|
||||
@@ -42,7 +42,12 @@ class Scanner:
|
||||
adjustables (sequence of BaseAdjustables): Adjustables to scan.
|
||||
positions (sequence of sequences): One sequence of positions to iterate through for each adjustable.
|
||||
n_pulses (int): Number of pulses per step.
|
||||
filename (str): Name of output file.
|
||||
|
||||
detectors (sequence of strings, optional): List of detectors to acquire. If None (default), the default lists of the acquisitions will be used.
|
||||
channels (sequence of strings, optional): List of channels to acquire. If None (default), the default lists of the acquisitions will be used.
|
||||
pvs (sequence of strings, optional): List of PVs to acquire. If None (default), the default lists of the acquisitions will be used.
|
||||
|
||||
acquisitions (sequence of BaseAcquisitions, optional): List of acquisition objects to acquire from. If empty (default) the default list will be used.
|
||||
start_immediately (bool, optional): If True (default), start the scan immediately. If False, the returned scan can be started via its run method.
|
||||
step_info: Arbitrary data that is appended to the ScanInfo in each step.
|
||||
@@ -65,6 +70,7 @@ class Scanner:
|
||||
return scan
|
||||
|
||||
|
||||
@forwards_to(make_scan, nfilled=3)
|
||||
def scan1D(self, adjustable, start_pos, end_pos, step_size, *args, relative=False, **kwargs):
|
||||
"""One-dimensional scan
|
||||
|
||||
@@ -74,8 +80,8 @@ class Scanner:
|
||||
end_pos (number): End position
|
||||
step_size (number): Size of each step
|
||||
relative (bool, optional): Positions relative to current position of adjustable (in contrast to absolute)
|
||||
args: are forwarded to make_scan()
|
||||
kwargs: are forwarded to make_scan()
|
||||
|
||||
All further parameters are forwarded to make_scan() and described there.
|
||||
|
||||
Returns:
|
||||
ScanBackend: Scan instance
|
||||
@@ -93,6 +99,7 @@ class Scanner:
|
||||
return self.make_scan(adjustables, positions, *args, **kwargs)
|
||||
|
||||
|
||||
@forwards_to(make_scan, nfilled=3)
|
||||
def scan2D(self, adjustable1, start_pos1, end_pos1, step_size1, adjustable2, start_pos2, end_pos2, step_size2, *args, relative1=False, relative2=False, **kwargs):
|
||||
"""Two-dimensional scan
|
||||
|
||||
@@ -109,8 +116,7 @@ class Scanner:
|
||||
step_size2 (number): Size of each step for second Adjustable
|
||||
relative2 (bool, optional): Positions relative to current position of adjustable2 (in contrast to absolute)
|
||||
|
||||
args: are forwarded to make_scan()
|
||||
kwargs: are forwarded to make_scan()
|
||||
All further parameters are forwarded to make_scan() and described there.
|
||||
|
||||
Returns:
|
||||
ScanBackend: Scan instance
|
||||
@@ -135,16 +141,17 @@ class Scanner:
|
||||
return self.make_scan(adjustables, positions, *args, **kwargs)
|
||||
|
||||
|
||||
@forwards_to(make_scan, nfilled=3)
|
||||
def ascan(self, adjustable, start_pos, end_pos, n_intervals, *args, **kwargs):
|
||||
"""One-dimensional scan
|
||||
"""Absolute scan
|
||||
|
||||
Parameters:
|
||||
adjustable (BaseAdjustable): Adjustable to scan
|
||||
start_pos (number): Starting position
|
||||
end_pos (number): End position
|
||||
n_intervals (int): Number of intervals
|
||||
args: are forwarded to make_scan()
|
||||
kwargs: are forwarded to make_scan()
|
||||
|
||||
All further parameters are forwarded to make_scan() and described there.
|
||||
|
||||
Returns:
|
||||
ScanBackend: Scan instance
|
||||
@@ -157,7 +164,26 @@ class Scanner:
|
||||
return self.make_scan(adjustables, positions, *args, **kwargs)
|
||||
|
||||
|
||||
@forwards_to(make_scan, nfilled=3)
|
||||
def a2scan(self, adjustable1, start_pos1, end_pos1, adjustable2, start_pos2, end_pos2, n_intervals, *args, **kwargs):
|
||||
"""Absolute scan -- 2 adjustables
|
||||
|
||||
Parameters:
|
||||
adjustable1 (BaseAdjustable): First Adjustable to scan
|
||||
start_pos1 (number): Starting position of first Adjustable
|
||||
end_pos1 (number): End position of first Adjustable
|
||||
|
||||
adjustable2 (BaseAdjustable): Second Adjustable to scan
|
||||
start_pos2 (number): Starting position of second Adjustable
|
||||
end_pos2 (number): End position of second Adjustable
|
||||
|
||||
n_intervals (int): Number of intervals
|
||||
|
||||
All further parameters are forwarded to make_scan() and described there.
|
||||
|
||||
Returns:
|
||||
ScanBackend: Scan instance
|
||||
"""
|
||||
adjustables = [adjustable1, adjustable2]
|
||||
|
||||
positions1 = make_positions(start_pos1, end_pos1, n_intervals)
|
||||
@@ -167,7 +193,21 @@ class Scanner:
|
||||
return self.make_scan(adjustables, positions, *args, **kwargs)
|
||||
|
||||
|
||||
@forwards_to(make_scan, nfilled=3)
|
||||
def rscan(self, adjustable, start_pos, end_pos, n_intervals, *args, **kwargs):
|
||||
"""Relative scan
|
||||
|
||||
Parameters:
|
||||
adjustable (BaseAdjustable): Adjustable to scan
|
||||
start_pos (number): Starting position
|
||||
end_pos (number): End position
|
||||
n_intervals (int): Number of intervals
|
||||
|
||||
All further parameters are forwarded to make_scan() and described there.
|
||||
|
||||
Returns:
|
||||
ScanBackend: Scan instance
|
||||
"""
|
||||
adjustables = [adjustable]
|
||||
|
||||
positions = make_positions(start_pos, end_pos, n_intervals)
|
||||
@@ -177,7 +217,19 @@ class Scanner:
|
||||
return self.make_scan(adjustables, positions, *args, **kwargs)
|
||||
|
||||
|
||||
@forwards_to(make_scan, nfilled=3)
|
||||
def ascan_list(self, adjustable, positions, *args, **kwargs):
|
||||
"""Absolute scan -- list of positions
|
||||
|
||||
Parameters:
|
||||
adjustable (BaseAdjustable): Adjustable to scan
|
||||
positions (sequence of numbers): Sequence of positions for adjustable to iterate through
|
||||
|
||||
All further parameters are forwarded to make_scan() and described there.
|
||||
|
||||
Returns:
|
||||
ScanBackend: Scan instance
|
||||
"""
|
||||
adjustables = [adjustable]
|
||||
|
||||
positions = transpose(positions)
|
||||
@@ -185,7 +237,22 @@ class Scanner:
|
||||
return self.make_scan(adjustables, positions, *args, **kwargs)
|
||||
|
||||
|
||||
@forwards_to(make_scan, nfilled=3)
|
||||
def a2scan_list(self, adjustable1, positions1, adjustable2, positions2, *args, **kwargs):
|
||||
"""Absolute scan -- list of positions -- 2 adjustables
|
||||
|
||||
Parameters:
|
||||
adjustable1 (BaseAdjustable): First Adjustable to scan
|
||||
positions1 (sequence of numbers): Sequence of positions for first Adjustable to iterate through
|
||||
|
||||
adjustable2 (BaseAdjustable): Second Adjustable to scan
|
||||
positions2 (sequence of numbers): Sequence of positions for second Adjustable to iterate through
|
||||
|
||||
All further parameters are forwarded to make_scan() and described there.
|
||||
|
||||
Returns:
|
||||
ScanBackend: Scan instance
|
||||
"""
|
||||
adjustables = [adjustable1, adjustable2]
|
||||
|
||||
positions = transpose(positions1, positions2)
|
||||
@@ -193,7 +260,18 @@ class Scanner:
|
||||
return self.make_scan(adjustables, positions, *args, **kwargs)
|
||||
|
||||
|
||||
@forwards_to(make_scan, nfilled=3)
|
||||
def acquire(self, n_intervals, *args, **kwargs):
|
||||
"""Static acquisition via scan of DummyAdjustable
|
||||
|
||||
Parameters:
|
||||
n_intervals (int): Number of intervals (i.e., repetitions)
|
||||
|
||||
All further parameters are forwarded to make_scan() and described there.
|
||||
|
||||
Returns:
|
||||
ScanBackend: Scan instance
|
||||
"""
|
||||
dummy = DummyAdjustable()
|
||||
adjustables = [dummy]
|
||||
|
||||
@@ -204,7 +282,9 @@ class Scanner:
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return typename(self) #TODO
|
||||
tn = typename(self)
|
||||
used = "\n- ".join(repr(i) for i in self.default_acquisitions + [self.condition])
|
||||
return f"{tn} using:\n- {used}"
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user