Skip to content

Commit

Permalink
Set start method to spawn in multiprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
alphapsa committed Jan 9, 2024
1 parent 18cee38 commit 0d6c765
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pipe/make_multi_psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pipe/multi_cent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions pipe/multi_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pipe/multi_psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions pipe/multi_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion pipe/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 0d6c765

Please sign in to comment.