Skip to content

Commit

Permalink
Minor changes to arguments of DFT-based recentering function for rece…
Browse files Browse the repository at this point in the history
…ntering tests to pass
  • Loading branch information
VChristiaens committed Feb 7, 2024
1 parent 54926d9 commit c0371ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
23 changes: 10 additions & 13 deletions tests/pre_3_10/test_preproc_recentering.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,14 @@ def test_dft(debug=False):
randay[0] = 0

# ===== odd, subi_size=None
size = 21
size = 25
mean = size // 2
cube = create_cube_with_gauss2d(shape=(n_frames, size, size), mean=mean,
stddev=3.)
stddev=4.)

method_args = dict(
center_fr1=(mean, mean),
subi_size=15,
subi_size=19,
negative=False,
**method_args_additional
)
Expand All @@ -444,13 +444,13 @@ def test_dft(debug=False):
)

# ===== even, subi_size
size = 20
size = 26
mean = size // 2 # - 0.5 # 0-indexed
cube = create_cube_with_gauss2d(shape=(n_frames, size, size), mean=mean,
stddev=3.)
stddev=4.)

method_args = dict(
center_fr1=(mean, mean), subi_size=16, negative=False,
center_fr1=(mean, mean), subi_size=20, negative=False,
**method_args_additional
)
do_recenter(
Expand All @@ -465,7 +465,7 @@ def test_dft(debug=False):
)

# ===== odd negative (ring), subi_size
size = 21
size = 25
mean = size // 2
cube = create_cube_with_gauss2d_ring(
shape=(n_frames, size, size), mean=mean, stddev_outer=3, stddev_inner=2
Expand All @@ -486,7 +486,7 @@ def test_dft(debug=False):
)

# ===== even negative (ring), subi_size=None
size = 20
size = 26
mean = size // 2 # - 0.5
cube = create_cube_with_gauss2d_ring(
shape=(n_frames, size, size), mean=mean, stddev_outer=3, stddev_inner=2
Expand Down Expand Up @@ -708,17 +708,14 @@ def test_radon(debug=False):
cropsize=131,
satspots_cfg='custom',
theta_0=52,
mask_center=40,
mask_center=30,
verbose=True,
imlib="opencv",
hpf=True,
filter_fwhm=2 * np.mean(fwhm),
)
# # first recenter with Radon to make sure it is well recentered
try:
cube = cube_recenter_radon(cube, **method_args)
except:
pass
cube = cube_recenter_radon(cube, **method_args)

# ===== shift
shift_magnitude = 2
Expand Down
5 changes: 2 additions & 3 deletions vip_hci/preproc/badframes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#! /usr/bin/env python

"""
Module with functions for outlier frame detection.
"""
Expand Down Expand Up @@ -86,8 +85,8 @@ def cube_detect_badfr_pxstats(array, mode='annulus', in_radius=10, width=10,
if window is None:
window = n//3
mean_smooth = pn.Series(mean_values).rolling(window, center=True).mean()
mean_smooth = mean_smooth.fillna(method='backfill')
mean_smooth = mean_smooth.fillna(method='ffill')
mean_smooth = mean_smooth.bfill() # fillna(method='backfill')
mean_smooth = mean_smooth.ffill() # fillna(method='ffill')
sigma = np.std(mean_values)
bad_index_list = []
good_index_list = []
Expand Down
8 changes: 4 additions & 4 deletions vip_hci/preproc/recentering.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,16 +866,16 @@ def _center_radon(array, cropsize=None, hsize=1., step=0.1,
threshold=False, sigfactor=1, debug=debug,
full_output=True)
# optimal shift -> optimal position
opt_yind = float(fit_res['centroid_y'])
opt_xind = float(fit_res['centroid_x'])
opt_yind = float(fit_res['centroid_y'].iloc[0])
opt_xind = float(fit_res['centroid_x'].iloc[0])
opt_yshift = -hsize + opt_yind*step
opt_xshift = -hsize + opt_xind*step
optimy = ori_cent_y - opt_yshift
optimx = ori_cent_x - opt_xshift

# find uncertainty on centering
unc_y = float(fit_res['fwhm_y'])*step
unc_x = float(fit_res['fwhm_x'])*step
unc_y = float(fit_res['fwhm_y'].iloc[0])*step
unc_x = float(fit_res['fwhm_x'].iloc[0])*step
dyx = (unc_y, unc_x) # np.sqrt(unc_y**2 + unc_x**2)

# Replace the position found by Gaussian fit
Expand Down

0 comments on commit c0371ff

Please sign in to comment.