def sync(stream_list=None, all_snaps=False, check_sync_all=True, publish_global_key=False): if all_snaps: ATA_SNAP_TAB = snap_config.get_ata_snap_tab() stream_list = [snap for snap in ATA_SNAP_TAB.snap_hostname] if check_sync_all: print(*stream_list, sep='\n') response = input( 'Are you sure you want to sync all the snaps (above) (Y/n): ') if len(response) > 0 and response[0] in ['n', 'N']: print('Aborting...') return if stream_list is not None and len(stream_list) > 0: print("Syncing: ") print(stream_list) fengs = snap_control.init_snaps(stream_list) host_unique_fengs = hpguppi_auxillary.filter_unique_fengines(fengs) if len(host_unique_fengs) < len(fengs): fengs = host_unique_fengs print('Simplified F-Engines to unique hosts:', [feng.host for feng in fengs]) sync_time = snap_control.arm_snaps(fengs) print("Synctime is: %i" % sync_time) if publish_global_key: print("Writing sync time to redis database") r = redis.Redis(host='redishost') r.set('SYNCTIME', sync_time) print(r.get('SYNCTIME'))
def collect_feng_obj(antlo_stream_list=None, all_streams=False, check_stop_all=True): if all_streams: ATA_SNAP_TAB = snap_config.get_ata_snap_tab() antstream_hostname_list_to_silence = [ stream for stream in ATA_SNAP_TAB.snap_hostname ] if check_stop_all: print(*antstream_hostname_list_to_silence, sep='\n') response = input( 'Are you sure you want to control the ethernet of all the streams (above) (Y/n): ' ) if len(response) > 0 and response[0] in ['n', 'N']: print('Aborting...') return None elif antlo_stream_list is not None and len(antlo_stream_list) > 0: print( hpguppi_auxillary.get_stream_hostname_dict_for_antenna_names( antlo_stream_list)) antstream_hostname_list_to_silence = hpguppi_auxillary.get_stream_hostname_per_antenna_names( antlo_stream_list) return hpguppi_auxillary.filter_unique_fengines( snap_control.init_snaps(antstream_hostname_list_to_silence))
def get_stream_hostname_per_antenna_names(antenna_names): ATA_SNAP_TAB = snap_config.get_ata_snap_tab() if not all(ant in list(ATA_SNAP_TAB.antlo) for ant in antenna_names): raise RuntimeError( "Not all antennae (%s) are provided in the config table (%s)", antenna_names, ATA_SNAP_TAB.antlo) antenna_names_ant_tab = ATA_SNAP_TAB[ATA_SNAP_TAB.antlo.isin( antenna_names)] return [i.snap_hostname for i in antenna_names_ant_tab.itertuples()]
def get_antenna_name_per_stream_hostnames(stream_hostnames): ATA_SNAP_TAB = snap_config.get_ata_snap_tab() if not all(snap in list(ATA_SNAP_TAB.snap_hostname) for snap in stream_hostnames): raise RuntimeError( "Not all snaps (%s) are provided in the config table (%s)", stream_hostnames, ATA_SNAP_TAB.snap_hostname) stream_hostnames_ant_tab = ATA_SNAP_TAB[ATA_SNAP_TAB.snap_hostname.isin( stream_hostnames)] return [i.antlo for i in stream_hostnames_ant_tab.itertuples()]
def generate_stream_antnames_to_marshall(): streams_to_marshall = [ i.snap_hostname for i in snap_config.get_ata_snap_tab().itertuples() if i.snap_hostname.startswith('rfsoc') ] # Gather antenna-configuration for the listed snaps stream_ant_name_dict = hpguppi_auxillary.get_antenna_name_dict_for_stream_hostnames( streams_to_marshall) antenna_names = [ ant_name for stream_name, ant_name in stream_ant_name_dict.items() ] return streams_to_marshall, antenna_names
from string import Template from typing import List from SNAPobs import snap_defaults, snap_config from ATATools import ata_control from datetime import datetime from astropy.time import Time as astropy_Time from . import snap_hpguppi_defaults as hpguppi_defaults from . import auxillary as hpguppi_auxillary from . import record_in as hpguppi_record_in from ATATools.ata_rest import ATARestException ATA_SNAP_TAB = snap_config.get_ata_snap_tab() def _get_stream_mapping(stream_hosts, ignore_control=False): """ 1) Get the centre frequency for each of the stream_hosts from the REST/control machine, given what tunings are fed to what snaps 2) Get the antenna name associated with the snap An overly complicated function for what it does really """ if type(stream_hosts) != list: raise RuntimeError("Please input a list") if not all(stream in list(ATA_SNAP_TAB.snap_hostname) for stream in stream_hosts): raise RuntimeError("Not all snaps (%s) are provided in the config table (%s)", stream_hosts, ATA_SNAP_TAB.snap_hostname)
def main(): parser = argparse.ArgumentParser(description='Wrapper to call'\ 'sumfilbanks') parser.add_argument('ants', nargs='+', type=str, help='antennas in observation') parser.add_argument('-p', dest='nproc', type=int, help='nprocesses to run [%i]' % DEFAULT_NPROC, default=DEFAULT_NPROC) parser.add_argument('-s', dest='script', type=str, help='sumfils executable [%s]' % DEFAULT_SCRIPT, default=DEFAULT_SCRIPT) parser.add_argument('-f', dest='filname', type=str, default=DEFAULT_FNAME, help='fnames to sum [%s]' % DEFAULT_FNAME) parser.add_argument('-n', dest='dry_run', action='store_true', help="Don't execute commands") parser.add_argument('-d', dest='outdir', type=str, help='outdir to use [%s]' % DEFAULT_OUTDIR, default=DEFAULT_OUTDIR) parser.add_argument('-o', dest='outname', type=str, help='outname to use [%s]' % DEFAULT_OUTNAME, default=DEFAULT_OUTNAME) args = parser.parse_args() ants = args.ants snap_tab = snap_config.get_ata_snap_tab() obs_ant_tab = snap_tab[snap_tab.ANT_name.isin(ants)] los = np.unique(obs_ant_tab.LO) for lo in los: subtab = obs_ant_tab[obs_ant_tab.LO == lo] inp_list = " ".join( [os.path.join(ant, args.filname) for ant in list(subtab.ANT_name)]) out_basename = "%s_%s.fil" % (args.outname, lo) out_name = os.path.join(args.outdir, out_basename) cmd = args.script +\ " " +\ inp_list +\ " " +\ " -o %s" %out_name +\ " " +\ " -p %i" %args.nproc cmd_args = [subs for subs in cmd.split(" ") if subs] if args.dry_run: print(cmd_args) else: print("Running:") print(cmd_args) p = subprocess.Popen(cmd_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) str_out, str_err = p.communicate()