# {py:mod}`haniwers.v1.cli.threshold`

```{py:module} haniwers.v1.cli.threshold
```

```{autodoc2-docstring} haniwers.v1.cli.threshold
:allowtitles:
```

## Module Contents

### Functions

````{list-table}
:class: autosummary longtable
:align: left

* - {py:obj}`_apply_overrides <haniwers.v1.cli.threshold._apply_overrides>`
  - ```{autodoc2-docstring} haniwers.v1.cli.threshold._apply_overrides
    :summary:
    ```
* - {py:obj}`count_hits_by_channel <haniwers.v1.cli.threshold.count_hits_by_channel>`
  - ```{autodoc2-docstring} haniwers.v1.cli.threshold.count_hits_by_channel
    :summary:
    ```
* - {py:obj}`get_all_thresholds <haniwers.v1.cli.threshold.get_all_thresholds>`
  - ```{autodoc2-docstring} haniwers.v1.cli.threshold.get_all_thresholds
    :summary:
    ```
* - {py:obj}`write <haniwers.v1.cli.threshold.write>`
  - ```{autodoc2-docstring} haniwers.v1.cli.threshold.write
    :summary:
    ```
* - {py:obj}`serial <haniwers.v1.cli.threshold.serial>`
  - ```{autodoc2-docstring} haniwers.v1.cli.threshold.serial
    :summary:
    ```
* - {py:obj}`parallel <haniwers.v1.cli.threshold.parallel>`
  - ```{autodoc2-docstring} haniwers.v1.cli.threshold.parallel
    :summary:
    ```
* - {py:obj}`_parse_fit_parameters <haniwers.v1.cli.threshold._parse_fit_parameters>`
  - ```{autodoc2-docstring} haniwers.v1.cli.threshold._parse_fit_parameters
    :summary:
    ```
* - {py:obj}`fit <haniwers.v1.cli.threshold.fit>`
  - ```{autodoc2-docstring} haniwers.v1.cli.threshold.fit
    :summary:
    ```
````

### Data

````{list-table}
:class: autosummary longtable
:align: left

* - {py:obj}`app <haniwers.v1.cli.threshold.app>`
  - ```{autodoc2-docstring} haniwers.v1.cli.threshold.app
    :summary:
    ```
````

### API

````{py:data} app
:canonical: haniwers.v1.cli.threshold.app
:value: >
   'Typer(...)'

```{autodoc2-docstring} haniwers.v1.cli.threshold.app
```

````

````{py:function} _apply_overrides(config, overrides: dict) -> None
:canonical: haniwers.v1.cli.threshold._apply_overrides

```{autodoc2-docstring} haniwers.v1.cli.threshold._apply_overrides
```
````

````{py:function} count_hits_by_channel(events: list[haniwers.v1.daq.model.RawEvent]) -> dict[str, int]
:canonical: haniwers.v1.cli.threshold.count_hits_by_channel

```{autodoc2-docstring} haniwers.v1.cli.threshold.count_hits_by_channel
```
````

````{py:function} get_all_thresholds(sensors: dict[str, haniwers.v1.config.model.SensorConfig]) -> dict[str, int | None]
:canonical: haniwers.v1.cli.threshold.get_all_thresholds

```{autodoc2-docstring} haniwers.v1.cli.threshold.get_all_thresholds
```
````

````{py:function} write(ctx: typer.Context, config: typing.Optional[pathlib.Path] = ConfigOptions.config, port: typing.Optional[str] = DeviceOptions.port, baudrate: typing.Optional[int] = DeviceOptions.baudrate, timeout: typing.Optional[float] = DeviceOptions.timeout, thresholds: str = ThresholdOptions.thresholds, max_retry: int = ThresholdOptions.max_retry, history: pathlib.Path = ThresholdOptions.history, workspace: pathlib.Path = OutputOptions.workspace, filename_prefix: typing.Optional[str] = OutputOptions.filename_prefix, filename_suffix: typing.Optional[str] = OutputOptions.filename_suffix, events_per_file: typing.Optional[int] = SamplerOptions.events_per_file, number_of_files: typing.Optional[int] = SamplerOptions.number_of_files, stream_mode: bool = SamplerOptions.stream_mode, mode: typing.Optional[str] = SamplerOptions.mode, duration: typing.Optional[float] = SamplerOptions.duration, mock: bool = TestingOptions.mock, load_from: typing.Optional[pathlib.Path] = TestingOptions.load_from, speed: float = TestingOptions.speed, shuffle: bool = TestingOptions.shuffle, jitter: float = TestingOptions.jitter, loop: bool = TestingOptions.loop, verbose: bool = LoggerOptions.verbose, logfile: str = LoggerOptions.logfile) -> None
:canonical: haniwers.v1.cli.threshold.write

