pybearing 1.0.0__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 (36) hide show
  1. pybearing-1.0.0/.github/workflows/pytest.yml +36 -0
  2. pybearing-1.0.0/.github/workflows/release-and-publish-to-pypi.yml +32 -0
  3. pybearing-1.0.0/.gitignore +210 -0
  4. pybearing-1.0.0/License +21 -0
  5. pybearing-1.0.0/PKG-INFO +43 -0
  6. pybearing-1.0.0/README.md +27 -0
  7. pybearing-1.0.0/examples/0_bearing_and_fault_frequencies.ipynb +207 -0
  8. pybearing-1.0.0/examples/1_bearing_database.ipynb +281 -0
  9. pybearing-1.0.0/examples/2_envelope_analysis.ipynb +267 -0
  10. pybearing-1.0.0/examples/data/measurement.pkl +0 -0
  11. pybearing-1.0.0/images/pyBearing.png +0 -0
  12. pybearing-1.0.0/pybearing/__init__.py +7 -0
  13. pybearing-1.0.0/pybearing/analysis/__init__.py +4 -0
  14. pybearing-1.0.0/pybearing/analysis/envelope_analysis.py +110 -0
  15. pybearing-1.0.0/pybearing/analysis/fault_frequencies_analysis.py +151 -0
  16. pybearing-1.0.0/pybearing/core/__init__.py +4 -0
  17. pybearing-1.0.0/pybearing/core/bearing.py +80 -0
  18. pybearing-1.0.0/pybearing/core/fault_frequencies.py +95 -0
  19. pybearing-1.0.0/pybearing/data/__init__.py +5 -0
  20. pybearing-1.0.0/pybearing/data/bearing_database.py +97 -0
  21. pybearing-1.0.0/pybearing/data/database.csv +5 -0
  22. pybearing-1.0.0/pybearing/data/loaders.py +22 -0
  23. pybearing-1.0.0/pybearing/data/utils.py +18 -0
  24. pybearing-1.0.0/pybearing/signal/__init__.py +5 -0
  25. pybearing-1.0.0/pybearing/signal/features.py +124 -0
  26. pybearing-1.0.0/pybearing/signal/filtering.py +36 -0
  27. pybearing-1.0.0/pybearing/signal/spectral.py +69 -0
  28. pybearing-1.0.0/pybearing/visualization/__init__.py +3 -0
  29. pybearing-1.0.0/pybearing/visualization/envelope_analysis.py +39 -0
  30. pybearing-1.0.0/pyproject.toml +36 -0
  31. pybearing-1.0.0/tests/analysis/test_envelope_analysis.py +56 -0
  32. pybearing-1.0.0/tests/analysis/test_fault_frequencies_analysis.py +142 -0
  33. pybearing-1.0.0/tests/core/test_bearing.py +114 -0
  34. pybearing-1.0.0/tests/core/test_fault_frequencies.py +136 -0
  35. pybearing-1.0.0/tests/test_data/envelope_force.npy +0 -0
  36. pybearing-1.0.0/tests/test_data/raw_force.npy +0 -0
