shr-parser 0.1.10__cp315-cp315-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
shr_parser/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .shr_parser import *
2
+
3
+ __doc__ = shr_parser.__doc__
4
+ if hasattr(shr_parser, "__all__"):
5
+ __all__ = shr_parser.__all__
Binary file
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.4
2
+ Name: shr_parser
3
+ Version: 0.1.10
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ License-File: LICENSE
8
+ Summary: Parses sweeps from a Signal Hound Spike file.
9
+ Author: Lasse Nielsen
10
+ Requires-Python: >=3.8, <4
11
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
12
+
13
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/xerrion/shr_parser_py/CI.yml) ![GitHub License](https://img.shields.io/github/license/xerrion/shr_parser_py) ![Crates.io Version](https://img.shields.io/crates/v/shr_parser_py?link=https%3A%2F%2Fcrates.io%2Fcrates%2Fshr_parser_py)
14
+
15
+ # NOTE: No longer actively maintained, if anyone want to take over please contact me. Will probably be archived at some point.
16
+
17
+ # SHR Parser Python Bindings
18
+
19
+ This project provides Python bindings for the Rust-based `shr_parser` library, which is designed to parse and handle SHR files. The SHR file format includes a file header and multiple sweeps, each with its own header and data. This library uses memory mapping for efficient file reading and Rayon for parallel processing of sweeps.
20
+
21
+ ## Features
22
+
23
+ - **Parse SHR Files:** Read and interpret SHR files, including headers and sweeps.
24
+ - **Validate Files:** Ensure the integrity of SHR files by validating signatures and versions.
25
+ - **Sweep Metrics Calculation:** Compute key metrics such as peak, mean, and low values from sweep data.
26
+ - **CSV Export:** Export parsed SHR data to CSV format for easy analysis and reporting.
27
+
28
+ ## Installation
29
+
30
+ To install the Python bindings, you need to build the Rust library and install it as a Python module using `maturin`. Make sure you have Rust and Python installed on your system.
31
+
32
+ 1. Install `maturin`:
33
+ ```sh
34
+ pip install maturin
35
+ ```
36
+
37
+ 2. Build and install the module:
38
+ ```sh
39
+ maturin develop
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ Create a parser with a `SHRParsingType` enum member:
45
+
46
+ ```python
47
+ import shr_parser
48
+
49
+ file_path = "path/to/your/shrfile.shr"
50
+ parser = shr_parser.SHRParser(file_path, shr_parser.SHRParsingType.PEAK)
51
+ print(parser.get_file_path())
52
+ print(parser.get_file_header())
53
+ for sweep in parser.get_sweeps():
54
+ print(sweep)
55
+ for frequency_hz, amplitude in sweep.get_data():
56
+ print(frequency_hz, amplitude)
57
+ parser.to_csv("output.csv")
58
+ ```
59
+
60
+ You can also create a parser with `create_parser(file_path: str, parsing_type: SHRParsingType) -> SHRParser`.
61
+
62
+ ## Module Structure
63
+
64
+ ### `SHRParsingType`
65
+
66
+ Enum members: `PEAK = 0`, `MEAN = 1`, and `LOW = 2`. Pass a member to `SHRParser` or `create_parser`.
67
+
68
+ ### `SHRParser`
69
+
70
+ - `__init__(self, file_path: str, parsing_type: SHRParsingType) -> SHRParser`
71
+ - `__repr__(self) -> str`
72
+ - `to_csv(self, path: str) -> None`
73
+ - `get_file_path(self) -> str`
74
+ - `get_file_header(self) -> str` — returns Rust Debug-formatted text, not a structured header.
75
+ - `get_sweeps(self) -> list[SHRSweep]`
76
+
77
+ Parse and CSV-write failures raise `OSError` (`PyIOError`), with messages prefixed by `Failed to parse SHR file: ` and `Failed to write to CSV: `, respectively.
78
+
79
+ ### `SHRSweep`
80
+
81
+ `SHRSweep` has a `__repr__` method and these read-only fields: `sweep_number`, `timestamp`, `frequency`, `amplitude`, `latitude`, and `longitude`.
82
+
83
+ - `get_data(self) -> list[tuple[float, float]]` — returns all bins in file order as
84
+ `(frequency_hz, amplitude)` tuples. Frequencies are in Hz, unlike the summary
85
+ `frequency` field, which is in MHz. Each amplitude is the original file's
86
+ 32-bit float value exposed as a Python `float`, without rescaling.
87
+
88
+ `get_sweeps()` creates summary wrappers without copying their bin data. The tuple
89
+ list is created only when `get_data()` is called. A sweep keeps its parser alive,
90
+ so its data remains accessible after the original parser variable is deleted.
91
+
92
+ ## Building from source
93
+
94
+ The binding depends on the Rust parser at `../shr_parser`. Check out both
95
+ repositories as siblings:
96
+
97
+ ```text
98
+ projects/
99
+ ├── shr_parser/
100
+ └── shr_parser_py/
101
+ ```
102
+
103
+ From `projects/`, build with `maturin build --manifest-path shr_parser_py/Cargo.toml`.
104
+ The CI workflow checks out both repositories in this layout.
105
+
106
+ ## Documentation
107
+
108
+ For detailed documentation on the `shr_parser` library, refer to the [Rust documentation](https://docs.rs/shr_parser/latest/shr_parser/). To generate the documentation locally, run:
109
+
110
+ ```sh
111
+ cargo doc --open
112
+ ```
113
+
114
+ ## Contributing
115
+
116
+ Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.
117
+
118
+ ## License
119
+
120
+ This project is licensed under the GPLv3 License. See the `LICENSE` file for details.
121
+
@@ -0,0 +1,7 @@
1
+ shr_parser/__init__.py,sha256=869EnThbF-IjDveLRqoc_Sgutc_WUB35Kx8Fu55xALc,123
2
+ shr_parser/shr_parser.cp315-win32.pyd,sha256=HQadDx_orIfMG1hm3JmAORd3qqG33P6MyQd88-NTxrg,377856
3
+ shr_parser-0.1.10.dist-info/METADATA,sha256=41kWbg0BUAtaHzSvbUYZsrMWTmlT9G1sLTBdJpys9t4,4807
4
+ shr_parser-0.1.10.dist-info/WHEEL,sha256=EfmT5yHmSsKCMf88H0y_gDJxXP11dyYwZSLaX0aGPEg,93
5
+ shr_parser-0.1.10.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
6
+ shr_parser-0.1.10.dist-info/sboms/shr_parser_py.cyclonedx.json,sha256=379h1Ywd8BDRknlc0hlM9mZwC5PyvNyohkHTQtsbZyQ,30434
7
+ shr_parser-0.1.10.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.15.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp315-cp315-win32