PyTTaMaster / PyTTa

Python in Technical Acoustics and Vibration
MIT License
94 stars 33 forks source link

Error with RoomAnalysis #40

Open the-drunk-coder opened 2 years ago

the-drunk-coder commented 2 years ago

I tried the reverberation_time example, and I get the following error:

[/usr/local/lib/python3.7/dist-packages/scipy/signal/filter_design.py](https://localhost:8080/#) in iirfilter(N, Wn, rp, rs, btype, analog, ftype, output, fs)
   2344     if not analog:
   2345         if numpy.any(Wn <= 0) or numpy.any(Wn >= 1):
-> 2346             raise ValueError("Digital filter critical frequencies "
   2347                              "must be 0 < Wn < 1")
   2348         fs = 2.0

ValueError: Digital filter critical frequencies must be 0 < Wn < 1

Any hints?

Best, N

the-drunk-coder commented 2 years ago

Here's the full traceback:

(pytta-env) ubuntu@op-mm-deeparts-os:~/PyTTa/examples$ python reverberation_time.py 
Traceback (most recent call last):
  File "reverberation_time.py", line 19, in <module>
    maxFreq=float(2e4))
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/PyTTa-0.1.2a0-py3.7.egg/pytta/classes/analysis.py", line 970, in __init__
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/PyTTa-0.1.2a0-py3.7.egg/pytta/classes/analysis.py", line 996, in estimate_energy_parameters
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/PyTTa-0.1.2a0-py3.7.egg/pytta/classes/analysis.py", line 1471, in cumulative_integration
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/PyTTa-0.1.2a0-py3.7.egg/pytta/classes/analysis.py", line 1161, in _filter
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/PyTTa-0.1.2a0-py3.7.egg/pytta/classes/filter.py", line 83, in __init__
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/PyTTa-0.1.2a0-py3.7.egg/pytta/classes/filter.py", line 115, in get_sos_filters
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/PyTTa-0.1.2a0-py3.7.egg/pytta/classes/filter.py", line 105, in __design_sos_butter
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/scipy/signal/filter_design.py", line 2867, in butter
    output=output, ftype='butter', fs=fs)
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/scipy/signal/filter_design.py", line 2346, in iirfilter
    raise ValueError("Digital filter critical frequencies "
ValueError: Digital filter critical frequencies must be 0 < Wn < 1
Chum4k3r commented 2 years ago

Hello @the-drunk-coder, thank you for the traceback and your interest in pytta.

My time for pytta lies only on the weekends, when there's spare time, so I won't be able to give you some more hints right away. If you don't mind trying to run it from de code in development and get us the traceback, we might coordinate a solution to this issue.

Thanks again, and feel free to question as much as you want!

the-drunk-coder commented 2 years ago

Hi @Chum4k3r, no worries :)

The traceback above is from the latest development version, I checked it out this morning, in a conda environment generated from the requirements.yml.

I played around with it and tried to scale the edge frequencies to [0, 1] (by dividing them by samplerate//2, but now I get a different error, so I'm not sure whether that was the right way to go ...

Best, Niklas

Chum4k3r commented 2 years ago

Ok, from the scipy.signal.iirfilter documentation, it seems that the parameter fs receives a None, instead of the actual .samplingRate property.

If it is None, it is coming from the OctFilter class as a samplingRate == None.

Can you debug the filtering steps to check?

This is the critical code line of the filtering process.

best, João Vitor

the-drunk-coder commented 2 years ago

That doesn't seem to be it, the samplerate is passed correctly to the OctFilter constructor.

I also tried the following (mentioned above but here's the details):

In filter.py, line 102, add: edges = edges / (samplingRate//2) to normalize the frequencies to [0,1]

This leaves me with another error, though:

Traceback (most recent call last):
  File "revtime_local.py", line 21, in <module>
    maxFreq=float(2e4))
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/PyTTa-0.1.2a0-py3.7.egg/pytta/classes/analysis.py", line 970, in __init__
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/PyTTa-0.1.2a0-py3.7.egg/pytta/classes/analysis.py", line 996, in estimate_energy_parameters
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/PyTTa-0.1.2a0-py3.7.egg/pytta/classes/analysis.py", line 1488, in cumulative_integration
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/PyTTa-0.1.2a0-py3.7.egg/pytta/classes/analysis.py", line 1414, in energy_decay_calculation
  File "/home/ubuntu/miniconda3/envs/pytta-env/lib/python3.7/site-packages/PyTTa-0.1.2a0-py3.7.egg/pytta/classes/analysis.py", line 1281, in _Lundeby_correction
IndexError: index -1 is out of bounds for axis 0 with size 0