Scan¶
- class liso.scan.linac_scan.LinacScan(linac: liso.simulation.linac.Linac)¶
Bases:
liso.scan.abstract_scan.AbstractScan
Class for performing scans in simulations.
- __init__(linac: liso.simulation.linac.Linac) None ¶
Initialization.
- Parameters
linac – Linac instance.
- add_param(name: str, *, dist=- 1.0, **kwargs)¶
Add a parameter for scan.
The kwargs will be passed to the construct of a ScanParam subclass.
- Parameters
name – Parameter name in the simulation input file.
kwargs – Keyword arguments will be passed to the constructor of the appropriate
liso.scan.scan_param.ScanParam
.
- scan(cycles: int = 1, *, n_tasks: Optional[int] = None, output_dir: Union[str, pathlib.Path] = './', chmod: bool = True, group: int = 1, seed: Optional[int] = None, start_id: int = 1, timeout: Optional[int] = None) None ¶
Run the scan.
- Parameters
cycles – Number of cycles of the parameter space. For pure jitter study, it is the number of runs since the size of variable space is 1.
n_tasks – Maximum number of concurrent tasks.
output_dir – Directory where the output simulation data is saved.
chmod – True for changing the permission to 400 after finishing writing.
group – Writer group.
seed – Seed for the legacy MT19937 BitGenerator in numpy.
start_id – Starting simulation id. Default = 1.
timeout – Timeout in seconds for running a single simulation. None for no timeout.
- Raises
ValueError – If generation of parameter sequence fails.
FileExistsError – If there is already any directory which has the same name as the temporary simulation directory to be created.
LisoRuntimeError – If any Beamline of the Linac cannot create a temporary directory to run simulation.
- class liso.scan.machine_scan.MachineScan(interface: liso.experiment.machine_interface.MachineInterface, policy: liso.scan.machine_scan.ScanPolicy = ScanPolicy.READ_AFTER_DELAY, read_delay: float = 1.0, n_reads: int = 1)¶
Bases:
liso.scan.abstract_scan.AbstractScan
Class for performing scans with a real machine.
- __init__(interface: liso.experiment.machine_interface.MachineInterface, policy: liso.scan.machine_scan.ScanPolicy = ScanPolicy.READ_AFTER_DELAY, read_delay: float = 1.0, n_reads: int = 1) None ¶
Initialization.
- Parameters
interface – MachineInterface instance.
policy – Policy about how the scan is performed.
read_delay – Delay for reading channel data in seconds after writing channels. Use only when policy = ScanPolicy.READ_AFTER_DELAY.
n_reads – Number of reads after each write.
- add_param(name: str, *, dist=- 1.0, **kwargs)¶
Add a parameter for scan.
The kwargs will be passed to the construct of a ScanParam subclass.
- Parameters
name – Parameter name in the simulation input file.
kwargs – Keyword arguments will be passed to the constructor of the appropriate
liso.scan.scan_param.ScanParam
.
- scan(cycles: int = 1, *, n_tasks: Optional[int] = None, output_dir: Union[str, pathlib.Path] = './', chmod: bool = True, group: int = 1, seed: Optional[int] = None)¶
Run the scan.
- Parameters
cycles – Number of cycles of the parameter space. For pure jitter study, it is the number of runs since the size of variable space is 1.
n_tasks – Maximum number of concurrent tasks for read and write.
output_dir – Directory in which data for each run is stored in in its own sub-directory.
chmod – True for changing the permission to 400 after finishing writing.
group – Writer group.
seed – Seed for the legacy MT19937 BitGenerator in numpy.
- Raises
ValueError – If generation of parameter sequence fails.
Scan parameters¶
There are three different kinds of ScanParam types:
- class liso.scan.scan_param.ScanParam(name)¶
Base class for parameters used in parameter scan.
- class liso.scan.scan_param.StepParam(name: str, *, start: float, stop: float, num: int, sigma: Optional[float] = 0.0)¶
Bases:
liso.scan.scan_param.ScanParam
Generate parameters that change from start to end values stepwise.
- __init__(name: str, *, start: float, stop: float, num: int, sigma: Optional[float] = 0.0)¶
Initialization.
- Parameters
start – The starting value of the scan.
stop – The end value of the scan (included).
num – Number of scanning points.
sigma – Standard deviation of the jitter of the parameter if given. Positive for absolute jitter and negative for relative jitter.
- class liso.scan.scan_param.SampleParam(name: str, *, lb: float, ub: float)¶
Bases:
liso.scan.scan_param.ScanParam
Generate parameters that are sampled uniformly within a given range.
- __init__(name: str, *, lb: float, ub: float)¶
Initialization.
- Parameters
lb – The lower boundary of the sample.
ub – The upper boundary of the sample (not included).
- class liso.scan.scan_param.JitterParam(name: str, *, value: float, sigma: Optional[float] = 0.0)¶
Bases:
liso.scan.scan_param.ScanParam
Generate parameters that are randomly sampled around a given value.
- __init__(name: str, *, value: float, sigma: Optional[float] = 0.0)¶
Initialization.
- Parameters
value – The reference value.
sigma – Standard deviation of the jitter of the parameter if given. Positive for absolute jitter and negative for relative jitter.