Skip to content
Snippets Groups Projects
Commit 964f5c64 authored by Alexander Kutkin's avatar Alexander Kutkin
Browse files

added ddcal step

parent 3a98e336
No related branches found
No related tags found
No related merge requests found
...@@ -456,7 +456,7 @@ def main(img, resid, model, auto=True, add_manual=False, nclusters=5, boxsize=25 ...@@ -456,7 +456,7 @@ def main(img, resid, model, auto=True, add_manual=False, nclusters=5, boxsize=25
nbright=80, cluster_radius=5, cluster_overlap=1.6): nbright=80, cluster_radius=5, cluster_overlap=1.6):
path = os.path.split(os.path.abspath(img))[0] path = os.path.split(os.path.abspath(img))[0]
output = os.path.join(path, 'clustered.txt') output = os.path.spitext(img)[0]+'-clustered.txt'
df = pd.read_csv(model, skipinitialspace=True) df = pd.read_csv(model, skipinitialspace=True)
df['ra'] = df.Ra.apply(ra2deg) df['ra'] = df.Ra.apply(ra2deg)
...@@ -492,6 +492,7 @@ def main(img, resid, model, auto=True, add_manual=False, nclusters=5, boxsize=25 ...@@ -492,6 +492,7 @@ def main(img, resid, model, auto=True, add_manual=False, nclusters=5, boxsize=25
write_df(df, clusters, output=output) write_df(df, clusters, output=output)
fig.tight_layout() fig.tight_layout()
fig.savefig(path+'/clustering.png') fig.savefig(path+'/clustering.png')
return output
### if __name__ == "__main__": ### if __name__ == "__main__":
......
...@@ -26,6 +26,8 @@ from astropy.time import Time ...@@ -26,6 +26,8 @@ from astropy.time import Time
import astropy.units as u import astropy.units as u
from astropy.io import fits from astropy.io import fits
from cluster import main as cluster
_POOL_TIME = 300 # SECONDS _POOL_TIME = 300 # SECONDS
_MAX_TIME = 1 * 3600 # SECONDS _MAX_TIME = 1 * 3600 # SECONDS
...@@ -325,6 +327,8 @@ def main(msin, outbase=None, cfgfile='imcal.yml'): ...@@ -325,6 +327,8 @@ def main(msin, outbase=None, cfgfile='imcal.yml'):
img2 = outbase + '_2' img2 = outbase + '_2'
img3 = outbase + '_3' img3 = outbase + '_3'
img_final = outbase img_final = outbase
img_ddsub = outbase + '-ddsub'
img_ddcal = outbase + '-ddcal'
mask0 = 'mask0.fits' mask0 = 'mask0.fits'
mask1 = 'mask1.fits' mask1 = 'mask1.fits'
...@@ -337,13 +341,15 @@ def main(msin, outbase=None, cfgfile='imcal.yml'): ...@@ -337,13 +341,15 @@ def main(msin, outbase=None, cfgfile='imcal.yml'):
dical1 = outbase + '_dical1.MS' dical1 = outbase + '_dical1.MS'
dical2 = outbase + '_dical2.MS' dical2 = outbase + '_dical2.MS'
dical3 = outbase + '_dical3.MS' dical3 = outbase + '_dical3.MS'
ddsub = outbase + '_ddsub.MS'
h5_1 = outbase + '_dical1.h5' h5_1 = outbase + '_dical1.h5'
h5_2 = outbase + '_dical2.h5' h5_2 = outbase + '_dical2.h5'
h5_3 = outbase + '_dical3.h5' h5_3 = outbase + '_dical3.h5'
h5_dd = outbase + '_dd.h5'
if os.path.exists(img_final+'-image.fits'): if os.path.exists(img_ddcal+'-image.fits'):
logging.info('The final image exists. Exiting...') logging.info('The final image exists. Exiting...')
return 0 return 0
...@@ -398,6 +404,31 @@ def main(msin, outbase=None, cfgfile='imcal.yml'): ...@@ -398,6 +404,31 @@ def main(msin, outbase=None, cfgfile='imcal.yml'):
if (not os.path.exists(img_final +'-image.fits')) and (not os.path.exists(img_final +'-MFS-image.fits')): if (not os.path.exists(img_final +'-image.fits')) and (not os.path.exists(img_final +'-MFS-image.fits')):
wsclean(dical3, outname=img_final, **cfg['clean4']) wsclean(dical3, outname=img_final, **cfg['clean4'])
# Cluster
if (not os.path.exists(img_final +'-clustered.txt')):
clustered_model = cluster(img_final+'-image.fits', img_final+'-residual.fits', img_final+'-sources.txt', **cfg['cluster'])
# Makesourcedb
clustered_sdb = makesourcedb(clustered_model, img_final+'-clustered.sourcedb')
# DDE calibration + peeling everything
if (not os.path.exists(ddsub)):
ddsub, h5out = ddecal(dical3, clustered_sdb, msout=ddsub, h5out=h5_dd,
solint=120, mode='diagonal')
# view the solutions and save figure
view_sols(h5_dd)
if (not os.path.exists(img_ddsub+'-image.fits')):
wsclean(ddsub, outname=img_ddsub, **cfg['clean4'])
aomodel = bbs2model(img_final+'-sources.txt', img_final+'-model.ao')
render(img_ddsub+'-image.fits', aomodel, out=img_ddcal+'-image.fits')
return 0 return 0
......
...@@ -64,7 +64,7 @@ dical3: ...@@ -64,7 +64,7 @@ dical3:
solint: 800 solint: 800
mode: 'diagonal' mode: 'diagonal'
uvlambdamin: 500 # Ignore baselines / channels with UV < uvlambdamin wavelengths. uvlambdamin: 500 # Ignore baselines / channels with UV < uvlambdamin wavelengths.
cal_nchan: 30 # number of chans with the same solutions cal_nchan: 31 # number of chans with the same solutions
clean4: clean4:
imagesize: 3072 imagesize: 3072
...@@ -76,27 +76,38 @@ clean4: ...@@ -76,27 +76,38 @@ clean4:
fitsmask: 'mask2.fits' fitsmask: 'mask2.fits'
kwstring: '-use-wgridder -parallel-deconvolution 1400 -parallel-gridding 8 -deconvolution-channels 3 -weight briggs 0.0' kwstring: '-use-wgridder -parallel-deconvolution 1400 -parallel-gridding 8 -deconvolution-channels 3 -weight briggs 0.0'
### END
####################### CLUSTERING ####################### ####################### CLUSTERING #######################
#cluster: cluster:
# nbright: 80 # number of brightest clean components (CC) to check for artefacts nbright: 80 # number of brightest clean components (CC) to check for artefacts
# boxsize: 250 # the boxsize around CC in pixels where to check for artefacts boxsize: 250 # the boxsize around CC in pixels where to check for artefacts
# nclusters: 10 # number of clusters ('auto' -- to set automatically) nclusters: 10 # number of clusters ('auto' -- to set automatically)
# cluster_radius: 5 # arcmin cluster_radius: 5 # arcmin
# cluster_overlap: 1.6 # if lower than 2 clusters can intersect cluster_overlap: 1.6 # if lower than 2 clusters can intersect
# auto: True auto: True
# add_manual: False add_manual: False
#
######################## DD CALIBRATION ####################### ######################## DD CALIBRATION #######################
#ddcal: # see DPPP/DDECal documentation ddcal: # see DPPP/DDECal documentation
# solint: 120 # Solution interval in timesteps (1 ~ 30sec for Apertif). solint: 120 # Solution interval in timesteps (1 ~ 30sec for Apertif).
# mode: 'diagonal' # Type of constraint to apply. mode: 'diagonal' # Type of constraint to apply.
# nchan: 15 # Number of channels in each channel block, for which the solution is assumed to be constant. nfreq: 15 # Number of channels in each channel block, for which the solution is assumed to be constant.
# startchan: 0 startchan: 0
# nchan: 192 nchan: 0
# uvlambdamin: 500 # Ignore baselines / channels with UV < uvlambdamin wavelengths. uvlambdamin: 500 # Ignore baselines / channels with UV < uvlambdamin wavelengths.
#
clean5:
imagesize: 3072
pixelsize: 3
multifreq: 8
automask: 4.5
autothresh: 0.5
multiscale: True
fitsmask: 'mask2.fits'
kwstring: '-use-wgridder -parallel-deconvolution 1400 -parallel-gridding 8 -deconvolution-channels 3 -weight briggs 0.0'
### END
## TODO: ## TODO:
#plotsols: #plotsols:
# #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment