gcfit.core.Observations#

class gcfit.core.Observations(cluster, *, standardize_name=True, restrict_to=None)#

Read-only interface for all observational cluster data.

The main interface for reading and interacting with (reading) all observational data for the specified globular cluster.

Defined based on a given cluster datafile, handles creation and access to all contained `Dataset`s, as well as the setup and arguments for all relevant likelihoods.

The relevant cluster data files will be found using the gcfit.util.get_cluster_path function, and can likewise be retricted to “core” or “local” files. The data file used must be considered valid (i.e. pass all tests within gcfit.utils.data.ClusterFile.test).

Parameters:
clusterstr

Name of the globular cluster. Will be used to retrieve the relevant cluster data file.

standardize_namebool, optional

Whether to “standardize” the given cluster name to match the exact format of “core” cluster files or not. Searches against core clusters will always be standardized, no matter this parameter. Defaults to True.

restrict_to{None, ‘local’, ‘core’}

Where to search for the cluster data file, see gcfit.util.get_cluster_path for more information.

Attributes:
valid_likelihoods

List of likelihoods valid for the contained datasets.

datasets

Dictionary of all `Dataset`s contained in this class

mdatadict

Dictionary of all “cluster-level” metadata.

See also

gcfit.util.get_cluster_path

Locating of data file based on cluster name.

gcfit.util.data.ClusterFile

Handling of data file creation and editing.

Methods

__init__(cluster, *[, standardize_name, ...])

filter_datasets(pattern[, valid_only])

Return a subset of Observations.datasets based on given pattern.

filter_likelihoods(patterns[, exclude, ...])

Return subset of valid_likelihoods based on patterns.

get_sources([fmt])

Return a dict of formatted citations for each contained dataset

Attributes

datasets

Dictionary of all `Dataset`s contained in this class

valid_likelihoods

List of likelihoods valid for the contained datasets. Returns a list of lists, with each list representing a different likelihood function, of the form of [dataset name, likelihood function, *function params].

property datasets#

Dictionary of all `Dataset`s contained in this class

filter_datasets(pattern, valid_only=False)#

Return a subset of Observations.datasets based on given pattern.

Parameters:
patternstr

A pattern string to filter all dataset names on, using fnmatch.

valid_onlybool, optional

Whether to filter on all datasets or only those considered “valid” by Observations.valid_likelihoods.

Returns:
dict

Dictionary of name:dataset pairs for all datasets which match the given pattern.

filter_likelihoods(patterns, exclude=False, keys_only=False)#

Return subset of valid_likelihoods based on patterns.

Filters the results of Observations.valid_likelihoods based on a list of patterns. The pattern matching (for each pattern in the patterns list) is applied to both the dataset name and the likelihood function name (func.__name__).

Parameters:
patternslist of str

List of pattern strings to filter all likelihoods on using fnmatch.

excludebool, optional

Whether to return all likelihoods which match the filters (False, default) or to exclude them, and return all others (True).

keys_onlybool, optional

Whether to return only the filtered dataset names (True) or the entire likelihood format as given by Observations.valid_likelihoods (False, default). Filtering will still be done on both dataset and likelihood names, no matter this parameter.

Returns:
list

A list of lists, in the same format as valid_likelihoods, which has been filtered.

get_sources(fmt='bibtex')#

Return a dict of formatted citations for each contained dataset

property valid_likelihoods#

List of likelihoods valid for the contained datasets. Returns a list of lists, with each list representing a different likelihood function, of the form of [dataset name, likelihood function, *function params].