@@ -0,0 +1,36 @@
1
+ name: Pytest on push and pull requests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ build:
13
+ strategy:
14
+ matrix:
15
+ os: ['ubuntu-latest', 'windows-latest']
16
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
17
+ runs-on: ${{ matrix.os }}
18
+
19
+ steps:
20
+ - name: Checkout repository
21
+ uses: actions/checkout@v4
22
+
23
+ - name: Set up Python ${{ matrix.python-version }}
24
+ uses: actions/setup-python@v5
25
+ with:
26
+ python-version: ${{ matrix.python-version }}
27
+ cache: 'pip'
28
+
29
+ - name: Install packages
30
+ run: |
31
+ python -m pip install --upgrade pip
32
+ python -m pip install ".[dev]"
33
+
34
+ - name: Run tests
35
+ run: |
36
+ pytest
@@ -0,0 +1,32 @@
1
+ name: Release and Publish to PyPI
2
+ on:
3
+ push:
4
+ tags:
5
+ - 'v*'
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+
11
+ # IMPORTANT: These permissions are required for Trusted Publishing (OIDC)
12
+ permissions:
13
+ id-token: write
14
+ contents: read
15
+
16
+ steps:
17
+ - name: Checkout code
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: '3.11'
24
+
25
+ - name: Install dependencies
26
+ run: python -m pip install -U build
27
+
28
+ - name: Build package
29
+ run: python -m build
30
+
31
+ - name: Publish to PyPI
32
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,210 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+ # Skip dev folder
210
+ dev/*
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Ladisk 2026
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ Metadata-Version: 2.4
2
+ Name: pybearing
3
+ Version: 1.0.0
4
+ Summary: Simple package to calculate bearing characteristic frequencies and perform envelope analysis.
5
+ Author-email: "Matej Anko, Janko Slavič" <janko.slavic@fs.uni-lj.si>
6
+ Maintainer-email: "Matej Anko, Janko Slavič" <janko.slavic@fs.uni-lj.si>
7
+ Keywords: bearing,characteristic frequencies,envelope analysis
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: matplotlib
10
+ Requires-Dist: numpy
11
+ Requires-Dist: pandas
12
+ Requires-Dist: scipy
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=9.0.0; extra == 'dev'
15
+ Description-Content-Type: text/markdown
16
+
17
+ ![pyBearing](images/pyBearing.png)
18
+
19
+ # pyBearing
20
+
21
+ A lightweight Python package for calculating bearing fault characteristic frequencies and performing envelope analysis for fault detection.
22
+
23
+ ## Features
24
+
25
+ - Bearing fault characteristic frequencies calculation
26
+ - Bearing database
27
+ - Envelope extraction and visualization
28
+
29
+ ## Installation
30
+
31
+ To install the package, run:
32
+
33
+ ```bash
34
+ pip install pybearing
35
+ ```
36
+
37
+ ## Examples
38
+
39
+ Example notebooks and scripts are available in the `examples/` directory:
40
+
41
+ - Bearing and FaultFrequencies dataclass showcase
42
+ - Use of bearing database
43
+ - Showcase of envelope extraction and spectrum on measurement of faulty bearing
@@ -0,0 +1,27 @@
1
+ ![pyBearing](images/pyBearing.png)
2
+
3
+ # pyBearing
4
+
5
+ A lightweight Python package for calculating bearing fault characteristic frequencies and performing envelope analysis for fault detection.
6
+
7
+ ## Features
8
+
9
+ - Bearing fault characteristic frequencies calculation
10
+ - Bearing database
11
+ - Envelope extraction and visualization
12
+
13
+ ## Installation
14
+
15
+ To install the package, run:
16
+
17
+ ```bash
18
+ pip install pybearing
19
+ ```
20
+
21
+ ## Examples
22
+
23
+ Example notebooks and scripts are available in the `examples/` directory:
24
+
25
+ - Bearing and FaultFrequencies dataclass showcase
26
+ - Use of bearing database
27
+ - Showcase of envelope extraction and spectrum on measurement of faulty bearing
@@ -0,0 +1,207 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "dd2f8734",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Bearing\n",
9
+ "\n",
10
+ "The core component of pyBearing library is `Bearing` dataclass and holds information about the bearing name, type, manufacturer and geometry."
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 1,
16
+ "id": "4b0fab36",
17
+ "metadata": {},
18
+ "outputs": [],
19
+ "source": [
20
+ "from pybearing.core.bearing import Bearing"
21
+ ]
22
+ },
23
+ {
24
+ "cell_type": "code",
25
+ "execution_count": 2,
26
+ "id": "ca69c88c",
27
+ "metadata": {},
28
+ "outputs": [
29
+ {
30
+ "name": "stdout",
31
+ "output_type": "stream",
32
+ "text": [
33
+ "Bearing NMB_1560kk (Deep Groove Ball Bearing):\n",
34
+ " Inner Diameter: 6 mm\n",
35
+ " Outer Diameter: 15 mm\n",
36
+ " Width: 5 mm\n",
37
+ " Rolling element Diameter: 2.77 mm\n",
38
+ " Mean Diameter: 10.514 mm\n",
39
+ " Contact Angle: Not specified rad\n",
40
+ " Number of Rolling Elements: 7\n",
41
+ " Manufacturer: NMB\n",
42
+ "\n"
43
+ ]
44
+ }
45
+ ],
46
+ "source": [
47
+ "bearing_1 = Bearing(\n",
48
+ " name=\"NMB_1560kk\",\n",
49
+ " d=6, # mm\n",
50
+ " D=15, # mm\n",
51
+ " B=5, # mm\n",
52
+ " D_b=2.77, # mm\n",
53
+ " D_m=10.514, # mm\n",
54
+ " theta=0, # rad\n",
55
+ " N_b=7, # number of rolling elements\n",
56
+ " bearing_type=\"Deep Groove Ball Bearing\",\n",
57
+ " manufacturer=\"NMB\"\n",
58
+ ")\n",
59
+ "\n",
60
+ "print(bearing_1)"
61
+ ]
62
+ },
63
+ {
64
+ "cell_type": "markdown",
65
+ "id": "ae308292",
66
+ "metadata": {},
67
+ "source": [
68
+ "# Fault Frequencies\n",
69
+ "\n",
70
+ "Another core component of pyBearing is `FaultFrequencies` dataclass and holds information about frequency of rotation and coresponding bearing fault frequencies."
71
+ ]
72
+ },
73
+ {
74
+ "cell_type": "code",
75
+ "execution_count": 3,
76
+ "id": "e409c505",
77
+ "metadata": {},
78
+ "outputs": [],
79
+ "source": [
80
+ "from pybearing.core.fault_frequencies import FaultFrequencies"
81
+ ]
82
+ },
83
+ {
84
+ "cell_type": "code",
85
+ "execution_count": 4,
86
+ "id": "330012fa",
87
+ "metadata": {},
88
+ "outputs": [
89
+ {
90
+ "name": "stdout",
91
+ "output_type": "stream",
92
+ "text": [
93
+ "Fault Frequencies at 6.0 Hz:\n",
94
+ " Cage: 1.0 Hz\n",
95
+ " Rolling Element About Axis: 2.0 Hz\n",
96
+ " Outer Ring: 3.0 Hz\n",
97
+ " Rolling Element: 4.0 Hz\n",
98
+ " Inner Ring: 5.0 Hz\n"
99
+ ]
100
+ }
101
+ ],
102
+ "source": [
103
+ "fault_frequencies_1 = FaultFrequencies(\n",
104
+ " f_cage=1.0, # Hz\n",
105
+ " f_rolling_element_about_axis=2.0, # Hz\n",
106
+ " f_outer_ring=3.0, # Hz\n",
107
+ " f_rolling_element=4.0, # Hz\n",
108
+ " f_inner_ring=5.0, # Hz\n",
109
+ " f_of_rotation=6.0, # Hz\n",
110
+ ")\n",
111
+ "\n",
112
+ "print(fault_frequencies_1)"
113
+ ]
114
+ },
115
+ {
116
+ "cell_type": "markdown",
117
+ "id": "56f10aba",
118
+ "metadata": {},
119
+ "source": [
120
+ "The `FaultFrequencies` dataclass can be multiplied by the rotational frequency to scale fault frequencies to the right value of `f_of_rotation`."
121
+ ]
122
+ },
123
+ {
124
+ "cell_type": "code",
125
+ "execution_count": 5,
126
+ "id": "30b2f602",
127
+ "metadata": {},
128
+ "outputs": [
129
+ {
130
+ "name": "stdout",
131
+ "output_type": "stream",
132
+ "text": [
133
+ "Fault Frequencies at 180.0 Hz:\n",
134
+ " Cage: 30.0 Hz\n",
135
+ " Rolling Element About Axis: 60.0 Hz\n",
136
+ " Outer Ring: 90.0 Hz\n",
137
+ " Rolling Element: 120.0 Hz\n",
138
+ " Inner Ring: 150.0 Hz\n"
139
+ ]
140
+ }
141
+ ],
142
+ "source": [
143
+ "new_f_of_rotation = 30 # Hz\n",
144
+ "print(fault_frequencies_1 * new_f_of_rotation)"
145
+ ]
146
+ },
147
+ {
148
+ "cell_type": "markdown",
149
+ "id": "5b1a7093",
150
+ "metadata": {},
151
+ "source": [
152
+ "`FaultFrequencies` can be calculated from the known internal geometry of the bearing, using the `get_fault_frequencies` function."
153
+ ]
154
+ },
155
+ {
156
+ "cell_type": "code",
157
+ "execution_count": 6,
158
+ "id": "32add70e",
159
+ "metadata": {},
160
+ "outputs": [
161
+ {
162
+ "name": "stdout",
163
+ "output_type": "stream",
164
+ "text": [
165
+ "Fault Frequencies at 16.6667 Hz:\n",
166
+ " Cage: 6.1379 Hz\n",
167
+ " Rolling Element About Axis: 29.4351 Hz\n",
168
+ " Outer Ring: 42.965 Hz\n",
169
+ " Rolling Element: 58.8702 Hz\n",
170
+ " Inner Ring: 73.7019 Hz\n"
171
+ ]
172
+ }
173
+ ],
174
+ "source": [
175
+ "from pybearing.analysis.fault_frequencies_analysis import get_fault_frequencies\n",
176
+ "\n",
177
+ "fault_frequencies_2 = get_fault_frequencies(bearing_1, # Bearing object\n",
178
+ " 1000, # RPM\n",
179
+ " True, # If inner ring is rotating\n",
180
+ " \"geometry\" # Calculate fault frequencies from geometry\n",
181
+ " )\n",
182
+ "print(fault_frequencies_2)"
183
+ ]
184
+ }
185
+ ],
186
+ "metadata": {
187
+ "kernelspec": {
188
+ "display_name": "venv (3.13.5)",
189
+ "language": "python",
190
+ "name": "python3"
191
+ },
192
+ "language_info": {
193
+ "codemirror_mode": {
194
+ "name": "ipython",
195
+ "version": 3
196
+ },
197
+ "file_extension": ".py",
198
+ "mimetype": "text/x-python",
199
+ "name": "python",
200
+ "nbconvert_exporter": "python",
201
+ "pygments_lexer": "ipython3",
202
+ "version": "3.13.5"
203
+ }
204
+ },
205
+ "nbformat": 4,
206
+ "nbformat_minor": 5
207
+ }