add requirements for ContourSet depreciation in matplotlib 3.8
This commit is contained in:
@@ -221,6 +221,8 @@ def polarization_map(
|
|||||||
savename=None,
|
savename=None,
|
||||||
plots_folder="",
|
plots_folder="",
|
||||||
display="default",
|
display="default",
|
||||||
|
fig=None,
|
||||||
|
ax=None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Plots polarization map from Stokes HDUList.
|
Plots polarization map from Stokes HDUList.
|
||||||
@@ -338,9 +340,12 @@ def polarization_map(
|
|||||||
# Plot the map
|
# Plot the map
|
||||||
plt.rcParams.update({"font.size": 14})
|
plt.rcParams.update({"font.size": 14})
|
||||||
plt.rcdefaults()
|
plt.rcdefaults()
|
||||||
|
if fig is None:
|
||||||
ratiox = max(int(stkI.shape[1] / (stkI.shape[0])), 1)
|
ratiox = max(int(stkI.shape[1] / (stkI.shape[0])), 1)
|
||||||
ratioy = max(int((stkI.shape[0]) / stkI.shape[1]), 1)
|
ratioy = max(int((stkI.shape[0]) / stkI.shape[1]), 1)
|
||||||
fig, ax = plt.subplots(figsize=(7 * ratiox, 7 * ratioy), layout="compressed", subplot_kw=dict(projection=wcs))
|
fig = plt.figure(figsize=(7 * ratiox, 7 * ratioy), layout="constrained")
|
||||||
|
if ax is None:
|
||||||
|
ax = fig.add_subplot(111, projection=wcs)
|
||||||
ax.set(aspect="equal", fc="k", ylim=[-stkI.shape[0] * 0.10, stkI.shape[0] * 1.15])
|
ax.set(aspect="equal", fc="k", ylim=[-stkI.shape[0] * 0.10, stkI.shape[0] * 1.15])
|
||||||
# fig.subplots_adjust(hspace=0, wspace=0, left=0.102, right=1.02)
|
# fig.subplots_adjust(hspace=0, wspace=0, left=0.102, right=1.02)
|
||||||
|
|
||||||
|
|||||||
7
package/requirements.txt
Normal file
7
package/requirements.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Requirements for FOC_Reduction
|
||||||
|
|
||||||
|
numpy
|
||||||
|
scipy
|
||||||
|
astropy
|
||||||
|
astroquery # To directly query the Mast archives
|
||||||
|
matplotlib >= 3.8 # Brought some depreciation on ContourSet
|
||||||
@@ -15,11 +15,9 @@ def main(infile, target=None, output_dir=None):
|
|||||||
from lib.plots import polarization_map
|
from lib.plots import polarization_map
|
||||||
from lib.utils import CenterConf, PCconf
|
from lib.utils import CenterConf, PCconf
|
||||||
from matplotlib.patches import Rectangle
|
from matplotlib.patches import Rectangle
|
||||||
from matplotlib.pyplot import show
|
from matplotlib.pyplot import figure, show
|
||||||
|
|
||||||
output = []
|
output = []
|
||||||
levelssnr = np.array([3.0, 4.0])
|
|
||||||
levelsconf = np.array([0.99])
|
|
||||||
|
|
||||||
Stokes = fits_open(infile)
|
Stokes = fits_open(infile)
|
||||||
stkI = Stokes["I_STOKES"].data
|
stkI = Stokes["I_STOKES"].data
|
||||||
@@ -42,26 +40,30 @@ 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, ax = polarization_map(Stokes, P_cut=0.99, step_vec=2, scale_vec=5, display="i")
|
fig = figure(figsize=(8,9),layout="constrained")
|
||||||
|
fig, ax = polarization_map(Stokes, P_cut=0.99, step_vec=2, scale_vec=5, display="i", fig=fig)
|
||||||
|
|
||||||
snrcont = ax.contour(Stokessnr, levelssnr, colors="b")
|
ax.plot(*Stokescenter, marker="+", color="gray", label="Best confidence for center: {0}".format(Stokespos.to_string("hmsdms")))
|
||||||
confcont = ax.contour(Stokesconf, levelsconf, colors="r")
|
|
||||||
confcenter = 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.01], colors="gray")
|
||||||
|
confcont = ax.contour(Stokesconf, [0.99], colors="r")
|
||||||
|
snr3cont = ax.contour(Stokessnr, [3.0], colors="b", linestyles="dashed")
|
||||||
|
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"$SNR_P \geq$ 3 and 4 contours")
|
|
||||||
handles.append(Rectangle((0, 0), 1, 1, fill=False, ec=snrcont.get_edgecolor()[0]))
|
|
||||||
labels.append(r"Polarization $Conf_{99\%}$ contour")
|
|
||||||
handles.append(Rectangle((0, 0), 1, 1, fill=False, ec=confcont.get_edgecolor()[0]))
|
|
||||||
labels.append(r"Center $Conf_{99\%}$ contour")
|
labels.append(r"Center $Conf_{99\%}$ 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]))
|
||||||
ax.legend(handles=handles, labels=labels, bbox_to_anchor=(0.0, -0.12, 1.0, 0.102), loc="lower left", mode="expand", borderaxespad=0.0)
|
labels.append(r"Polarization $Conf_{99\%}$ contour")
|
||||||
show()
|
handles.append(Rectangle((0, 0), 1, 1, fill=False, ec=confcont.get_edgecolor()[0]))
|
||||||
|
labels.append(r"$SNR_P \geq$ 3 contour")
|
||||||
|
handles.append(Rectangle((0, 0), 1, 1, fill=False, ls="--", ec=snr3cont.get_edgecolor()[0]))
|
||||||
|
labels.append(r"$SNR_P \geq$ 4 contour")
|
||||||
|
handles.append(Rectangle((0, 0), 1, 1, fill=False, ec=snr4cont.get_edgecolor()[0]))
|
||||||
|
ax.legend(handles=handles, labels=labels, bbox_to_anchor=(0.0, -0.02, 1.0, 0.01), loc="upper left", mode="expand", borderaxespad=0.0)
|
||||||
|
|
||||||
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=150, facecolor="None")
|
||||||
output.append(filename)
|
output.append(filename)
|
||||||
|
show()
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user