haniwers.v1.cli.scan#
Threshold scanning command.
This module provides the scan command for systematic threshold exploration. The scan mode helps users find optimal detector threshold settings by collecting data across a range of threshold values.
Subcommands: serial: Serial threshold scanning with manual parameter control
Module Contents#
Classes#
Result of measuring detector at a specific threshold. |
Functions#
Aggregate events into ScanResult. |
|
Append scan result to CSV file. |
|
Perform serial threshold scan. |
Data#
API#
- haniwers.v1.cli.scan.scan_app#
‘Typer(…)’
- class haniwers.v1.cli.scan.ScanResult(/, **data: typing.Any)#
Bases:
pydantic.BaseModelResult of measuring detector at a specific threshold.
Initialization
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- timestamp: datetime.datetime#
None
- channel: int#
‘Field(…)’
- vth: int#
‘Field(…)’
- duration: int#
‘Field(…)’
- counts: int#
‘Field(…)’
- hit_top: int#
‘Field(…)’
- hit_mid: int#
‘Field(…)’
- hit_btm: int#
‘Field(…)’
- tmp: float#
None
- atm: float#
None
- hmd: float#
None
- to_csv_row() list#
Convert to CSV row format.
- classmethod csv_header() list[str]#
Get CSV header.
- haniwers.v1.cli.scan.aggregate_scan_result(events: list[haniwers.v1.daq.model.RawEvent], channel: int, vth: int, duration: int) Optional[haniwers.v1.cli.scan.ScanResult]#
Aggregate events into ScanResult.
- haniwers.v1.cli.scan.save_scan_result(csv_path: pathlib.Path, result: haniwers.v1.cli.scan.ScanResult) None#
Append scan result to CSV file.
- haniwers.v1.cli.scan.serial(ctx: typer.Context, config: Optional[pathlib.Path] = ConfigOptions.config, port: Optional[str] = DeviceOptions.port, baudrate: Optional[int] = DeviceOptions.baudrate, timeout: Optional[float] = DeviceOptions.timeout, device_label: Optional[str] = DeviceOptions.device_label, thresholds: str = ThresholdOptions.thresholds, max_retry: int = ThresholdOptions.max_retry, history: pathlib.Path = ThresholdOptions.history, nsteps: int = ScanOptions.nsteps, step: int = ScanOptions.step, duration: int = ScanOptions.duration, suppress: int = ScanOptions.suppress, workspace: Optional[pathlib.Path] = OutputOptions.workspace, filename_prefix: Optional[str] = typer.Option('scan_data', '--filename-prefix', help="Prefix for output file names (default: 'scan_data').", rich_help_panel='Output Settings'), filename_suffix: Optional[str] = OutputOptions.filename_suffix, events_per_file: Optional[int] = typer.Option(1000, '--events-per-file', min=1, help='Number of detector events per output file before rollover (default: 1000).', rich_help_panel='Output Settings'), number_of_files: Optional[int] = typer.Option(1, '--number-of-files', min=1, help='Maximum number of files to create per threshold level (default: 1).', rich_help_panel='Output Settings'), stream_mode: bool = OutputOptions.stream_mode, daq_label: Optional[str] = typer.Option(None, '--daq-label', help='Session identifier label for this DAQ run.', rich_help_panel='Output Settings'), mock: bool = TestingOptions.mock, verbose: bool = LoggerOptions.verbose, logfile: str = LoggerOptions.logfile) None#
Perform serial threshold scan.
Supports both single-channel and multi-channel scanning modes with flexible configuration loading: CLI options override config file values override defaults.
Includes automatic audit logging of threshold operations with configurable retry behavior and result saving.
Single-channel mode: $ haniwers-v1 scan serial --thresholds 1:280 --nsteps 10 --step 5
Multi-channel mode: $ haniwers-v1 scan serial --thresholds “1:290;2:320;3:298”
–nsteps 10 --step 5With custom retry and logging: $ haniwers-v1 scan serial --thresholds 1:280 --max-retry 5
–history scan_ops.csvConfig-file mode: $ haniwers-v1 scan serial --config config.toml
Config with CLI override: $ haniwers-v1 scan serial --config config.toml --port /dev/ttyUSB0