Skip to content

Commit

Permalink
Merge pull request #64 from Athanaseus/Online-Compare
Browse files Browse the repository at this point in the history
Online compare
  • Loading branch information
Athanaseus authored Oct 24, 2022
2 parents d24b7b7 + 9887e98 commit d454d63
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 65 deletions.
77 changes: 40 additions & 37 deletions aimfast/aimfast.py
Original file line number Diff line number Diff line change
Expand Up @@ -3336,14 +3336,14 @@ 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
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)
Expand All @@ -3359,45 +3359,48 @@ 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)
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)


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 = []
Expand Down
55 changes: 28 additions & 27 deletions aimfast/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit d454d63

Please sign in to comment.