Scan

class liso.scan.linac_scan.LinacScan(linac: liso.simulation.linac.Linac)

Bases: liso.scan.base_scan.BaseScan

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, output_dir: str = './', *, start_id: int = 1, n_tasks: Optional[int] = None, chmod: bool = True, group: int = 1, seed: Optional[int] = None, **kwargs) None

Start a parameter 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.

  • output_dir – Directory where the output simulation data is saved.

  • start_id – Starting simulation id. Default = 1.

  • n_tasks – Maximum number of concurrent tasks.

  • chmod – True for changing the permission to 400 after finishing writing.

  • group – Writer group.

  • seed – Seed for the legacy MT19937 BitGenerator in numpy.

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)

Bases: liso.scan.base_scan.BaseScan

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) 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.

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, output_dir: str = './', *, tasks: Optional[int] = None, chmod: bool = True, timeout: Optional[float] = None, group: int = 1, seed: Optional[int] = None)

Start a parameter 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.

  • output_dir – Directory in which data for each run is stored in in its own sub-directory.

  • tasks – Maximum number of concurrent tasks for read and write.

  • chmod – True for changing the permission to 400 after finishing writing.

  • timeout – Timeout when correlating data by macropulse ID, in seconds.

  • group – Writer group.

  • seed – Seed for the legacy MT19937 BitGenerator in numpy.

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.