Skip to content

Commit

Permalink
Merge pull request david-macmahon#8 from HERA-Team/antpos_fix
Browse files Browse the repository at this point in the history
Make fix for antenna positions
  • Loading branch information
jack-h authored Nov 29, 2018
2 parents 6706b34 + d152b6b commit 20e3483
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/scripts/hera_make_hdf5_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ def get_antpos_enu(antpos, lat, lon, alt):
enu = uvutils.ENU_from_ECEF(ecef, lat, lon, alt)
return enu

def get_telescope_location_ecef(lat, lon, alt):
import pyuvdata.utils as uvutils
xyz = uvutils.XYZ_from_LatLonAlt(lat, lon, alt)
ecef = uvutils.ECEF_from_ENU(xyz, lat, lon, alt)
return ecef

def create_header(h5, use_cm=False, use_redis=False):
"""
Create an HDF5 file with appropriate datasets in a "Header"
Expand Down Expand Up @@ -147,13 +153,18 @@ def create_header(h5, use_cm=False, use_redis=False):
header.create_dataset("telescope_name", data=np.string_("HERA"))
header.create_dataset("vis_units", data=np.string_("UNCALIB"))
if use_cm:
# convert lat and lon from degrees -> radians
lat = cminfo['cofa_lat'] * np.pi / 180.
lon = cminfo['cofa_lon'] * np.pi / 180.
alt = cminfo['cofa_alt']
telescope_location_ecef = get_telescope_location_ecef(lat, lon, alt)
header.create_dataset("altitude", dtype="<f8", data=cminfo['cofa_alt'])
ant_pos = np.zeros([NANTS,3], dtype=np.int64)
ant_pos_enu = np.zeros([NANTS,3], dtype=np.int64)
ant_pos = -1 * np.ones([NANTS,3], dtype=np.int64) * telescope_location_ecef
ant_pos_enu = -1 * np.ones([NANTS,3], dtype=np.int64) * telescope_location_ecef
ant_names = ["NONE"]*NANTS
ant_nums = [-1]*NANTS
for n, i in enumerate(cminfo["antenna_numbers"]):
ant_pos[i] = cminfo["antenna_positions"][n]
ant_pos[i] = cminfo["antenna_positions"][n] - telescope_location_ecef
ant_names[i] = np.string_(cminfo["antenna_names"][n])
ant_nums[i] = cminfo["antenna_numbers"][n]
ant_pos_enu[i] = cminfo["antenna_positions_enu"][n]
Expand Down

0 comments on commit 20e3483

Please sign in to comment.