Skip to content

Commit

Permalink
Merge pull request #432 from SpheMakh/montage_mosaic
Browse files Browse the repository at this point in the history
Montage mosaic
  • Loading branch information
SpheMakh authored Jul 23, 2019
2 parents 2778114 + 71db833 commit 9bb1078
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
5 changes: 5 additions & 0 deletions stimela/cargo/cab/montage_mosaic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM stimela/montage:1.1.3
MAINTAINER <[email protected]>
ADD src /scratch/code
ENV LOGFILE ${OUTPUT}/logfile.txt
CMD /scratch/code/run.sh
47 changes: 47 additions & 0 deletions stimela/cargo/cab/montage_mosaic/parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"task": "montage_mosaic",
"base": "stimela/montage",
"tag": "1.1.3",
"description": "A package that allows continuum (2D) images and spectral (3D) images to be mosaicked together, using montage commands.",
"prefix": "--",
"binary": "montage-mosaic",
"msdir": false,
"parameters": [
{
"info": "State 'continuum' or 'spectral' as the type of mosaic to be made.",
"name": "mosaic-type",
"default": null,
"dtype": "str",
"required": true
},
{
"info": "Include this argument if you wish to use montage for regridding the images and beams (if they have not already been created).",
"name": "domontage",
"default": null,
"dtype": "bool",
"required": false
},
{
"info": "The cutoff in the primary beam to use (assuming a Gaussian at the moment). E.g. The default of 0.1 means going down to the 10 percent level for each pointing.",
"name": "cutoff",
"default": 0.1,
"dtype": "float",
"required": false
},
{
"info": "The prefix to be used for output files.",
"name": "name",
"default": "mymosaic",
"dtype": "str",
"required": false
},
{
"info": "The filenames of each target/pointing image to be mosaicked. A suffix of 'image.fits' is expected, and this is replaced by 'pb.fits' in order to locate the corresponding beams (which are also required as input).",
"name": "target-images",
"io": "input",
"default": null,
"dtype": "list:file",
"required": true
}
]
}
42 changes: 42 additions & 0 deletions stimela/cargo/cab/montage_mosaic/src/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import sys

sys.path.append('/scratch/stimela')
import utils


CONFIG = os.environ["CONFIG"]
INPUT = os.environ["INPUT"]
MSDIR = os.environ["MSDIR"]
OUTPUT = os.environ["OUTPUT"]

cab = utils.readJson(CONFIG)
args = []
targets = None
for param in cab['parameters']:
name = param['name']
value = param['value']

if value is None:
continue
elif value is False:
continue
elif value is True:
value = ''
elif name == 'target-images':
targets = value
continue

args += ['{0}{1} {2}'.format(cab['prefix'], name, value)]

indir = os.path.dirname(targets[0])
target_names = map(os.path.basename, targets)
target_images = "--target-images " + " --target-images ".join(target_names)

args += ["--input {0:s} {1:s} --output {2:s}".format(indir, target_images,
OUTPUT)]

if target_images:
utils.xrun(cab['binary'], args)
else:
raise RuntimeError('Filenames of the images to be mosaicked have not been specified.')
3 changes: 3 additions & 0 deletions stimela/cargo/cab/montage_mosaic/src/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
python /scratch/code/run.py 2>&1 | tee -a $LOGFILE
(exit ${PIPESTATUS[0]})

0 comments on commit 9bb1078

Please sign in to comment.