11import subprocess
22from pathlib import Path
3+ import pandas as pd
34
45
56def run_pyse (files , extra_args , out_dir ):
@@ -10,20 +11,7 @@ def run_pyse(files, extra_args, out_dir):
1011 test = subprocess .Popen (cli_args , stdout = subprocess .PIPE )
1112 raw_output = test .communicate ()[0 ]
1213 output = raw_output .decode ("utf8" ).split ("\n " )
13-
14- nr_sources_per_image = []
15- for line in output :
16- if "Number of detected sources" in line :
17- nr_sources = int (line .split (" = " )[- 1 ].strip ())
18- nr_sources_per_image .append (nr_sources )
19-
20- if len (nr_sources_per_image ) != len (files ):
21- raise ValueError (
22- f"Not all images finished correctly. Found { len (nr_sources_per_image )} sets of sources with { len (files )} input images. "
23- )
24-
25- return nr_sources_per_image
26-
14+ return output
2715
2816def test_pyse_export (tmpdir ):
2917 files = ["test/data/GRB120422A-120429.fits" ]
@@ -37,13 +25,12 @@ def test_pyse_export(tmpdir):
3725 "--islands" ,
3826 ]
3927 extra_args = ["--detection-thr" , "6" , "--analysis-thr" , "5" , * export_args ]
40- nr_sources_per_image = run_pyse (files , extra_args , tmpdir )
41-
42- for n in nr_sources_per_image :
43- assert n == 1
28+ output = run_pyse (files , extra_args , tmpdir )
4429
4530 # Check CSV
4631 assert Path (f"{ tmpdir } /GRB120422A-120429.csv" ).exists ()
32+ df = pd .read_csv (f"{ tmpdir } /GRB120422A-120429.csv" )
33+ assert len (df ) == 1
4734
4835 # Check skymodel
4936 assert Path (f"{ tmpdir } /GRB120422A-120429.skymodel" ).exists ()
@@ -62,3 +49,16 @@ def test_pyse_export(tmpdir):
6249
6350 # Check islands
6451 assert Path (f"{ tmpdir } /GRB120422A-120429.islands.fits" ).exists ()
52+
53+ def test_pyse_fixed_posns (tmpdir ):
54+ files = ["test/data/GRB120422A-120429.fits" ]
55+ export_args = [
56+ "--csv" ,
57+ ]
58+ extra_args = ["--detection-thr" , "6" , "--analysis-thr" , "5" , "--fixed-posns" , "[[136.896, 14.0222]]" , * export_args ]
59+ nr_sources_per_image = run_pyse (files , extra_args , tmpdir )
60+
61+ # Check CSV
62+ assert Path (f"{ tmpdir } /GRB120422A-120429.csv" ).exists ()
63+ df = pd .read_csv (f"{ tmpdir } /GRB120422A-120429.csv" )
64+ assert len (df ) == 1
0 commit comments