Commit f3bf73e1 authored by ljbing's avatar ljbing
Browse files

change to work on CONCERTO cluster

parent 18291445
......@@ -139,26 +139,30 @@ def CreateParallelJackkifes(jkiter, parity_threshold):
##############################################################
method = 211
min_detection_threshold = 4
photometry = True
detection = True
flux = np.geomspace(0.1, 10, 50) * u.mJy
flux = np.geomspace(0.1, 10, 50) * u.mJy #np.geomspace(0.1, 10, 50) for 1mm
nsim = 1000
ncores = 24
nsources = 50
parity_threshold = 1
parity_threshold = 0 # incomplete map when using 1 as threshold
band = '1mm'
outdir = Path("montecarlo_results/")
method_dir = Path(f'{method}')
outdir = Path(f"{band}")#montecarlo_results/
if 1:
np.random.seed(5)
flux = np.array([10]) * u.mJy
nsim = 1
ncores = 2
nsources = 2
outdir = Path("testdir")
#if 1:
# np.random.seed(5)
# flux = np.array([10]) * u.mJy
# nsim = 1
# ncores = 2
# nsources = 2
# outdir = Path("testdir")
filenamecomment = 'NewRealisation_'
##############################################################
......@@ -167,10 +171,15 @@ filenamecomment = 'NewRealisation_'
# "HLS091828_common_mode_one_block/v_1")
# DATA_DIR_SERVER = Path("/data/NIKA/Reduced/May2018/"
# "HLS091828_common_mode_one_block/v_1/")
DATA_DIR_SERVER = Path("/data/NIKA/Reduced/May2018/HLS091828_atm_and"
"_all_box_iter_IterativeMM_CosSinElevOffset/v_1")
DATA_DIR_MYPC = Path("/home/peter/Dokumente/Uni/Paris/Stage/data/v_1")
#DATA_DIR_SERVER = Path("/data/NIKA/Reduced/May2018/HLS091828_atm_and"
# "_all_box_iter_IterativeMM_CosSinElevOffset/v_1")
#DATA_DIR_MYPC = Path("/home/peter/Dokumente/Uni/Paris/Stage/data/v_1")
DATA_DIR_SERVER = Path(f"/data/PHOTOM/Reduced/23515M/GOODSNORTH/{method}/iter15/v_1")
DATA_DIR_MYPC = Path("/home/lbing/data/purity_completeness")
outdir = DATA_DIR_MYPC / method_dir / outdir
message = '''\
###############################################################
......@@ -195,7 +204,7 @@ timeprefix += filenamecomment
if not outdir.exists():
print('creating directory {}'.format(outdir))
outdir.mkdir()
os.makedirs(outdir)
print("Creating Jackkife Object")
......@@ -222,6 +231,7 @@ p = Pool(ncores)
if nsources == 0:
flux = np.array([0]) * u.mJy
ii = 0
for _flux in flux:
print("Creating {} Jackkife Maps".format(nsim))
......@@ -230,8 +240,19 @@ for _flux in flux:
for i in range(nsim):
jackknifes.append(jk_iter())
if ii == 0:
if i == 0:
jk_std = jackknifes[0].data
jk_std = jk_std[np.newaxis,:,:]
else:
jk_std = np.append(jk_std,jackknifes[i].data[np.newaxis,:,:],axis=0)
if ii == 0:
jk_std = np.std(jk_std,axis=0)
print('Done in {:.2f}s'.format(clock()-t0))
ii += 1
min_source_dist = 2 * jackknifes[0].beam.fwhm_pix.value
helpfunc = partial(fake_worker, **{'min_threshold':
......@@ -280,13 +301,15 @@ for _flux in flux:
immask = np.sum(immask, axis=0)
matchmask = np.sum(matchmask, axis=0)
fname = ('flux{:.2f}mJy_thresh{}_nsources{}_nsim{}_phot{}_detect{}.fits'
fname = ('flux{:.3f}mJy_thresh{}_nsources{}_nsim{}_phot{}_detect{}.fits'
.format(_flux.to_value(unit=u.mJy),
min_detection_threshold, nsources, nsim, photometry,
detection))
fname = timeprefix + fname
outfile = outdir / fname
stdname = f'stddev.fits'
stdfile = outdir / stdname
phdu = fits.PrimaryHDU(header=jackknifes[0].wcs.to_header())
phdu.header['influx'] = '{}'.format(_flux)
......@@ -304,4 +327,12 @@ for _flux in flux:
hdul.append(ImageHDU(data=matchmask, name='matchmask'))
hdul = fits.HDUList(hdul)
hdul.writeto(outfile, overwrite=False)
if ii == 0:
stdhdu = fits.PrimaryHDU()
stdhdu = [stdhdu]
stdhdu.append(ImageHDU(data=jk_std,name='stddev_from_jackknife',header=jackknifes[0].wcs.to_header()))
stdhdu = fits.HDUList(stdhdu)
stdhdu.writeto(stdfile,overwrite=False)
print('results written to {}'.format(outfile))
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