From 94b8edf81760a921ee62fc8e623baaa80b783d55 Mon Sep 17 00:00:00 2001 From: Athanaseus Javas Ramaila Date: Fri, 21 Oct 2022 11:53:08 +0200 Subject: [PATCH 1/3] Log a warning if no online candidates are not found --- aimfast/aimfast.py | 74 +++++++++++++++++++++++--------------------- aimfast/auxiliary.py | 55 ++++++++++++++++---------------- 2 files changed, 66 insertions(+), 63 deletions(-) diff --git a/aimfast/aimfast.py b/aimfast/aimfast.py index 4edf79f..a1503bc 100644 --- a/aimfast/aimfast.py +++ b/aimfast/aimfast.py @@ -3336,7 +3336,7 @@ def main(): models = args.online sourcery = args.sourcery threshold = args.thresh - width = args.width or '4.0d' + width = args.width or '5.0d' LOGGER.info(f'Using sky width of {width}') catalog_prefix = args.catalog_name or 'default' online_catalog = args.online_catalog @@ -3359,45 +3359,47 @@ def main(): else: LOGGER.error('Please supply central coordinates using -ptc. See --help') - get_online_catalog(catalog=online_catalog.upper(), centre_coord=centre_coord, - width='3.0d', thresh=threshold, - catalog_table=catalog_name) + table = get_online_catalog(catalog=online_catalog.upper(), centre_coord=centre_coord, + width='5.0d', thresh=threshold, catalog_table=catalog_name) - for i, ims in enumerate(models): - image1 = ims[0] - if image1.endswith('.fits'): - configfile = 'default_sf_config.yml' - generate_default_config(configfile) - sf_params1 = get_sf_params(configfile) - sf_params1[sourcery]['filename'] = image1 - out1 = source_finding(sf_params1, sourcery) - image1 = out1 + if table: + for i, ims in enumerate(models): + image1 = ims[0] + if image1.endswith('.fits'): + configfile = 'default_sf_config.yml' + generate_default_config(configfile) + sf_params1 = get_sf_params(configfile) + sf_params1[sourcery]['filename'] = image1 + out1 = source_finding(sf_params1, sourcery) + image1 = out1 - images_list.append( - [dict(label="{}-model_a_{}".format(args.label, i), - path=image1), - dict(label="{}-model_b_{}".format(args.label, i), - path=catalog_name)]) + images_list.append( + [dict(label="{}-model_a_{}".format(args.label, i), + path=image1), + dict(label="{}-model_b_{}".format(args.label, i), + path=catalog_name)]) - output_dict = compare_models(images_list, - tolerance=args.tolerance, - shape_limit=args.shape_limit, - off_axis=args.off_axis, - all_sources=args.all, - closest_only=args.closest_only, - prefix=args.htmlprefix, - flux_plot=args.fluxplot, - ftitles=args.ftitles, - fxlabels=args.fxlabels, - fylabels=args.fylabels, - title_size=args.tsize, - x_label_size=args.xsize, - y_label_size=args.ysize, - legend_size=args.legsize, - xmajor_size=args.xmaj_size, - ymajor_size=args.ymaj_size, - svg=svg) + output_dict = compare_models(images_list, + tolerance=args.tolerance, + shape_limit=args.shape_limit, + off_axis=args.off_axis, + all_sources=args.all, + closest_only=args.closest_only, + prefix=args.htmlprefix, + flux_plot=args.fluxplot, + ftitles=args.ftitles, + fxlabels=args.fxlabels, + fylabels=args.fylabels, + title_size=args.tsize, + x_label_size=args.xsize, + y_label_size=args.ysize, + legend_size=args.legsize, + xmajor_size=args.xmaj_size, + ymajor_size=args.ymaj_size, + svg=svg) + else: + LOGGER.warn(f'No object found around (ICRS) position {centre_coord}') if args.subimage_noise: centre_coords = [] diff --git a/aimfast/auxiliary.py b/aimfast/auxiliary.py index 25ea1bc..7be32c5 100644 --- a/aimfast/auxiliary.py +++ b/aimfast/auxiliary.py @@ -250,7 +250,7 @@ def get_subimage(fitsname, centre_coord, size, padding=1): return subdata -def get_online_catalog(catalog='NVSS', width='3.0d', thresh=None, +def get_online_catalog(catalog='NVSS', width='5.0d', thresh=None, centre_coord=['0:0:0', '-30:0:0'], catalog_table='nvss_catalog_table.txt'): """Query an online catalog to compare with local catalog @@ -278,32 +278,33 @@ def get_online_catalog(catalog='NVSS', width='3.0d', thresh=None, C = Vizier.query_region(coord.SkyCoord(centre_coord[0], centre_coord[1], unit=(u.hourangle, u.deg), frame='icrs'), width=width, catalog=catalog) - if not C.values(): - raise NameError(f"No object found around (ICRS) position {centre_coord}") - - table = C[0] - ra_deg = [] - dec_deg = [] - - if catalog in ['NVSS', 'SUMSS']: - for i in range(0, len(table['RAJ2000'])): - table['RAJ2000'][i] = ':'.join(table['RAJ2000'][i].split(' ')) - ra_deg.append(ra2deg(table['RAJ2000'][i])) - table['DEJ2000'][i] = ':'.join(table['DEJ2000'][i].split(' ')) - dec_deg.append(dec2deg(table['DEJ2000'][i])) - - if thresh: - if catalog in ['NVSS']: - above_thresh = table['S1.4'] < thresh - if catalog in ['SUMSS']: - above_thresh = table['St'] < thresh - - for i in range(1, len(table.colnames)): - table[table.colnames[i]][above_thresh] = np.nan - - table = Table(table, masked=True) - ascii.write(table, catalog_table, overwrite=True) - return table + if C.values(): + + table = C[0] + ra_deg = [] + dec_deg = [] + + if catalog in ['NVSS', 'SUMSS']: + for i in range(0, len(table['RAJ2000'])): + table['RAJ2000'][i] = ':'.join(table['RAJ2000'][i].split(' ')) + ra_deg.append(ra2deg(table['RAJ2000'][i])) + table['DEJ2000'][i] = ':'.join(table['DEJ2000'][i].split(' ')) + dec_deg.append(dec2deg(table['DEJ2000'][i])) + + if thresh: + if catalog in ['NVSS']: + above_thresh = table['S1.4'] < thresh + if catalog in ['SUMSS']: + above_thresh = table['St'] < thresh + + for i in range(1, len(table.colnames)): + table[table.colnames[i]][above_thresh] = np.nan + + table = Table(table, masked=True) + ascii.write(table, catalog_table, overwrite=True) + return table + else: + return None def aegean(image, kwargs, log): From 75910165fc962e5eaf4f96564705c8685d056518 Mon Sep 17 00:00:00 2001 From: Athanaseus Javas Ramaila Date: Fri, 21 Oct 2022 12:01:28 +0200 Subject: [PATCH 2/3] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fbe9038..bdf14e0 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages pkg = 'aimfast' -__version__ = "1.3.2" +__version__ = "1.3.3" build_root = os.path.dirname(__file__) def readme(): From 9887e98178e267363d33342aaca6a5c6b2d23547 Mon Sep 17 00:00:00 2001 From: Athanaseus Javas Ramaila Date: Fri, 21 Oct 2022 12:08:54 +0200 Subject: [PATCH 3/3] Better logging --- aimfast/aimfast.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aimfast/aimfast.py b/aimfast/aimfast.py index a1503bc..55cf219 100644 --- a/aimfast/aimfast.py +++ b/aimfast/aimfast.py @@ -3340,10 +3340,10 @@ def main(): LOGGER.info(f'Using sky width of {width}') catalog_prefix = args.catalog_name or 'default' online_catalog = args.online_catalog - LOGGER.info(f'Quering the {online_catalog} catalog') catalog_name = f"{catalog_prefix}_{online_catalog}_catalog_table.txt" images_list = [] + LOGGER.info(f'Extracting phase centre coordinates form {models[0][0]}') if models[0][0].endswith('.html'): Tigger_model = Tigger.load(models[0][0]) centre_ra_deg, centre_dec_deg = _get_phase_centre(Tigger_model) @@ -3359,6 +3359,7 @@ def main(): else: LOGGER.error('Please supply central coordinates using -ptc. See --help') + LOGGER.info(f'Quering the {online_catalog} catalog with width of {width} at {centre_coord}') table = get_online_catalog(catalog=online_catalog.upper(), centre_coord=centre_coord, width='5.0d', thresh=threshold, catalog_table=catalog_name)