Commit a5108b0e authored by Alessio Nuti's avatar Alessio Nuti
Browse files

version 1.0

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+111 −0
Original line number Diff line number Diff line
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# stupid windows explorer filez
*.ini

# pycharm project filez
.idea/*
 No newline at end of file

LICENSE

0 → 100644
+0 −0

File added.

Preview size limit exceeded, changes collapsed.

README.md

0 → 100644
+38 −0
Original line number Diff line number Diff line
# pyvibration

A Python vibration data analysis library

## Description

The aim is to provide a convenient Python interface for vibration data analysis (fourier analysis, PSD estimation, plotting) using where possible numpy/scipy implementations, with the addition of some utilities.  

Data sets are represented as numpy arrays where the first column is time or frequency. 

Module ```ioutil``` contains functions to load data from text and excel files.

Module ```plots``` is used for plotting time histories and spectra.

## Prerequisites

* [NumPy](https://numpy.org/)
* [SciPy](https://www.scipy.org/)
* [Matplotlib](https://matplotlib.org/)
* [pandas](https://pandas.pydata.org/)
* package [nastran_pch_reader](https://pypi.org/project/nastran_pch_reader/) for parsing NASTRAN punch files

## Use

```
import pyvibration
```

See examples folder for some examples (did you ever imagine that?).

## License

This project is licensed under the GNU General Public License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

* Tom Irvine http://www.vibrationdata.com/, for the many useful notes and scripts about vibration and shock analysis.
* Nikolay Asmolovskiy https://github.com/anick107/, for the python pch parser.
+17 −0
Original line number Diff line number Diff line
import matplotlib.pyplot as plt

import pyvibration
from pyvibration.ioutil import read_pch_111

POINT_ID = 293979
SUBCASE = 1
COMPONENT = 3    # TZ

# Extract acceleration magnitude from punch file
frf = read_pch_111("./sample_punch.pch", SUBCASE, "ACCELERATION", POINT_ID, COMPONENT, "MAGNITUDE")

# Plot the frequency response
plt.figure()
pyvibration.plots.frfplot(frf, 'acceleration, POINT ID ' + str(POINT_ID), 'k')

plt.show()
+19 −0
Original line number Diff line number Diff line
import matplotlib.pyplot as plt

import pyvibration
from pyvibration.ioutil import readtxtarray, openfiledialog

psdin = readtxtarray(openfiledialog("Select data file: input PSD"))
frf = readtxtarray(openfiledialog("Select data file: FRF amplitude"))

# Calculate response PSD
psdout = pyvibration.frf2psd(frf, psdin, 20, 2000)

# Print some statistics of the response
pyvibration.psd_stats(psdout)

# Plot the response PSD
plt.figure()
pyvibration.plots.psdplot(psdout, "response", "b")

plt.show()