Skip to content

litmus.GP_working

gp_working.py

Contains all interfacing with the tinyGP gaussian process modelling package

Multi-band kernel adapated from: "Gaussian Process regression for astronomical time-series" Aigrain & Foreman-Mackey, 2022: https://arxiv.org/abs/2209.08940

HM 2024

Multiband

Bases: Wrapper

Multi-band GP kernel that knows how to scale GP to output amplitudes

amplitudes: jnp.ndarray instance-attribute
coord_to_sortable(Y) -> float

Extracts the time value from the (time,band) coordinate so the GP can interpret the ordering of points in multiple bands

Source code in litmus/gp_working.py
51
52
53
54
55
56
57
def coord_to_sortable(self, Y) -> float:
    """
    Extracts the time value from the (time,band) coordinate so the GP can interpret the ordering of points
    in multiple bands
    """
    t, band = Y
    return t
observation_model(Y) -> float

Scales the prediction for each band by their respective band amplitude in the predicted model

Source code in litmus/gp_working.py
59
60
61
62
63
64
def observation_model(self, Y) -> float:
    """
    Scales the prediction for each band by their respective band amplitude in the predicted model
    """
    t, band = Y
    return self.amplitudes[band] * self.kernel.observation_model(t)

mean_func(means, Y) -> _types.ArrayN

DEPRECATED - means are subtracted in the model now Utitlity function to take array of constants and return as gp-friendly functions

Source code in litmus/gp_working.py
35
36
37
38
39
40
41
def mean_func(means, Y) -> _types.ArrayN:
    """
    DEPRECATED - means are subtracted in the model now
    Utitlity function to take array of constants and return as gp-friendly functions
    """
    t, band = Y
    return (means[band])

build_gp(T: _types.ArrayN, Y: _types.ArrayN, diag: _types.ArrayNxN, bands: _types.ArrayN, tau: float, amps: tuple[float, float], means: tuple[float, float], basekernel: tinygp.kernels.quasisep.Quasisep = tinygp.kernels.quasisep.Exp) -> GaussianProcess

Builds a tinygp two-band kernel for predictions

Parameters:

Name Type Description Default
T ArrayN

Time values for the GP

required
Y ArrayN

Y values for the GP (No effect)

required
diag ArrayNxN

Variance matrix (square uncertainties) of the GP

required
bands ArrayN

The bands that the different entries in the time series correspond to

required
tau float

Timescale of the GP

required
amps tuple[float, float]

Amplitudes of the GP

required
means tuple[float, float]
required
basekernel Quasisep
Exp

Returns:

Type Description
GaussianProcess

The tinyGP gaussian process object

Source code in litmus/gp_working.py
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def build_gp(T: _types.ArrayN, Y: _types.ArrayN, diag: _types.ArrayNxN, bands: _types.ArrayN, tau: float,
             amps: tuple[float, float], means: tuple[float, float],
             basekernel: tinygp.kernels.quasisep.Quasisep = tinygp.kernels.quasisep.Exp) -> GaussianProcess:
    """
    Builds a tinygp two-band kernel for predictions

    :parameter T: Time values for the GP
    :parameter Y: Y values for the GP (No effect)
    :parameter diag: Variance matrix (square uncertainties) of the GP
    :parameter bands: The bands that the different entries in the time series correspond to
    :parameter tau: Timescale of the GP
    :parameter amps: Amplitudes of the GP
    :parameter means:
    :parameter basekernel:

    :return: The tinyGP gaussian process object
    """

    # Create GP kernel with Multiband
    multi_kernel = Multiband(
        kernel=basekernel(scale=tau),
        amplitudes=amps,
    )

    # Mean functions for offsetting signals
    meanf = lambda X: mean_func(means, X)

    # Construct GP object and return
    gp = GaussianProcess(
        multi_kernel,
        (T, bands),
        diag=diag,
        mean=meanf
    )
    return (gp)