Chain¶
The Chain class object allows for easy interaction with a Commander chainfile.
- class cosmoglobe.h5.chain.Chain(path, burn_in=None)[source]¶
An interface for Cosmoglobe chainfiles.
This class aims to provide a convenient interface for working with Cosmoglobe chain files.
- __init__(path, burn_in=None)[source]¶
Validate and initialize the Chain object.
- Parameters
path (str | Path) – Path to the chainfile.
burn_in (Optional[int]) – Burn in sample. All samples prior to (and including) the burn in sample is discarded.
- combine(other_chain, group_list, new_name=None)[source]¶
Creates a new chainfile that combines specific groups from two chains.
- Return type
None
- property components: list[str]¶
List of the sky components in the chain.
- copy(samples=- 1, new_name=None)[source]¶
Creates a copy of the chain with a single or multiple samples.
- Return type
None
- get(key, *, samples=None, unpack=True)[source]¶
Returns the value of an key for all samples.
- Parameters
key (str) – The path to an item that has been sampled in the chain, e.g ‘dust/amp_alm’.
samples (Optional[range | int | Sequence[int]]) – An int or a range of samples for which to return the value. If None, all samples in the chain are used.
unpack (bool) – If True, alms are unpacked from Commander format to healpy format. Default is True
- Returns
The value of the key for each samples.
- Return type
values
- load(key, *, samples=None)[source]¶
Returns a generator to be used in a for loop.
NOTE to devs: The unpack_alms decorator wont work on this function due to it not processing the returned data until it is iterated over.
- Parameters
key (str) – The path to an item that has been sampled in the chain, e.g ‘dust/amp_alm’.
samples (Optional[range | int | Sequence[int]]) – An int or a range of samples to average over. If None, all samples in the chain are used.
- Return type
A generator that can be looped over to yield each sampled value.
- mean(key, *, samples=None, unpack=True)[source]¶
Returns the mean of an key over all samples.
- Parameters
key (str) – The path to an item that has been sampled in the chain, e.g ‘dust/amp_alm’.
samples (Optional[range | int | Sequence[int]]) – An int or a range of samples to average over. If None, all samples in the chain are used.
unpack (bool) – If True, alms are unpacked from Commander format to healpy format. Default is True
- Returns
The averaged value of the key over all samples.
- Return type
value
- property nsamples: int¶
Number of samples in the chain.
- Return type
int
- property parameters: dict[str, dict[str, Any]]¶
Dictionary of the parameters in the parameter group in the chain.
- property path: pathlib.Path¶
Path to the chainfile.
- Return type
Path
- property samples: list[str]¶
List of all samples in the chain.
- stddev(key, *, alm2map=False, samples=None)[source]¶
Returns the stddev of an key over all samples.
- Parameters
key (str) – The path to an item that has been sampled in the chain, e.g ‘dust/amp_alm’.
samples (Optional[range | int | Sequence[int]]) – An int or a range of samples to average over. If None, all samples in the chain are used.
- Returns
The averaged value of the key over all samples.
- Return type
value
- property tree¶
Prints group and dataset structure of the chainfile.
- property version: cosmoglobe.h5.ChainVersion¶
Chain version.
- Return type
ChainVersion