aboutsummaryrefslogtreecommitdiffstats
path: root/astro
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-11-27 22:51:13 +0800
committerAaron LI <aly@aaronly.me>2017-11-27 22:51:13 +0800
commitbbf790267d5cbc3407f8464a328d26e2bf69a2bf (patch)
tree900c2db9c1faa438c54d0ad4867d2410dfce9996 /astro
parentc433da11b5b2ece5e9e6da70ae3b9d62a03bf786 (diff)
downloadatoolbox-bbf790267d5cbc3407f8464a328d26e2bf69a2bf.tar.bz2
astro/calc_psd.py: Improve plot style and minor cleanups
Diffstat (limited to 'astro')
-rwxr-xr-xastro/calc_psd.py34
-rwxr-xr-xastro/oskar/wsclean.py3
2 files changed, 20 insertions, 17 deletions
diff --git a/astro/calc_psd.py b/astro/calc_psd.py
index 6f0c2f6..2d4f4fe 100755
--- a/astro/calc_psd.py
+++ b/astro/calc_psd.py
@@ -25,17 +25,29 @@ from functools import lru_cache
import numpy as np
from astropy.io import fits
-import matplotlib.pyplot as plt
+import matplotlib
+import matplotlib.style
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
-plt.style.use("ggplot")
+# Matplotlib settings
+matplotlib.style.use("ggplot")
+for k, v in [("font.family", "monospace"),
+ ("xtick.major.size", 7.0),
+ ("xtick.major.width", 2.0),
+ ("xtick.minor.size", 4.0),
+ ("xtick.minor.width", 1.5),
+ ("ytick.major.size", 7.0),
+ ("ytick.major.width", 2.0),
+ ("ytick.minor.size", 4.0),
+ ("ytick.minor.width", 1.5)]:
+ matplotlib.rcParams[k] = v
class PSD:
"""
- Computes the 2D power spectral density and the azimuthally averaged power
- spectral density (i.e., 1D radial power spectrum).
+ Calculate the 2D power spectral density and then apply azimuthal
+ averaging to obtain the 1D radial power spectrum.
Parameters
----------
@@ -124,9 +136,8 @@ class PSD:
"""
print("Calculating 2D power spectral density ... ", end="", flush=True)
rows, cols = self.shape
- # Compute the power spectral density (i.e., power spectrum)
imgf = np.fft.fftshift(np.fft.fft2(self.image))
- # Normalization w.r.t. image size
+ # NOTE: normalize w.r.t. image size
norm = rows * cols * self.pixel[0]**2
self.psd2d = (np.abs(imgf) ** 2) / norm
print("DONE", flush=True)
@@ -134,7 +145,7 @@ class PSD:
def calc_psd(self):
"""
- Azimuthally average the above 2D power spectral density to generate
+ Azimuthally average the above 2D power spectral density to obtain
the 1D radial power spectral density.
Returns
@@ -212,15 +223,6 @@ class PSD:
phi = np.arctan2(y, x)
return (rho, phi)
- @staticmethod
- def pol2cart(rho, phi):
- """
- Convert polar coordinates to Cartesian coordinates.
- """
- x = rho * np.cos(phi)
- y = rho * np.sin(phi)
- return (x, y)
-
def save(self, outfile):
data = np.column_stack((self.frequencies, self.psd1d,
self.psd1d_errl, self.psd1d_erru))
diff --git a/astro/oskar/wsclean.py b/astro/oskar/wsclean.py
index eeceb22..383510d 100755
--- a/astro/oskar/wsclean.py
+++ b/astro/oskar/wsclean.py
@@ -76,7 +76,8 @@ def main():
"in a quoted string separated by space, e.g.," +
"' -simulate-noise 0.001' (NOTE the beginning space!)")
parser.add_argument("-d", "--dirty", dest="dirty", action="store_true",
- help="only create dirty images (by setting niter=0)")
+ help="only create the dirty image by overriding " +
+ "--niter to 0")
parser.add_argument("-n", "--dry-run", dest="dryrun", action="store_true",
help="do not actually run WSClean")
parser.add_argument("--update-model", dest="update_model",