ZH: renaming phase variables I: phase->beacon_phase

This commit is contained in:
Eric Teunis de Boone 2023-01-17 18:17:12 +01:00
parent daf2209c73
commit 3ba45f4f52
4 changed files with 19 additions and 18 deletions

View file

@ -136,7 +136,7 @@ if __name__ == "__main__":
# Do Fourier Transforms
# to find phases and amplitudes
if True:
freqs, phases, amps = lib.find_beacon_in_traces(
freqs, beacon_phases, amps = lib.find_beacon_in_traces(
test_traces, t_trace,
f_beacon_estimate=f_beacon,
frequency_fit=allow_frequency_fitting,
@ -147,17 +147,17 @@ if __name__ == "__main__":
freqs = [f_beacon]
t0 = h5ant.attrs['t0']
phases = [ 2*np.pi*t0*f_beacon ]
beacon_phases = [ 2*np.pi*t0*f_beacon ]
amps = [ 3e-7 ]
# choose highest amp
idx = 0
if False and len(phases) > 1:
if False and len(beacon_phases) > 1:
#idx = np.argmax(amplitudes, axis=-1)
raise NotImplementedError
frequency = freqs[idx]
phase = phases[idx]
beacon_phase = beacon_phases[idx]
amplitude = amps[idx]
orientation = orients[idx]
@ -166,16 +166,16 @@ if __name__ == "__main__":
if False:
# Subtract phase due to not starting at t=0
# This is already done in beacon_find_traces
phase = lib.phase_mod(phase + corr_phase)
beacon_phase = lib.phase_mod(beacon_phase + corr_phase)
# for reporting using plots
found_data[i] = frequency, phase, amplitude
found_data[i] = frequency, beacon_phase, amplitude
if (show_plots or fig_dir) and (i == 0 or i == 72 or i == 70):
p2t = lambda phase: phase/(2*np.pi*f_beacon)
fig, ax = plt.subplots()
ax.set_title(f"Beacon at antenna {h5ant.attrs['name']}\nF:{frequency:.2e}, P:{phase:.4f}, A:{amplitude:.1e}")
ax.set_title(f"Beacon at antenna {h5ant.attrs['name']}\nF:{frequency:.2e}, P:{beacon_phase:.4f}, A:{amplitude:.1e}")
ax.set_xlabel("t [ns]")
ax.set_ylabel("Amplitude")
@ -191,9 +191,9 @@ if __name__ == "__main__":
ax.plot(t_trace - t_0, test_traces[j], marker='.', label='trace '+orients[j])
myt = np.linspace(min(t_trace), max(t_trace), 10*len(t_trace)) - t_0
ax.plot(myt, lib.sine_beacon(frequency, myt, amplitude=amplitude, t0=0, phase=phase+extra_phase), ls='dotted', label='simulated beacon')
ax.plot(myt, lib.sine_beacon(frequency, myt, amplitude=amplitude, t0=0, phase=beacon_phase+extra_phase), ls='dotted', label='simulated beacon')
ax.axvline( p2t(lib.phase_mod(-1*(phase+extra_phase), low=0)), color='r', ls='dashed', label='$t_\\varphi$')
ax.axvline( p2t(lib.phase_mod(-1*(beacon_phase+extra_phase), low=0)), color='r', ls='dashed', label='$t_\\varphi$')
ax.axvline(0,color='grey',alpha=0.5)
ax.axhline(0,color='grey',alpha=0.5)
@ -226,7 +226,7 @@ if __name__ == "__main__":
h5attrs = h5beacon_freq_info.attrs
h5attrs['freq'] = frequency
h5attrs['phase'] = phase
h5attrs['beacon_phase'] = beacon_phase
h5attrs['amplitude'] = amplitude
h5attrs['orientation'] = orientation

View file

@ -44,20 +44,20 @@ if __name__ == "__main__":
# Make sure at least one beacon has been identified
if not hasattr(antennas[0], 'beacon_info') or len(antennas[0].beacon_info) == 0:
print(f"No analysed beacon found for {antennas[0].name}, try running the phase analysis script first.")
print(f"No analysed beacon found for {antennas[0].name}, try running the beacon phase analysis script first.")
sys.exit(1)
#
N_beacon_freqs = len(antennas[0].beacon_info)
for freq_name in antennas[0].beacon_info.keys():
measured_phases = np.empty( (len(antennas)) )
beacon_phases = np.empty( (len(antennas)) )
for i, ant in enumerate(antennas):
measured_phases[i] = ant.beacon_info[freq_name]['phase']
beacon_phases[i] = ant.beacon_info[freq_name]['beacon_phase']
f_beacon = antennas[0].beacon_info[freq_name]['freq']
true_phases = lib.remove_antenna_geometry_phase(tx, antennas, f_beacon, measured_phases, c_light=c_light)
true_phases = lib.remove_antenna_geometry_phase(tx, antennas, f_beacon, beacon_phases, c_light=c_light)
# Remove the phase from one antenna
# this is a free parameter

View file

@ -208,10 +208,11 @@ if __name__ == "__main__":
if remove_beacon_from_trace:
clock_phase = measured_repair_offsets[i]*2*np.pi*f_beacon
meas_phase = ant.beacon_info[freq_name]['phase']
beacon_phase = ant.beacon_info[freq_name]['beacon_phase']
f = ant.beacon_info[freq_name]['freq']
ampl = ant.beacon_info[freq_name]['amplitude']
calc_beacon = lib.sine_beacon(f, ev.antennas[i].t_AxB, amplitude=ampl, phase=meas_phase-clock_phase)
calc_beacon = lib.sine_beacon(f, ev.antennas[i].t_AxB, amplitude=ampl, phase=beacon_phase-clock_phase)
ev.antennas[i].E_AxB -= calc_beacon

View file

@ -32,9 +32,9 @@ if __name__ == "__main__":
freq_name = list(antennas[0].beacon_info.keys())[0]
beacon_frequencies = np.array([ant.beacon_info[freq_name]['freq'] for ant in antennas])
beacon_amplitudes = np.array([ant.beacon_info[freq_name]['amplitude'] for ant in antennas])
beacon_phases = lib.phase_mod(np.array([ant.beacon_info[freq_name]['phase'] for ant in antennas]))
beacon_phases = lib.phase_mod(np.array([ant.beacon_info[freq_name]['beacon_phase'] for ant in antennas]))
if 'true_phase' in antennas[0].beacon_info[freq_name]:
if False and 'true_phase' in antennas[0].beacon_info[freq_name]:
beacon_true_phases = lib.phase_mod(np.array([ant.beacon_info[freq_name]['true_phase'] for ant in antennas]))
else:
subtitle = " Phases from t0"