From 6d6f043188c4f7892ead7a33f1ad1952554ebf4d Mon Sep 17 00:00:00 2001 From: VChristiaens Date: Mon, 22 Jul 2024 13:49:39 +0200 Subject: [PATCH 1/4] Bug fix for IPCA-ARDI with initialization with PCA-RDI-DI --- vip_hci/greedy/ipca_fullfr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vip_hci/greedy/ipca_fullfr.py b/vip_hci/greedy/ipca_fullfr.py index 4f1e0bbb..0ffd7302 100644 --- a/vip_hci/greedy/ipca_fullfr.py +++ b/vip_hci/greedy/ipca_fullfr.py @@ -334,7 +334,7 @@ def _blurring_3d(array, mask_center_sz, fwhm_sz=2): class_params, rot_options = separate_kwargs_dict( initial_kwargs=all_kwargs, parent_class=IPCA_Params ) - # Do the same to separate IROLL and ROLL params + # Do the same to separate IPCA and PCA params pca_params, ipca_params = separate_kwargs_dict( initial_kwargs=class_params, parent_class=PCA_Params ) @@ -371,7 +371,7 @@ def _blurring_3d(array, mask_center_sz, fwhm_sz=2): mask_rdi_tmp = algo_params.mask_rdi.copy() if algo_params.cube_ref is None: raise ValueError("cube_ref should be provided for RDI or RADI") - if algo_params.strategy == 'ARDI': + if algo_params.strategy == 'ARDI' and algo_params.mask_rdi is None: ref_cube = np.concatenate((algo_params.cube, algo_params.cube_ref), axis=0) else: From bf89d41b173b4c07689e7dc0b3f4a61d13af128a Mon Sep 17 00:00:00 2001 From: VChristiaens Date: Wed, 31 Jul 2024 19:12:50 +0200 Subject: [PATCH 2/4] Propagated nproc value from cube_recenter_via_speckles to cube_shift --- vip_hci/preproc/recentering.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vip_hci/preproc/recentering.py b/vip_hci/preproc/recentering.py index 5acffbe6..f8f08e47 100644 --- a/vip_hci/preproc/recentering.py +++ b/vip_hci/preproc/recentering.py @@ -2098,7 +2098,7 @@ def cube_recenter_via_speckles(cube_sci, cube_ref=None, alignment_iter=5, cum_x_shifts_sci = cum_x_shifts[1:(n + 1)] cube_reg_sci = cube_shift(cube_sci, cum_y_shifts_sci, cum_x_shifts_sci, imlib=imlib, interpolation=interpolation, - border_mode=border_mode) + border_mode=border_mode, nproc=nproc) if plot: plt.figure(figsize=vip_figsize) @@ -2124,7 +2124,7 @@ def cube_recenter_via_speckles(cube_sci, cube_ref=None, alignment_iter=5, cum_x_shifts_ref = cum_x_shifts[(n + 1):] cube_reg_ref = cube_shift(cube_ref, cum_y_shifts_ref, cum_x_shifts_ref, imlib=imlib, interpolation=interpolation, - border_mode=border_mode) + border_mode=border_mode, nproc=nproc) if ref_star: if full_output: From 2ed8e350df746579fe90cea00d8f8be5f34ce8d0 Mon Sep 17 00:00:00 2001 From: VChristiaens Date: Wed, 31 Jul 2024 19:28:39 +0200 Subject: [PATCH 3/4] Attempt to add multiprocessing support for Windows users --- vip_hci/config/utils_conf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vip_hci/config/utils_conf.py b/vip_hci/config/utils_conf.py index 1938ef14..c5d42fd8 100644 --- a/vip_hci/config/utils_conf.py +++ b/vip_hci/config/utils_conf.py @@ -471,7 +471,13 @@ def pool_map(nproc, fkt, *args, **kwargs): if not _generator: res = list(res) else: - multiprocessing.set_start_method("fork", force=True) + # Check available start methods and pick accordingly (machine-dependent) + avail_methods = multiprocessing.get_all_start_methods() + if 'fork' in avail_methods: + # faster when available + multiprocessing.set_start_method("fork", force=True) + else: + multiprocessing.set_start_method("spawn", force=True) from multiprocessing import Pool # deactivate multithreading From a2ce534a66ab07b91758edca9143b485611af7c0 Mon Sep 17 00:00:00 2001 From: VChristiaens Date: Wed, 31 Jul 2024 20:07:28 +0200 Subject: [PATCH 4/4] Added more cases for multiprocessing start methods, and try/except statements depending on error/warning raised --- vip_hci/config/utils_conf.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vip_hci/config/utils_conf.py b/vip_hci/config/utils_conf.py index c5d42fd8..2b24a9b7 100644 --- a/vip_hci/config/utils_conf.py +++ b/vip_hci/config/utils_conf.py @@ -15,6 +15,7 @@ from inspect import signature, Parameter from functools import wraps import multiprocessing +import warnings from vip_hci import __version__ sep = "―" * 80 @@ -475,9 +476,16 @@ def pool_map(nproc, fkt, *args, **kwargs): avail_methods = multiprocessing.get_all_start_methods() if 'fork' in avail_methods: # faster when available - multiprocessing.set_start_method("fork", force=True) + warnings.filterwarnings("error") # allows to catch warning as error + try: + multiprocessing.set_start_method("fork", force=True) + except (DeprecationWarning, OSError): + multiprocessing.set_start_method("spawn", force=True) + elif 'forkserver' in avail_methods: + multiprocessing.set_start_method("forkserver", force=True) else: multiprocessing.set_start_method("spawn", force=True) + warnings.resetwarnings() # reset warning behaviour to default from multiprocessing import Pool # deactivate multithreading