Skip to content

Commit

Permalink
aimfast automatically finds its own centre given html or fits file el…
Browse files Browse the repository at this point in the history
…se uses user supplied -ptc option
  • Loading branch information
3rico committed Jan 12, 2021
1 parent 6364d21 commit f860493
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
18 changes: 16 additions & 2 deletions aimfast/aimfast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -80,6 +81,7 @@
# Decimal places
DECIMALS = 2


def create_logger():
"""Create a console logger"""
log = logging.getLogger(__name__)
Expand Down Expand Up @@ -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)
Expand Down
41 changes: 41 additions & 0 deletions aimfast/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit f860493

Please sign in to comment.