import pyfar as pf
import matplotlib.pyplot as plt
import numpy as np
impulse = pf.signals.impulse(1000, sampling_rate=48000)
no_weighting = pf.dsp.filter.frequency_weighting_filter(impulse)
with_weighting = pf.dsp.filter.frequency_weighting_filter(
    impulse, error_weighting=lambda nf: 100**nf)
pf.plot.freq(no_weighting, c="b", label="without weighting")
pf.plot.freq(with_weighting, c="o", label="with weighting")
f = np.logspace(1, 4.4, 100)
ideal = pf.constants.frequency_weighting_curve("A", f)
plt.plot(f, ideal, linestyle="--", c="black", label="ideal")
plt.legend()
plt.ylim(-13, 3)
plt.xlim(4e3, 24e3)
plt.show()
