-
Notifications
You must be signed in to change notification settings - Fork 2
Scattering-diffuse-mni #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
First version of scattering_diffuse. |
imkar/scattering/diffuse.py
Outdated
|
||
Parameters | ||
---------- | ||
reverb_time : pf.FrequencyData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverb_time : pf.FrequencyData | |
reverberation_time : pf.FrequencyData |
imkar/scattering/diffuse.py
Outdated
|
||
sample_area : float | ||
Surface area of the measurement sample in square meter. Standard value | ||
according to the test sample at IHTA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to the test sample at IHTA. | |
according to the test sample. |
measurement time. | ||
|
||
calculation_method : 'ISO','Eyring' or 'Sabine' | ||
Defines the method by which alpha is calculated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``'ISO'``
... baseplate_area and sample_area need to be equal. (add test)
``'Eyring'``
imkar/scattering/diffuse.py
Outdated
Frequency object containing the reverbaration times calculated during | ||
the four different measurements. If the measurement is performed at | ||
multiple positions, the mean value for every condition of the | ||
measurements is taken. Its cshape has to be (4,). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
measurements is taken. Its cshape has to be (4,). | |
measurements is taken. Its cshape has to be (..., 4) |
import pytest | ||
import numpy.testing as npt | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add test for multidimensional inputs
np.vstack(([T60_1, T60_2, T60_3, T60_4], [T60_1, T60_2, T60_3, T60_4]))
imkar/scattering/diffuse.py
Outdated
if (np.any(np.asarray(speed_of_sound, dtype=float) <= 0)): | ||
raise ValueError("speed_of_sound has to be a value bigger than zero") | ||
|
||
if type(air_attenuation) == pf.classes.audio.FrequencyData: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if isinstance(air_attenuation, pf.FrequencyData):
imkar/scattering/diffuse.py
Outdated
raise ValueError("air_attenuation has to be a value bigger or equal \ | ||
to zero") | ||
|
||
if (calculation_method != "ISO" and calculation_method != "Eyring" and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (calculation_method != "ISO" and calculation_method != "Eyring" and | |
if calculation_method in ['ISO', 'Eyring', 'Sabine']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestions applied and addition of multidimensional input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for appling the changes. I merged the latest version into the branch and added the docs. I have a few further small comments. If you still have time, please include it.
Parameters | ||
---------- | ||
reverberation_time : pf.FrequencyData | ||
Frequency object containing the reverbaration times calculated during |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frequency object containing the reverbaration times calculated during | |
Frequency object containing the reverberation times calculated during |
|
||
scale_factor : float | ||
Factor that corrects the frequencies when using a smaller scale | ||
reverbaration room than defined in the ISO standard. Standard value is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverbaration room than defined in the ISO standard. Standard value is | |
reverberation room than defined in the ISO standard. Standard value is |
measurement condition calculated by temperature and air humidity during | ||
measurement time. Its cshape has to be (..., 4). | ||
|
||
calculation_method : 'ISO','Eyring' or 'Sabine' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calculation_method : 'ISO','Eyring' or 'Sabine' | |
calculation_method : string |
describe each option as it is done for distance_measure in find_nearest
https://pyfar.readthedocs.io/en/stable/classes/pyfar.coordinates.html#pyfar.classes.coordinates.Coordinates.find_nearest
raise ValueError("For calculation method 'ISO' the baseplate_area and \ | ||
sample_area need to be equal.") | ||
|
||
if not isinstance(scale_factor, numbers.Real) or scale_factor <= 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not isinstance(scale_factor, numbers.Real) or scale_factor <= 0: | |
if not isinstance(scale_factor, (float, int)) or scale_factor <= 0: |
in this way we dont need numbers package anymore
if not isinstance(scale_factor, numbers.Real) or scale_factor <= 0: | ||
raise TypeError("scale_factor has to be a real number >0") | ||
|
||
if not isinstance(sample_area, numbers.Real) or sample_area <= 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
if not isinstance(surface_room, numbers.Real) or surface_room <= 0: | ||
raise TypeError("surface_room has to be a real number >0") | ||
|
||
if not isinstance(volume_room, numbers.Real) or volume_room <= 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
condition calculated by the temperature and air humidity during | ||
measurement time. | ||
|
||
air_attenuation : array, pf.FrequencyData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't allow array, it's frequency data, so force pf.FrequencyData
air_attenuation : array, pf.FrequencyData | |
air_attenuation : pf.FrequencyData |
raise ValueError("speed_of_sound has to be a value bigger than zero") | ||
|
||
if isinstance(air_attenuation, pf.FrequencyData): | ||
air_attenuation = np.asarray(air_attenuation.freq, dtype=float) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont convert to array, use pf.FrequencyData
|
||
if (np.any(np.asarray(speed_of_sound, dtype=float) <= 0)): | ||
raise ValueError("speed_of_sound has to be a value bigger than zero") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a check if frequencies of air_attenuation
and reverberation_times
are same.
(alpha[:, 2]-alpha[:, 0]).clip(min=0) | ||
|
||
# random-incidence scattering coefficient | ||
scatterring_coefficient = (1-(1-a_spec)/(1-a_s)).clip(min=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scatterring_coefficient = (1-(1-a_spec)/(1-a_s)).clip(min=0) | |
scattering_coefficient = (1-(1-a_spec)/(1-a_s)).clip(min=0) |
replaced by #23 |
Which issue(s) are closed by this pull request?
Closes #
Changes proposed in this pull request:
Labels
Label your issue to make it easier for us to assign and track:
Use one of these labels: