# {py:mod}`haniwers.v1.daq.sampler`

```{py:module} haniwers.v1.daq.sampler
```

```{autodoc2-docstring} haniwers.v1.daq.sampler
:allowtitles:
```

## Module Contents

### Classes

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

* - {py:obj}`Sampler <haniwers.v1.daq.sampler.Sampler>`
  - ```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler
    :summary:
    ```
````

### Functions

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

* - {py:obj}`run_session <haniwers.v1.daq.sampler.run_session>`
  - ```{autodoc2-docstring} haniwers.v1.daq.sampler.run_session
    :summary:
    ```
````

### API

`````{py:class} Sampler(device: typing.Union[haniwers.v1.daq.device.Device, haniwers.v1.daq.mocker.Mocker, haniwers.v1.daq.mocker.RandomMocker], config: typing.Union[haniwers.v1.config.model.DaqConfig, haniwers.v1.config.model.ScanConfig, haniwers.v1.config.model.SamplerConfig], output_dir: typing.Optional[pathlib.Path] = None, show_progress: bool = True, mac_address: str = 'unknown')
:canonical: haniwers.v1.daq.sampler.Sampler

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler
```

```{rubric} Initialization
```

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.__init__
```

````{py:method} timestamped_filename(fid: int, mac_address: str = 'unknown') -> pathlib.Path
:canonical: haniwers.v1.daq.sampler.Sampler.timestamped_filename

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.timestamped_filename
```

````

````{py:method} read_event() -> RawEvent | None
:canonical: haniwers.v1.daq.sampler.Sampler.read_event

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.read_event
```

````

````{py:method} stream_events(iterator: collections.abc.Iterator) -> collections.abc.Iterator[haniwers.v1.daq.model.RawEvent]
:canonical: haniwers.v1.daq.sampler.Sampler.stream_events

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.stream_events
```

````

````{py:method} collect_events(iterator: collections.abc.Iterator) -> list[haniwers.v1.daq.model.RawEvent]
:canonical: haniwers.v1.daq.sampler.Sampler.collect_events

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.collect_events
```

````

````{py:method} save_events(file_path: pathlib.Path, source: typing.Union[collections.abc.Iterator, list[haniwers.v1.daq.model.RawEvent]]) -> None
:canonical: haniwers.v1.daq.sampler.Sampler.save_events

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.save_events
```

````

````{py:method} acquire_by_count(file_path: pathlib.Path, event_count: int)
:canonical: haniwers.v1.daq.sampler.Sampler.acquire_by_count

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.acquire_by_count
```

````

````{py:method} acquire_by_time(file_path: pathlib.Path, duration: float, sleep_interval: float)
:canonical: haniwers.v1.daq.sampler.Sampler.acquire_by_time

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.acquire_by_time
```

````

````{py:method} time_based_iterator(duration: float, sleep_interval: float) -> collections.abc.Generator[None, None, None]
:canonical: haniwers.v1.daq.sampler.Sampler.time_based_iterator

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.time_based_iterator
```

````

````{py:method} count_based_iterator(counts: int)
:canonical: haniwers.v1.daq.sampler.Sampler.count_based_iterator

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.count_based_iterator
```

````

````{py:method} run(mode: typing.Optional[str] = None, files: typing.Optional[int] = None) -> typing.Optional[list[haniwers.v1.daq.model.RawEvent]]
:canonical: haniwers.v1.daq.sampler.Sampler.run

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.run
```

````

````{py:method} sanitize(event: list) -> list
:canonical: haniwers.v1.daq.sampler.Sampler.sanitize
:staticmethod:

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.sanitize
```

````

````{py:method} tqdm_wrapper(iterable, desc: typing.Optional[str] = None, show: bool = True)
:canonical: haniwers.v1.daq.sampler.Sampler.tqdm_wrapper
:staticmethod:

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.tqdm_wrapper
```

````

````{py:method} mock_sample(*args, **kwargs)
:canonical: haniwers.v1.daq.sampler.Sampler.mock_sample
:staticmethod:

```{autodoc2-docstring} haniwers.v1.daq.sampler.Sampler.mock_sample
```

````

`````

````{py:function} run_session(mode: str, device: haniwers.v1.daq.device.Device, config: typing.Union[haniwers.v1.config.model.DaqConfig, haniwers.v1.config.model.ScanConfig], output_dir: pathlib.Path) -> None
:canonical: haniwers.v1.daq.sampler.run_session

```{autodoc2-docstring} haniwers.v1.daq.sampler.run_session
```
````
