@@ -57,7 +57,7 @@ def test_averaging(self):
5757
5858 # Frequency average into # octave bands
5959 octave = 3
60- td_spsdl_mean = acoustics .band_aggregate (td_spsdl , octave , fmin = 50 )
60+ td_spsdl_mean = acoustics .band_aggregate (td_spsdl , octave , fmin = 10 , fmax = 100000 )
6161
6262 # Time average into 30 s bins
6363 lbin = 30
@@ -81,29 +81,29 @@ def test_averaging(self):
8181 )
8282 cd_spsdl_50 = np .array (
8383 [
84- [73.71803613 , 70.97557445 , 69.79906778 , 69.04934313 , 67.56449352 ],
85- [73.72245955 , 71.53327285 , 70.55206775 , 68.69638127 , 67.75243522 ],
86- [73.64022645 , 72.24548986 , 70.09995522 , 69.00394292 , 68.22919418 ],
87- [73.1301846 , 71.99940268 , 70.56372046 , 69.01366589 , 67.19515351 ],
88- [74.67880072 , 71.27235403 , 70.23024477 , 67.4915765 , 66.73024553 ],
84+ [63.45507 , 64.753525 , 65.04905 , 67.15576 , 73.47938 ],
85+ [62.77437 , 64.58199 , 65.18464 , 66.37395 , 72.30796 ],
86+ [64.76277 , 64.950264 , 65.80557 , 67.88482 , 73.24013 ],
87+ [63.654488 , 62.31394 , 65.598816 , 67.370674 , 71.52472 ],
88+ [62.45623 , 62.461388 , 62.111694 , 66.06419 , 72.324936 ],
8989 ]
9090 )
9191 cd_spsdl_25 = np .array (
9292 [
93- [72.42136105 , 70.37422873 , 68.60783404 , 67.56108417 , 66.4751517 ],
94- [71.95173902 , 71.03281659 , 69.59019407 , 67.79615712 , 66.73980611 ],
95- [71.12756436 , 70.68228634 , 69.53891917 , 68.126758 , 67.48463198 ],
96- [71.71909635 , 70.1849931 , 69.22647784 , 68.14102709 , 66.18740693 ],
97- [72.25521793 , 70.18087912 , 68.97354823 , 66.71295946 , 65.35302077 ],
93+ [59.33189297 , 62.89503765 , 61.60455799 , 64.80938911 , 70.59576607 ],
94+ [60.37440872 , 60.69928551 , 61.9694643 , 64.91986465 , 70.00148964 ],
95+ [61.1297617 , 63.02504444 , 64.41207123 , 66.37802315 , 71.38513947 ],
96+ [59.52737236 , 59.45869541 , 62.48176765 , 66.0959053 , 70.06054497 ],
97+ [58.55439758 , 59.88098335 , 59.66310596 , 63.86431885 , 70.20335197 ],
9898 ]
9999 )
100100 cd_spsdl_75 = np .array (
101101 [
102- [75.29614796 , 71.86901413 , 71.08418954 , 69.6835928 , 68.26993291 ],
103- [74.51608597 , 72.82376854 , 71.31219865 , 70.38580566 , 69.01731822 ],
104- [75.17013043 , 73.45962974 , 71.30593827 , 71.50687178 , 69.49805535 ],
105- [74.38176106 , 73.13456376 , 72.13861655 , 70.45825381 , 67.93458589 ],
106- [75.52387419 , 72.99604074 , 71.26831962 , 68.90629303 , 67.79114848 ],
102+ [66.33672714 , 67.13593102 , 67.34234238 , 68.7525959 , 75.30982399 ],
103+ [64.58539009 , 66.84792709 , 67.11526108 , 69.7322197 , 74.50746346 ],
104+ [66.56425095 , 67.85562325 , 69.30602646 , 69.83069992 , 74.79984283 ],
105+ [67.34252357 , 65.65701294 , 67.48604202 , 70.948246 , 73.59340286 ],
106+ [66.26214409 , 65.43437958 , 64.36196518 , 67.67719078 , 74.33639717 ],
107107 ]
108108 )
109109
@@ -118,13 +118,17 @@ def test_freq_loss(self):
118118 self .assertEqual (fmin , 39.84375 )
119119
120120 def test_spl (self ):
121- td_spl = acoustics .sound_pressure_level (self .spsd , fmin = 50 )
121+ td_spl = acoustics .sound_pressure_level (self .spsd , fmin = 10 , fmax = 100000 )
122122
123123 # Decidecade octave sound pressure level
124- td_spl10 = acoustics .decidecade_sound_pressure_level (self .spsd , fmin = 50 )
124+ td_spl10 = acoustics .decidecade_sound_pressure_level (
125+ self .spsd , fmin = 10 , fmax = 100000
126+ )
125127
126128 # Median third octave sound pressure level
127- td_spl3 = acoustics .third_octave_sound_pressure_level (self .spsd , fmin = 50 )
129+ td_spl3 = acoustics .third_octave_sound_pressure_level (
130+ self .spsd , fmin = 10 , fmax = 100000
131+ )
128132
129133 cc = np .array (
130134 [
@@ -136,31 +140,74 @@ def test_spl(self):
136140 ],
137141 dtype = "datetime64[ns]" ,
138142 )
139- cd_spl = np .array (
140- [97.48727775 , 98.21888437 , 96.99586637 , 97.43571891 , 96.60915502 ]
143+ cd_spl_head = np .array ([98.12284 , 98.639824 , 97.62718 , 97.85709 , 96.98539 ])
144+ cd_spl_tail = np .array ([98.420975 , 98.10879 , 97.430115 , 97.99395 , 97.95798 ])
145+
146+ cd_spl10_freq_head = np .array (
147+ [10.0 , 10.717735 , 11.486984 , 12.311444 , 13.195079 ]
148+ )
149+ cd_spl10_head = np .array (
150+ [
151+ [64.40389 , 64.78221 , 63.64469 , 67.782845 , 73.05421 ],
152+ [56.934277 , 62.80422 , 66.329056 , 67.336395 , 65.79995 ],
153+ [67.16593 , 69.089096 , 69.5835 , 67.69844 , 63.657196 ],
154+ [66.010025 , 67.567635 , 68.16686 , 66.72678 , 64.52246 ],
155+ [63.887203 , 68.73698 , 72.71424 , 72.98322 , 69.08172 ],
156+ ]
141157 )
142- cd_spl10 = np .array (
158+ cd_spl10_freq_tail = np .array (
159+ [38217.031333 , 40960.0 , 43899.841025 , 47050.684621 , 50427.675171 ]
160+ )
161+ cd_spl10_tail = np .array (
143162 [
144- [82.06503071 , 78.20349846 , 79.78088446 , 75.31281183 , 82.1194826 ],
145- [82.66175023 , 79.77804574 , 82.86005403 , 77.57078269 , 76.7598224 ],
146- [77.48975416 , 82.72580274 , 83.88251531 , 74.71242694 , 74.01377947 ],
147- [79.11312683 , 76.56114947 , 82.18953494 , 75.40888015 , 74.80285354 ],
148- [81.26751434 , 82.29074565 , 80.08831394 , 75.75364773 , 73.52176641 ],
163+ [77.38338 , 73.43317 , 72.7755 , 72.53339 , np . nan ],
164+ [77.72596 , 73.57787 , 73.16561 , 72.637436 , np . nan ],
165+ [77.61121 , 73.59171 , 73.20265 , 72.57601 , np . nan ],
166+ [77.3753 , 73.35718 , 72.89339 , 72.386765 , np . nan ],
167+ [77.31649 , 73.806496 , 73.296 , 72.73348 , np . nan ],
149168 ]
150169 )
151- cd_spl3 = np .array (
170+ cd_spl3_freq_head = np .array ([10.0 , 12.59921 , 15.874011 , 20.0 , 25.198421 ])
171+ cd_spl3_head = np .array (
152172 [
153- [86.5847236 , 84.98068691 , 85.61056131 , 83.55067796 , 84.41810962 ],
154- [87.5449842 , 84.48841036 , 84.09406069 , 85.81895309 , 86.71437852 ],
155- [86.37334939 , 84.08914125 , 86.01614536 , 83.36059983 , 84.54635288 ],
156- [84.21413445 , 84.63996392 , 82.52906024 , 84.54731095 , 83.45652422 ],
157- [86.90033232 , 84.8217658 , 83.85297355 , 82.92231618 , 81.39163217 ],
173+ [68.88561 , 75.65294 , 68.29522 , 75.80323 , 82.53724 ],
174+ [62.806908 , 69.76993 , 62.64113 , 73.26091 , 83.27883 ],
175+ [71.73166 , 68.541534 , 68.056076 , 75.438034 , 84.268715 ],
176+ [70.84345 , 68.65471 , 63.4681 , 72.818085 , 77.38771 ],
177+ [69.23148 , 74.04387 , 64.49707 , 74.146164 , 79.52727 ],
178+ ]
179+ )
180+ cd_spl3_freq_tail = np .array (
181+ [20480.0 , 25803.183102 , 32509.973544 , 40960.0 , 51606.366204 ]
182+ )
183+ cd_spl3_tail = np .array (
184+ [
185+ [80.37833 , 81.21788 , 83.5725 , 80.37073 , 72.06452 ],
186+ [81.848434 , 81.772064 , 83.928505 , 80.70311 , 72.164345 ],
187+ [81.13474 , 81.67803 , 83.96902 , 80.6636 , 72.07929 ],
188+ [81.532005 , 81.694954 , 83.796875 , 80.38368 , 71.94872 ],
189+ [80.70353 , 81.6905 , 83.76083 , 80.53248 , 72.248276 ],
158190 ]
159191 )
160192
161- np .testing .assert_allclose (td_spl .head ().values , cd_spl , atol = 1e-6 )
162- np .testing .assert_allclose (td_spl10 .head ().values , cd_spl10 , atol = 1e-6 )
163- np .testing .assert_allclose (td_spl3 .head ().values , cd_spl3 , atol = 1e-6 )
193+ np .testing .assert_allclose (td_spl .head ().values , cd_spl_head , atol = 1e-6 )
194+ np .testing .assert_allclose (td_spl .tail ().values , cd_spl_tail , atol = 1e-6 )
195+ np .testing .assert_allclose (
196+ td_spl10 ["freq_bins" ].head ().values , cd_spl10_freq_head , atol = 1e-6
197+ )
198+ np .testing .assert_allclose (td_spl10 .head ().values , cd_spl10_head , atol = 1e-6 )
199+ np .testing .assert_allclose (
200+ td_spl10 ["freq_bins" ].tail ().values , cd_spl10_freq_tail , atol = 1e-6
201+ )
202+ np .testing .assert_allclose (td_spl10 .tail ().values , cd_spl10_tail , atol = 1e-6 )
203+ np .testing .assert_allclose (
204+ td_spl3 ["freq_bins" ].head ().values , cd_spl3_freq_head , atol = 1e-6
205+ )
206+ np .testing .assert_allclose (td_spl3 .head ().values , cd_spl3_head , atol = 1e-6 )
207+ np .testing .assert_allclose (
208+ td_spl3 ["freq_bins" ].tail ().values , cd_spl3_freq_tail , atol = 1e-6
209+ )
210+ np .testing .assert_allclose (td_spl3 .tail ().values , cd_spl3_tail , atol = 1e-6 )
164211 np .testing .assert_equal (td_spl ["time" ].head ().values , cc )
165212
166213 def test_sound_pressure_spectral_density (self ):
0 commit comments