<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> REFERENCE_PRESSURE = <NUM_LIT> <EOL> """<STR_LIT>""" <EOL> def sound_pressure_level ( pressure , reference_pressure = REFERENCE_PRESSURE ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT> * np . log10 ( pressure ** <NUM_LIT> / reference_pressure ** <NUM_LIT> ) <EOL> def equivalent_sound_pressure_level ( pressure , reference_pressure = REFERENCE_PRESSURE , axis = - <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT> * np . log10 ( ( pressure ** <NUM_LIT> ) . mean ( axis = axis ) / reference_pressure ** <NUM_LIT> ) <EOL> def max_sound_pressure_level ( pressure , reference_pressure = REFERENCE_PRESSURE , axis = - <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> return sound_pressure_level ( pressure , reference_pressure = reference_pressure ) . max ( axis = axis ) <EOL> def peak_sound_pressure ( pressure , axis = - <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> return np . abs ( pressure ) . max ( axis = axis ) <EOL> def peak_sound_pressure_level ( pressure , reference_pressure = REFERENCE_PRESSURE , axis = - <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT> * np . log10 ( peak_sound_pressure ( pressure , axis = axis ) ** <NUM_LIT> / reference_pressure ** <NUM_LIT> ) <EOL> REFERENCE_SOUND_EXPOSURE = <NUM_LIT> <EOL> """<STR_LIT>""" <EOL> def sound_exposure ( pressure , fs , axis = - <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> return ( pressure ** <NUM_LIT> / fs ) . sum ( axis = axis ) <EOL> def sound_exposure_level ( pressure , fs , reference_sound_exposure = REFERENCE_SOUND_EXPOSURE , axis = - <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT> * np . log10 ( sound_exposure ( pressure , fs , axis = axis ) / reference_sound_exposure ) <EOL> REFERENCE_POWER = <NUM_LIT> <EOL> """<STR_LIT>""" <EOL> def sound_power_level ( power , reference_power = REFERENCE_POWER ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT> * np . log10 ( power / reference_power ) <EOL> def sound_energy ( power , axis = - <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> return power . sum ( axis = axis ) <EOL> REFERENCE_ENERGY = <NUM_LIT> <EOL> """<STR_LIT>""" <EOL> def sound_energy_level ( energy , reference_energy = REFERENCE_ENERGY ) : <EOL> """<STR_LIT>""" <EOL> return np . log10 ( energy / reference_energy ) <EOL> def sound_intensity ( pressure , velocity ) : <EOL> """<STR_LIT>""" <EOL> return pressure * velocity <EOL> REFERENCE_INTENSITY = <NUM_LIT> <EOL> """<STR_LIT>""" <EOL> def time_averaged_sound_intensity ( intensity , axis = - <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> return intensity . mean ( axis = axis ) <EOL> def time_averaged_sound_intensity_level ( time_averaged_sound_intensity , reference_intensity = REFERENCE_INTENSITY , axis = - <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT> * np . log10 ( np . linalg . norm ( time_averaged_sound_intensity , axis = axis ) / reference_intensity ) <EOL> def normal_time_averaged_sound_intensity ( time_averaged_sound_intensity , unit_normal_vector ) : <EOL> """<STR_LIT>""" <EOL> return time_averaged_sound_intensity . dot ( unit_normal_vector ) <EOL> def normal_time_averaged_sound_intensity_level ( normal_time_averaged_sound_intensity , reference_intensity = REFERENCE_INTENSITY ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT> * np . log10 ( np . abs ( normal_time_averaged_sound_intensity / reference_intensity ) ) </s>
