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

clustering option to search for bright artifacts

parent 1fbb77c3
No related branches found
No related tags found
No related merge requests found
...@@ -598,7 +598,8 @@ def write_df_voronoi(df, vor, output=None): ...@@ -598,7 +598,8 @@ def write_df_voronoi(df, vor, output=None):
def voronoi_clustering(fig, ax, df, wcs, resid_data, nbright, nclusters, def voronoi_clustering(fig, ax, df, wcs, resid_data, nbright, nclusters,
boxsize=250, same_source_radius=5, central_region=True): boxsize=250, same_source_radius=5, central_region=True,
search_artifacts=False):
""" """
Use Voronoi clustering instead of fixed radius around sources Use Voronoi clustering instead of fixed radius around sources
""" """
...@@ -606,7 +607,6 @@ def voronoi_clustering(fig, ax, df, wcs, resid_data, nbright, nclusters, ...@@ -606,7 +607,6 @@ def voronoi_clustering(fig, ax, df, wcs, resid_data, nbright, nclusters,
# logging.info('Checking {} brightest model components'.format(nbright)) # logging.info('Checking {} brightest model components'.format(nbright))
bright_df = df.sort_values('I')[::-1][['ra', 'dec', 'I']] bright_df = df.sort_values('I')[::-1][['ra', 'dec', 'I']]
# rms = mad(resid_data)
logging.info('Getting measures for the potential clusters...') logging.info('Getting measures for the potential clusters...')
clusters = [] clusters = []
clusters_centers = [] # clusters_centers = [] #
...@@ -622,11 +622,16 @@ def voronoi_clustering(fig, ax, df, wcs, resid_data, nbright, nclusters, ...@@ -622,11 +622,16 @@ def voronoi_clustering(fig, ax, df, wcs, resid_data, nbright, nclusters,
if clusters and any([c.separation(_).arcmin<same_source_radius for _ in clusters]): if clusters and any([c.separation(_).arcmin<same_source_radius for _ in clusters]):
continue continue
# search for artifacts:
if search_artifacts:
small_resid = resid_data[py-boxsize:py+boxsize, px-boxsize:px+boxsize] small_resid = resid_data[py-boxsize:py+boxsize, px-boxsize:px+boxsize]
ellipse_mean, ecc, amaj, numpix = ellipses_coh(small_resid, amin=20, amax=boxsize-1, dr=1.0) ellipse_mean, ecc, amaj, numpix = ellipses_coh(small_resid, amin=20, amax=boxsize-1, dr=1.0)
rms = mad(resid_data)
# Uncomment the condition to search for artifacts: if abs(ellipse_mean/rms) > 1.4:
# if abs(ellipse_mean/rms) > 1.4: clusters_centers.append([ra, dec])
clusters.append(c)
else:
clusters_centers.append([ra, dec]) clusters_centers.append([ra, dec])
clusters.append(c) clusters.append(c)
print(ra, dec) print(ra, dec)
...@@ -898,7 +903,7 @@ def write_ds9(fname, h5, image, points=None): ...@@ -898,7 +903,7 @@ def write_ds9(fname, h5, image, points=None):
def main(img, resid, model, clustering_method='Voronoi', add_manual=False, nclusters=10, boxsize=250, def main(img, resid, model, clustering_method='Voronoi', add_manual=False, nclusters=10, boxsize=250,
nbright=80, cluster_radius=5, cluster_overlap=1.6): nbright=80, cluster_radius=5, cluster_overlap=1.6, voronoi_search_artifacts=False):
""" """
clustering clustering
methods: methods:
...@@ -933,7 +938,7 @@ def main(img, resid, model, clustering_method='Voronoi', add_manual=False, nclus ...@@ -933,7 +938,7 @@ def main(img, resid, model, clustering_method='Voronoi', add_manual=False, nclus
if clustering_method.lower() == 'voronoi': if clustering_method.lower() == 'voronoi':
vor = voronoi_clustering(fig, ax, df, wcs, resid_data, nbright, nclusters=nclusters) vor = voronoi_clustering(fig, ax, df, wcs, resid_data, nbright, nclusters=nclusters, search_artifacts=voronoi_search_artifacts)
write_df_voronoi(df, vor, output=output) write_df_voronoi(df, vor, output=output)
elif clustering_method.lower() == 'auto': elif clustering_method.lower() == 'auto':
...@@ -955,15 +960,4 @@ def main(img, resid, model, clustering_method='Voronoi', add_manual=False, nclus ...@@ -955,15 +960,4 @@ def main(img, resid, model, clustering_method='Voronoi', add_manual=False, nclus
### if __name__ == "__main__": ### if __name__ == "__main__":
if __name__ == "__main__": if __name__ == "__main__":
base = '/kutkin/apipeline/to_validate/210109001_06-dical-'
img = base + 'image.fits'
resid = base + 'residual.fits'
model = base + 'sources.txt'
h5 = ''
# img = sys.argv[1]
# resid = sys.argv[2]
# model = sys.argv[3]
main(img, resid, model, clustering_method='Voronoi', nclusters=6) main(img, resid, model, clustering_method='Voronoi', nclusters=6)
...@@ -9,9 +9,9 @@ split: ...@@ -9,9 +9,9 @@ split:
nchan: 0 # 0 means till the end nchan: 0 # 0 means till the end
####################### NVSS calibration ###################################### ####################### NVSS calibration ######################################
nvss: False
# calibrate against the NVSS catalog. Generally works well # calibrate against the NVSS catalog. Generally works well
# except for cases with and extended Apertif source unresolved by NVSS # except for cases with an extended Apertif source unresolved by NVSS
nvss: False
nvsscal: nvsscal:
clip_model: 0.001 # Clip NVSS model to not to have sources weaker (Jy) clip_model: 0.001 # Clip NVSS model to not to have sources weaker (Jy)
solint: 60 solint: 60
...@@ -32,7 +32,7 @@ preflag: # See DP3 steps.preflag ...@@ -32,7 +32,7 @@ preflag: # See DP3 steps.preflag
blmin: # in meters blmin: # in meters
freqrange: # [1440 .. 1470 MHz] # freq range to flag freqrange: # [1440 .. 1470 MHz] # freq range to flag
clean1: # wsclean setup clean1: # wsclean setup (see https://wsclean.readthedocs.io/en/latest/)
imagesize: 3072 imagesize: 3072
pixelsize: 3 pixelsize: 3
multifreq: 0 multifreq: 0
...@@ -100,7 +100,8 @@ cluster: ...@@ -100,7 +100,8 @@ cluster:
# the following is only for 'auto' and 'manual' mathods: # the following is only for 'auto' and 'manual' mathods:
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
clustering_method : voronoi # or auto clustering_method : voronoi # can also be auto or manual
voronoi_search_artifacts: False # set True to search for artifacts around bright sources
add_manual: False add_manual: False
######################## DD CALIBRATION ####################### ######################## DD CALIBRATION #######################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment