adjustements to pdf static output
This commit is contained in:
@@ -60,7 +60,10 @@ from mpl_toolkits.axes_grid1.anchored_artists import (
|
|||||||
)
|
)
|
||||||
from scipy.ndimage import zoom as sc_zoom
|
from scipy.ndimage import zoom as sc_zoom
|
||||||
|
|
||||||
|
try:
|
||||||
from .utils import PCconf, princ_angle, rot2D, sci_not
|
from .utils import PCconf, princ_angle, rot2D, sci_not
|
||||||
|
except ImportError:
|
||||||
|
from utils import PCconf, princ_angle, rot2D, sci_not
|
||||||
|
|
||||||
|
|
||||||
def plot_obs(data_array, headers, rectangle=None, savename=None, plots_folder="", **kwargs):
|
def plot_obs(data_array, headers, rectangle=None, savename=None, plots_folder="", **kwargs):
|
||||||
@@ -205,7 +208,6 @@ def plot_Stokes(Stokes, savename=None, plots_folder=""):
|
|||||||
else:
|
else:
|
||||||
savename = savename[:-4] + "_IQU" + savename[-4:]
|
savename = savename[:-4] + "_IQU" + savename[-4:]
|
||||||
fig.savefig(path_join(plots_folder, savename), bbox_inches="tight", dpi=150, facecolor="None")
|
fig.savefig(path_join(plots_folder, savename), bbox_inches="tight", dpi=150, facecolor="None")
|
||||||
plt.show()
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@@ -562,7 +564,7 @@ def polarization_map(
|
|||||||
if savename is not None:
|
if savename is not None:
|
||||||
if savename[-4:] not in [".png", ".jpg", ".pdf"]:
|
if savename[-4:] not in [".png", ".jpg", ".pdf"]:
|
||||||
savename += ".pdf"
|
savename += ".pdf"
|
||||||
fig.savefig(path_join(plots_folder, savename), bbox_inches="tight", dpi=150, facecolor="None")
|
fig.savefig(path_join(plots_folder, savename), bbox_inches="tight", dpi=300, facecolor="None")
|
||||||
|
|
||||||
return fig, ax
|
return fig, ax
|
||||||
|
|
||||||
@@ -3353,15 +3355,32 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-pdf", "--static-pdf", metavar="static_pdf", required=False, help="Whether the analysis tool or the static pdfs should be outputed", default=None
|
"-pdf", "--static-pdf", metavar="static_pdf", required=False, help="Whether the analysis tool or the static pdfs should be outputed", default=None
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-t", "--type", metavar="type", required=False, help="Type of plot to be be outputed", default=None
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.file is not None:
|
if args.file is not None:
|
||||||
Stokes_UV = fits.open(args.file, mode="readonly")
|
Stokes_UV = fits.open(args.file, mode="readonly")
|
||||||
if args.static_pdf is not None:
|
if args.static_pdf is not None:
|
||||||
|
if args.type is not None:
|
||||||
polarization_map(
|
polarization_map(
|
||||||
Stokes_UV,
|
Stokes_UV,
|
||||||
Stokes_UV["DATA_MASK"].data.astype(bool),
|
Stokes_UV["DATA_MASK"].data.astype(bool),
|
||||||
P_cut=args.p_cut,
|
P_cut=args.pcut,
|
||||||
|
SNRi_cut=args.snri,
|
||||||
|
flux_lim=args.lim,
|
||||||
|
step_vec=args.step_vec,
|
||||||
|
scale_vec=args.scale_vec,
|
||||||
|
savename="_".join([Stokes_UV[0].header["FILENAME"], args.type]),
|
||||||
|
plots_folder=args.static_pdf,
|
||||||
|
display=args.type,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
polarization_map(
|
||||||
|
Stokes_UV,
|
||||||
|
Stokes_UV["DATA_MASK"].data.astype(bool),
|
||||||
|
P_cut=args.pcut,
|
||||||
SNRi_cut=args.snri,
|
SNRi_cut=args.snri,
|
||||||
flux_lim=args.lim,
|
flux_lim=args.lim,
|
||||||
step_vec=args.step_vec,
|
step_vec=args.step_vec,
|
||||||
@@ -3372,7 +3391,7 @@ if __name__ == "__main__":
|
|||||||
polarization_map(
|
polarization_map(
|
||||||
Stokes_UV,
|
Stokes_UV,
|
||||||
Stokes_UV["DATA_MASK"].data.astype(bool),
|
Stokes_UV["DATA_MASK"].data.astype(bool),
|
||||||
P_cut=args.p_cut,
|
P_cut=args.pcut,
|
||||||
SNRi_cut=args.snri,
|
SNRi_cut=args.snri,
|
||||||
flux_lim=args.lim,
|
flux_lim=args.lim,
|
||||||
step_vec=args.step_vec,
|
step_vec=args.step_vec,
|
||||||
@@ -3384,7 +3403,7 @@ if __name__ == "__main__":
|
|||||||
polarization_map(
|
polarization_map(
|
||||||
Stokes_UV,
|
Stokes_UV,
|
||||||
Stokes_UV["DATA_MASK"].data.astype(bool),
|
Stokes_UV["DATA_MASK"].data.astype(bool),
|
||||||
P_cut=args.p_cut,
|
P_cut=args.pcut,
|
||||||
SNRi_cut=args.snri,
|
SNRi_cut=args.snri,
|
||||||
flux_lim=args.lim,
|
flux_lim=args.lim,
|
||||||
step_vec=args.step_vec,
|
step_vec=args.step_vec,
|
||||||
@@ -3396,7 +3415,7 @@ if __name__ == "__main__":
|
|||||||
polarization_map(
|
polarization_map(
|
||||||
Stokes_UV,
|
Stokes_UV,
|
||||||
Stokes_UV["DATA_MASK"].data.astype(bool),
|
Stokes_UV["DATA_MASK"].data.astype(bool),
|
||||||
P_cut=args.p_cut,
|
P_cut=args.pcut,
|
||||||
SNRi_cut=args.snri,
|
SNRi_cut=args.snri,
|
||||||
flux_lim=args.lim,
|
flux_lim=args.lim,
|
||||||
step_vec=args.step_vec,
|
step_vec=args.step_vec,
|
||||||
@@ -3408,7 +3427,7 @@ if __name__ == "__main__":
|
|||||||
polarization_map(
|
polarization_map(
|
||||||
Stokes_UV,
|
Stokes_UV,
|
||||||
Stokes_UV["DATA_MASK"].data.astype(bool),
|
Stokes_UV["DATA_MASK"].data.astype(bool),
|
||||||
P_cut=args.p_cut,
|
P_cut=args.pcut,
|
||||||
SNRi_cut=args.snri,
|
SNRi_cut=args.snri,
|
||||||
flux_lim=args.lim,
|
flux_lim=args.lim,
|
||||||
step_vec=args.step_vec,
|
step_vec=args.step_vec,
|
||||||
@@ -3420,7 +3439,7 @@ if __name__ == "__main__":
|
|||||||
polarization_map(
|
polarization_map(
|
||||||
Stokes_UV,
|
Stokes_UV,
|
||||||
Stokes_UV["DATA_MASK"].data.astype(bool),
|
Stokes_UV["DATA_MASK"].data.astype(bool),
|
||||||
P_cut=args.p_cut,
|
P_cut=args.pcut,
|
||||||
SNRi_cut=args.snri,
|
SNRi_cut=args.snri,
|
||||||
flux_lim=args.lim,
|
flux_lim=args.lim,
|
||||||
step_vec=args.step_vec,
|
step_vec=args.step_vec,
|
||||||
@@ -3432,7 +3451,7 @@ if __name__ == "__main__":
|
|||||||
polarization_map(
|
polarization_map(
|
||||||
Stokes_UV,
|
Stokes_UV,
|
||||||
Stokes_UV["DATA_MASK"].data.astype(bool),
|
Stokes_UV["DATA_MASK"].data.astype(bool),
|
||||||
P_cut=args.p_cut,
|
P_cut=args.pcut,
|
||||||
SNRi_cut=args.snri,
|
SNRi_cut=args.snri,
|
||||||
flux_lim=args.lim,
|
flux_lim=args.lim,
|
||||||
step_vec=args.step_vec,
|
step_vec=args.step_vec,
|
||||||
@@ -3444,7 +3463,7 @@ if __name__ == "__main__":
|
|||||||
polarization_map(
|
polarization_map(
|
||||||
Stokes_UV,
|
Stokes_UV,
|
||||||
Stokes_UV["DATA_MASK"].data.astype(bool),
|
Stokes_UV["DATA_MASK"].data.astype(bool),
|
||||||
P_cut=args.p_cut,
|
P_cut=args.pcut,
|
||||||
SNRi_cut=args.snri,
|
SNRi_cut=args.snri,
|
||||||
flux_lim=args.lim,
|
flux_lim=args.lim,
|
||||||
step_vec=args.step_vec,
|
step_vec=args.step_vec,
|
||||||
@@ -3456,7 +3475,7 @@ if __name__ == "__main__":
|
|||||||
polarization_map(
|
polarization_map(
|
||||||
Stokes_UV,
|
Stokes_UV,
|
||||||
Stokes_UV["DATA_MASK"].data.astype(bool),
|
Stokes_UV["DATA_MASK"].data.astype(bool),
|
||||||
P_cut=args.p_cut if args.p_cut >= 1.0 else 3.0,
|
P_cut=args.pcut if args.pcut >= 1.0 else 3.0,
|
||||||
SNRi_cut=args.snri,
|
SNRi_cut=args.snri,
|
||||||
flux_lim=args.lim,
|
flux_lim=args.lim,
|
||||||
step_vec=args.step_vec,
|
step_vec=args.step_vec,
|
||||||
@@ -3468,7 +3487,7 @@ if __name__ == "__main__":
|
|||||||
polarization_map(
|
polarization_map(
|
||||||
Stokes_UV,
|
Stokes_UV,
|
||||||
Stokes_UV["DATA_MASK"].data.astype(bool),
|
Stokes_UV["DATA_MASK"].data.astype(bool),
|
||||||
P_cut=args.p_cut if args.p_cut < 1.0 else 0.99,
|
P_cut=args.pcut if args.pcut < 1.0 else 0.99,
|
||||||
SNRi_cut=args.snri,
|
SNRi_cut=args.snri,
|
||||||
flux_lim=args.lim,
|
flux_lim=args.lim,
|
||||||
step_vec=args.step_vec,
|
step_vec=args.step_vec,
|
||||||
@@ -3478,7 +3497,7 @@ if __name__ == "__main__":
|
|||||||
display="confp",
|
display="confp",
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
pol_map(Stokes_UV, P_cut=args.p_cut, SNRi_cut=args.snri, step_vec=args.step_vec, scale_vec=args.scale_vec, flux_lim=args.lim, pa_err=args.pang_err)
|
pol_map(Stokes_UV, P_cut=args.pcut, SNRi_cut=args.snri, step_vec=args.step_vec, scale_vec=args.scale_vec, flux_lim=args.lim, pa_err=args.pang_err, selection=args.type)
|
||||||
else:
|
else:
|
||||||
print(
|
print(
|
||||||
"python3 plots.py -f <path_to_reduced_fits> -p <P_cut> -i <SNRi_cut> -st <step_vec> -sc <scale_vec> -l <flux_lim> -pa <pa_err> --pdf <static_pdf>"
|
"python3 plots.py -f <path_to_reduced_fits> -p <P_cut> -i <SNRi_cut> -st <step_vec> -sc <scale_vec> -l <flux_lim> -pa <pa_err> --pdf <static_pdf>"
|
||||||
|
|||||||
@@ -40,16 +40,16 @@ def main(infile, target=None, output_dir=None):
|
|||||||
if target is None:
|
if target is None:
|
||||||
target = Stokes[0].header["TARGNAME"]
|
target = Stokes[0].header["TARGNAME"]
|
||||||
|
|
||||||
fig = figure(figsize=(8,9),layout="constrained")
|
fig = figure(figsize=(8,8),layout="constrained")
|
||||||
fig, ax = polarization_map(Stokes, P_cut=0.99, step_vec=2, scale_vec=5, display="i", fig=fig)
|
fig, ax = polarization_map(Stokes, P_cut=0.99, step_vec=2, scale_vec=5, display="i", fig=fig)
|
||||||
|
|
||||||
ax.plot(*Stokescenter, marker="+", color="gray", label="Best confidence for center: {0}".format(Stokespos.to_string("hmsdms")))
|
ax.plot(*Stokescenter, marker="+", color="gray", label="Best confidence for center: {0}".format(Stokespos.to_string("hmsdms")))
|
||||||
confcentcont = ax.contour(Stokescentconf, [0.01], colors="gray")
|
confcentcont = ax.contour(Stokescentconf, [0.001], colors="gray")
|
||||||
confcont = ax.contour(Stokesconf, [0.99], colors="r")
|
confcont = ax.contour(Stokesconf, [0.9905], colors="r")
|
||||||
snr3cont = ax.contour(Stokessnr, [3.0], colors="b", linestyles="dashed")
|
snr3cont = ax.contour(Stokessnr, [3.0], colors="b", linestyles="dashed")
|
||||||
snr4cont = ax.contour(Stokessnr, [4.0], colors="b")
|
snr4cont = ax.contour(Stokessnr, [4.0], colors="b")
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
labels.append(r"Center $Conf_{99\%}$ contour")
|
labels.append(r"Center $Conf_{99.9\%}$ contour")
|
||||||
handles.append(Rectangle((0, 0), 1, 1, fill=False, ec=confcentcont.get_edgecolor()[0]))
|
handles.append(Rectangle((0, 0), 1, 1, fill=False, ec=confcentcont.get_edgecolor()[0]))
|
||||||
labels.append(r"Polarization $Conf_{99\%}$ contour")
|
labels.append(r"Polarization $Conf_{99\%}$ contour")
|
||||||
handles.append(Rectangle((0, 0), 1, 1, fill=False, ec=confcont.get_edgecolor()[0]))
|
handles.append(Rectangle((0, 0), 1, 1, fill=False, ec=confcont.get_edgecolor()[0]))
|
||||||
@@ -61,7 +61,7 @@ def main(infile, target=None, output_dir=None):
|
|||||||
|
|
||||||
if output_dir is not None:
|
if output_dir is not None:
|
||||||
filename = pathjoin(output_dir, "%s_center.pdf" % target)
|
filename = pathjoin(output_dir, "%s_center.pdf" % target)
|
||||||
fig.savefig(filename, dpi=150, facecolor="None")
|
fig.savefig(filename, dpi=300, facecolor="None")
|
||||||
output.append(filename)
|
output.append(filename)
|
||||||
show()
|
show()
|
||||||
return output
|
return output
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from astropy.io import fits
|
|||||||
from lib.plots import overplot_chandra, overplot_pol
|
from lib.plots import overplot_chandra, overplot_pol
|
||||||
from matplotlib.colors import LogNorm
|
from matplotlib.colors import LogNorm
|
||||||
|
|
||||||
Stokes_UV = fits.open("./data/MRK463E/5960/MRK463E_FOC_b0.05arcsec_c0.07arcsec.fits")
|
Stokes_UV = fits.open("./data/MRK463E/5960/MRK463E_FOC_b0.05arcsec_c0.10arcsec.fits")
|
||||||
Stokes_IR = fits.open("./data/MRK463E/WFPC2/IR_rot_crop.fits")
|
Stokes_IR = fits.open("./data/MRK463E/WFPC2/IR_rot_crop.fits")
|
||||||
Stokes_Xr = fits.open("./data/MRK463E/Chandra/X_ray_crop.fits")
|
Stokes_Xr = fits.open("./data/MRK463E/Chandra/X_ray_crop.fits")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user