Answers.Body: <p>It is correct that the sound exposure level (SEL) is an integral and it value is typically increasing with time. The classical approximation is</p>
  <blockquote>
  <p>SEL=10*log10(sum(wav^2) * dt)</p>
  </blockquote>
  <p>As</p>
  <blockquote>
  <p>dt = 1/fs</p>
  </blockquote>
  <p>you snippet is correct</p>
  <blockquote>
  <p>SEL=10*log10(sum(wav^2) /fs)</p>
  </blockquote>
  <p>However, the text is misleading and should read</p>
  <blockquote>
  <p>#Integrate squared pressure and convert to dB</p>
  </blockquote>
  <p>or</p>
  <blockquote>
  <p>#sum squared pressures, divide by sample rate, convert to dB</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-13T04:52:53.770Z
Answers.LastActivityDate: 2022-09-14T17:17:35.530Z
Answers.LastEditDate: 2022-09-14T17:17:35.530Z
Answers.UserDisplayName: WMXZ
Answers.Body: <p>A common way to calculate the exposure level (LE, also known as sound exposure level, <a href="https://www.iso.org/obp/ui/#iso:std:iso:18405:ed-1:v1:en" rel="nofollow noreferrer">https://www.iso.org/obp/ui/#iso:std:iso:18405:ed-1:v1:en</a> paragraph 3.2.1.5) would be using the &quot;trapz&quot; method (available as in-build function in MatLab/Octave etc.). Indeed this is a common integration method for solving integrals numerically.</p>
  <p>Note that in the two examples below the time step is used, and the LE is therefore sample-rate independent.</p>
  <p>Something like this in MatLab:</p>
  <pre><code>sig_length = 1000; # 1000 samples
  sig = rand(sig_length,1); # noise assumed to be in Pascal
  fs = 500; # sample rate
  PaReference = 1e-6; # reference pressure
  time = (0:sig_length-1)/fs; # time in seconds
  dT = 1/fs; # time step
  LE = 10*log10(trapz(dT,sig.^2)/PaReference^2)
  # trapz can also take a vector instead of &quot;dT&quot; if timestep is not constant
  
  # or manually
  cumEnergy = zeros(sig_length,1); # preallocate memory
  sig_sqr = sig.^2; # squared values for energy calcs
  cumEnergy(1) = sig_sqr(1); #  set first sample
  for i = 2:sig_length
      # if timestep is not constant use dT = time(i)-time(i-1);
      dPasqr = sig_sqr(i)-sig_sqr(i-1);
      rect = sig_sqr(i-1)*dT; # area of square from last sample to current sample
      tri = (dPasqr*dT)/2; # area of triangle given by dT and dPasqr
      cumEnergy(i) = cumEnergy(i-1) + rect + tri; 
  endfor
  # above loop can probably be done with vectors only (no loop needed) if you're good
  
  LE_manual = 10*log10(cumEnergy(end)/Parefence^2) 
  </code></pre>
  <p>In the above we could also have &quot;cumEnergy&quot; be a single value that we update, but with this approach we can calculate the LE over time, with <code>LE=10*log10(cumEnergy./PaReference^2)</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-15T19:33:04.197Z
Answers.Text: Can you please define "LE"?
Answers.UserDisplayName: ASimonis
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-16T21:11:21.973Z
Answers.Text: "LE" is the ISO standard name for exposure level in underwater acoustics. SEL is often still used, but I'm happier sticking to well defined standards as makes less room for confusion
Answers.UserDisplayName: Rasmus
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-22T08:41:18.050Z
Answers.Text: Not sure why I should use ISO when I have to pay for obtaining it?
Answers.UserDisplayName: WMXZ
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-22T08:46:01.143Z
Answers.Text: Just realized that the formula you give "LE=10.*log10(cumEnergy./PaReference^2)" is not consistent as the ratio is not dimension free (energy/pressure-squared). ISO seems to say that ratio is for same units "L_Q = log_r(Q/Q_0)"
Answers.UserDisplayName: WMXZ
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-23T18:05:14.600Z
Answers.Text: The ISO standard has all the relevant info in the intro, and the intro is free :). I can edit the formula to include the integral, but as the answer is using general language, cumulative energy is calculated as the integral of the squared pressure, so that becomes dimensionsless, unless I'm mistaken?
Answers.UserDisplayName: Rasmus
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-15T15:25:52.943Z
Answers.LastActivityDate: 2022-10-22T09:03:09.347Z
Answers.LastEditDate: 2022-10-22T09:03:09.347Z
Answers.UserDisplayName: Rasmus
Answers.Body: <blockquote>
  <p>My understanding is that a sound exposure level is supposed to be an integral, not a sum, with the major difference being that an integral incorporates the distance between each value (e.g. the &quot;dt&quot;), which is dependent on the sample rate.</p>
  </blockquote>
  <p><strong>Generally speaking</strong> An integral (over a continuous variable <span class="math-container">$t$</span>) can be approximated as a sum (over a discrete variable <span class="math-container">$k=t/{∆t}$</span>)  (<a href="https://en.wikipedia.org/wiki/Riemann_sum#Connection_with_integration" rel="nofollow noreferrer">see the exact mathematical relashionship</a>) if the infinitesimal variable <span class="math-container">$dt$</span> is approximated by a small quantity <span class="math-container">$∆t$</span>:</p>
  <p><span class="math-container">$$\int_{t=t_1}^{t=t_2}f(t)dt \simeq\sum_{k=k_1}^{k=k_2}f(t=k\Delta t)\Delta t $$</span></p>
  <p>with
  <span class="math-container">$$\Delta t = 1/f_s$$</span>
  <span class="math-container">$$t_1=k_1\Delta t$$</span>
  <span class="math-container">$$t_2=k_2\Delta t$$</span></p>
  <p><strong>In your case</strong> <span class="math-container">$f(k)= $</span> <em>Wav100ms</em><span class="math-container">$^2$</span> (calibrated squared pressure), <span class="math-container">$t_1= 0$</span>, <span class="math-container">$t_2= 0.1$</span> sec and the shortest time step <span class="math-container">$∆t$</span> available is the sample period <span class="math-container">$1/f_s$</span>. So the factor <span class="math-container">$1/f_s$</span> is necessary, otherwise the integral estimate is definitely wrong. Then the SEL estimation <span class="math-container">$10\log_{10}(\sum$</span><em>Wav100ms</em><span class="math-container">$^2/f_s$</span>) in your R code is correct.</p>
  <p>NB: From <code>SEL = 10*log10(sum(*Wav100ms*^2)/fs)</code>, it looks like that changing <span class="math-container">$f_s$</span> will change SEL. Strictly speaking this is right (the approximation of an integral to a sum of a finite number of elements is dependent of the step length,  here the sample period <span class="math-container">$1/f_s$</span>. However, if your sample rate <span class="math-container">$f_s$</span> is standard (i.e. high enough to record the frequencies you are dealing with; <a href="https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem" rel="nofollow noreferrer">Nyquist-Shannon theorem</a>), then the effect of changing <span class="math-container">$f_s$</span> the sound exposure level is negligible  compared to the variance of the sound exposure level over time and other uncertainties.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-13T21:39:35.710Z
Answers.Text: Noil –if an increase in the number of summed elements must be compensated by multiplying the ‘fs’ in the denominator, then ‘fs’ needs to be in the denominator. If there is no ‘fs’ in the denominator, then the numerator just increases independently.  Therefore, including the sample rate in the denominator is in fact critical. Do you agree?
Answers.UserDisplayName: ASimonis
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-14T10:27:43.650Z
Answers.Text: @ASimonis  fs appears in the denominator because the time step ∆t is 1/fs (see new equation in my response). This ∆t is needed to approximate the integral to a sum. Is this clearer?
Answers.UserDisplayName: Noil
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-14T15:46:18.377Z
Answers.Text: Yes - I agree with you 100%. Thank you.  I have found that some authors calculate SELs as a sum instead of an integral, and it's possible that "the weak dependence of fs on the integral estimate"  that you describe may be incorrectly interpreted as a justification for why sample rate is not relevant to sound exposure level.
Answers.UserDisplayName: ASimonis
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-14T17:23:49.850Z
Answers.Text: In the context of SEL that is used for risk mitigation and permitting purposes, the data are always assumed to be proper sampled. So, the Nyquist aspect is not an issue. As far as I interpret the question the "sample rates are (or are not) included in the calculation of sound exposure levels" would mean sum() or sum()*dt or sum()/fs. Obviously sum() alone is wrong and sum()*dt and sum()/fs are equivalent.
Answers.UserDisplayName: WMXZ
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-15T11:27:44.493Z
Answers.Text: I had misunderstood the question actually @ASimonis. Edited now! It is fondamentally the same as the WMXZ's response now, but I've tried to give more details. I was confused by the interchanged uses of intergral/sum in the question as WMXZ pointed and I incorrectly thought that you was asking whether the sample rate should be *reported* when measuring SEL because it would change the SEL value. Sorry for the confusion, you may have wondered why I was explaining such things haha.
Answers.UserDisplayName: Noil
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-15T19:31:43.253Z
Answers.Text: Thank you friends! I'm glad to be able to discuss these questions with you :-)
Answers.UserDisplayName: ASimonis
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-12T23:04:37.810Z
Answers.LastActivityDate: 2022-10-19T14:19:44.700Z
Answers.LastEditDate: 2022-10-19T14:19:44.700Z
Answers.UserDisplayName: Noil
Body: <p>A <a href="https://www.iso.org/obp/ui/#iso:std:iso:18405:ed-1:v1:en" rel="nofollow noreferrer">sound exposure level</a> is defined as the integral of squared pressures, over a defined time-period and frequency range, and it is reported with units of dB re: 1 µPa<span class="math-container">$^2$</span>s (for water-borne acoustics). My understanding is that a sound exposure level is supposed to be an integral, not a sum, with the major difference being that an integral incorporates the distance between each value (e.g. the &quot;dt&quot;), which is dependent on the sample rate.</p>
  <p>In my discussions with a few scientists on this topic, I’m finding inconsistent methods in the way that sample rates are (or are not) included in the calculation of sound exposure levels. This is particularly concerning because sound exposure levels are often used in management contexts, like the <a href="https://www.fisheries.noaa.gov/national/marine-mammal-protection/marine-mammal-acoustic-technical-guidance" rel="nofollow noreferrer">US National Marine Fisheries Marine Mammal Acoustic Technical Guidance</a> and <a href="https://sites.duke.edu/oceansatduke/files/2021/04/Paper1.pdf" rel="nofollow noreferrer">Southall et al 2019 Marine Mammal Noise Exposure Criteria</a>.</p>
  <p><strong>Here's a snippet of R-code which demonstrates how I think the SEL should be calculated</strong></p>
  <pre><code>#Calculate a SEL over 100 ms window, from 20 Hz - 1000 Hz 
  
  library(tuneR)
  library(seewave)
  
  clip&lt;-readWave(wavfile)
  WavClip&lt;-clip@left - mean(clip@left) #Account for DC offset
  fs&lt;-clip@samp.rate
  
  #Calibration
  cal=177 #full system calibration  
  cal = 10^(cal/20) #convert from dB to linear
  Nbit &lt;- clip@bit
  WavBit &lt;- WavClip/(2^(Nbit-1))
  WavCal&lt;-WavBit*cal
  
  #Limit frequence range with bandpass filter
  WavFilt&lt;- bwfilter(WavCal, f = fs, n =4, from = 20, to=1000, output = &quot;Sample&quot;,bandpass = TRUE)
  
  #Limit time range 
  winLen_sec&lt;-0.1*fs 
  Wav100ms&lt;-WavFilt[1:winLen_sec]
  
  #Integrate squared pressures, divide by sample rate, convert to dB
  SEL&lt;-10*log10(sum(Wav100ms^2)/fs) 
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-13T21:41:39.187Z
Comments.Text: To further illustrate the problem: 
  For simplicity, let's consider a signal with a duration of 1-second. For a 5 kHz sample rate, we will integrate 5,000 discrete points; a 48 kHz sample rate will integrate 48,000 points. Even if we use an appropriate low-pass filter on each file, the number of discrete points that are integrated will have a significant influence on the resulting SEL, i.e. the sum of 5,000 points is less than the sum of 48,000 points.
Comments.UserDisplayName: ASimonis
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-14T09:50:13.967Z
Comments.Text: you don't directly integrate over the number of points, you integrate over time (e.g. in second), so globally, integrating 48k points at fs=48kHz will be the same as 5k points as fs=5kHz, i.e. the same duration for the integral. Does this answer the point you've raised?
Comments.UserDisplayName: Noil
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-14T15:40:21.203Z
Comments.Text: Yes, I agree that as long as the SEL is calculated as an integral, and the Nyquist-Shannon theorem is respected, then the choice of sample rate doesn't matter. The SEL should be the same.
Comments.UserDisplayName: ASimonis
Tags: <noise><signal-processing><noise-impact>
Title: Should the sample rate be incorporated when calculating sound exposure levels?
ThreadText: # Should the sample rate be incorporated when calculating sound exposure levels?
  
  (Asked by: username_0 on 2022-09-12)
  
  A sound exposure level is defined as the integral of squared pressures, over a defined time-period and frequency range, and it is reported with units of dB re: 1 µPa$^2$s (for water-borne acoustics). My understanding is that a sound exposure level is supposed to be an integral, not a sum, with the major difference being that an integral incorporates the distance between each value (e.g. the "dt"), which is dependent on the sample rate.
  In my discussions with a few scientists on this topic, I’m finding inconsistent methods in the way that sample rates are (or are not) included in the calculation of sound exposure levels. This is particularly concerning because sound exposure levels are often used in management contexts, like the US National Marine Fisheries Marine Mammal Acoustic Technical Guidance and Southall et al 2019 Marine Mammal Noise Exposure Criteria.
  Here's a snippet of R-code which demonstrates how I think the SEL should be calculated
  #Calculate a SEL over 100 ms window, from 20 Hz - 1000 Hz 
  
  library(tuneR)
  library(seewave)
  
  clip<-readWave(wavfile)
  WavClip<-clip@left - mean(clip@left) #Account for DC offset
  fs<-clip@samp.rate
  
  #Calibration
  cal=177 #full system calibration  
  cal = 10^(cal/20) #convert from dB to linear
  Nbit <- clip@bit
  WavBit <- WavClip/(2^(Nbit-1))
  WavCal<-WavBit*cal
  
  #Limit frequence range with bandpass filter
  WavFilt<- bwfilter(WavCal, f = fs, n =4, from = 20, to=1000, output = "Sample",bandpass = TRUE)
  
  #Limit time range 
  winLen_sec<-0.1*fs 
  Wav100ms<-WavFilt[1:winLen_sec]
  
  #Integrate squared pressures, divide by sample rate, convert to dB
  SEL<-10*log10(sum(Wav100ms^2)/fs)
  
  **Tags:** noise, signal-processing, noise-impact
  
  > **Comments:**
  > **username_0**: To further illustrate the problem:  For simplicity, let's consider a signal with a duration of 1-second. For a 5 kHz sample rate, we will integrate 5,000 discrete points; a 48 kHz sample rate will integrate 48,000 points. Even if we use an appropriate low-pass filter on each file, the number of discrete points that are integrated will have a significant influence on the resulting SEL, i.e. the sum of 5,000 points is less than the sum of 48,000 points.  
  > **username_1**: you don't directly integrate over the number of points, you integrate over time (e.g. in second), so globally, integrating 48k points at fs=48kHz will be the same as 5k points as fs=5kHz, i.e. the same duration for the integral. Does this answer the point you've raised?  
  > **username_0**: Yes, I agree that as long as the SEL is calculated as an integral, and the Nyquist-Shannon theorem is respected, then the choice of sample rate doesn't matter. The SEL should be the same.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2022-09-12. Score: 5 | Accepted answer
  
  > My understanding is that a sound exposure level is supposed to be an integral, not a sum, with the major difference being that an integral incorporates the distance between each value (e.g. the "dt"), which is dependent on the sample rate.
  
  **Generally speaking** An integral (over a continuous variable $t$) can be approximated as a sum (over a discrete variable $k=t/{∆t}$) ([see the exact mathematical relashionship](https://en.wikipedia.org/wiki/Riemann_sum#Connection_with_integration)) if the infinitesimal variable $dt$ is approximated by a small quantity $∆t$:
  
  $$\int\_{t=t\_1}^{t=t\_2}f(t)dt \simeq\sum\_{k=k\_1}^{k=k\_2}f(t=k\Delta t)\Delta t $$
  
  with
  $$\Delta t = 1/f\_s$$
  $$t\_1=k\_1\Delta t$$
  $$t\_2=k\_2\Delta t$$
  
  **In your case** $f(k)= $ *Wav100ms*$^2$ (calibrated squared pressure), $t\_1= 0$, $t\_2= 0.1$ sec and the shortest time step $∆t$ available is the sample period $1/f\_s$. So the factor $1/f\_s$ is necessary, otherwise the integral estimate is definitely wrong. Then the SEL estimation $10\log\_{10}(\sum$*Wav100ms*$^2/f\_s$) in your R code is correct.
  
  NB: From `SEL = 10*log10(sum(*Wav100ms*^2)/fs)`, it looks like that changing $f\_s$ will change SEL. Strictly speaking this is right (the approximation of an integral to a sum of a finite number of elements is dependent of the step length, here the sample period $1/f\_s$. However, if your sample rate $f\_s$ is standard (i.e. high enough to record the frequencies you are dealing with; [Nyquist-Shannon theorem](https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem)), then the effect of changing $f\_s$ the sound exposure level is negligible compared to the variance of the sound exposure level over time and other uncertainties.
  
  > **Comments:**
  > **username_0**: username_1 –if an increase in the number of summed elements must be compensated by multiplying the ‘fs’ in the denominator, then ‘fs’ needs to be in the denominator. If there is no ‘fs’ in the denominator, then the numerator just increases independently.  Therefore, including the sample rate in the denominator is in fact critical. Do you agree?  
  > **username_1**: @username_0  fs appears in the denominator because the time step ∆t is 1/fs (see new equation in my response). This ∆t is needed to approximate the integral to a sum. Is this clearer?  
  > **username_0**: Yes - I agree with you 100%. Thank you.  I have found that some authors calculate SELs as a sum instead of an integral, and it's possible that "the weak dependence of fs on the integral estimate"  that you describe may be incorrectly interpreted as a justification for why sample rate is not relevant to sound exposure level.  
  > **username_2**: In the context of SEL that is used for risk mitigation and permitting purposes, the data are always assumed to be proper sampled. So, the Nyquist aspect is not an issue. As far as I interpret the question the "sample rates are (or are not) included in the calculation of sound exposure levels" would mean sum() or sum()*dt or sum()/fs. Obviously sum() alone is wrong and sum()*dt and sum()/fs are equivalent.  
  > **username_1**: I had misunderstood the question actually @username_0. Edited now! It is fondamentally the same as the username_2's response now, but I've tried to give more details. I was confused by the interchanged uses of intergral/sum in the question as username_2 pointed and I incorrectly thought that you was asking whether the sample rate should be *reported* when measuring SEL because it would change the SEL value. Sorry for the confusion, you may have wondered why I was explaining such things haha.  
  > **username_0**: Thank you friends! I'm glad to be able to discuss these questions with you :-)  
  
  ---
  
  ### Answer by username_2 on 2022-09-13. Score: 3
  
  It is correct that the sound exposure level (SEL) is an integral and it value is typically increasing with time. The classical approximation is
  
  > SEL=10\*log10(sum(wav^2) \* dt)
  
  As
  
  > dt = 1/fs
  
  you snippet is correct
  
  > SEL=10\*log10(sum(wav^2) /fs)
  
  However, the text is misleading and should read
  
  > #Integrate squared pressure and convert to dB
  
  or
  
  > #sum squared pressures, divide by sample rate, convert to dB
  
  
  ---
  
  ### Answer by username_3 on 2022-09-15. Score: 2
  
  A common way to calculate the exposure level (LE, also known as sound exposure level, https://www.iso.org/obp/ui/#iso:std:iso:18405:ed-1:v1:en paragraph 3.2.1.5) would be using the "trapz" method (available as in-build function in MatLab/Octave etc.). Indeed this is a common integration method for solving integrals numerically.
  Note that in the two examples below the time step is used, and the LE is therefore sample-rate independent.
  Something like this in MatLab:
  sig_length = 1000; # 1000 samples
  sig = rand(sig_length,1); # noise assumed to be in Pascal
  fs = 500; # sample rate
  PaReference = 1e-6; # reference pressure
  time = (0:sig_length-1)/fs; # time in seconds
  dT = 1/fs; # time step
  LE = 10*log10(trapz(dT,sig.^2)/PaReference^2)
  # trapz can also take a vector instead of "dT" if timestep is not constant
  
  # or manually
  cumEnergy = zeros(sig_length,1); # preallocate memory
  sig_sqr = sig.^2; # squared values for energy calcs
  cumEnergy(1) = sig_sqr(1); #  set first sample
  for i = 2:sig_length
      # if timestep is not constant use dT = time(i)-time(i-1);
      dPasqr = sig_sqr(i)-sig_sqr(i-1);
      rect = sig_sqr(i-1)*dT; # area of square from last sample to current sample
      tri = (dPasqr*dT)/2; # area of triangle given by dT and dPasqr
      cumEnergy(i) = cumEnergy(i-1) + rect + tri; 
  endfor
  # above loop can probably be done with vectors only (no loop needed) if you're good
  
  LE_manual = 10*log10(cumEnergy(end)/Parefence^2) 
  
  In the above we could also have "cumEnergy" be a single value that we update, but with this approach we can calculate the LE over time, with LE=10*log10(cumEnergy./PaReference^2)
  
  > **Comments:**
  > **username_0**: Can you please define "LE"?  
  > **username_3**: "LE" is the ISO standard name for exposure level in underwater acoustics. SEL is often still used, but I'm happier sticking to well defined standards as makes less room for confusion  
  > **username_2**: Not sure why I should use ISO when I have to pay for obtaining it?  
  > **username_2**: Just realized that the formula you give "LE=10.*log10(cumEnergy./PaReference^2)" is not consistent as the ratio is not dimension free (energy/pressure-squared). ISO seems to say that ratio is for same units "L_Q = log_r(Q/Q_0)"  
  > **username_3**: The ISO standard has all the relevant info in the intro, and the intro is free :). I can edit the formula to include the integral, but as the answer is using general language, cumulative energy is calculated as the integral of the squared pressure, so that becomes dimensionsless, unless I'm mistaken?  
  
  ---
  
  