aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xastro/calc_psd.py24
-rwxr-xr-xastro/ps2d.py7
2 files changed, 12 insertions, 19 deletions
diff --git a/astro/calc_psd.py b/astro/calc_psd.py
index ad7659e..f8f9f6b 100755
--- a/astro/calc_psd.py
+++ b/astro/calc_psd.py
@@ -339,8 +339,9 @@ def main():
parser.add_argument("-C", "--clobber", dest="clobber", action="store_true",
help="overwrite the output files if already exist")
parser.add_argument("-s", "--step", dest="step", type=float, default=1.1,
- help="step ratio (>1) between 2 consecutive radial " +
- "frequency points, i.e., a logarithmic grid used. " +
+ help="step ratio (>1; default: 1.1) between 2 " +
+ "consecutive radial frequency points, " +
+ "i.e., a logarithmic grid used. " +
"if specified a value <=1, then the power at every " +
"radial frequency point will be calculated, " +
"i.e., using a even grid, which may be very slow " +
@@ -353,8 +354,8 @@ def main():
help="calculate the mean and standard deviation " +
"for each averaged annulus instead of the median " +
"16%% and 84%% percentiles (i.e., 68%% error)")
- parser.add_argument("-P", "--plot", dest="plot", action="store_true",
- help="plot the PSD and save as a PNG image")
+ parser.add_argument("-P", "--no-plot", dest="noplot", action="store_true",
+ help="do NOT plot the PSD and save")
parser.add_argument("-i", "--infile", dest="infile", nargs="+",
help="input FITS image(s); if multiple images " +
"are provided, they are added first.")
@@ -362,15 +363,8 @@ def main():
help="output TXT file to save the PSD data")
args = parser.parse_args()
- if args.plot:
- plotfile = os.path.splitext(args.outfile)[0] + ".png"
-
- # Check output files whether already exists
if (not args.clobber) and os.path.exists(args.outfile):
raise OSError("outfile '%s' already exists" % args.outfile)
- if args.plot:
- if (not args.clobber) and os.path.exists(plotfile):
- raise OSError("output plot file '%s' already exists" % plotfile)
header, image = open_image(args.infile[0])
bunit = header.get("BUNIT", "???")
@@ -404,14 +398,14 @@ def main():
psd.calc_psd()
psd.save(args.outfile)
- if args.plot:
- # Make and save a plot
- fig = Figure(figsize=(8, 8))
+ if not args.noplot:
+ fig = Figure(figsize=(8, 8), dpi=150)
FigureCanvas(fig)
ax = fig.add_subplot(1, 1, 1)
psd.plot(ax=ax)
fig.tight_layout()
- fig.savefig(plotfile, format="png", dpi=150)
+ plotfile = os.path.splitext(args.outfile)[0] + ".png"
+ fig.savefig(plotfile)
print("Plotted PSD and saved to image: %s" % plotfile)
diff --git a/astro/ps2d.py b/astro/ps2d.py
index f7c9801..cbb3a93 100755
--- a/astro/ps2d.py
+++ b/astro/ps2d.py
@@ -525,9 +525,8 @@ def main():
help="calculate the mean and standard deviation " +
"for each averaged annulus instead of the median " +
"16%% and 84%% percentiles (i.e., 68%% error)")
- parser.add_argument("-P", "--plot", dest="plot",
- action="store_true",
- help="plot the 2D power spectrum and save")
+ parser.add_argument("-P", "--no-plot", dest="noplot", action="store_true",
+ help="do NOT plot the 2D power spectrum and save")
parser.add_argument("-p", "--pixelsize", dest="pixelsize", type=float,
help="spatial pixel size [arcsec] (required " +
"if cannot obtain from FITS header)")
@@ -580,7 +579,7 @@ def main():
ps2d.calc_ps2d()
ps2d.save(outfile=args.outfile, clobber=args.clobber)
- if args.plot:
+ if not args.noplot:
fig = Figure(figsize=(16, 8), dpi=150)
FigureCanvas(fig)
ax = fig.add_subplot(1, 2, 1)