Esempio n. 1
0
 def non_herm_hoff(self):
     """
     Returns the 2-sided h(f) associated with the real-valued h(t) seen in a real instrument.
     Translates epoch as needed.
     Based on 'non_herm_hoff' in lalsimutils.py
     """
     htR = self.real_hoft(
     )  # Generate real-valued TD waveform, including detector response
     if self.P.deltaF == None:  # h(t) was not zero-padded, so do it now
         TDlen = nextPow2(htR.data.length)
         htR = lal.ResizeREAL8TimeSeries(htR, 0, TDlen)
     else:  # Check zero-padding was done to expected length
         TDlen = int(1. / self.P.deltaF * 1. / self.P.deltaT)
         assert TDlen == htR.data.length
     fwdplan = lal.CreateForwardCOMPLEX16FFTPlan(htR.data.length, 0)
     htC = lal.CreateCOMPLEX16TimeSeries("hoft", htR.epoch, htR.f0,
                                         htR.deltaT, htR.sampleUnits,
                                         htR.data.length)
     # copy h(t) into a COMPLEX16 array which happens to be purely real
     htC.data.data[:htR.data.length] = htR.data.data
     #        for i in range(htR.data.length):
     #            htC.data.data[i] = htR.data.data[i]
     hf = lal.CreateCOMPLEX16FrequencySeries(
         "Template h(f)", htR.epoch, htR.f0,
         1. / htR.deltaT / htR.data.length, lalsimutils.lsu_HertzUnit,
         htR.data.length)
     lal.COMPLEX16TimeFreqFFT(hf, htC, fwdplan)
     return hf
def DataFourier(
    ht
):  # Complex fft wrapper (COMPLEX16Time ->COMPLEX16Freq. No error checking or padding!
    TDlen = ht.data.length
    fwdplan = lal.CreateForwardCOMPLEX16FFTPlan(TDlen, 0)
    hf = lal.CreateCOMPLEX16FrequencySeries("Template h(f)", ht.epoch, ht.f0,
                                            1. / ht.deltaT / TDlen,
                                            lal.lalHertzUnit, TDlen)
    lal.COMPLEX16TimeFreqFFT(hf, ht, fwdplan)
    # assume memory freed by swig python
    return hf
Esempio n. 3
0
 def complex_hoff(self, force_T=False):
     htC = self.complex_hoft(force_T=force_T, deltaT=self.P.deltaT)
     TDlen = int(1. / self.P.deltaF * 1. / self.P.deltaT)
     assert TDlen == htC.data.length
     hf = lal.CreateCOMPLEX16FrequencySeries(
         "Template h(f)", htC.epoch, htC.f0,
         1. / htC.deltaT / htC.data.length, lalsimutils.lsu_HertzUnit,
         htC.data.length)
     fwdplan = lal.CreateForwardCOMPLEX16FFTPlan(htC.data.length, 0)
     lal.COMPLEX16TimeFreqFFT(hf, htC, fwdplan)
     return hf
Esempio n. 4
0
def create_FIR_whitener_kernel(length, duration, sample_rate, psd):
    assert psd
    #
    # Add another COMPLEX16TimeSeries and COMPLEX16FrequencySeries for kernel's FFT (Leo)
    #

    # Add another FFT plan for kernel FFT (Leo)
    fwdplan_kernel = lal.CreateForwardCOMPLEX16FFTPlan(length, 1)
    kernel_tseries = lal.CreateCOMPLEX16TimeSeries(
        name="timeseries of whitening kernel",
        epoch=LIGOTimeGPS(0.),
        f0=0.,
        deltaT=1.0 / sample_rate,
        length=length,
        sampleUnits=lal.Unit("strain"))
    kernel_fseries = lal.CreateCOMPLEX16FrequencySeries(
        name="freqseries of whitening kernel",
        epoch=LIGOTimeGPS(0),
        f0=0.0,
        deltaF=1.0 / duration,
        length=length,
        sampleUnits=lal.Unit("strain s"))

    #
    # Obtain a kernel of zero-latency whitening filter and
    # adjust its length (Leo)
    #

    psd_fir_kernel = reference_psd.PSDFirKernel()
    (kernel, latency,
     fir_rate) = psd_fir_kernel.psd_to_linear_phase_whitening_fir_kernel(
         psd, nyquist=sample_rate / 2.0)
    (
        kernel, theta
    ) = psd_fir_kernel.linear_phase_fir_kernel_to_minimum_phase_whitening_fir_kernel(
        kernel, fir_rate)
    kernel = kernel[-1::-1]
    # FIXME this is off by one sample, but shouldn't be. Look at the miminum phase function
    # assert len(kernel) == length
    if len(kernel) < length:
        kernel = numpy.append(kernel, numpy.zeros(length - len(kernel)))
    else:
        kernel = kernel[:length]

    kernel_tseries.data.data = kernel

    #
    # FFT of the kernel
    #

    lal.COMPLEX16TimeFreqFFT(kernel_fseries, kernel_tseries,
                             fwdplan_kernel)  #FIXME

    return kernel_fseries
Esempio n. 5
0
c8inv = lal.CreateCOMPLEX8Vector(len(c8in))
c8inv.data = c8in
c8outv = lal.CreateCOMPLEX8Vector(len(c8in))
plan = lal.CreateForwardCOMPLEX8FFTPlan(len(c8in), 0)
lal.COMPLEX8VectorFFT(c8outv, c8inv, plan)
c8out = numpy.zeros(numpy.shape(c8outv.data), dtype=c8outv.data.dtype)
lal.COMPLEX8VectorFFT(c8out, c8in, plan)
assert ((c8out == c8outv.data).all())
del c8inv
del c8outv
del plan
lal.CheckMemoryLeaks()
c16inv = lal.CreateCOMPLEX16Vector(len(c16in))
c16inv.data = c16in
c16outv = lal.CreateCOMPLEX16Vector(len(c16in))
plan = lal.CreateForwardCOMPLEX16FFTPlan(len(c16in), 0)
lal.COMPLEX16VectorFFT(c16outv, c16inv, plan)
c16out = numpy.zeros(numpy.shape(c16outv.data), dtype=c16outv.data.dtype)
lal.COMPLEX16VectorFFT(c16out, c16in, plan)
assert ((c16out == c16outv.data).all())
del c16inv
del c16outv
del plan
lal.CheckMemoryLeaks()
r4inv = lal.CreateREAL4Vector(len(r4in))
r4inv.data = r4in
c8outv = lal.CreateCOMPLEX8Vector(len(r4in) // 2 + 1)
plan = lal.CreateForwardREAL4FFTPlan(len(r4in), 0)
lal.REAL4ForwardFFT(c8outv, r4inv, plan)
c8out = numpy.zeros(numpy.shape(c8outv.data), dtype=c8outv.data.dtype)
lal.REAL4ForwardFFT(c8out, r4in, plan)