#!/usr/bin/env python import numpy as np import matplotlib.pyplot as plt from directionFinder_backend.correlator import Correlator import scipy.signal from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes from mpl_toolkits.axes_grid1.inset_locator import mark_inset if __name__ == '__main__': c = Correlator() c.fetch_time_domain_snapshot(force=True) time_domain_padding = 10 fs = 800e6 upsample_factor = 100 a_idx = 0 b_idx = 1 a = np.concatenate( (np.zeros(time_domain_padding), c.time_domain_signals[a_idx], np.zeros(time_domain_padding))) a_time = np.linspace(-(time_domain_padding/fs), (len(a)-time_domain_padding)/fs, len(a), endpoint=False) b = c.time_domain_signals[b_idx] b_time = np.linspace(0, len(b)/fs, len(b), endpoint=False)
for idx in range(6): to_plot = 10*np.log10((np.abs(cross[idx]))) #a, b = baselines[idx] #to_plot = np.angle(np.fft.rfft(time[a]) * np.conj(np.fft.rfft(time[b])))[0:-1] lines[2][idx].set_ydata(to_plot) lines[3][idx].set_ydata(np.angle(cross[idx])) plt.pause(0.05) if __name__ == '__main__': logger = logging.getLogger('main') handler = logging.StreamHandler() colored_formatter = ColoredFormatter("%(log_color)s%(asctime)s%(levelname)s:%(name)s:%(message)s") handler.setFormatter(colored_formatter) logger.addHandler(handler) logger.setLevel(logging.DEBUG) correlator = Correlator(logger = logger.getChild('correlator')) correlator.set_shift_schedule(0b00000000000) correlator.set_accumulation_len(40000) correlator.re_sync() correlator.fetch_autos() correlator.fetch_time_domain_snapshot(force=True) correlator.add_cable_length_calibrations('/home/jgowans/workspace/directionFinder_backend/config/cable_length_calibration.json') #correlator.apply_frequency_bin_calibrations('/home/jgowans/workspace/directionFinder_backend/config/frequency_domain_calibration_through_chain.json') correlator.add_frequency_bin_calibrations('/home/jgowans/workspace/directionFinder_backend/config/frequency_domain_calibration_direct_in_phase.json') created = False while True: time = [] correlator.fetch_time_domain_snapshot(force=True) for antenna_idx in range(4): time.append(correlator.time_domain_signals[antenna_idx][0:2048]) correlator.fetch_all()
ax.set_ylim(top=3, bottom=-3) ax.legend(loc=2) plt.show() if __name__ == '__main__': # logging infrastructure logger = logging.getLogger('main') handler = logging.StreamHandler() colored_formatter = ColoredFormatter( "%(log_color)s%(asctime)s%(levelname)s:%(name)s:%(message)s") handler.setFormatter(colored_formatter) logger.addHandler(handler) logger.setLevel(logging.DEBUG) correlator = Correlator(logger=logger.getChild('correlator')) correlator.set_shift_schedule(0b00000000000) correlator.set_accumulation_len(40000) correlator.add_frequency_bin_calibrations('baseline.json') time.sleep(1) correlator.re_sync() siggen = SCPI(host='localhost') offsets = {} offsets['axis'] = [] for a, b in correlator.cross_combinations: offsets["{a}{b}".format(a=a, b=b)] = [] for f in correlator.frequency_correlations[(0, 1)].frequency_bins: siggen.setFrequency(f)
#a, b = baselines[idx] #to_plot = np.angle(np.fft.rfft(time[a]) * np.conj(np.fft.rfft(time[b])))[0:-1] lines[2][idx].set_ydata(to_plot) lines[3][idx].set_ydata(np.angle(cross[idx])) plt.pause(0.05) if __name__ == '__main__': logger = logging.getLogger('main') handler = logging.StreamHandler() colored_formatter = ColoredFormatter( "%(log_color)s%(asctime)s%(levelname)s:%(name)s:%(message)s") handler.setFormatter(colored_formatter) logger.addHandler(handler) logger.setLevel(logging.DEBUG) correlator = Correlator(logger=logger.getChild('correlator')) correlator.set_shift_schedule(0b00000000000) correlator.set_accumulation_len(40000) correlator.re_sync() correlator.fetch_autos() correlator.fetch_time_domain_snapshot(force=True) correlator.add_cable_length_calibrations( '/home/jgowans/workspace/directionFinder_backend/config/cable_length_calibration.json' ) #correlator.apply_frequency_bin_calibrations('/home/jgowans/workspace/directionFinder_backend/config/frequency_domain_calibration_through_chain.json') correlator.add_frequency_bin_calibrations( '/home/jgowans/workspace/directionFinder_backend/config/frequency_domain_calibration_direct_in_phase.json' ) created = False while True: time = []
#axins.xaxis.set_ticks(np.arange(-0.4, 2.9, 0.4)) axins.xaxis.set_ticks(np.arange(-0.4, 0.4, 0.2)) mark_inset(ax, axins, loc1=2, loc2=3, fc='none', ec='0.5') plt.xticks(visible=True) plt.yticks(visible=False) ax.set_title( "Time domain cross correlations with broad band noise\n arriving through full RF chain AFTER calibration" ) ax.set_xlabel("Time delay (ns)") ax.set_ylabel("Cross correlation value (normalised)") ax.legend(loc=2) #ax.legend() plt.show() if __name__ == '__main__': logger = logging.getLogger('main') handler = logging.StreamHandler() colored_formatter = ColoredFormatter( "%(log_color)s%(asctime)s%(levelname)s:%(name)s:%(message)s") handler.setFormatter(colored_formatter) logger.addHandler(handler) logger.setLevel(logging.DEBUG) c = Correlator(logger=logger.getChild('correlator')) #c.apply_time_domain_calibration("./time_domain_calibration.json") #c.apply_cable_length_calibrations('../config/cable_length_calibration.json') c.fetch_time_domain_snapshot(force=True) do_calibration(c, write=False) plot_calibration(c, insert=True)
parser = argparse.ArgumentParser(description="Run RMS error simulations") parser.add_argument('--f_start', default=220e6, type=float) parser.add_argument('--f_stop', default=261e6, type=float) parser.add_argument('--array_geometry_file', default=None) parser.add_argument('--impulse', type=bool, default=False) parser.add_argument('--impulse_setpoint', type=int) parser.add_argument('--acc_len', type=int, default=40000) parser.add_argument('--comment', type=str) args = parser.parse_args() df_raw_dir = '/home/jgowans/Documents/df_raw/{c}/'.format(c=args.comment) if not os.path.exists(df_raw_dir): os.mkdir(df_raw_dir) array = AntennaArray.mk_from_config(args.array_geometry_file) correlator = Correlator(logger=logger.getChild('correlator')) correlator.set_accumulation_len(args.acc_len) correlator.add_cable_length_calibrations( '/home/jgowans/workspace/directionFinder_backend/config/cable_length_calibration_actual_array.json' ) correlator.add_frequency_bin_calibrations( '/home/jgowans/workspace/directionFinder_backend/config/frequency_domain_calibration_through_chain.json' ) df = DirectionFinder(correlator, array, args.f_start, logger.getChild('df')) if args.impulse == True: df.set_time() # go into time mode # 100 impulse filter len = 0.5 us correlator.set_impulse_filter_len(100) correlator.set_impulse_setpoint(args.impulse_setpoint)
import matplotlib.pyplot as plt from directionFinder_backend.snapshot import Snapshot from directionFinder_backend.correlator import Correlator import corr import itertools import logging from colorlog import ColoredFormatter if __name__ == '__main__': logger = logging.getLogger('main') handler = logging.StreamHandler() colored_formatter = ColoredFormatter("%(log_color)s%(asctime)s%(levelname)s:%(name)s:%(message)s") handler.setFormatter(colored_formatter) logger.addHandler(handler) logger.setLevel(logging.DEBUG) correlator = Correlator(logger = logger.getChild('correlator')) correlator.set_shift_schedule(0b00000000000) correlator.set_accumulation_len(40000) correlator.re_sync() correlator.fetch_crosses() to_plot = correlator.frequency_correlations[(0,1)].signal to_plot = np.abs(to_plot) to_plot[0] = 0 to_plot = np.log10(to_plot) plt.plot(correlator.frequency_correlations[(0,1)].frequency_bins / 1e6, to_plot) plt.title("Spectrum of the 0x1 visibility") plt.xlabel("Frequency (MHz)") plt.ylabel("Power (arbitrary units) [log]") plt.show()
import matplotlib.pyplot as plt from directionFinder_backend.correlator import Correlator import corr import itertools import logging from colorlog import ColoredFormatter if __name__ == '__main__': logger = logging.getLogger('main') handler = logging.StreamHandler() colored_formatter = ColoredFormatter("%(log_color)s%(asctime)s%(levelname)s:%(name)s:%(message)s") handler.setFormatter(colored_formatter) logger.addHandler(handler) logger.setLevel(logging.DEBUG) correlator = Correlator(logger = logger.getChild('correlator')) time.sleep(1) correlator.set_impulse_filter_len(50) correlator.set_impulse_setpoint(3772) correlator.add_time_domain_calibration('/home/jgowans/workspace/directionFinder_backend/config/time_domain_calibration_long_sma_cables_only.json') correlator.add_cable_length_calibrations('/home/jgowans/workspace/directionFinder_backend/config/cable_length_calibration.json') correlator.re_sync() correlator.impulse_arm() fig = plt.figure() axes = [[], []] axes[0].append(fig.add_subplot(2, 4, 1)) axes[0].append(fig.add_subplot(2, 4, 2, sharex=axes[0][0], sharey=axes[0][0])) axes[0].append(fig.add_subplot(2, 4, 3, sharex=axes[0][0], sharey=axes[0][0])) axes[0].append(fig.add_subplot(2, 4, 4, sharex=axes[0][0], sharey=axes[0][0]))
ax.set_ylim(top=3, bottom=-3) ax.legend(loc=2) plt.show() if __name__ == '__main__': # logging infrastructure logger = logging.getLogger('main') handler = logging.StreamHandler() colored_formatter = ColoredFormatter( "%(log_color)s%(asctime)s%(levelname)s:%(name)s:%(message)s") handler.setFormatter(colored_formatter) logger.addHandler(handler) logger.setLevel(logging.DEBUG) correlator = Correlator(logger=logger.getChild('correlator')) correlator.set_shift_schedule(0b00000000000) correlator.set_accumulation_len(400000) #correlator.apply_cable_length_calibrations('/home/jgowans/workspace/directionFinder_backend/config/cable_length_calibration.json') #correlator.apply_frequency_bin_calibrations('/home/jgowans/workspace/directionFinder_backend/config/frequency_domain_calibration_through_chain.json') #correlator.add_frequency_bin_calibrations('/home/jgowans/workspace/directionFinder_backend/config/frequency_domain_calibration_direct_in_phase.json') time.sleep(1) correlator.re_sync() offsets = {} offsets['axis'] = [] for a, b in correlator.cross_combinations: offsets["{a}{b}".format(a=a, b=b)] = [] correlator.fetch_crosses() #correlator.apply_frequency_domain_calibrations()
from directionFinder_backend.correlator import Correlator import corr import itertools import logging from colorlog import ColoredFormatter if __name__ == '__main__': logger = logging.getLogger('main') handler = logging.StreamHandler() colored_formatter = ColoredFormatter( "%(log_color)s%(asctime)s%(levelname)s:%(name)s:%(message)s") handler.setFormatter(colored_formatter) logger.addHandler(handler) logger.setLevel(logging.DEBUG) correlator = Correlator(logger=logger.getChild('correlator')) time.sleep(1) correlator.set_impulse_filter_len(50) correlator.set_impulse_setpoint(3772) correlator.add_time_domain_calibration( '/home/jgowans/workspace/directionFinder_backend/config/time_domain_calibration_long_sma_cables_only.json' ) correlator.add_cable_length_calibrations( '/home/jgowans/workspace/directionFinder_backend/config/cable_length_calibration.json' ) correlator.re_sync() correlator.impulse_arm() fig = plt.figure() axes = [[], []]
# setup root logger. Shouldn't be used much but will catch unexpected messages colored_formatter = ColoredFormatter("%(log_color)s%(asctime)s:%(levelname)s:%(name)s:%(message)s") handler = logging.StreamHandler() handler.setFormatter(colored_formatter) handler.setLevel(logging.DEBUG) root = logging.getLogger() root.addHandler(handler) root.setLevel(logging.INFO) logger = logging.getLogger('main') logger.propagate = False logger.addHandler(handler) logger.setLevel(logging.INFO) correlator = Correlator(logger = logger.getChild('correlator')) time.sleep(1) correlator.set_impulse_filter_len(100) correlator.set_impulse_setpoint(100) correlator.add_time_domain_calibration('/home/jgowans/workspace/directionFinder_backend/bin/time_domain_calibration.json') correlator.re_sync() correlator.impulse_arm() impulse_levels = [] for _ in range(1000): impulse_levels.append( correlator.get_current_impulse_level()) #time.sleep(0.01) logger.info("Mean: {}".format(np.mean(impulse_levels)))
colored_formatter = ColoredFormatter( "%(log_color)s%(asctime)s:%(levelname)s:%(name)s:%(message)s") handler = logging.StreamHandler() handler.setFormatter(colored_formatter) handler.setLevel(logging.DEBUG) root = logging.getLogger() root.addHandler(handler) root.setLevel(logging.INFO) logger = logging.getLogger('main') logger.propagate = False logger.addHandler(handler) logger.setLevel(logging.INFO) correlator = Correlator(logger=logger.getChild('correlator')) time.sleep(1) correlator.set_impulse_filter_len(100) correlator.set_impulse_setpoint(100) correlator.add_time_domain_calibration( '/home/jgowans/workspace/directionFinder_backend/bin/time_domain_calibration.json' ) correlator.re_sync() correlator.impulse_arm() impulse_levels = [] for _ in range(1000): impulse_levels.append(correlator.get_current_impulse_level()) #time.sleep(0.01)
parser = argparse.ArgumentParser(description = "Run RMS error simulations") parser.add_argument('--f_start', default=220e6, type=float) parser.add_argument('--f_stop', default=261e6, type=float) parser.add_argument('--array_geometry_file', default=None) parser.add_argument('--impulse', type=bool, default=False) parser.add_argument('--impulse_setpoint', type=int) parser.add_argument('--acc_len', type=int, default=40000) parser.add_argument('--comment', type=str) args = parser.parse_args() df_raw_dir = '/home/jgowans/Documents/df_raw/{c}/'.format(c = args.comment) if not os.path.exists(df_raw_dir): os.mkdir(df_raw_dir) array = AntennaArray.mk_from_config(args.array_geometry_file) correlator = Correlator(logger = logger.getChild('correlator')) correlator.set_accumulation_len(args.acc_len) correlator.add_cable_length_calibrations('/home/jgowans/workspace/directionFinder_backend/config/cable_length_calibration_actual_array.json') correlator.add_frequency_bin_calibrations('/home/jgowans/workspace/directionFinder_backend/config/frequency_domain_calibration_through_chain.json') df = DirectionFinder(correlator, array, args.f_start, logger.getChild('df')) if args.impulse == True: df.set_time() # go into time mode # 100 impulse filter len = 0.5 us correlator.set_impulse_filter_len(100) correlator.set_impulse_setpoint(args.impulse_setpoint) correlator.re_sync() time.sleep(0.1) correlator.impulse_arm() while True:
#!/usr/bin/env python import numpy as np import matplotlib.pyplot as plt from directionFinder_backend.correlator import Correlator import scipy.signal from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes from mpl_toolkits.axes_grid1.inset_locator import mark_inset if __name__ == '__main__': c = Correlator() c.fetch_time_domain_snapshot(force=True) time_domain_padding = 10 fs = 800e6 upsample_factor = 100 a_idx = 0 b_idx = 1 a = np.concatenate( (np.zeros(time_domain_padding), c.time_domain_signals[a_idx], np.zeros(time_domain_padding))) a_time = np.linspace(-(time_domain_padding / fs), (len(a) - time_domain_padding) / fs, len(a), endpoint=False) b = c.time_domain_signals[b_idx] b_time = np.linspace(0, len(b) / fs, len(b), endpoint=False) correlation = np.correlate(a, b, mode='valid') correlation_time = np.linspace(a_time[0] - b_time[0], a_time[-1] - b_time[-1], len(correlation),