Tests and checks#

Functions for checking that the inference model is working correctly.

check_inference

Master function (calls each of the functions in the tests module) for checking that superposition is never violated in the posterior.

check_superposition

Check that stratigraphic superposition between all age constriants and samples is respected in the posterior.

check_detrital_ages

Check that detrital age constraints have been enforced in the posterior.

check_intrusive_ages

Check that intrusive age constraints have been enforced in the posterior.

stratmc.tests.check_detrital_ages(full_trace, sample_df, ages_df, quiet=True, **kwargs)[source]#

Check that detrital age constraints have been enforced in the posterior.

Parameters:
full_trace: arviz.InferenceData

An arviz.InferenceData object containing the full set of prior and posterior samples from get_trace() in stratmc.inference.

sample_df: pandas.DataFrame

pandas.DataFrame containing proxy data for all sections.

ages_df: pandas.DataFrame

pandas.DataFrame containing age constraints for all sections.

sections: list(str) or numpy.array(str), optional

List of sections included in the inference. Defaults to all sections in sample_df.

quiet: bool, optional

Whether to print the section name and chain/draw of each superposition violation; defaults to False.

Returns:
bad_chains: numpy.array

Array of chain indices where superposition was violated in the posterior.

stratmc.tests.check_inference(full_trace, sample_df, ages_df, quiet=True, **kwargs)[source]#

Master function (calls each of the functions in the tests module) for checking that superposition is never violated in the posterior. Returns a list of chain indices where superposition was violated; these chains can be dropped from the trace using drop_chains(). Run automatically inside of get_trace() in stratmc.inference.

Because of the likelihood penalty used to manually enforce detrital and intrusive ages in intermediate_detrital_potential() and intermediate_intrusive_potential() (called in build_model()), rare chains may have minor superposition violations when deterital/intrusive ages are present. These chains can simply be discarded. If superposition is frequently violated in a given section, or if superposition violations are severe, check that the heights for all age constraints in ages_df are correct, and that the reported ages respect superposition. The model can correct for mean ages that are out of superposition, but may fail if the age constraints do not overlap given their 2$sigma$ uncertainties.

Parameters:
full_trace: arviz.InferenceData

An arviz.InferenceData object containing the full set of prior and posterior samples from get_trace() in stratmc.inference.

sample_df: pandas.DataFrame

pandas.DataFrame containing proxy data for all sections.

ages_df: pandas.DataFrame

pandas.DataFrame containing age constraints for all sections.

sections: list(str) or numpy.array(str), optional

List of sections included in the inference. Defaults to all sections in sample_df.

quiet: bool, optional

Whether to print the type, section name, and chain/draw of each superposition violation; defaults to False.

Returns:
bad_chains: numpy.array

Array of chain indices where superposition was violated in the posterior.

stratmc.tests.check_intrusive_ages(full_trace, sample_df, ages_df, quiet=True, **kwargs)[source]#

Check that intrusive age constraints have been enforced in the posterior.

Parameters:
full_trace: arviz.InferenceData

An arviz.InferenceData object containing the full set of prior and posterior samples from get_trace() in stratmc.inference.

sample_df: pandas.DataFrame

pandas.DataFrame containing proxy data for all sections.

ages_df: pandas.DataFrame

pandas.DataFrame containing age constraints for all sections.

sections: list(str) or numpy.array(str), optional

List of sections included in the inference. Defaults to all sections in sample_df.

quiet: bool, optional

Whether to print the section name and chain/draw of each superposition violation; defaults to False.

Returns:
bad_chains: numpy.array

Array of chain indices where superposition was violated in the posterior.

stratmc.tests.check_superposition(full_trace, sample_df, ages_df, quiet=True, **kwargs)[source]#

Check that stratigraphic superposition between all age constriants and samples is respected in the posterior.

Parameters:
full_trace: arviz.InferenceData

An arviz.InferenceData object containing the full set of prior and posterior samples from get_trace() in stratmc.inference.

sample_df: pandas.DataFrame

pandas.DataFrame containing proxy data for all sections.

ages_df: pandas.DataFrame

pandas.DataFrame containing age constraints for all sections.

sections: list(str) or numpy.array(str), optional

List of sections included in the inference. Defaults to all sections in sample_df.

quiet: bool, optional

Whether to print the section name and chain/draw of each superposition violation; defaults to False.

Returns:
bad_chains: numpy.array

Array of chain indices where superposition was violated in the posterior.