Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions vip_hci/metrics/contrcurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,20 @@ def contrast_curve(
else:
fwhm_med = fwhm

# Retrieve ncomp info
ncomp = algo_dict["ncomp"]

if verbose:
start_time = time_ini()
if isinstance(starphot, float) or isinstance(starphot, int):
msg0 = "ALGO : {}, FWHM = {}, # BRANCHES = {}, SIGMA = {},"
msg0 += " STARPHOT = {}"
print(msg0.format(algo.__name__, fwhm_med, nbranch, sigma,
starphot))
msg0 = "ALGO : {}, ncomp = {}, FWHM = {}, \n"
msg0 += "# BRANCHES = {}, SIGMA = {}, STARPHOT = {}"
print(msg0.format(algo.__name__, ncomp, fwhm_med, nbranch,
sigma, starphot))
else:
msg0 = "ALGO : {}, FWHM = {}, # BRANCHES = {}, SIGMA = {}"
print(msg0.format(algo.__name__, fwhm_med, nbranch, sigma))
msg0 = "ALGO : {}, ncomp = {}, FWHM = {}, \n"
msg0 += "# BRANCHES = {}, SIGMA = {}, "
print(msg0.format(algo.__name__, ncomp, fwhm_med, nbranch, sigma))

# throughput
verbose_thru = False
Expand Down Expand Up @@ -496,8 +500,7 @@ def contrast_curve(

# Give a title to the contrast curve plot
if object_name is not None and frame_size is not None:
# Retrieve ncomp and pca_type info to use in title
ncomp = algo_dict["ncomp"]
# Retrieve pca_type info to use in title
if algo_dict["cube_ref"] is None:
pca_type = "ADI"
else:
Expand Down
1 change: 1 addition & 0 deletions vip_hci/objects/pppca.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def run(
self.frame_final,
self.dataframe,
self.opt_number_pc,
self.opt_SNR,
) = res
if self.results is not None:
self.results.register_session(
Expand Down
2 changes: 1 addition & 1 deletion vip_hci/psfsub/pca_fullfr.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ def pca(*all_args: List, **all_kwargs: dict):
# PCA grid, computing S/Ns
if isinstance(algo_params.ncomp, (tuple, list)):
if algo_params.full_output:
final_residuals_cube, frame, table, _ = res_pca
final_residuals_cube, frame, table, _, _ = res_pca
else:
# returning only the optimal residual
frame = res_pca[1]
Expand Down
8 changes: 6 additions & 2 deletions vip_hci/psfsub/utils_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ def pca_grid(cube, angle_list, fwhm=None, range_pcs=None, source_xy=None,
S/Ns for ``source_xy``.
opt_npc : int
[source_xy is not None] Optimal number of PCs for ``source_xy``.
opt_SNR : float
[source_xy is not None] Optimal signal-to-noise ratio for ``source_xy``
at opt_npc

"""
from ..metrics import snr, frame_report
Expand Down Expand Up @@ -371,14 +374,15 @@ def get_snr(frame, y, x, fwhm, fmerit):
if x is not None and y is not None and fwhm is not None:
argmax = np.argmax(snrlist)
opt_npc = pclist[argmax]
opt_SNR = snrlist[argmax]
df = DataFrame({'PCs': pclist, 'S/Ns': snrlist, 'fluxes': fluxlist})
if debug:
print(df, '\n')

if verbose:
print('Number of steps', len(pclist))
msg = 'Optimal number of PCs = {}, for S/N={:.3f}'
print(msg.format(opt_npc, snrlist[argmax]))
print(msg.format(opt_npc, opt_SNR))

# Plot of SNR and flux as function of PCs
if plot:
Expand Down Expand Up @@ -411,7 +415,7 @@ def get_snr(frame, y, x, fwhm, fmerit):
finalfr = cubeout[argmax]
_ = frame_report(finalfr, fwhm, (x, y), verbose=verbose)

return cubeout, finalfr, df, opt_npc
return cubeout, finalfr, df, opt_npc, opt_SNR

else:
if verbose:
Expand Down
Loading