GithubHelp home page GithubHelp logo

bozzlab / pyacoustics-stc Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 0.0 390 KB

The Python library for Sound Transmission Class (STC) calculation

Home Page: https://pypi.org/project/pyacoustics-stc/

License: MIT License

Python 100.00%
acoustic-wave acoustics sound stc sound-transmission-class sound-transmission-loss hacktoberfest

pyacoustics-stc's Introduction

pyacoustics-stc

The Python library for Sound Transmission Class (STC) calculation

Installation

pip install pyacoustics-stc

Quickstart


Calculate STC

from pyacoustics_stc import SoundTransmissionClass

# sound transmission loss as dict object {Frequency : Value}
stl = {
    125: 11.66, 160: 13.303, 200: 14.825, 250: 20.861,
    315: 22.868,400: 24.943, 500: 26.881, 630: 28.889,
    800: 30.964, 1000: 32.902,1250: 34.84,1600: 36.984,
    2000: 38.923, 2500: 40.861, 3150: 27.557, 4000: 30.67,
}

stc = SoundTransmissionClass(stl=stl)

stc.index
# 29
stc.deficiency
# 25.579
stc.contour
# {125: 13, 160: 16, 200: 19, 250: 22, 315: 25, 400: 28, 500: 29, 630: 30, 800: 31, 1000: 32, 1250: 33, 1600: 33, 2000: 33, 2500: 33, 3150: 33, 4000: 33}
stc.delta
# {125: 1.34, 160: 2.697, 200: 4.175, 250: 1.139, 315: 2.132, 400: 3.057, 500: 2.119, 630: 1.111, 800: 0.036, 1000: 0, 1250: 0, 1600: 0, 2000: 0, 2500: 0, 3150: 5.443, 4000: 2.33}

Visualization

stc.plot() # display result as graph

Interactive Graph by Plotly

Interactive Graph on Browser

Static File Export

stc.export_graph_to_file("stc.png") # save graph result as PNG image file
stc.export_graph_to_file("stc.jpeg") # save graph result as JPEG image file
stc.export_graph_to_file("stc.pdf") # save graph result as PDF file

# <your_local_path>/stc.png

Sound Transimission Class Graph

Utils

from pyacoustics_stc.utils import build_frequency_stl_map

stl_without_key = [
    22.49669, 27.85324, 32.77704, 46.30192, 
    52.32415, 58.54912, 64.36372, 70.38595, 
    76.61092, 82.80217, 87.39175, 92.54538, 
    97.27899, 70.36132, 77.44058, 84.8613
]
stl = build_frequency_stl_map(stl_without_key)

stl
# {125: 22.49669, 160: 27.85324, 200: 32.77704, 250: 46.30192, 315: 52.32415, 400: 58.54912, 500: 64.36372, 630: 70.38595, 800: 76.61092, 1000: 82.80217, 1250: 87.39175, 1600: 92.54538, 2000: 97.27899, 2500: 70.36132, 3150: 77.44058, 4000: 84.8613}

Testing

python -m pytest

Formatter

black pyacoustics_stc 

pyacoustics-stc's People

Contributors

bozzlab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pyacoustics-stc's Issues

[Question] issue installing through pip

seems to be an issue with the setup.py egg_info not quite sure on the solution.

`%pip install pyacoustics-stc==0.3.0
Collecting pyacoustics-stc==0.3.0
Using cached pyacoustics_stc-0.3.0-py3-none-any.whl (6.0 kB)
Collecting matplotlib==2.2.2
Using cached matplotlib-2.2.2.tar.gz (37.3 MB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
Note: you may need to restart the kernel to use updated packages.
error: subprocess-exited-with-error

python setup.py egg_info did not run successfully.
exit code: 1

[6 lines of output]
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "C:\Users\XXXX\AppData\Local\Temp\pip-install-yrbalca_\matplotlib_32f41768f2d04b0fba25ba353c92446c\setup.py", line 43, in
import setupext
ModuleNotFoundError: No module named 'setupext'
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Encountered error while generating package metadata.

See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.