add requirements for ContourSet depreciation in matplotlib 3.8

This commit is contained in:
2024-09-23 14:13:18 +02:00
parent db3deac6c2
commit 946e6cd5c9
3 changed files with 31 additions and 17 deletions

View File

@@ -221,6 +221,8 @@ def polarization_map(
savename=None,
plots_folder="",
display="default",
fig=None,
ax=None,
):
"""
Plots polarization map from Stokes HDUList.
@@ -338,10 +340,13 @@ def polarization_map(
# Plot the map
plt.rcParams.update({"font.size": 14})
plt.rcdefaults()
ratiox = max(int(stkI.shape[1] / (stkI.shape[0])), 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))
ax.set(aspect="equal", fc="k", ylim=[-stkI.shape[0] * 0.10, stkI.shape[0] * 1.15])
if fig is None:
ratiox = max(int(stkI.shape[1] / (stkI.shape[0])), 1)
ratioy = max(int((stkI.shape[0]) / stkI.shape[1]), 1)
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])
# fig.subplots_adjust(hspace=0, wspace=0, left=0.102, right=1.02)
# ax.coords.grid(True, color='white', ls='dotted', alpha=0.5)

7
package/requirements.txt Normal file
View 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

View File

@@ -15,11 +15,9 @@ def main(infile, target=None, output_dir=None):
from lib.plots import polarization_map
from lib.utils import CenterConf, PCconf
from matplotlib.patches import Rectangle
from matplotlib.pyplot import show
from matplotlib.pyplot import figure, show
output = []
levelssnr = np.array([3.0, 4.0])
levelsconf = np.array([0.99])
Stokes = fits_open(infile)
stkI = Stokes["I_STOKES"].data
@@ -42,26 +40,30 @@ def main(infile, target=None, output_dir=None):
if target is None:
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")
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")))
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")
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()
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")
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)
show()
labels.append(r"Polarization $Conf_{99\%}$ contour")
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:
filename = pathjoin(output_dir, "%s_center.pdf" % target)
fig.savefig(filename, dpi=150, facecolor="None")
output.append(filename)
show()
return output