Skip to content

Commit

Permalink
Merge pull request #558 from VChristiaens/master
Browse files Browse the repository at this point in the history
New options for bad pixel correction and low-pass filters, and other minor improvements
  • Loading branch information
VChristiaens authored Nov 25, 2022
2 parents aed258b + ba749e0 commit 9b100a2
Show file tree
Hide file tree
Showing 13 changed files with 196 additions and 136 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ scipy
astropy
photutils
scikit-learn
scikit-image<=0.18.3
scikit-image>0.17.0, <=0.18.3
emcee==2.2.1
nestle
corner
Expand Down
32 changes: 16 additions & 16 deletions tests/test_metrics_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,44 +36,44 @@ def get_frame_snrmap(example_dataset_adi):

def test_detection_log(get_frame_snrmap):
res_frame, coord, fwhm = get_frame_snrmap
table = detection(res_frame, fwhm, psf=None, mode='log', plot=False)
y, x = detection(res_frame, fwhm, psf=None, mode='log', plot=False)
check = False
for i in range(len(table.y)):
if np.allclose(table.y[i], coord[0], atol=2) and \
np.allclose(table.x[i], coord[1], atol=2):
for i in range(len(y)):
if np.allclose(y[i], coord[0], atol=2) and \
np.allclose(x[i], coord[1], atol=2):
check = True
assert check


def test_detection_dog(get_frame_snrmap):
res_frame, coord, fwhm = get_frame_snrmap
table = detection(res_frame, fwhm, psf=None, mode='dog', plot=False)
y, x = detection(res_frame, fwhm, psf=None, mode='dog', plot=False)
check = False
for i in range(len(table.y)):
if np.allclose(table.y[i], coord[0], atol=2) and \
np.allclose(table.x[i], coord[1], atol=2):
for i in range(len(y)):
if np.allclose(y[i], coord[0], atol=2) and \
np.allclose(x[i], coord[1], atol=2):
check = True
assert check


def test_detection_lpeaks(get_frame_snrmap):
res_frame, coord, fwhm = get_frame_snrmap
table = detection(res_frame, fwhm, psf=None, mode='lpeaks', plot=False)
y, x = detection(res_frame, fwhm, psf=None, mode='lpeaks', plot=False)
check = False
for i in range(len(table.y)):
if np.allclose(table.y[i], coord[0], atol=2) and \
np.allclose(table.x[i], coord[1], atol=2):
for i in range(len(y)):
if np.allclose(y[i], coord[0], atol=2) and \
np.allclose(x[i], coord[1], atol=2):
check = True
assert check


def test_detection_snrmap(get_frame_snrmap):
res_frame, coord, fwhm = get_frame_snrmap
table = detection(res_frame, fwhm, psf=None, mode='snrmapf',
y, x = detection(res_frame, fwhm, psf=None, mode='snrmapf',
plot=False, snr_thresh=5, nproc=2)
check = False
for i in range(len(table.y)):
if np.allclose(table.y[i], coord[0], atol=2) and \
np.allclose(table.x[i], coord[1], atol=2):
for i in range(len(y)):
if np.allclose(y[i], coord[0], atol=2) and \
np.allclose(x[i], coord[1], atol=2):
check = True
assert check
2 changes: 1 addition & 1 deletion vip_hci/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.3.2"
__version__ = "1.3.3"


from . import preproc
Expand Down
2 changes: 1 addition & 1 deletion vip_hci/fits/fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def open_fits(fitsfilename, n=0, header=False, ignore_missing_end=False,
precision=np.float32, return_memmap=False, verbose=True,
**kwargs):
"""
Load a fits file into a memory as numpy array.
Load a fits file into memory as numpy array.
Parameters
----------
Expand Down
13 changes: 7 additions & 6 deletions vip_hci/fm/negfc_fmerit.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def chisquare(modelParameters, cube, angs, psfs_norm, fwhm, annulus_width,
Parameters
----------
modelParameters: tuple
The model parameters, typically (r, theta, flux). Where flux can be a
1d array if cube is 4d.
The model parameters: (r, theta, flux) for a 3D input cube, or
(r, theta, f1, ..., fN) for a 4D cube with N spectral channels.
cube: 3d or 4d numpy ndarray
Input ADI or ADI+IFS cube.
angs: numpy.array
Expand Down Expand Up @@ -317,7 +317,7 @@ def get_values_optimize(cube, angs, ncomp, annulus_width, aperture_radius,
nproc=nproc)

elif algo == pca_annular:

tol = algo_options.get('tol', 1e-1)
min_frames_lib = algo_options.get('min_frames_lib', 2)
max_frames_lib = algo_options.get('max_frames_lib', 200)
Expand All @@ -327,12 +327,12 @@ def get_values_optimize(cube, angs, ncomp, annulus_width, aperture_radius,
crop_sz = int(2*np.ceil(radius_int+annulus_width+1))
if not crop_sz % 2:
crop_sz += 1
if crop_sz < cube.shape[1] and crop_sz < cube.shape[2]:
pad = int((cube.shape[1]-crop_sz)/2)
if crop_sz < cube.shape[-2] and crop_sz < cube.shape[-1]:
pad = int((cube.shape[-2]-crop_sz)/2)
crop_cube = cube_crop_frames(cube, crop_sz, verbose=False)
else:
crop_cube = cube

pad = 0
res_tmp = pca_annular(crop_cube, angs, radius_int=radius_int, fwhm=fwhm,
asize=annulus_width, delta_rot=delta_rot,
ncomp=ncomp, svd_mode=svd_mode, scaling=scaling,
Expand Down Expand Up @@ -527,6 +527,7 @@ def get_mu_and_sigma(cube, angs, ncomp, annulus_width, aperture_radius, fwhm,
pad = int((cube.shape[1]-crop_sz)/2)
crop_cube = cube_crop_frames(cube, crop_sz, verbose=False)
else:
pad=0
crop_cube = cube

pca_res_tmp = pca_annular(crop_cube, angs, radius_int=radius_int,
Expand Down
1 change: 1 addition & 0 deletions vip_hci/fm/negfc_simplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ def firstguess(cube, angs, psfn, ncomp, planets_xy_coord, fwhm=4,
transmission=transmission,
mu_sigma=mu_sigma, weights=weights,
plot=plot, verbose=verbose, save=save)

r_pre = res_init[0]
theta_pre = res_init[1]
f_pre = res_init[2:]
Expand Down
6 changes: 3 additions & 3 deletions vip_hci/metrics/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def detection(array, fwhm=4, psf=None, mode='lpeaks', bkg_sigma=5,
Two vectors with the y and x coordinates of the centers of the sources
(potential planets).
If full_output is True then a table with all the candidates that passed the
2d Gaussian fit constrains and their S/N is returned.
2d Gaussian fit constrains and the S/N threshold is returned.
Note
----
Expand Down Expand Up @@ -377,9 +377,9 @@ def print_abort():
print(table_full)

if full_output:
return table_full
else:
return table
else:
return yy_final, xx_final


def peak_coordinates(obj_tmp, fwhm, approx_peak=None, search_box=None,
Expand Down
Loading

0 comments on commit 9b100a2

Please sign in to comment.