Skip to content

Commit

Permalink
peak ew and ns beam passed to coordinate call to make ra/dec refer to…
Browse files Browse the repository at this point in the history
… beam loc
  • Loading branch information
VR-DSA committed Feb 25, 2025
1 parent 6806378 commit 7559d37
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions T2/cluster_heimdall.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def dump_cluster_results_json(
(
output_dict[candname]["ra"],
output_dict[candname]["dec"],
) = get_radec(beamnum=127) # quick and dirty
) = get_radec(output_dict, beamnum=127) # quick and dirty

if gulp is not None:
output_dict[candname]["gulp"] = gulp
Expand Down Expand Up @@ -606,16 +606,34 @@ def dump_cluster_results_json(
return None, lastname, None


def get_radec(mjd=None, beamnum=None):
"""Use time, beam number, and and antenna elevation to get RA, Dec of beam."""
def get_radec(output_dict=None, mjd=None, beamnum=None, nsnr=5):
"""Estimate RA and Dec.
Early method is to get 1-arm localization from time, beam number, and and antenna elevation to get RA, Dec of beam.
Newer method is to get 2-arm localization from beam number in both arms. Uses the canddict info.
"""

if mjd is not None:
if output_dict is not None:
candname, canddict = output_dict.popitem()
tt = canddict['mjds']
beamnum_ew = None
beamnum_ns = None
for i in range(nsnr):
if canddict[f'snrs{i}'] > 0:
beam = canddict[f'beams{i}']
if beam < 256 and beamnum_ew is None:
beamnum_ew = beam
elif beam >= 256 and beamnum_ns is None:
beamnum_ns = beam
elif beamnum_ns is not None and beamnum_ew is not None:
break
beamnum = beamnum_ew
elif mjd is not None:
print("Using time to get ra,dec")
tt = time.Time(mjd, format="mjd")
else:
tt = None

ra, dec = coordinates.get_pointing(ibeam=beamnum, obstime=tt)
ra, dec = coordinates.get_pointing(ibeam=beamnum, jbeam=beamnum_ns, obstime=tt)

return ra.value, dec.value

Expand Down

0 comments on commit 7559d37

Please sign in to comment.