Skip to content

Commit

Permalink
prior file
Browse files Browse the repository at this point in the history
  • Loading branch information
abhisrkckl committed Dec 18, 2024
1 parent 0e3243e commit b311d8d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,5 @@ profile.pb.gz
*_results.pdf

pyvela/tests/_*_out/
pyvela_results
pyvela_results
__prior.json
29 changes: 18 additions & 11 deletions pyvela/tests/test_run_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit b311d8d

Please sign in to comment.