-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_pyse.py
More file actions
64 lines (51 loc) · 1.92 KB
/
test_pyse.py
File metadata and controls
64 lines (51 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import subprocess
from pathlib import Path
import pandas as pd
def run_pyse(files, extra_args, out_dir):
cli_args = ["pyse", *files, "--config-file", "test/data/config.toml"]
cli_args.extend(extra_args)
cli_args.extend(["--output-dir", str(out_dir)])
test = subprocess.Popen(cli_args, stdout=subprocess.PIPE)
raw_output = test.communicate()[0]
output = raw_output.decode("utf8").split("\n")
return output
def test_pyse_export(tmpdir):
files = ["test/data/GRB120422A-120429.fits"]
export_args = [
"--skymodel",
"--csv",
"--regions",
"--rmsmap",
"--sigmap",
"--residuals",
"--islands",
]
extra_args = ["--detection-thr", "6", "--analysis-thr", "5", *export_args]
output = run_pyse(files, extra_args, tmpdir)
# Check CSV
assert Path(f"{tmpdir}/GRB120422A-120429.csv").exists()
df = pd.read_csv(f"{tmpdir}/GRB120422A-120429.csv")
assert len(df) == 1
# Check skymodel
assert Path(f"{tmpdir}/GRB120422A-120429.skymodel").exists()
# Check regions
assert Path(f"{tmpdir}/GRB120422A-120429.reg").exists()
# Check rmsmap
assert Path(f"{tmpdir}/GRB120422A-120429.rms.fits").exists()
# Check sigmap
assert Path(f"{tmpdir}/GRB120422A-120429.sig.fits").exists()
# Check residuals
assert Path(f"{tmpdir}/GRB120422A-120429.residuals.fits").exists()
# Check islands
assert Path(f"{tmpdir}/GRB120422A-120429.islands.fits").exists()
def test_pyse_fixed_posns(tmpdir):
files = ["test/data/GRB120422A-120429.fits"]
export_args = [
"--csv",
]
extra_args = ["--detection-thr", "6", "--analysis-thr", "5", "--fixed-posns", "[[136.896, 14.0222]]", *export_args]
nr_sources_per_image = run_pyse(files, extra_args, tmpdir)
# Check CSV
assert Path(f"{tmpdir}/GRB120422A-120429.csv").exists()
df = pd.read_csv(f"{tmpdir}/GRB120422A-120429.csv")
assert len(df) == 1