Commit 71e22c18 authored by LUSTIG Peter's avatar LUSTIG Peter

added photometry option in simulation

parent 05886a0a
......@@ -59,7 +59,7 @@ def get_size(obj, seen=None):
def fake_worker(img, min_threshold=2, nsources=8**2, flux=1*u.Jy,
within=(0, 1), cat_gen=pos_uniform, parity_threshold=1,
retmask=True, **kwargs):
retmask=True, photometry=False, **kwargs):
"""The completness purity worker, create a fake dataset from an jackknifed
image and return catalogs
......@@ -100,10 +100,18 @@ def fake_worker(img, min_threshold=2, nsources=8**2, flux=1*u.Jy,
# The gaussian fit from subpixel=True is very slow here...
mf_img.detect_sources(threshold=min_threshold)
if photometry:
img.phot_sources(sources=mf_img.sources, peak=False, psf=True)
sources = img.sources
else:
sources = mf_img.sources
fake_sources = mf_img.fake_sources
if retmask:
return mf_img.sources, mf_img.fake_sources, img.mask, mf_img.mask
return sources, fake_sources, img.mask, mf_img.mask
else:
return mf_img.sources, mf_img.fake_sources
return sources, fake_sources
plt.close('all')
......@@ -119,12 +127,16 @@ flux = np.array([10]) * u.mJy
nsim = 4
min_detection_threshold = 3
nsources = 2
nsources = 0
outdir = Path("montecarlo_results/")
outdir = Path("testdir")
#nsources = 0
photometry = True
ncores = 2
parity_threshold = 1
outdir = Path("montecarlo_results/")
outdir = Path("testdir")
timeprefix = '{date:%y%m%d_%H%M%S}_'.format(date=datetime.datetime.now())
if not outdir.exists():
......@@ -164,17 +176,6 @@ t0 = clock()
jk_iter = Jackknife(jk_filenames, n=nsim)
print('Done in {:.2f}s'.format(clock()-t0))
'''
jk_iter_list = [jk_iter] * nsim
jk_iter_list = [jk_iter]
for i in range(1, ncores):
jk_iter_list.append(Jackknife(jk_filenames, n=nsim))
jk_iter_list = jk_iter_list * int(np.ceil(nsim / ncores))
jk_iter_list = jk_iter_list[:nsim]
print(jk_iter_list)
'''
print("Creating {} Jackkife Maps".format(nsim))
jackknifes = []
for i in range(nsim):
......@@ -194,7 +195,8 @@ if nsources != 0:
'within': (0, 1),
'cat_gen': pos_uniform,
'dist_threshold': min_source_dist,
'parity_threshold': 0.5})
'parity_threshold': 0.5,
'photometry': photometry})
print('Simulation with {:.2f}...'.format(_flux))
......@@ -272,7 +274,8 @@ if nsources == 0:
'flux': None,
'nsources': 0,
'within': (0, 1),
'parity_threshold': 0.5})
'parity_threshold': 0.5,
'photometry': photometry})
print('Simulation without sources...')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment