aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-09-02 20:52:00 +0800
committerAaron LI <aly@aaronly.me>2017-09-02 20:52:00 +0800
commitd83b3e57cb6e8354463915f52690115e7fdd1396 (patch)
tree1ccbc790b78c51790a454f9c15d7dd74eec4d6ed
parentd4e96f2d3fd1f266609c9d0f6b3661682b423333 (diff)
downloadatoolbox-d83b3e57cb6e8354463915f52690115e7fdd1396.tar.bz2
ps2d.py: support adding multiple FITS cubes first
-rwxr-xr-xastro/ps2d.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/astro/ps2d.py b/astro/ps2d.py
index d17da66..3ae78f6 100755
--- a/astro/ps2d.py
+++ b/astro/ps2d.py
@@ -402,13 +402,14 @@ def main():
choices=["nuttall"],
help="apply window along frequency axis " +
"(default: None)")
- parser.add_argument("-i", "--infile", dest="infile", required=True,
- help="input FITS image cube")
+ parser.add_argument("-i", "--infile", dest="infile", nargs="+",
+ help="input FITS image cube(s); if multiple cubes " +
+ "are provided, they are added first.")
parser.add_argument("-o", "--outfile", dest="outfile", required=True,
help="output 2D power spectrum FITS file")
args = parser.parse_args()
- with fits.open(args.infile) as f:
+ with fits.open(args.infile[0]) as f:
cube = f[0].data
header = f[0].header
bunit = header.get("BUNIT", "UNKNOWN")
@@ -417,6 +418,10 @@ def main():
else:
logger.info("Data unit: %s" % bunit)
+ for fn in args.infile[1:]:
+ logger.info("Adding additional FITS cube: %s" % fn)
+ cube += fits.open(fn)[0].data
+
wcs = WCS(header)
nfreq = cube.shape[0]
frequencies = get_frequencies(wcs, nfreq)