Skip to content

SPL graph over time #161

@silviaurraa

Description

@silviaurraa

I'm using the ASA object with a test folder. To do this, I selected 3 bands (63Hz, 125Hz, 1kHz) and 'rms' as the method_name to use asa.evolution. The problem is I end up getting negative values for the 1kHz frequency, and I don't think it makes sense. I don't know if it's a matter of scale or some other factor I'm not taking into account.

import pyhydrophone as pyhy
import pypam
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
mpl.rcParams['text.usetex'] = False

# Soundtrap
model = "SoundTrap 300 HF"
name = "H1_6338"
serial_number = 6338
soundtrap = pyhy.soundtrap.SoundTrap(
    name=name, model=model,serial_number=serial_number)

# SURVEY PARAMETERS
nfft = 4096 #puntos FFT, resolucion espectral
# para afinar más las bandas nfft = 8192
binsize = 60.0 #en segundos, fragmento temporal para el analisis

#bandas de interes
band_63 = [56.23, 70.79]
band_125 = [11.36, 140.36]
band_1000 = [889.05, 1122.46]
band_list = [band_63, band_125, band_1000]

features = ["rms", "peak", "sel"] #metricas acusticas que se calculan
#rms: energia total, peak: pico maximo, SEL: sound sxposure level

third_octaves = None
dc_subtract = True

include_dirs = False
zipped_files = False

# Run the different parameters
asa = pypam.ASA(
    hydrophone=soundtrap,
    folder_path="//pnetapp/PAM/TFM_PRUEBAS/2.despliegue/6338/",
    binsize=binsize,
    nfft=nfft,
    fft_overlap = 0.5,
    timezone="UTC",
    include_dirs=include_dirs,
    zipped=zipped_files,
    dc_subtract=dc_subtract,
)


#visualizacion RMS () evolucion temporal
rms_evolution = asa.evolution('rms', band_list=band_list)
#RMS (Root Mean Square) Nivel medio de presión acústica durante un intervalo de tiempo
#cuantificar ruido de naturaleza continua (fuentes como trafico marino o ruido ambiente)
#devuelve un array

#visualizar evolution 
tiempo = rms_evolution['datetime'].values
rms = rms_evolution['rms'].values

band_labels = ['63 Hz', '125 Hz', '1 kHz']

plt.figure(figsize=(12,6))

for i,label in enumerate(band_labels):
    plt.plot(tiempo, rms[:,i], label=label)
    
plt.xlabel('Tiempo')
plt.ylabel('SPL (dB)')
plt.legend()
plt.show()

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions