ml4gw.transforms.heterodyne

Classes

Heterodyne(sample_rate, kernel_length, ...)

Heterodyne transform for time-series data using a single chirp mass or a grid of chirp masses.

class ml4gw.transforms.heterodyne.Heterodyne(sample_rate, kernel_length, chirp_mass, return_type)

Bases: Module

Heterodyne transform for time-series data using a single chirp mass or a grid of chirp masses.

This module applies a frequency-domain heterodyne transformation to an input timeseries by multiplying its Fourier transform with a bank of phase factors corresponding to different chirp masses. The result is a set of heterodyned signals.

The heterodyning phase is defined as the leading-order (0PN) term in the post-Newtonian expansion of the inspiral phase:

\[e^{\frac{3i}{128} (\pi \mathcal{M}_c f)^{-5/3}}\]

where \(\mathcal{M}_c\) is the chirp mass and \(f\) is the frequency.

Note

This uses only the 0PN phase term. Higher-order PN corrections are not included in this heterodyne transform.

Parameters:
  • sample_rate (float) -- Sampling rate (Hz) of the input timeseries.

  • kernel_length (float) -- Duration (seconds) of the input timeseries segment.

  • chirp_mass (torch.Tensor) -- 1D tensor of chirp mass(es) in units of solar masses. The shape should be (M,) where M is the number of masses.

  • return_type (Literal["time", "freq", "both"]) --

    Specifies whether to return -
    • "time": heterodyned time-domain signals

    • "freq": heterodyned frequency-domain signals

    • "both": tuple of (time, frequency) representations

Shape:
  • Input: (B, C, T) where
    • B = batch size

    • C = number of channels (e.g., detectors for GW strain)

    • T = number of time samples (= sample_rate * kernel_length)

  • Frequency-domain intermediate:

    (B, C, F) where F = T // 2 + 1

  • After heterodyning:

    (B, C, M, F) where M = number of chirp masses

  • Output:
    • If return_type="time"(B, C, M, T)

    • If return_type="freq"(B, C, M, F)

    • If return_type="both" → tuple: (B, C, M, T), (B, C, M, F)

Returns:

Heterodyned signals in the requested domain(s).

Return type:

torch.Tensor or tuple[torch.Tensor, torch.Tensor]

Parameters:
  • sample_rate (float)

  • kernel_length (float)

  • chirp_mass (Tensor)

  • return_type (Literal['time', 'freq', 'both'])

forward(X)

Apply the heterodyne transformation to the input timeseries.

Parameters:

X (torch.Tensor) -- Input tensor of shape (B, C, T).

Returns:

  • If return_type="time"(B, C, M, T)

  • If return_type="freq"(B, C, M, F)

  • If return_type="both"(time, freq)

Return type:

torch.Tensor or tuple[torch.Tensor, torch.Tensor]