diff --git a/aimfast/aimfast.py b/aimfast/aimfast.py index 16329c2..19acb77 100644 --- a/aimfast/aimfast.py +++ b/aimfast/aimfast.py @@ -43,6 +43,7 @@ from aimfast.auxiliary import deg2arcsec, deg2arcsec, rad2arcsec from aimfast.auxiliary import dec2deg, ra2deg, rad2deg, deg2rad, unwrap +from aimfast.auxiliary import deg2dec, deg2ra # Get version from pkg_resources import get_distribution @@ -80,6 +81,7 @@ # Decimal places DECIMALS = 2 + def create_logger(): """Create a console logger""" log = logging.getLogger(__name__) @@ -2628,8 +2630,20 @@ def main(): online_catalog = args.online_catalog catalog_name = f"{catalog_prefix}_{online_catalog}_catalog_table.txt" images_list = [] - centre_coord = args.centre_coord.split(',') - # import ipdb; ipdb.set_trace() + + if models[0][0].endswith('html'): + Tigger_model = Tigger.load(models[0][0]) + centre_ra_deg, centre_dec_deg = _get_phase_centre(Tigger_model) + centre_coord = deg2ra(centre_ra_deg) + ',' + deg2dec(centre_dec_deg) + centre_coord = centre_coord.split(',') + elif models[0][0].endswith('.fits'): + centre_ra_deg, centre_dec_deg = fitsInfo(models[0][0])['centre'] + centre_coord = deg2ra(centre_ra_deg) + ',' + deg2dec(centre_dec_deg) + centre_coord = centre_coord.split(',') + else: + print('Please supply central coordinates using -ptc see help') + centre_coord = args.centre_coord.split(',') + get_online_catalog(catalog=online_catalog.upper(), centre_coord=centre_coord, width='1.0d', thresh=1.0, catalog_table=catalog_name) diff --git a/aimfast/auxiliary.py b/aimfast/auxiliary.py index af9f606..2a4306c 100644 --- a/aimfast/auxiliary.py +++ b/aimfast/auxiliary.py @@ -107,6 +107,27 @@ def ra2deg(ra_hms): return h_m_s +def deg2ra(ra_deg): + """Converts right ascension in hms coordinates to degrees + + Parameters + ---------- + ra_deg : float + ra in degrees format + + Returns + ------- + HH:MM:SS : str + + """ + if ra_deg < 0: + ra_deg = 360 + ra_deg + HH = int((ra_deg*24)/360.) + MM = int((((ra_deg*24)/360.)-HH)*60) + SS = (((((ra_deg*24)/360.)-HH)*60)-MM)*60 + return "%s:%s:%s"%(HH,MM,SS) + + def dec2deg(dec_dms): """Converts declination in dms coordinates to degrees @@ -138,6 +159,26 @@ def dec2deg(dec_dms): return d_m_s + +def deg2dec(dec_deg): + """Converts declination in degrees to dms coordinates + + Parameters + ---------- + dec_deg : float + dec in float format + + Returns + ------- + dms : str + """ + DD = int(dec_deg) + dec_deg_abs = np.abs(dec_deg) + DD_abs = np.abs(DD) + MM = int((dec_deg_abs - DD_abs)*60) + SS = ((dec_deg_abs - DD_abs)*60)-MM + return "%s:%s:%s"%(DD,MM,SS) + def unwrap(angle): """Unwrap angle greater than 180""" if angle > 180: