Esempio n. 1
0
# and set the times of our query, and the channels we want:
start = tconvert('May 27 2014 04:00')
end = start + 1800
gndchannel = 'L1:ISI-GND_STS_ITMY_Z_DQ'
hpichannel = 'L1:HPI-ITMY_BLND_L4C_Z_IN1_DQ'

# We can call the :meth:`~TimeSeriesDict.fetch` method of the `TimeSeriesDict`
# to retrieve all data in a single operation:
data = TimeSeriesDict.fetch([gndchannel, hpichannel], start, end, verbose=True)
gnd = data[gndchannel]
hpi = data[hpichannel]

# Next, we can call the :meth:`~TimeSeries.average_fft` method to calculate
# an averages, complex-valued FFT for each `TimeSeries`:
gndfft = gnd.average_fft(100, 50, window='hamming')
hpifft = hpi.average_fft(100, 50, window='hamming')

# Finally, we can divide one by the other to get the transfer function
# (up to the lower Nyquist)
size = min(gndfft.size, hpifft.size)
tf = hpifft[:size] / gndfft[:size]

# The `~gwpy.plotter.BodePlot` knows how to separate a complex-valued
# `~gwpy.spectrum.Spectrum` into magnitude and phase:
plot = BodePlot(tf)
plot.maxes.set_title(
    r'L1 ITMY ground $\rightarrow$ HPI transfer function')
plot.maxes.set_ylim(-55, 50)
plot.show()
Esempio n. 2
0
# and set the times of our query, and the channels we want:
start = tconvert('May 27 2014 04:00')
end = start + 1800
gndchannel = 'L1:ISI-GND_STS_ITMY_Z_DQ'
hpichannel = 'L1:HPI-ITMY_BLND_L4C_Z_IN1_DQ'

# We can call the :meth:`~TimeSeriesDict.get` method of the `TimeSeriesDict`
# to retrieve all data in a single operation:
data = TimeSeriesDict.get([gndchannel, hpichannel], start, end, verbose=True)
gnd = data[gndchannel]
hpi = data[hpichannel]

# Next, we can call the :meth:`~TimeSeries.average_fft` method to calculate
# an averages, complex-valued FFT for each `TimeSeries`:
gndfft = gnd.average_fft(100, 50, window='hamming')
hpifft = hpi.average_fft(100, 50, window='hamming')

# Finally, we can divide one by the other to get the transfer function
# (up to the lower Nyquist)
size = min(gndfft.size, hpifft.size)
tf = hpifft[:size] / gndfft[:size]

# The `~gwpy.plotter.BodePlot` knows how to separate a complex-valued
# `~gwpy.spectrum.Spectrum` into magnitude and phase:
plot = BodePlot(tf)
plot.maxes.set_title(
    r'L1 ITMY ground $\rightarrow$ HPI transfer function')
plot.maxes.set_ylim(-55, 50)
plot.show()
Esempio n. 3
0
# To create a low-pass filter at 1000 Hz for 4096 Hz-sampled data:

from gwpy.signal.filter_design import notch
n = notch(100, 4096)

# To view the filter, you can use the `~gwpy.plotter.BodePlot`:

from gwpy.plotter import BodePlot
plot = BodePlot(n, sample_rate=4096)
plot.show()
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)
Esempio n. 5
0
from scipy import signal
from gwpy.plotter import BodePlot
highpass = signal.butter(4, 10 * (2.0 / 256), btype='highpass')
plot = BodePlot(highpass, sample_rate=256)
Esempio n. 6
0
filter2 = filters2[options.filter_name].flatten()

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")
Esempio n. 7
0
# 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)
Esempio n. 8
0
from gwpy.signal import bandpass
from gwpy.plotter import BodePlot
zpk = bandpass(40, 1000, 4096, analog=True)
plot = BodePlot(f, title='40-1000\,Hz bandpass filter')
plot.show()
Esempio n. 9
0
from gwpy.signal import bandpass
from gwpy.plotter import BodePlot
zpk = bandpass(40, 1000, 4096, analog=True)
plot = BodePlot(zpk, analog=True, title='40-1000\,Hz bandpass filter')
plot.show()
data = TimeSeriesDict.fetch([gndchannel, hpichannel], start, end, verbose=True)
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)