Example 2: Directly access PeakPerformance’s functions to create a custom pipeline#
import pandas
import numpy as np
import arviz as az
from pathlib import Path
from peak_performance import pipeline as pl, models, plots
Define your time series, e.g. by giving a path to the raw data file und loading it.
path = Path(".").absolute().parent / "example" / "A1t1R1Part2_110_109.9_110.1.npy"
timeseries = np.load(path)
Decide on a model featured in PeakPerformance and create one based on the time series.
E.g. for a normally distributed model:
pmodel = models.define_model_skew(
time=timeseries[0],
intensity=timeseries[1]
)
Sample the model with an appropriate number of tuning samples and draws.
idata = pl.sampling(pmodel, tune=6000, draws=2000)
Define a path for the results plot and its name (identifier), then use e.g. the plots.plot_posterior() function to plot the posterior samples against the raw data. For other plots, check out the plots module or the ArviZ documentation.
path_result = Path(r"")
plots.plot_posterior(
identifier="test_plot",
time=timeseries[0],
intensity=timeseries[1],
path=path_result,
idata=idata,
discarded=False,
)