Exemplo n.º 1
0
print "Taking projection"

fd_reconstruction = pmpca.reconstruct_freqseries(
    waveform_FD.data, npcs=npcs, this_fpeak=target_fpeak)['recon_spectrum']

# Invert the reconstruction to time-domain (also do this to the target since
# we've padded it)
td_reconstruction = fd_reconstruction.to_timeseries()
td_target = waveform_FD.to_timeseries()

#
# Rescale amplitudes to original values
#
td_target.data *= targetAmp / td_target.max()

psd = pwave.make_noise_curve(delta_f=fd_reconstruction.delta_f,
                             noise_curve='aLIGO')

target_snr = pycbc.filter.sigma(td_target, psd=psd, low_frequency_cutoff=1000)
rec_snr = pycbc.filter.sigma(fd_reconstruction,
                             psd=psd,
                             low_frequency_cutoff=1000)

#td_reconstruction.data *= targetAmp / td_reconstruction.max()
td_reconstruction.data *= target_snr / rec_snr

fd_target = td_target.to_frequencyseries()
fd_reconstruction = td_reconstruction.to_frequencyseries()

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Match Calculation
#
Exemplo n.º 2
0
def tripleplot(cwt_result):

    signal = cwt_result['analysed_data']

    Z = np.copy(cwt_result['map'])

    for c in xrange(np.shape(Z)[1]):
        Z[:, c] /= np.log10(np.sqrt(cwt_result['frequencies']) / 2)

    # Open the figure
    fig, ax_cont = pl.subplots(figsize=(10, 5))

    #maxcol = 0.45*Z.max()
    maxcol = 0.8 * Z.max()
    vmin, vmax = 0, maxcol
    collevs = np.linspace(vmin, vmax, 100)

    # Characteristic times
    tmax = signal.sample_times[np.argmax(signal.data)]

    # --- CWT
    c = ax_cont.contourf(cwt_result['times'] - tmax,
                         cwt_result['frequencies'],
                         Z,
                         levels=collevs,
                         extend='both')

    c.cmap.set_over('k')
    c.set_cmap('gnuplot2_r')

    #ax_cont.set_yscale('log')
    ax_cont.set_xlabel('Time [s]')
    ax_cont.set_ylabel('Frequency [Hz]')

    divider = make_axes_locatable(ax_cont)

    # --- Time-series
    ax_ts = divider.append_axes("top", 1.5, sharex=ax_cont)
    ax_ts.plot(signal.sample_times - tmax, signal.data, color='k')

    # --- Fourier spectrum
    signal_frequency_spectrum = signal.to_frequencyseries()
    ax_fs = divider.append_axes("right", 3.0, sharey=ax_cont)
    x = 2 * abs(signal_frequency_spectrum.data[1:]) * np.sqrt(
        signal_frequency_spectrum.sample_frequencies.data[1:])
    y = signal_frequency_spectrum.sample_frequencies[1:]
    ax_fs.semilogx(x, y, color='k')

    #
    # Construct PSD
    #
    psd = pwave.make_noise_curve(
        fmax=signal_frequency_spectrum.sample_frequencies.max(),
        delta_f=signal_frequency_spectrum.delta_f,
        noise_curve='aLIGO')
    ax_fs.semilogx(np.sqrt(psd.data),
                   psd.sample_frequencies,
                   color='k',
                   linestyle='--',
                   label='aLIGO')
    ax_fs.legend()

    #   pl.figure()
    #   pl.plot(y, x)
    #   pl.show()
    #   sys.exit()

    # --- Mark features
    ax_fs.set_xlabel('2|H$_+$($f$)|$\sqrt{f}$ & $\sqrt{S(f)}$')
    ax_ts.set_ylabel('h$_+$(t)')

    #ax_cont.axvline(0,color='r')#,linewidth=2)
    #ax_ts.axvline(0,color='r')#,linewidth=2)

    #ax_cont.set_yscale('log')
    #ax_fs.set_yscale('log')
    #ax_cont.set_yticks(np.arange(1000,5000,1000))
    #ax_cont.set_yticklabels(np.arange(1000,5000,1000))

    # Adjust axis limits
    ax_fs.set_ylim(900, 3096)
    ax_cont.set_ylim(900, 3096)
    ax_ts.set_xlim(-2e-3, 1.5e-2)
    ax_cont.set_xlim(-2e-3, 1.5e-2)

    ax_fs.set_xlim(3e-24, 2.5e-22)

    ax_ts.minorticks_on()
    ax_fs.minorticks_on()
    ax_cont.minorticks_on()

    #ax_ts.grid(linestyle='-', color='grey')
    #ax_fs.grid(linestyle='-', color='grey')
    #ax_cont.grid(linestyle='-', color='grey')

    ax_cont.invert_yaxis()

    # Clean up tick text
    pl.setp(ax_ts.get_xticklabels() + ax_fs.get_yticklabels(), visible=False)

    ax_cont.xaxis.get_ticklabels()[-1].set_visible(False)

    ax_ts.yaxis.get_ticklabels()[0].set_visible(False)

    fig.tight_layout()

    return fig, ax_cont, ax_ts, ax_fs
