diff --git a/tests/test_unimpeded.py b/tests/test_unimpeded.py new file mode 100644 index 0000000..d3c88fc --- /dev/null +++ b/tests/test_unimpeded.py @@ -0,0 +1,17 @@ +from unimpeded.unimpeded import unimpeded + +# These locations will be changed to Zenodo links in the future. +loc = 'local' +if loc == 'local': + location = '/Users/ongdily/Documents/Cambridge/project2/codes/' +elif loc == 'hpc': + location = '/home/dlo26/rds/rds-dirac-dp192-63QXlf5HuFo/dlo26/' + + +def test_get(): + database = unimpeded(location=location) + samples = database.get(model='klcdm', dataset='bao.sdss_dr16', method='ns') + return samples + + +samples = test_get() diff --git a/unimpeded/unimpeded.py b/unimpeded/unimpeded.py new file mode 100644 index 0000000..ca5fa38 --- /dev/null +++ b/unimpeded/unimpeded.py @@ -0,0 +1,32 @@ +"""Loading datasets.""" +from anesthetic import read_chains + + +class unimpeded: + """Loading datasets. + + **kwargs + ---------- + location : str + The location where the datasets are stored. + + """ + def __init__(self, **kwargs): + self.location = kwargs.pop('location', None) + + def get(self, model, dataset, method): + """Get the samples from the dataset. + + Parameters + ---------- + method : str + The chosen method, ns or mcmc. + model : str + The chosen model, e.g. klcdm. + dataset : str + The chosen dataset, e.g. bao.sdss_dr16. + """ + samples = read_chains( + self.location + f"{method}/{model}/{dataset}/" + f"{dataset}_polychord_raw/{dataset}") + return samples