ACID_code_v2.MCMC

class ACID_code_v2.MCMC(x_or_data: ndarray | object, y: ndarray | None = None, yerr: ndarray | None = None, alpha: ndarray | None = None, velocities: ndarray | None = None, c_factor=None, deterministic_profile: bool = False)[source]

Initialise MCMC functions with necessary data. Called once per worker if using multiprocessing.

Parameters:
  • x_or_data (np.ndarray|object) – Wavelength array or Data object. If a Data object is provided, takes all the arguments below from there. If a Data object is provided, all other arguments are ignored.

  • y (np.ndarray, optional) – Observed flux array, required if x_or_data is a np.ndarray.

  • yerr (np.ndarray, optional) – Observed flux error array, required if x_or_data is a np.ndarray.

  • alpha (np.ndarray, optional) – Precomputed alpha matrix, required if x_or_data is a np.ndarray.

  • velocities (np.ndarray|None, optional) – Velocity grid for LSD profile, only needed when calling log-probability function, by default None.

  • c_factor (optional) – Precomputed c_factor for LSD profile calculation, by default None.

  • deterministic_profile (bool, optional) – Whether to fit the full profile (True) or use the fast model (False), by default True.

full_model(theta)[source]

Full model for mcmc - takes all inputs (profile points + continuum coefficents) to create a model spectrum.

Parameters:

theta (array-like) – Model parameters: first k_max values are profile points (z), followed by continuum polynomial coefficients and scale factor.

Returns:

Model spectrum and profile points (z).

Return type:

tuple

deterministic_model(theta)[source]

Deterministic model for mcmc - takes only continuum coefficents and scale factor to create a model spectrum, solving for the profile points (z) directly.

Parameters:

theta (array-like) – Model parameters: continuum polynomial coefficients followed by scale factor.

Returns:

Model spectrum and profile points (z).

Return type:

tuple

run_model_function(*args, **kwargs)[source]

Runs the selected model function (full or fast) with given arguments.

Returns:

Model spectrum and profile points (z).

Return type:

tuple

log_prior(z)[source]

Calculates the log prior probability of the profile points (z) and imposes the prior restrictions on the inputs - rejects if profile point is less than -0.4 or greater than 1.6.

Parameters:

z (array-like) – Profile points.

Returns:

Log prior probability.

Return type:

float

log_probability(theta)[source]

Calculates log probability depending on which model (full or fast).

Parameters:

theta (array-like) – Model parameters.

Returns:

Log probability.

Return type:

float

static get_mcmc_stopping_criterion(tau_list, step_number, min_checks, min_tau_factor, tau_rel_tol)[source]
static get_tqdm_desc(last_tolerance, last_neff, config)[source]