Is it possible to calculate average PSD values per hour through the ppsd.extract_psd_values?

Hello !
I can use ppsd.plot_temporal to plot PSD for every file(one file for one day), and I have 280 files(almost one year data), so is it possible to calculate average PSD values per hour for the long term data,
because I want to see the average hourly change for my station.
I am wondering that can I use ppsd.extract_psd_values to calculate the average PSD values and solve my problem ?
Thank you

Thats quite a special task so it’s not builtin but easy to do using e.g. numpy.

You can have a look at PPSD.calculate_histogram() where you can use time constraints like hour-of-day but that also bins the data so might not be exactly what you want.
You could create a mask with your conditions with numpy on the PSD timestamps though and use that to filter out PSD slices and work from there

Quick piece of code to get you started…

from obspy.signal.tests.test_spectral_estimation import _get_ppsd
ppsd = _get_ppsd()

mask = [True if t.minute == 30 else False for t in ppsd.times_processed]
np.array(ppsd.psd_values)[mask]
1 Like