Skip to content

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

Closed
wants to merge 10 commits into from
Closed

Conversation

MaxNilo
Copy link

@MaxNilo MaxNilo commented Jul 18, 2023

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:

  • hot: For bugs on the master branch
  • bug: For bugs not on the master branch
  • enhancement: For suggesting enhancements of current functionality
  • feature: For requesting new features
  • documentation: Everything related to docstrings and comments

@MaxNilo
Copy link
Author

MaxNilo commented Jul 18, 2023

First version of scattering_diffuse.


Parameters
----------
reverb_time : pf.FrequencyData
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reverb_time : pf.FrequencyData
reverberation_time : pf.FrequencyData


sample_area : float
Surface area of the measurement sample in square meter. Standard value
according to the test sample at IHTA.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

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'``

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,).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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


Copy link
Member

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]))

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:
Copy link
Member

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):

raise ValueError("air_attenuation has to be a value bigger or equal \
to zero")

if (calculation_method != "ISO" and calculation_method != "Eyring" and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (calculation_method != "ISO" and calculation_method != "Eyring" and
if calculation_method in ['ISO', 'Eyring', 'Sabine']:

@MaxNilo MaxNilo marked this pull request as ready for review January 23, 2024 17:14
Copy link
Author

@MaxNilo MaxNilo left a 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.

@ahms5 ahms5 changed the base branch from develop to cookiecutter February 20, 2024 15:49
Copy link
Member

@ahms5 ahms5 left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Member

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:
Copy link
Member

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
Copy link
Member

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

Suggested change
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)
Copy link
Member

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")

Copy link
Member

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_attenuationand reverberation_timesare same.

(alpha[:, 2]-alpha[:, 0]).clip(min=0)

# random-incidence scattering coefficient
scatterring_coefficient = (1-(1-a_spec)/(1-a_s)).clip(min=0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
scatterring_coefficient = (1-(1-a_spec)/(1-a_s)).clip(min=0)
scattering_coefficient = (1-(1-a_spec)/(1-a_s)).clip(min=0)

@ahms5
Copy link
Member

ahms5 commented Mar 28, 2024

replaced by #23

@ahms5 ahms5 closed this Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants