From 0d6c765a0588eb9816e813d171c17b7c34acf6f6 Mon Sep 17 00:00:00 2001 From: Alexis Brandekers Date: Tue, 9 Jan 2024 02:11:11 +0100 Subject: [PATCH] Set start method to spawn in multiprocess --- pipe/make_multi_psf.py | 5 +++++ pipe/multi_cent.py | 5 +++++ pipe/multi_level.py | 6 ++++++ pipe/multi_psf.py | 5 +++++ pipe/multi_star.py | 5 +++++ pipe/read.py | 2 +- 6 files changed, 27 insertions(+), 1 deletion(-) diff --git a/pipe/make_multi_psf.py b/pipe/make_multi_psf.py index 2fdecf7..8fa0518 100644 --- a/pipe/make_multi_psf.py +++ b/pipe/make_multi_psf.py @@ -17,6 +17,11 @@ from .psf_model import map_coo, psf_model from .pipe_statistics import sigma_clip +try: + mp.set_start_method('spawn', force=True) +except RuntimeError: + pass + class MultiPSFMaker: """ Collects routines to compute the PSF from data contained in diff --git a/pipe/multi_cent.py b/pipe/multi_cent.py index 6513357..2fd18d4 100644 --- a/pipe/multi_cent.py +++ b/pipe/multi_cent.py @@ -17,6 +17,11 @@ binary_lucy as cent_binary_deconvolve ) +try: + mp.set_start_method('spawn', force=True) +except RuntimeError: + pass + def deconvolve(psf_spline, cube, xi, yi, radius=30, subrad=3, nthreads=16): """Use deconvolution to compute PSF centres of frames in cube. xi, yi diff --git a/pipe/multi_level.py b/pipe/multi_level.py index 8435e10..4d51a74 100644 --- a/pipe/multi_level.py +++ b/pipe/multi_level.py @@ -11,6 +11,12 @@ import multiprocessing as mp from .level import estimate as level_estimate +try: + mp.set_start_method('spawn', force=True) +except RuntimeError: + pass + + def estimate(data_cube, nthreads=16): """Estimate background levels of scattered light for datacube. Assumes background stars have been subtracted or masked. Returns array of estimated diff --git a/pipe/multi_psf.py b/pipe/multi_psf.py index 4b9c14e..25e6a29 100644 --- a/pipe/multi_psf.py +++ b/pipe/multi_psf.py @@ -12,6 +12,11 @@ import multiprocessing as mp from .psf import fit as psf_fit, fit_binary as psf_fit_binary +try: + mp.set_start_method('spawn', force=True) +except RuntimeError: + pass + def fit(psf_list, data_cube, noise_cube, mask, xc, yc, fitrad=50, defrad=70, krn_scl=0.3, diff --git a/pipe/multi_star.py b/pipe/multi_star.py index e705f09..ad673c4 100644 --- a/pipe/multi_star.py +++ b/pipe/multi_star.py @@ -15,6 +15,11 @@ from .syntstar import make_bg_frame, refine_bg_model from .syntstar import make_bg_psf_mask, make_bg_circ_mask +try: + mp.set_start_method('spawn', force=True) +except RuntimeError: + pass + def make_star_bg(shape, psf_ids, psfs, work_cats, skip=[0], krn_scl=0.3, krn_rad=3, nthreads=1): in_params = [] diff --git a/pipe/read.py b/pipe/read.py index e5bde2d..78e1f08 100644 --- a/pipe/read.py +++ b/pipe/read.py @@ -362,7 +362,7 @@ def save_bg_star_phot_fits(filename, t, bjd, fluxes, gaia_IDs, header): tab = fits.BinTableHDU.from_columns(c, header=header) for n in range(fluxes.shape[1]): key = f'TTYPE{n+3}' - tab.header[key] = (tab.header[key], f'Gaia {gaia_IDs[n]}') + tab.header[key] = (tab.header[key], f'{gaia_IDs[n]}') tab.writeto(filename, overwrite=True, checksum=True)