LIGO/Virgo/KAGRAのデザイン感度をgwpyのFrequencySeriesとして扱う¶
LIGO-T2000012-v2で公開されている感度曲線を読んでみる
In [1]:
import numpy as np
# テキストファイルのスペクトルを読んでFrequencySeriesにする関数
def read_spectrum(path_txt, name='', unit='1 / Hz(1/2)'):
txt = np.loadtxt(path_txt,dtype='float')
f_txt = txt[:,0]
spec_txt = txt[:,1]
return FrequencySeries(spec_txt, frequencies=f_txt, unit=unit, name=name)
FrequencySeries.read(source,format='txt') は1列目を周波数、2列目をスペクトルの値として読んでくれる。
ただし単位は付けてくれないので、手で設定する必要がある。
In [2]:
from gwpy.frequencyseries import FrequencySeries
from astropy import units as u
import matplotlib.pyplot as plt
KAGRA = FrequencySeries.read('https://dcc.ligo.org/public/0165/T2000012/002/kagra_128Mpc.txt',format='txt')
KAGRA *= u.Hz**(-0.5)
print(KAGRA)
KAGRA.plot(color='gwpy:kagra', xscale='log',yscale='log')
plt.legend(['KAGRA (128Mpc)'])
FrequencySeries([7.7753e-16, 7.2260e-16, 6.7157e-16, ..., 9.1570e-23, 9.2417e-23, 9.3272e-23] unit: 1 / Hz(1/2), f0: 1.0 Hz, df: None, epoch: None, name: None, channel: None)
Out[2]:
<matplotlib.legend.Legend at 0x7f98b39668f0>
In [3]:
LIGO = FrequencySeries.read('https://dcc.ligo.org/public/0165/T2000012/002/aligo_O4low.txt', format='txt')*u.Hz**(-0.5)
Virgo = FrequencySeries.read('https://dcc.ligo.org/public/0165/T2000012/002/avirgo_O5low_NEW.txt',format='txt')*u.Hz**(-0.5)
plt.plot(LIGO, label='LIGO', color='gwpy:ligo-hanford')
plt.plot(Virgo, label='Virgo', color='gwpy:virgo')
plt.plot(KAGRA, label='KAGRA', color='gwpy:kagra')
plt.xlabel('Frequency [Hz]')
plt.ylabel(r'Strain [/$\mathrm{\sqrt{Hz}}$]')
plt.xscale('log')
plt.yscale('log')
plt.xlim(5,5e3)
plt.ylim(1e-24,1e-20)
plt.legend()
Out[3]:
<matplotlib.legend.Legend at 0x7f98ab7797e0>
3列以上あるようなテキストファイルはちゃんと読んでくれないので、numpyやpandasなどで読んでから渡す
In [4]:
import numpy as np
txt = np.loadtxt('https://dcc.ligo.org/public/0165/T2000012/002/kagra_10Mpc.txt',dtype='float')
KAGRA_10Mpc = FrequencySeries(txt[:,1],
frequencies=txt[:,0],
unit='1 / Hz(1/2)')
print(KAGRA_10Mpc)
KAGRA_10Mpc.plot(color='gwpy:kagra', xscale='log',yscale='log')
plt.legend(['KAGRA (10Mpc)'])
FrequencySeries([4.0000e-12, 3.7906e-12, 3.5729e-12, ..., 2.2773e-21, 2.3082e-21, 2.3396e-21] unit: 1 / Hz(1/2), f0: 1.0 Hz, df: None, epoch: None, name: None, channel: None)
Out[4]:
<matplotlib.legend.Legend at 0x7f98ab61fb50>
In [ ]: