From b311d8dccebee82fd1b8e158e114da2783bffbe0 Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Wed, 18 Dec 2024 14:26:38 +0100 Subject: [PATCH] prior file --- .gitignore | 3 ++- pyvela/tests/test_run_analysis.py | 29 ++++++++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 44697491..bc7f8898 100644 --- a/.gitignore +++ b/.gitignore @@ -191,4 +191,5 @@ profile.pb.gz *_results.pdf pyvela/tests/_*_out/ -pyvela_results \ No newline at end of file +pyvela_results +__prior.json \ No newline at end of file diff --git a/pyvela/tests/test_run_analysis.py b/pyvela/tests/test_run_analysis.py index 4d743dfc..14581eb7 100644 --- a/pyvela/tests/test_run_analysis.py +++ b/pyvela/tests/test_run_analysis.py @@ -8,6 +8,15 @@ from pyvela import pyvela_script from pint.models import get_model_and_toas +prior_str = """ + { + "EFAC": { + "distribution": "Uniform", + "args": [0.5, 1.5] + } + } +""" + def test_analysis_NGC6440E_emcee(): datadir = os.path.dirname(os.path.realpath(__file__)) + "/datafiles" @@ -16,19 +25,10 @@ def test_analysis_NGC6440E_emcee(): mp, tp = get_model_and_toas(parfile, timfile, planets=True) - prior_str = StringIO( - """{ - "EFAC": { - "distribution": "Uniform", - "args": [0.5, 1.5] - } - }""" - ) - spnta = SPNTA.from_pint( mp, tp, - custom_priors=prior_str, + custom_priors=StringIO(prior_str), ) nwalkers = 3 * spnta.ndim @@ -58,11 +58,18 @@ def test_script_NGC6440(): dataset = "NGC6440E" parfile, timfile = f"{datadir}/{dataset}.par", f"{datadir}/{dataset}.tim" outdir = "_NGC6440E_out" - args = f"{parfile} {timfile} -o {outdir}".split() + + prior_file = "__prior.json" + with open(prior_file, "w") as pf: + print(prior_str, file=pf) + + args = f"{parfile} {timfile} -p {prior_file} -o {outdir}".split() + pyvela_script.main(args) assert os.path.isdir(outdir) assert os.path.isfile(f"{outdir}/summary.json") + assert os.path.isfile(f"{outdir}/{prior_file}") assert os.path.isfile(f"{outdir}/param_names.txt") assert os.path.isfile(f"{outdir}/param_units.txt") assert os.path.isfile(f"{outdir}/param_scale_factors.txt")