gwpy icon indicating copy to clipboard operation
gwpy copied to clipboard

TimeSeries.demodulate with exp=True does not produce useful output

Open vbaws opened this issue 2 years ago • 0 comments

I have been trying to replicate the functionality of mixing two signals and use the beating products.

the following code almost does what I need

gwpyTimeSeries.demodulate(mixingFrequency,exp=True, stride=1/gwpyTimeSeries.sample_rate.decompose().value)

The problem (apart from being obscenely slow) is that this leaves the gwpyTimeSeries.data as complex, which breaks down the line, (for example if you want to look at an asd)

Below is a snippet of the lengths I need to go to to get a usable mixer out of this function:

def mixer(gwpyTimeSeries,mixingFrequency):
    demod = gwpyTimeSeries.demodulate(mixingFrequency,exp=True, stride=1/gwpyTimeSeries.sample_rate.decompose().value)
    data = np.array(demod.data, dtype=np.complex128)
    outData = np.zeros(len(data))
    for i in range(len(data)):
        outData[i] = np.sign(data[i]) * np.abs(data[i])
    outputObject = TimeSeries(      outData,
                                    channel     = gwpyTimeSeries.name,
                                    sample_rate = gwpyTimeSeries.sample_rate,
                                    t0          = gwpyTimeSeries.t0,
                                    )
    return outputObject

vbaws avatar Sep 15 '23 18:09 vbaws