filter1_fd = numpy.fft.rfft(filter1) filter2_fd = numpy.fft.rfft(filter2) freqs1 = numpy.fft.rfftfreq(len(filter1), d = float(options.dt)) freqs2 = numpy.fft.rfftfreq(len(filter2), d = float(options.dt)) df1 = freqs1[1]-freqs1[0] df2 = freqs2[1]-freqs2[0] f0 = 0 print(len(filter1)) print(len(filter2)) filter1_fs = FrequencySeries(filter1_fd, f0=f0, df=df1) # packagae as a FrequecySeries object filter2_fs = FrequencySeries(filter2_fd, f0=f0, df=df2) # packagae as a FrequecySeries object plot = BodePlot(filter1_fs, frequencies=freqs1, dB = False, linewidth=2) plot.add_frequencyseries(filter2_fs, dB = False, color='#ee0000',linewidth=2) # FIXME: Figure out how to make the legend and title appropriate and flexible plot.maxes.set_yscale('log') plot.paxes.set_yscale("linear") plot.save('filter_comparison.pdf') diff = filter1_fs / filter2_fs plot = BodePlot(diff, frequencies = freqs1, dB = False, linewidth = 2) plot.maxes.set_yscale('log') plot.paxes.set_yscale('linear') plot.maxes.set_ylim(.5, 1.5) plot.maxes.set_xlim(10, 5000) plot.paxes.set_ylim(-10, 10) plot.paxes.set_xlim(10, 5000) plot.save("filter_difference.pdf")
gnd = data[gndchannel] gnd.name = 'Before HEPI (ground)' hpi = data[hpichannel] hpi.name = 'After HEPI' gnd.unit = 'nm/s' hpi.unit = 'nm/s' # get FFTs gndfft = gnd.average_fft(100, 50, window='hamming') hpifft = hpi.average_fft(100, 50, window='hamming') # get transfer function (up to lower Nyquist) size = min(gndfft.size, hpifft.size) tf = hpifft[:size] / gndfft[:size] plot = BodePlot(tf) magax = plot.axes[0] magax.set_title(r'L1 ITMY ground $\rightarrow$ HPI transfer function') magax.set_ylim(-55, 50) if __name__ == '__main__': try: outfile = __file__.replace('.py', '.png') except NameError: pass else: plot.save(outfile) print("Example output saved as\n%s" % outfile)
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GWpy. If not, see <http://www.gnu.org/licenses/>"""GWpy Example: plotting a time-series """ GWpy Example: plotting a filter ------------------------------- I would like to look at the Bode representation of a linear filter. """ from scipy import signal from gwpy.plotter import BodePlot highpass = signal.butter(4, 10 * (2. * signal.np.pi), btype='highpass', analog=True) plot = BodePlot(highpass) plot.maxes.set_title('10\,Hz high-pass filter') if __name__ == '__main__': try: outfile = __file__.replace('.py', '.png') except NameError: pass else: plot.save(outfile) print("Example output saved as\n%s" % outfile)