Example #1
0
reffft = ref.average_fft(fft, ol, window='hanning')
comfft = com.average_fft(fft, ol, window='hanning')

size = min(reffft.size, comfft.size)
tf = comfft[:size] / reffft[:size]

plot = BodePlot(tf)
plot.maxes.set_title('Transfer function')
#coh = ref.coherence_spectrogram(com,stride,fftlength=fft,overlap=ol)

# The time axis of coherencegram seems buggy in this version. Temporal fix is needed.
#coh.dx = stride

#cohplot=coh.plot(figsize = (12, 8),vmin=0.,vmax=1.)
#ax = cohplot.gca()
ax = plot.gca()
#ax.set_ylabel('Frequency [Hz]')
#ax.set_yscale('log')
#ax.set_title(latexrefchname + ' ' + latexchname)

#if fmin < 0:
#    fmin = 0.8/fft
#ax.set_ylim(fmin,fmax)

#cohplot.add_colorbar(cmap='YlGnBu_r',label='Coherence')

fname = outdir + '/' + refchannel + '_' + channel + '_TF_' + gpsstart + '_' + gpsend + '_' + index + '.png'
plot.savefig(fname, dpi=dpi)

plot.clf()
plot.close()
Example #2
0
def main(channel, start, end):
    data = TimeSeries.read(dumped_gwf_fmt.format(start=start,
                                                 end=end,
                                                 chname=channel),
                           channel,
                           verbose=True,
                           nproc=8)

    # Make Filter
    dnumden_120qa = trillium.tf_120qa(analog=True,
                                      sample_rate=2048 / 2,
                                      Hz=False,
                                      normalize=False)

    #
    filters = [dnumden_120qa]

    #plot_dfilt(*dnumden_120qa)

    # Plot Bodeplot
    plot = BodePlot(*filters,
                    frequencies=numpy.logspace(-3, 3, 1e5),
                    dB=False,
                    sample_rate=2048 / 2,
                    unwrap=False,
                    analog=True,
                    title='filter')

    axes = plot.get_axes()
    labels = ['Trillium120QA', 'TrilliumCompact']
    for i, ax in enumerate(axes):
        ax.legend(labels, loc='lower left')

    #axes[0].set_yscale('log')
    axes[0].set_ylim(1e-3, 1e8)
    #axes[0].set_ylim(-40,2)
    #axes[-1].set_xlim(5e-3,3e0)
    axes[-1].set_ylim(-200, 200)
    plot.savefig('Bodeplot_Trillium120QA.png')
    plot.close()

    exit()
    # Filtering
    data_calib = data.filter(zpk_trillium120qa, filtfilt=True, analog=False)

    # crop
    data_calib = data_low.crop(*data_calib.span.contract(1))

    # Plot TimeSeries
    from gwpy.plot import Plot
    data_set = [data_calib]
    plot = Plot(*data_set,
                separate=True,
                sharex=True,
                sharey=True,
                color='gwpy:ligo-livingston',
                figsize=[10, 10])

    # Add text, and save figure
    title = channel[3:].replace('_', ' ')
    labels = [
        'No filt', 'High (300mHz-)', 'Mid (50mHz-300mHz)', 'Low (-50mHz)'
    ]
    if data.unit == ' ':
        yaxis_label = 'Count'
    else:
        yaxis_label = data.unit
    axes = plot.get_axes()
    for i, ax in enumerate(axes):
        ax.legend([labels[i]], loc='upper left')
    plot.text(0.04,
              0.5,
              yaxis_label,
              va='center',
              rotation='vertical',
              fontsize=18)
    axes[0].set_title(title, fontsize=16)
    axes[-1].set_xscale('Hours', epoch=start)
    plot.savefig(timeseriesplot_fname_fmt.format(channel=channel))
    plot.close()

    # Plot ASD
    fftlen = 2**7
    specgram = data.spectrogram2(fftlength=fftlen, overlap=2,
                                 window='hanning')**(1 / 2.)
    median = specgram.percentile(50)
    low = specgram.percentile(5)
    high = specgram.percentile(95)
    plot = Plot()
    ylabel_fmt = r'{yaxis_label} [{yaxis_label}/\rtHz]'
    ax = plot.gca(
        xscale='log',
        xlim=(1e-3, 10),
        xlabel='Frequency [Hz]',
        yscale='log',  #ylim=(3e-24, 2e-20),
        ylabel=ylabel_fmt.format(yaxis_label=yaxis_label))
    ax.plot_mmm(median, low, high, color='gwpy:ligo-livingston')
    ax.set_title(title, fontsize=16)
    plot.savefig(asdplot_fname_fmt.format(channel=channel))
    plot.close()

    # Plot Spectrogram
    specgram = data.spectrogram(fftlen * 2, fftlength=fftlen,
                                overlap=.5)**(1 / 2.)
    plot = specgram.imshow(norm='log')
    ax = plot.gca()
    ax.set_yscale('log')
    ax.set_ylim(1e-3, 10)
    ax.set_title(title, fontsize=16)
    ax.colorbar(label=ylabel_fmt.format(yaxis_label=yaxis_label))
    plot.savefig(spectrogramplot_fname_fmt.format(channel=channel))