Skip to content

Commit

Permalink
Merge pull request #567 from IainHammond/master
Browse files Browse the repository at this point in the history
misc. fixes
  • Loading branch information
VChristiaens authored Dec 27, 2022
2 parents 28617c0 + b8d737b commit becfc49
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
10 changes: 5 additions & 5 deletions vip_hci/metrics/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ def print_abort():
yy_out = []
xx_out = []
snr_list = []
snr_final = []

if mode in ('lpeaks', 'log', 'dog'):
xx -= pad
Expand All @@ -342,6 +343,7 @@ def print_abort():
_ = frame_report(array, fwhm, (x, y), verbose=verbose)
yy_final.append(y)
xx_final.append(x)
snr_final.append(snr_value)
else:
yy_out.append(y)
xx_out.append(x)
Expand All @@ -353,17 +355,18 @@ def print_abort():
if verbose:
print(sep)

if debug or full_output:
if debug:
table_full = pn.DataFrame({'y': yy.tolist(),
'x': xx.tolist(),
'px_snr': snr_list})
table_full.sort_values('px_snr')
print(table_full)

yy_final = np.array(yy_final)
xx_final = np.array(xx_final)
yy_out = np.array(yy_out)
xx_out = np.array(xx_out)
table = pn.DataFrame({'y': yy_final.tolist(), 'x': xx_final.tolist()})
table = pn.DataFrame({'y': yy_final.tolist(), 'x': xx_final.tolist(), 'px_snr': snr_final})

if plot:
coords = tuple(zip(xx_out.tolist() + xx_final.tolist(),
Expand All @@ -373,9 +376,6 @@ def print_abort():
plot_frames(array, dpi=120, circle=coords, circle_alpha=circlealpha,
circle_label=True, circle_radius=fwhm, **kwargs)

if debug:
print(table_full)

if full_output:
return table
else:
Expand Down
11 changes: 8 additions & 3 deletions vip_hci/preproc/badframes.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ def cube_detect_badfr_pxstats(array, mode='annulus', in_radius=10, width=10,
"""
check_array(array, 3, msg='array')

if in_radius+width > array[0].shape[0]/2:
msgve = 'Inner radius and annulus size are too big (out of boundaries)'
raise ValueError(msgve)
if mode == 'annulus':
if in_radius + width > array[0].shape[0] / 2:
msgve = 'Inner radius and annulus size are too big (out of boundaries)'
raise ValueError(msgve)
elif mode == 'circle':
if in_radius > array[0].shape[0] / 2:
msgve = 'Radius size is too big (out of boundaries)'
raise ValueError(msgve)

if verbose:
start_time = time_ini()
Expand Down
3 changes: 2 additions & 1 deletion vip_hci/preproc/recentering.py
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,8 @@ def cube_recenter_2dfit(array, xy=None, fwhm=4, subi_size=5, model='gauss',

if nproc == 1:
res = []
print('2d {}-fitting'.format(model))
if verbose:
print('2d {}-fitting'.format(model))
for i in Progressbar(range(n_frames), desc="frames", verbose=verbose):
if model == "2gauss":
args = [array, i, subi_size, pos_y, pos_x, debug, fwhm[i],
Expand Down
8 changes: 6 additions & 2 deletions vip_hci/stats/clip_sigma.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def _clip_array(array, lower_sigma, upper_sigma, bpm_mask_ori,
if bpm_mask_ori is None:
gpm_ori = np.ones(array.shape)
else:
gpm_ori = np.ones(array.shape)-bpm_mask_ori
gpm_ori = np.ones(array.shape) - bpm_mask_ori

ny, nx = array.shape
bpm = np.ones(array.shape)
Expand Down Expand Up @@ -331,7 +331,11 @@ def _clip_array(array, lower_sigma, upper_sigma, bpm_mask_ori,
x-hbox_l:x+hbox_r+1]
gp_arr = gpm_ori[y-hbox_b:y+hbox_t+1,
x-hbox_l:x+hbox_r+1]
neighbours = sub_arr[np.where(gp_arr)].flatten()
gp_idx = np.nonzero(gp_arr)
neighbours = []
for n, (i, j) in enumerate(zip(gp_idx[0], gp_idx[1])):
neighbours.append(sub_arr[i, j])
neighbours = np.array(neighbours)
neigh_list = []
remove_itself = True
for i in range(neighbours.shape[0]):
Expand Down

0 comments on commit becfc49

Please sign in to comment.