Exemplo n.º 3
0
    waveform = pwave.Waveform(eos=wave['eos'],
                              mass=wave['mass'],
                              viscosity=wave['viscosity'],
                              distance=reference_distance)
    waveform.reproject_waveform()

    hplus_padded = pycbc.types.TimeSeries(np.zeros(16384),
                                          delta_t=waveform.hplus.delta_t)
    hplus_padded.data[:len(waveform.hplus)] = np.copy(waveform.hplus.data)
    Hplus = hplus_padded.to_frequencyseries()

    #
    # Construct PSD
    #
    psd = pwave.make_noise_curve(fmax=Hplus.sample_frequencies.max(),
                                 delta_f=Hplus.delta_f,
                                 noise_curve=noise_curve)

    #
    # Compute Full SNR
    #
    full_snr = pycbc.filter.sigma(Hplus, psd=psd, low_frequency_cutoff=1000)

    #
    # Compute post-merger only SNR Signal windowed at maximum
    #
    hplus_post = \
            pycbc.types.TimeSeries(pwave.window_inspiral(hplus_padded.data),
                    delta_t=hplus_padded.delta_t)
    Hplus_post = hplus_post.to_frequencyseries()
Exemplo n.º 4
0
# Build curves and plot on the fly

f, ax = pl.subplots()

ax.semilogy(Hplus.sample_frequencies,
            2 * np.sqrt(Hplus.sample_frequencies) * abs(Hplus.data),
            label='BNS @ 50 Mpc',
            color='k')

lines = ["-", "--", "-.", ":"]
linecycler = cycle(lines)

for instrument in instruments:

    psd = pwave.make_noise_curve(fmax=fmax,
                                 delta_f=delta_f,
                                 noise_curve=instrument)

    det_label = detector_names(instrument)

    ax.semilogy(psd.sample_frequencies,
                np.sqrt(psd),
                label=det_label,
                linestyle=next(linecycler))

ax.grid()
ax.legend()
ax.minorticks_on()
ax.set_xlim(999, 4096)
ax.set_ylim(1e-25, 1e-20)
ax.set_xlabel('Frequency [Hz]')
Exemplo n.º 5
0
    waveform.compute_characteristics()

    # Standardise
    waveform_FD, target_fpeak, _ = ppca.condition_spectrum(waveform.hplus.data,
                                                           nsamples=nTsamples)

    # Normalise
    waveform_FD = ppca.unit_hrss(waveform_FD.data,
                                 delta=waveform_FD.delta_f,
                                 domain='frequency')

    #
    # Construct PSD
    #
    psd = pwave.make_noise_curve(fmax=waveform_FD.sample_frequencies.max(),
                                 delta_f=waveform_FD.delta_f,
                                 noise_curve=noise_curve)

    # Fisher matrix: expand likelihood about target_fpeak +/- 0.5*deltaF
    fpeak1 = target_fpeak + 0.5 * deltaF
    fpeak2 = target_fpeak - 0.5 * deltaF

    #
    # Compute results as functions of #s of PCs
    #
    for n, npcs in enumerate(xrange(1, waveform_data.nwaves)):

        fd_reconstruction = \
                pmpca.reconstruct_freqseries(waveform_FD.data,
                        npcs=npcs, wfnum=w)
        #
Exemplo n.º 6
0
hp, hc = get_td_waveform(approximant='NR_hdf5',
                         numrel_data=filepath,
                         mass1=params['mass1'],
                         mass2=params['mass2'],
                         spin1z=params['spin1z'],
                         spin2z=params['spin2z'],
                         delta_t=1.0 / 16384.,
                         f_lower=1000,
                         inclination=params['inclination'],
                         coa_phase=params['coa_phase'],
                         distance=params['distance'])

Hp = hp.to_frequencyseries()

psd = pwave.make_noise_curve(fmax=Hp.sample_frequencies.max(),
                             delta_f=Hp.delta_f,
                             noise_curve='aLIGO')

SNR = pycbc.filter.sigma(Hp, psd=psd, low_frequency_cutoff=1000)
print 'pycbc snr=', SNR

amp = wfutils.amplitude_from_polarizations(hp, hc)

#
# Generate own waveform
#
from pmns_utils import pmns_waveform as pwave
eos = "shen"
mass = "135135"
total_mass = 2 * 1.35
mass1 = 1.35