harm-analysis 1.2.0__tar.gz → 1.2.1__tar.gz

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.
Files changed (42) hide show
  1. harm_analysis-1.2.1/LICENSE +21 -0
  2. harm_analysis-1.2.1/PKG-INFO +36 -0
  3. harm_analysis-1.2.1/README.md +14 -0
  4. harm_analysis-1.2.1/pyproject.toml +153 -0
  5. harm_analysis-1.2.1/src/harm_analysis/__init__.py +29 -0
  6. harm_analysis-1.2.1/src/harm_analysis/cli.py +75 -0
  7. harm_analysis-1.2.0/harm_analysis/_harm_analysis.py → harm_analysis-1.2.1/src/harm_analysis/harm_analysis.py +181 -152
  8. harm_analysis-1.2.1/tests/__init__.py +22 -0
  9. harm_analysis-1.2.1/tests/test_cli.py +69 -0
  10. harm_analysis-1.2.1/tests/test_harm_analysis.py +326 -0
  11. harm_analysis-1.2.1/tests/test_harm_analysis_cli.py +91 -0
  12. harm_analysis-1.2.0/.DS_Store +0 -0
  13. harm_analysis-1.2.0/.gitignore +0 -160
  14. harm_analysis-1.2.0/.readthedocs.yaml +0 -32
  15. harm_analysis-1.2.0/PKG-INFO +0 -75
  16. harm_analysis-1.2.0/README.rst +0 -60
  17. harm_analysis-1.2.0/docs/Makefile +0 -20
  18. harm_analysis-1.2.0/docs/harm_analysis_out_example.png +0 -0
  19. harm_analysis-1.2.0/docs/make.bat +0 -35
  20. harm_analysis-1.2.0/docs/requirements.txt +0 -35
  21. harm_analysis-1.2.0/docs/source/conf.py +0 -49
  22. harm_analysis-1.2.0/docs/source/harm_analysis.rst +0 -6
  23. harm_analysis-1.2.0/docs/source/index.rst +0 -106
  24. harm_analysis-1.2.0/docs/source/tutorial/examples/run_harm_analysis.py +0 -30
  25. harm_analysis-1.2.0/docs/source/tutorial/examples/run_shaped_noise_example.py +0 -27
  26. harm_analysis-1.2.0/harm_analysis/__init__.py +0 -1
  27. harm_analysis-1.2.0/harm_analysis/cli.py +0 -49
  28. harm_analysis-1.2.0/harm_analysis.egg-info/PKG-INFO +0 -75
  29. harm_analysis-1.2.0/harm_analysis.egg-info/SOURCES.txt +0 -30
  30. harm_analysis-1.2.0/harm_analysis.egg-info/dependency_links.txt +0 -1
  31. harm_analysis-1.2.0/harm_analysis.egg-info/entry_points.txt +0 -2
  32. harm_analysis-1.2.0/harm_analysis.egg-info/requires.txt +0 -4
  33. harm_analysis-1.2.0/harm_analysis.egg-info/top_level.txt +0 -1
  34. harm_analysis-1.2.0/pyproject.toml +0 -40
  35. harm_analysis-1.2.0/requirents.txt +0 -4
  36. harm_analysis-1.2.0/setup.cfg +0 -4
  37. harm_analysis-1.2.0/tests/__init__.py +0 -0
  38. harm_analysis-1.2.0/tests/test_cli.py +0 -44
  39. harm_analysis-1.2.0/tests/test_data_cli.txt +0 -2048
  40. harm_analysis-1.2.0/tests/test_harm_analysis.py +0 -286
  41. harm_analysis-1.2.0/tests/test_harm_analysis_cli.py +0 -44
  42. {harm_analysis-1.2.0 → harm_analysis-1.2.1/tests}/test_data_cli.txt +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ericsmacedo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,36 @@
1
+ Metadata-Version: 2.1
2
+ Name: harm-analysis
3
+ Version: 1.2.1
4
+ Summary: A Python library to estimate parameters from a signal containing a tone.
5
+ Keywords: DSP,Signal-Processing,THD,SNR
6
+ Author-Email: Eric Macedo <ericsmacedo@gmail.com>
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Operating System :: OS Independent
13
+ Project-URL: Homepage, https://github.com/ericsmacedo/harm-analysis
14
+ Project-URL: Documentation, https://harm-analysis.readthedocs.io/en/stable/
15
+ Project-URL: Bug Tracker, https://github.com/ericsmacedo/harm-analysis/issues
16
+ Requires-Python: <4.0,>=3.10.0
17
+ Requires-Dist: click>=8.2.1
18
+ Requires-Dist: matplotlib>=3.10.3
19
+ Requires-Dist: numpy>=2.2.6
20
+ Requires-Dist: scipy>=1.15.3
21
+ Description-Content-Type: text/markdown
22
+
23
+
24
+ [![PyPI Version](https://badge.fury.io/py/harm-analysis.svg)](https://badge.fury.io/py/harm-analysis)
25
+ [![Python Build](https://github.com/ericsmacedo/harm-analysis/actions/workflows/main.yml/badge.svg)](https://github.com/ericsmacedo/harm-analysis/actions/workflows/main.yml)
26
+ [![Documentation](https://readthedocs.org/projects/harm-analysis/badge/?version=stable)](https://harm-analysis.readthedocs.io/en/stable/)
27
+ [![Coverage Status](https://coveralls.io/repos/github/ericsmacedo/harm-analysis/badge.svg?branch=main)](https://coveralls.io/github/ericsmacedo/harm-analysis?branch=main)
28
+ [![python-versions](https://img.shields.io/pypi/pyversions/harm-analysis.svg)](https://pypi.python.org/pypi/harm-analysis)
29
+ [![semantic-versioning](https://img.shields.io/badge/semver-2.0.0-green)](https://semver.org/)
30
+
31
+ [![Downloads](https://img.shields.io/pypi/dm/harm-analysis.svg?label=pypi%20downloads)](https://pypi.python.org/pypi/harm-analysis)
32
+ [![Contributors](https://img.shields.io/github/contributors/ericsmacedo/harm-analysis.svg)](https://github.com/ericsmacedo/harm-analysis/graphs/contributors/)
33
+ [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)
34
+ [![Issues](https://img.shields.io/github/issues/ericsmacedo/harm-analysis)](https://github.com/ericsmacedo/harm-analysis/issues)
35
+ [![PRs open](https://img.shields.io/github/issues-pr/ericsmacedo/harm-analysis.svg)](https://github.com/ericsmacedo/harm-analysis/pulls)
36
+ [![PRs done](https://img.shields.io/github/issues-pr-closed/ericsmacedo/harm-analysis.svg)](https://github.com/ericsmacedo/harm-analysis/pulls?q=is%3Apr+is%3Aclosed)
@@ -0,0 +1,14 @@
1
+
2
+ [![PyPI Version](https://badge.fury.io/py/harm-analysis.svg)](https://badge.fury.io/py/harm-analysis)
3
+ [![Python Build](https://github.com/ericsmacedo/harm-analysis/actions/workflows/main.yml/badge.svg)](https://github.com/ericsmacedo/harm-analysis/actions/workflows/main.yml)
4
+ [![Documentation](https://readthedocs.org/projects/harm-analysis/badge/?version=stable)](https://harm-analysis.readthedocs.io/en/stable/)
5
+ [![Coverage Status](https://coveralls.io/repos/github/ericsmacedo/harm-analysis/badge.svg?branch=main)](https://coveralls.io/github/ericsmacedo/harm-analysis?branch=main)
6
+ [![python-versions](https://img.shields.io/pypi/pyversions/harm-analysis.svg)](https://pypi.python.org/pypi/harm-analysis)
7
+ [![semantic-versioning](https://img.shields.io/badge/semver-2.0.0-green)](https://semver.org/)
8
+
9
+ [![Downloads](https://img.shields.io/pypi/dm/harm-analysis.svg?label=pypi%20downloads)](https://pypi.python.org/pypi/harm-analysis)
10
+ [![Contributors](https://img.shields.io/github/contributors/ericsmacedo/harm-analysis.svg)](https://github.com/ericsmacedo/harm-analysis/graphs/contributors/)
11
+ [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)
12
+ [![Issues](https://img.shields.io/github/issues/ericsmacedo/harm-analysis)](https://github.com/ericsmacedo/harm-analysis/issues)
13
+ [![PRs open](https://img.shields.io/github/issues-pr/ericsmacedo/harm-analysis.svg)](https://github.com/ericsmacedo/harm-analysis/pulls)
14
+ [![PRs done](https://img.shields.io/github/issues-pr-closed/ericsmacedo/harm-analysis.svg)](https://github.com/ericsmacedo/harm-analysis/pulls?q=is%3Apr+is%3Aclosed)
@@ -0,0 +1,153 @@
1
+ [project]
2
+ name = "harm-analysis"
3
+ dynamic = []
4
+ description = "A Python library to estimate parameters from a signal containing a tone."
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Eric Macedo", email = "ericsmacedo@gmail.com" },
8
+ ]
9
+ classifiers = [
10
+ "Programming Language :: Python :: 3",
11
+ "Programming Language :: Python :: 3.10",
12
+ "Programming Language :: Python :: 3.11",
13
+ "Programming Language :: Python :: 3.12",
14
+ "Programming Language :: Python :: 3.13",
15
+ "Operating System :: OS Independent",
16
+ ]
17
+ requires-python = ">=3.10.0,<4.0"
18
+ dependencies = [
19
+ "click>=8.2.1",
20
+ "matplotlib>=3.10.3",
21
+ "numpy>=2.2.6",
22
+ "scipy>=1.15.3",
23
+ ]
24
+ keywords = [
25
+ "DSP",
26
+ "Signal-Processing",
27
+ "THD",
28
+ "SNR",
29
+ ]
30
+ version = "1.2.1"
31
+
32
+ [project.urls]
33
+ Homepage = "https://github.com/ericsmacedo/harm-analysis"
34
+ Documentation = "https://harm-analysis.readthedocs.io/en/stable/"
35
+ "Bug Tracker" = "https://github.com/ericsmacedo/harm-analysis/issues"
36
+
37
+ [project.scripts]
38
+ harm-analysis = "harm_analysis.cli:cli"
39
+
40
+ [dependency-groups]
41
+ dev = [
42
+ "contextlib-chdir>=1.0.2",
43
+ "coveralls>=3.3.1",
44
+ "mkdocs-click>=0.8.1",
45
+ "mkdocs-include-markdown-plugin>=6.0.5",
46
+ "mkdocs-literate-nav>=0.6.1",
47
+ "mkdocs-material>=9.5.18",
48
+ "mkdocstrings-python>=1.9.2",
49
+ "mypy>=1.9.0",
50
+ "pre-commit>=4.1.0",
51
+ "pytest-cov>=5.0.0",
52
+ "ruff>=0.11.2",
53
+ "test2ref>=0.4.2",
54
+ ]
55
+
56
+ [build-system]
57
+ requires = [
58
+ "pdm-backend",
59
+ ]
60
+ build-backend = "pdm.backend"
61
+
62
+ [tool.pdm.build]
63
+ includes = [
64
+ "src/harm_analysis",
65
+ ]
66
+
67
+ [tool.pdm.version]
68
+ source = "scm"
69
+ fallback_version = "0.0.0"
70
+
71
+ [tool.ruff]
72
+ line-length = 120
73
+ fix = true
74
+ target-version = "py310"
75
+
76
+ [tool.ruff.lint]
77
+ select = [
78
+ "I",
79
+ "F",
80
+ "E",
81
+ "W",
82
+ "D",
83
+ "N",
84
+ "YTT",
85
+ "B",
86
+ "Q",
87
+ "T10",
88
+ "INT",
89
+ "PL",
90
+ "PIE",
91
+ "PYI",
92
+ "TID",
93
+ "ISC",
94
+ "TC",
95
+ "C",
96
+ "C4",
97
+ "PGH",
98
+ "RUF",
99
+ "S102",
100
+ "NPY002",
101
+ "PERF",
102
+ "FLY",
103
+ "G",
104
+ "UP",
105
+ "ARG",
106
+ "PTH",
107
+ "RET",
108
+ "RSE",
109
+ ]
110
+ ignore = [
111
+ "RUF012",
112
+ "G004",
113
+ "D107",
114
+ "D105",
115
+ ]
116
+
117
+ [tool.ruff.lint.per-file-ignores]
118
+ "tests/*" = [
119
+ "PLR2004",
120
+ "ARG001",
121
+ "S101",
122
+ "PTH123",
123
+ ]
124
+
125
+ [tool.ruff.lint.pydocstyle]
126
+ convention = "google"
127
+
128
+ [tool.pytest.ini_options]
129
+ addopts = " --cov src/harm_analysis\n --cov-report term\n --cov-report html\n --doctest-glob=docs/*\n --doctest-modules\n --ignore-glob=tests/testdata/*\n --log-level=INFO\n --junitxml=report.xml\n"
130
+ filterwarnings = [
131
+ "error",
132
+ ]
133
+ testpaths = [
134
+ "tests",
135
+ ]
136
+
137
+ [tool.coverage.run]
138
+ omit = []
139
+
140
+ [tool.coverage.report]
141
+ exclude_lines = [
142
+ "return NotImplemented",
143
+ "raise NotImplementedError()",
144
+ "pragma: no cover",
145
+ "assert False",
146
+ ]
147
+
148
+ [tool.mypy]
149
+ disable_error_code = "misc"
150
+ ignore_missing_imports = true
151
+ overrides = [
152
+ { module = "tests.*", allow_untyped_defs = true },
153
+ ]
@@ -0,0 +1,29 @@
1
+ # MIT License
2
+ #
3
+ # Copyright (c) 2025 ericsmacedo
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+ """Harmonic Analysis."""
23
+
24
+ from .harm_analysis import dc_measurement, harm_analysis
25
+
26
+ __all__ = [
27
+ "dc_measurement",
28
+ "harm_analysis",
29
+ ]
@@ -0,0 +1,75 @@
1
+ # MIT License
2
+ #
3
+ # Copyright (c) 2025 ericsmacedo
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+ """CLI for harm_analysis."""
23
+
24
+ import click
25
+ import matplotlib.pyplot as plt
26
+ import numpy as np
27
+ from matplotlib.ticker import EngFormatter
28
+
29
+ from .harm_analysis import dc_measurement, harm_analysis
30
+
31
+
32
+ @click.command()
33
+ @click.argument("filename", type=click.Path(exists=True, readable=True))
34
+ @click.option("--fs", default=1.0, help="Sampling frequency.")
35
+ @click.option("--plot", is_flag=True, help="Plot the power spectrum of the data")
36
+ @click.option("--dc", is_flag=True, help="Run only DC measurement")
37
+ @click.option("--sep", default=" ", help="Separator between items.")
38
+ @click.option(
39
+ "--sfactor",
40
+ default="1",
41
+ help="Scaling factor to apply to the data. Examples: 1/8, 5, etc",
42
+ )
43
+ def cli(filename, fs, plot, sep, sfactor, dc): # noqa: PLR0913
44
+ """Runs the harm_analysis function for a file containing time domain data."""
45
+ # scaling factor
46
+ file_data = np.fromfile(filename, sep=sep) * eval(sfactor)
47
+
48
+ if plot is True:
49
+ fig, ax = plt.subplots(1, 2, figsize=(15, 5))
50
+ if dc:
51
+ results, ax[1] = dc_measurement(file_data, fs=fs, plot=True, ax=ax[1])
52
+ else:
53
+ results, ax[1] = harm_analysis(file_data, fs=fs, plot=True, ax=ax[1])
54
+ elif dc:
55
+ results = dc_measurement(file_data, fs=fs)
56
+ else:
57
+ results = harm_analysis(file_data, fs=fs, plot=False)
58
+
59
+ print("Function results:")
60
+ for key, value in results.items():
61
+ click.echo(f"{key.ljust(10)}: {value}")
62
+
63
+ if plot is True:
64
+ ax[1].grid(True, which="both")
65
+ ax[1].set_title("Power spectrum")
66
+ ax[1].set_xscale("log")
67
+ ax[1].xaxis.set_major_formatter(EngFormatter(unit="Hz"))
68
+
69
+ ax[0].set_title("Data")
70
+ ax[0].plot(file_data)
71
+ ax[0].grid(True, which="both", linestyle="-")
72
+ ax[0].set_xlabel("[n]")
73
+
74
+ plt.tight_layout()
75
+ plt.show()