bedroc.isotope_anomalies package
Submodules
bedroc.isotope_anomalies.core module
Helper functions and classes for nucleosynthetic isotope anomalies
- bedroc.isotope_anomalies.core.DATA: Traversable = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/bedroc/checkouts/latest/bedroc/isotope_anomalies/NC_CC_AllData.csv')
Isotope anomalies data file
- class bedroc.isotope_anomalies.core.GroupData(name: str, datapath: Traversable | Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/bedroc/checkouts/latest/bedroc/isotope_anomalies/NC_CC_AllData.csv'), chondrites: Iterable[str] | None = None, elements: Iterable[str] | None = None, label_offsets: dict[str, tuple[float, float]] | None = None, eigvec_label_offsets: dict[str, tuple[float, float]] | None = None)
Bases:
objectGrouped isotope data
- Parameters:
name – Name of the group
datapath – Path to the data file. Defaults to
DATA.chondrites – Chondrites to select. Defaults to
Noneto select all.elements – Elements to select. Defaults to
Noneto select all.label_offsets – Offsets for plotting the feature (isotope) labels. Defaults to
None.eigvec_label_offsets – Offsets for plotting the eigenvectors. Defaults to
None.
- name: str
- datapath: Traversable | Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/bedroc/checkouts/latest/bedroc/isotope_anomalies/NC_CC_AllData.csv')
- chondrites: Iterable[str] | None = None
- elements: Iterable[str] | None = None
- label_offsets: dict[str, tuple[float, float]] | None = None
- eigvec_label_offsets: dict[str, tuple[float, float]] | None = None
- data: DataContainer
- property idata: DataTree
Inference data
- to_excel(directory: Path = PosixPath('.')) Path
Exports the inference data to Excel.
- Parameters:
directory – Directory to export to. Defaults to the current directory.
- Returns:
Excel file path
- to_pickle(directory: Path = PosixPath('.')) Path
Exports the inference data to a pickle file.
- Parameters:
directory – Directory to export to. Defaults to the current directory.
- Returns:
Pickle file path
- run_bayesian_pca(random_seed: int | None = None) None
Runs the Bayesian PCA
- Parameters:
random_seed – Optional random seed
- plot_pca(ax: Axes, plot_legend: bool = True, include_title: bool = True, skip: int = 10, plot_eigenvectors: bool = True) Axes
Plots the Bayesian and deterministic PCA.
- Parameters:
ax – Axis
plot_legend – Plots the legend. Defaults to
True.include_title – Adds a title. Defaults to
True.skip – Take every skip-th sample. Defaults to
10.plot_eigenvectors – Plot and label the eigenvectors. Defaults to
True.
- Returns:
Axes
- plot_predicted_observations(latent_factor_means: ndarray[tuple[Any, ...], dtype[float64]], latent_factor_stds: ndarray[tuple[Any, ...], dtype[float64]], data_names: list[str], reconstruction_only: bool = False, random_seed: int | None = None) tuple[list[Figure], DataFrame]
Plots predicted observations from latent factors, with optional noise.
This function supports two related but distinct visualizations:
Noise-free reconstruction (
reconstruction_only=True)Uses the latent variables and loadings
alphato compute the mean structure of the predicted data:mu = Z @ alpha.Corresponds to classical PCA-style backprojection, but propagates uncertainty from the latent factors.
Use this mode to assess how well the inferred latent structure explains the underlying signal in the observations.
Posterior predictive simulation (
reconstruction_only=False)Simulates noisy observations from the generative model’s likelihood (Student-T) for new data points.
Accounts for uncertainty in both the latent factors and the observation noise.
Since true per-data noise is unknown for new points, the feature-level noise is estimated from the training data as the mean per feature.
Draws Student-T random samples consistent with the model’s posterior for the degrees of freedom (
nu).
- Parameters:
latent_factor_means – Means of the latent factors (n_data, n_components)
latent_factor_stds – Standard deviations of the latent factors (n_data, n_components)
data_names – Data names
reconstruction_only –
If
True, plot only the latent-space reconstructionIf
False(default), simulate and plot noisy posterior-predictive observations
random_seed – Seed for random number generation to enable reproducibility. Defaults to
None.
- Returns:
Figures visualizing the predicted observations
Summary statistics (mean, std, quantiles, etc.) of the predicted observations across posterior samples
- Return type:
tuple
- plot_reconstructed_observations(reconstruction_only: bool = False, random_seed: int | None = None) tuple[list[Figure], DataFrame]
Plots reconstructions of the observed isotope anomalies.
This function supports two related but distinct visualizations:
Noise-free reconstruction (
reconstruction_only=True)Uses the posterior samples of the latent variables
Zand loadingsalphato compute the mean structure of the data:mu = Z @ alpha.Corresponds to classical PCA-style backprojection, but with full Bayesian uncertainty.
Use this mode to assess how well the inferred latent structure explains the underlying signal in the observations.
Posterior predictive simulation (
reconstruction_only=False)Draws noisy observations from the models’ likelihood (Student-t).
This evaluates how well the full generative model predicts the measured data, including observational noise.
Is the most direct and appropriate comparison to the actual observations (posterior predictive check).
- Parameters:
reconstruction_only –
If
True, plot only the latent-space reconstructionIf
False(default), simulate and plot noisy posterior-predictive observations
random_seed – Random seed for posterior predictive sampling. Defaults to
None.
- Returns:
Figures visualizing the reconstructed observations
Summary statistics (mean, std, quantiles, etc.) of the reconstructed observations across posterior samples
- Return type:
tuple
- _get_summary_dataframe(samples: ndarray[tuple[Any, ...], dtype[float64]], data_names: list[str]) DataFrame
Gets a dataframe of summary statistics for data
- Parameters:
samples – Data samples (n_data, n_features, n_samples)
data_names – Data names (n_data,)
- Returns:
Dataframe of summary statistics
- _plot_reconstruction(title_prefix: str, samples: ndarray[tuple[Any, ...], dtype[float64]], latent_factor_means: ndarray[tuple[Any, ...], dtype[float64]], data_names: list[str], observed: ndarray[tuple[Any, ...], dtype[float64]] | None = None) list[Figure]
Helper to plot the reconstructed or predicted observations
- Parameters:
title_prefix – Prefix of the title
samples – Data samples (n_data, n_features, n_samples)
latent_factor_means – Means of the latent factors
data_names – Data names
observed – Observed data to also plot, if not
None. Defaults toNone.
- Returns:
Figures visualizing the reconstruction
- bedroc.isotope_anomalies.core.is_vesta_group(chondrite_name: str) bool
Checks if a chondrite is part of the Vesta Group.
- Parameters:
chondrite_name – Chondrite name
- Returns:
Trueif part of the Vesta Group, otherwiseFalse
- bedroc.isotope_anomalies.core.get_color(chondrite_name: str, reservoir_name: str) tuple[str, str]
Gets the color and the light color associated with the chondrite and/or reservoir.
- Parameters:
chondrite_name – Chondrite name
reservoir_name – Reservoir name
- Returns:
Color
Light color
- Return type:
tuple
Module contents
Nucleosynthetic isotope anomalies
Citation:
Sossi, Paolo A., and Bower, Dan J. (2026), Homogeneous accretion of the Earth in the inner Solar System, Nature Astronomy.