```{autodoc2-docstring} haniwers.v1.cli.threshold.write
```
````

````{py:function} serial(ctx: typer.Context, config: typing.Optional[pathlib.Path] = ConfigOptions.config, port: typing.Optional[str] = DeviceOptions.port, baudrate: typing.Optional[int] = DeviceOptions.baudrate, timeout: typing.Optional[float] = DeviceOptions.timeout, thresholds: str = ThresholdOptions.thresholds, suppress_threshold: int = ThresholdOptions.suppress_threshold, max_retry: int = ThresholdOptions.max_retry, history: pathlib.Path = ThresholdOptions.history, workspace: typing.Optional[pathlib.Path] = OutputOptions.workspace, filename_prefix: typing.Optional[str] = OutputOptions.filename_prefix, filename_suffix: typing.Optional[str] = OutputOptions.filename_suffix, events_per_file: typing.Optional[int] = SamplerOptions.events_per_file, number_of_files: typing.Optional[int] = SamplerOptions.number_of_files, stream_mode: bool = SamplerOptions.stream_mode, mode: typing.Optional[str] = SamplerOptions.mode, duration: typing.Optional[float] = SamplerOptions.duration, nsteps: int = ScanOptions.nsteps, step: int = ScanOptions.step, mock: bool = TestingOptions.mock, load_from: typing.Optional[pathlib.Path] = TestingOptions.load_from, speed: float = TestingOptions.speed, shuffle: bool = TestingOptions.shuffle, jitter: float = TestingOptions.jitter, loop: bool = TestingOptions.loop, verbose: bool = LoggerOptions.verbose, logfile: str = LoggerOptions.logfile) -> None
:canonical: haniwers.v1.cli.threshold.serial

```{autodoc2-docstring} haniwers.v1.cli.threshold.serial
```
````

````{py:function} parallel(ctx: typer.Context, config: typing.Optional[pathlib.Path] = ConfigOptions.config, port: typing.Optional[str] = DeviceOptions.port, baudrate: typing.Optional[int] = DeviceOptions.baudrate, timeout: typing.Optional[float] = DeviceOptions.timeout, device_label: typing.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: typing.Optional[float] = SamplerOptions.duration, workspace: typing.Optional[pathlib.Path] = OutputOptions.workspace, filename_prefix: typing.Optional[str] = OutputOptions.filename_prefix, filename_suffix: typing.Optional[str] = OutputOptions.filename_suffix, events_per_file: typing.Optional[int] = SamplerOptions.events_per_file, number_of_files: typing.Optional[int] = SamplerOptions.number_of_files, stream_mode: bool = SamplerOptions.stream_mode, mock: bool = TestingOptions.mock, verbose: bool = LoggerOptions.verbose, logfile: str = LoggerOptions.logfile) -> None
:canonical: haniwers.v1.cli.threshold.parallel

```{autodoc2-docstring} haniwers.v1.cli.threshold.parallel
```
````

````{py:function} _parse_fit_parameters(parameters: typing.Optional[str]) -> dict
:canonical: haniwers.v1.cli.threshold._parse_fit_parameters

```{autodoc2-docstring} haniwers.v1.cli.threshold._parse_fit_parameters
```
````

````{py:function} fit(read_from: pathlib.Path = typer.Argument(..., help='Directory containing threshold scan result CSV files'), pattern: str = typer.Option('*.csv', '--pattern', '-p', help='Filename pattern to search for scan data'), parameters: typing.Optional[str] = typer.Option(None, '--parameters', help="Initial fit parameters. Two formats supported:\n  1. Global: '10,300,1,1' (height,mean,sigma,offset for all channels)\n  2. Per-channel: '1:10,300,1,1;2:10,300,1,1' (channel:height,mean,sigma,offset)"), verify: bool = typer.Option(False, '--verify', help='Perform verification checks on fit results (data quality, reasonableness)'), plot: bool = typer.Option(False, '--plot', help='Generate and save interactive hvplot visualizations of fit results'), workspace: typing.Optional[pathlib.Path] = OutputOptions.workspace, verbose: bool = LoggerOptions.verbose, logfile: str = LoggerOptions.logfile) -> None
:canonical: haniwers.v1.cli.threshold.fit

```{autodoc2-docstring} haniwers.v1.cli.threshold.fit
```
````
