Skip to content

Commit

Permalink
Save antenna positions with VIS files
Browse files Browse the repository at this point in the history
  • Loading branch information
tim committed Aug 26, 2020
1 parent 9685432 commit 8847dd0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions software/python_modules/tart/tart/imaging/visibility.py
Expand Up @@ -150,15 +150,15 @@ def Visibility_Save_JSON(vis, filename):
Load and save lists of visibilities. Use filename extensions to deal with the deprecated .pkl files (or .vis files)
'''

def list_save(vis_list, cal_gain, cal_ph, filename):
def list_save(vis_list, ant_pos, cal_gain, cal_ph, filename):
_, file_extension = os.path.splitext(filename)

if ('.pkl' == file_extension):
to_pkl(vis_list, filename)
elif ('.vis' == file_extension):
to_pkl(vis_list, filename)
elif ('.hdf' == file_extension):
to_hdf5(vis_list, cal_gain, cal_ph, filename)
to_hdf5(vis_list, ant_pos, cal_gain, cal_ph, filename)
else:
raise RuntimeError("Unknown visibility file extension {}".format(file_extension))

Expand Down Expand Up @@ -207,7 +207,7 @@ def from_pkl(filename):
Deal with HDF5 Files
'''

def to_hdf5(vis_list, cal_gain, cal_ph, filename):
def to_hdf5(vis_list, ant_pos, cal_gain, cal_ph, filename):
''' Save the Observation object,
to a portable HDF5 format
'''
Expand All @@ -232,6 +232,9 @@ def to_hdf5(vis_list, cal_gain, cal_ph, filename):
h5f.create_dataset('vis', data=np.array(vis_data))
h5f.create_dataset('gains', data=np.array(cal_gain))
h5f.create_dataset('phases', data=np.array(cal_ph))

h5f.create_dataset('antenna_positions', data=np.array(ant_pos))

h5f.create_dataset("timestamp", data=np.array(vis_ts, dtype=object), dtype=dt)

#ts_dset = h5f.create_dataset('timestamp', (len(vis_ts),), dtype=dt)
Expand Down
Expand Up @@ -77,7 +77,7 @@ def capture_loop(tart, process_queue, cmd_queue, runtime_config, logger=None,):
d, d_json = get_status_json(tart)
runtime_config['status'] = d
process_queue.put(data)
print(('Capture Loop: Acquired', data[0]))
logger.info(('Capture Loop: Acquired', data[0]))
except Exception as e:
logger.error("Capture Loop Error %s" % str(e))
logger.error(traceback.format_exc())
Expand Down
4 changes: 3 additions & 1 deletion software/python_modules/tart_web_api/tart_web_api/service.py
Expand Up @@ -306,7 +306,9 @@ def vis_stream_acquire(self):
cal_gain = [rows_dict[i][2] for i in range(24)]
cal_ph = [rows_dict[i][3] for i in range(24)]

visibility.list_save(self.vislist, cal_gain, cal_ph, fname)
ant_pos = self.config['antenna_positions']

visibility.list_save(self.vislist, ant_pos, cal_gain, cal_ph, fname)

logging.info("saved to {}".format(vis, fname))
ret['filename'] = fname
Expand Down

0 comments on commit 8847dd0

Please sign in to comment.