Skip to content

Commit

Permalink
Merge pull request #765 from ratt-ru/sofia_update
Browse files Browse the repository at this point in the history
Updating to the latest sofia
  • Loading branch information
dane-kleiner authored Oct 3, 2022
2 parents f738c4a + afbace2 commit 36da8af
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
2 changes: 1 addition & 1 deletion stimela/cargo/base/sofia2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN pip install -U setuptools \
astro-tigger-lsm
RUN git clone https://github.com/SoFiA-Admin/SoFiA-2.git
RUN cd /SoFiA-2 && git fetch && git fetch --tags
RUN cd /SoFiA-2 && git checkout v2.4.0
RUN cd /SoFiA-2 && git checkout v2.5.0
RUN cd /SoFiA-2 && ./compile.sh -fopenmp
RUN cd /SoFiA-2 && ln sofia /usr/bin/sofia

27 changes: 23 additions & 4 deletions stimela/cargo/cab/sofia2/parameters.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"task": "sofia2",
"base": "stimela/sofia2",
"tag": "1.7.4",
"version" : "2.4.0",
"tag": "1.7.6",
"version" : "2.5.0",
"description": "This is version 2 of the HI Source Finding Application (SoFiA), a source finding pipeline originally designed to detect and characterise galaxies in 3D extragalctic HI data cubes. SoFiA 2 is a reimplementation of the original SoFiA pipeline in the C programming language and provides most of the functionality of SoFiA 1.x",
"prefix": "--",
"binary": "sofia",
Expand Down Expand Up @@ -449,7 +449,13 @@
"dtype": "int",
"default": 1,
"name": "linker.radiusZ",
},
},
{
"info": "If set to true, SoFiA will try to automatically determine the optimal reliability kernel scale factor by iteratively increasing the kernel size until the absolute value of the median of the Skellam distribution decreases below reliability.tolerance. If the algorithm fails to converge after reliability.iterations steps, then the default value of reliability.scaleKernel will be used instead.",
"dtype": "bool",
"default": false,
"name": "reliability.autoKernel",
},
{
"info": "Path to a file containing positions on the sky to be excluded from the reliability analysis. The file must contain two columns separated by a space, tabulator or comma that specify the longitude and latitude of the position to be excluded in the native WCS coordinates and units of the input FITS file. Negative detections that contain any of those positions within their bounding box will be excluded from the reliability analysis, although they will still show up in the reliability plot.",
"dtype": "file",
Expand All @@ -469,6 +475,12 @@
"default": false,
"name": "reliability.enable",
},
{
"info": "Maximum number of iterations for the reliability kernel auto-scaling algorithm to converge. If convergence is not achieved, then reliability.scaleKernel will instead be applied.",
"dtype": "int",
"default": 30,
"name": "reliability.iterations",
},
{
"info": "Minimum total number of spatial and spectral pixels within the source mask for detections to be considered reliable. The reliability of any detection with fewer pixels will be set to zero by default.",
"dtype": "int",
Expand Down Expand Up @@ -519,7 +531,13 @@
"dtype": "float",
"default": 0.9,
"name": "reliability.threshold",
},
},
{
"info": "Convergence tolerance for the reliability kernel auto-scaling algorithm. Convergence is achieved when the absolute value of the median of the Skellam distribution drops below this tolerance.",
"dtype": "float",
"default": 0.05,
"name": "reliability.tolerance",
},
{
"info": "Set to true to enable source mask dilation whereby the mask of each source will be grown outwards until the resulting increase in integrated flux drops below a given threshold or the maximum number of iterations is reached.",
"dtype": "bool",
Expand Down Expand Up @@ -673,3 +691,4 @@
]
}


30 changes: 13 additions & 17 deletions stimela/cargo/cab/sofia2/src/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from astLib.astWCS import WCS
from astropy.io.votable import parse_single_table
from Tigger.Models import SkyModel, ModelClasses
from stimela import utils


CONFIG = os.environ["CONFIG"]
Expand Down Expand Up @@ -129,21 +128,6 @@ def tigger_src(src, idx):
table = parse_single_table('{0}_cat.xml'.format(prefix))
data = table.array

#with open('{0}_cat.txt'.format(prefix)) as stdr:
# # Header
# stdr.readline()
# # Column names
# names = stdr.readline().split("#")[9].strip().split()
# print(names)
# # Units
# stdr.readline()
# # Column numbers
# stdr.readline()
# sys.stdout.write(" ".join(names))
# data = numpy.genfromtxt(stdr,
# names=names + ["col"])
# print(data)

for i, src in enumerate(data):
model.sources.append(tigger_src(src, i))

Expand All @@ -153,4 +137,16 @@ def tigger_src(src, idx):

model.save(tname_lsm)
# Rename using CORPAT
utils.xrun("tigger-convert", [tname_lsm, "--rename -f"])
_runc = "tigger-convert %s --rename -f" % tname_lsm
try:
subprocess.check_call(shlex.split(_runc))
finally:
for item in junk:
for dest in [OUTPUT, MSDIR]: # these are the only writable volumes in the container
items = glob.glob("{dest}/{item}".format(**locals()))
for f in items:
if os.path.isfile(f):
os.remove(f)
elif os.path.isdir(f):
shutil.rmtree(f)

0 comments on commit 36da8af

Please sign in to comment.