litmus.mocks
Some handy sets of mock data for use in testing
HM Apr 2024
mock_A = mock(season=None, lag=300)
module-attribute
Instead of a GP this mock has a clear bell-curve like hump. This works as a generous test-case of lag recovery methods
mock_B = mock(lag=256, maxtime=360 * 5, E=[0.01, 0.01], seed=2, season=180)
module-attribute
A standard oz-des like seasonal GP but with high SNR on the response LC. Good for testing failure states in the lag axis)
mock_C = mock(lag=128, maxtime=360 * 5, E=[0.01, 0.01], season=None)
module-attribute
A mock with no seasonal windowing
mock(seed: int = 0, **kwargs)
Bases: logger
Handy class for making mock data. When calling with init, args can be passed as keyword arguments
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seed
|
int
|
seed for randomization |
0
|
tau
|
float
|
Timescale of the GP to be simulated |
required |
cadence
|
float
|
Mean cadence of the signals, either both or [signal 1, signal 2]. Defaults to [7 days, 30 days]. |
required |
cadence_var
|
float
|
std of cadence of the signals, either both or [signal 1, signal 2]. Defaults to [1 day, 5 days]. |
required |
season
|
float
|
Average season length. Defaults to 180 days. |
required |
season_var
|
float
|
std of season length. Defaults to 14 days. |
required |
N
|
int
|
Number of datapoints for the underlying realisation. Defaults to 2048. |
required |
maxtime
|
float
|
Max time of the underlying simulation. Defaults to 5 years. |
required |
lag
|
float
|
Lag for signal 2. Defaults to 30 days. |
required |
E
|
float
|
Mean measurement error for the signals, either both or [signal 1, signal 2]. Defaults to 1% and 10%. |
required |
E_var
|
float
|
Std of measurement error for the signals, either both or [signal 1, signal 2]. Defaults to 0% |
required |
Source code in litmus/mocks.py
seed: int = seed
instance-attribute
lag: float = 0.0
instance-attribute
args = {}
instance-attribute
generate_true(seed: int = 0) -> (_types.ArrayN, _types.ArrayN)
Generates an underlying true DRW signal and stores in the self attribute self.lc
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seed
|
int
|
seed for random generation |
0
|
Returns:
Type | Description |
---|---|
(ArrayN, ArrayN)
|
Array tuple (T,Y), underlying curve extending to maxtime + 2 * lag |
Source code in litmus/mocks.py
generate(seed: int = 0) -> (lightcurve, lightcurve)
Generates a mock and sampled light-curve including a delayed response and stores in the self-attributes self.lc_1 and self.lc_2. Also returns as tuple (lc, lc_1, lc_2)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seed
|
int
|
seed for random generation |
0
|
Returns:
Type | Description |
---|---|
(lightcurve, lightcurve)
|
lightcurve object |
Source code in litmus/mocks.py
copy(seed: int = None, **kwargs) -> _types.Self
Returns a copy of the mock while over-writing certain params.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seed
|
int
|
int seed for random generation |
None
|
kwargs
|
kwargs to pass to the new lightcurve object, will overwrite self.kwargs in the copy |
{}
|
Returns:
Type | Description |
---|---|
Self
|
A copy of self with kwargs and seed changed accordingly |
Source code in litmus/mocks.py
swap_response(other: lightcurve) -> None
Swaps the response lightcurves between this mock and its target. Over-writes target and self
Source code in litmus/mocks.py
plot(axis: matplotlib.axes.Axes = None, true_args: dict = {}, series_args: dict = {}, show: bool = True) -> _types.Figure
Plots the lightcurves and subsamples
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
Axes
|
matplotlib axis to plot to. If none will create new |
None
|
true_args
|
dict
|
matplotlib plotting kwargs for the true underlying lightcurve |
{}
|
series_args
|
dict
|
matplotlib plotting kwargs for the observations |
{}
|
show
|
bool
|
If true will use plt.show() at the end fo the plot |
True
|
Returns:
Type | Description |
---|---|
Figure
|
Maplotlib figure |
Source code in litmus/mocks.py
corrected_plot(params: dict = {}, axis: matplotlib.axis.Axis = None, true_args: dict = {}, series_args: dict = {}, show: bool = False) -> _types.Figure
A copy of plot that offsets the displayed signals by self.lag to bring them into alignment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
Axis
|
matplotlib axis to plot to. If none will create new |
None
|
true_args
|
dict
|
matplotlib plotting kwargs for the true underlying lightcurve |
{}
|
series_args
|
dict
|
matplotlib plotting kwargs for the observations |
{}
|
show
|
bool
|
If true will use plt.show() at the end fo the plot |
False
|
Returns:
Type | Description |
---|---|
Figure
|
matplotlib figure |
Source code in litmus/mocks.py
params()
Helper utility that returns numpyro-like parameters.
Returns:
Type | Description |
---|---|
Dict of param sites for gp_simple. |
Source code in litmus/mocks.py
lcs() -> (lightcurve, lightcurve)
Utility function for returning the two observed lightcurve, e.g. for fitter.fit(*mock.lcs())
mock_cadence(maxtime, seed: int = 0, cadence: float = 7, cadence_var: float = 1, season: float = 180, season_var: float = 14, N: int = 1024)
Returns time series X values for a mock signal
Parameters:
Name | Type | Description | Default |
---|---|---|---|
maxtime
|
Length of simulation |
required | |
seed
|
int
|
Seed for randomization |
0
|
cadence
|
float
|
Average cadence of observations |
7
|
cadence_var
|
float
|
Standard deviation of the cadence |
1
|
season
|
float
|
Average length of the observation season (default 180 days) |
180
|
season_var
|
float
|
Standard deviation of the season length (default 14 days) |
14
|
N
|
int
|
Number of observations used prior to trimming. This is auto-tuned and is deprecated |
1024
|
Returns:
Type | Description |
---|---|
returns as array of sample times |
Source code in litmus/mocks.py
subsample(T: _types.ArrayN, Y: _types.ArrayN, Tsample: _types.ArrayN) -> _types.ArrayN
Linearly interpolates between X and Y and returns interped Y's at positions Xsample
Parameters:
Name | Type | Description | Default |
---|---|---|---|
T
|
ArrayN
|
Time values of time series to be interpolated |
required |
Y
|
ArrayN
|
Y values of time series to be interpolated |
required |
Tsample
|
ArrayN
|
Times to subample at |
required |
Returns:
Type | Description |
---|---|
ArrayN
|
Elements of Y interpolated to times Tsample |
Source code in litmus/mocks.py
outly(Y, q) -> _types.ArrayN
Returns a copy of Y with fraction 'q' elements replaced with unit - normally distributed outliers
gp_realization(T, err: _types.Union[float, _types.ArrayN] = 0.0, tau: float = 400.0, basekernel: tinygp.kernels.quasisep = tinygp.kernels.quasisep.Exp, seed=None) -> lightcurve
Generates a gaussian process at times T and errors err
Parameters:
Name | Type | Description | Default |
---|---|---|---|
T
|
Time of observations |
required | |
err
|
Union[float, ArrayN]
|
Measurements uncertainty at observations. Must be float or array of same length as T |
0.0
|
tau
|
float
|
Timescale of the kernel |
400.0
|
basekernel
|
quasisep
|
Kernel of the GP. Any tinyGP quasisep kernel |
Exp
|
seed
|
|
None
|
Returns:
Type | Description |
---|---|
lightcurve
|
Returns as lightcurve object |