Modify PPSD function

Hey everyone,

is it possible (by manipulating some ObsPy script…?) to modify the PPSD function of ObsPy such that I can change the plot output? I would like to change the range of the x-axis and if possible add extra lines for e.g. drawing a line that marks NHNM - 20 dB for a certain period range.

Any idea how I could to that?

Thanks a lot and best regards,
Florian Fuchs

Hi Florian

Sure you can edit the source files, but this is probably not the recommended thing to do. Instead its safer to extend the PPSD class with a new plotting function that does what you want. To ease this you may want to have a look at the original code of PPSD.plot(), this you will find here: � regP

..or just tweak the plot with matplotlib after doing the builtin PPSD
plotting, e.g.:

import matplotlib.pyplot as plt
from obspy.signal.spectral_estimation import get_NLNM
from obspy.signal.tests.test_spectral_estimation import _get_ppsd

ppsd = _get_ppsd()
ppsd.plot(period_lim=[0.5, 10], show=False)
fig = plt.gcf()
ax = fig.axes[0]

x, y = get_NLNM()

ax.plot(x, y + 10, color="r", lw=2.5, ls="--", label="NLNM + 10db")




thanks a lot!

- Florian

Attached are NLNM and NHNM noise models in case anyone needs them ...


NHNM.ascii (187 Bytes)

NLNM.ascii (3.65 KB)

Thanks Mike, however, as indicated in the previous example they are also
included in ObsPy. No need to keep them around separately.

from obspy.signal.spectral_estimation import get_NLNM, get_NHNM
x, y = get_NLNM()