Skip to content

Commit

Permalink
Merge pull request #47 from 3rico/devel
Browse files Browse the repository at this point in the history
added -ptc user option
  • Loading branch information
Athanaseus committed Jan 27, 2021
2 parents 93c108b + f860493 commit 5e4ba92
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
22 changes: 21 additions & 1 deletion 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 @@ -2424,6 +2426,9 @@ def get_argparser():
argument('-oc', '--online-catalog', dest='online_catalog',
choices=('sumss', 'nvss'), default='nvss',
help='Online catalog to compare local image/model.')
argument('-ptc', '--centre_coord', dest='centre_coord',
default="0:0:0, -30:0:0",
help='Centre of online catalog to compare local image/model in "RA hh:mm:ss, Dec deg:min:sec".')
argument('-fdr', '--fidelity-results', dest='json',
help='aimfast fidelity results file (JSON format)')
argument("--outfile",
Expand Down Expand Up @@ -2625,10 +2630,25 @@ def main():
online_catalog = args.online_catalog
catalog_name = f"{catalog_prefix}_{online_catalog}_catalog_table.txt"
images_list = []
get_online_catalog(catalog=online_catalog.upper(),

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)


for i, ims in enumerate(models):
image1 = ims[0]
if '.fits' in image1:
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 5e4ba92

Please sign in to comment.