mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-13 01:53:31 +01:00
ZH: show sigma_phase matrix as a plot
This commit is contained in:
parent
37943a19b0
commit
755426e156
1 changed files with 65 additions and 7 deletions
|
@ -4,6 +4,8 @@
|
||||||
import h5py
|
import h5py
|
||||||
from itertools import combinations, zip_longest
|
from itertools import combinations, zip_longest
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
from matplotlib.colors import Normalize
|
||||||
|
import matplotlib as mpl
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
import aa_generate_beacon as beacon
|
import aa_generate_beacon as beacon
|
||||||
|
@ -50,17 +52,53 @@ if __name__ == "__main__":
|
||||||
idx = (name2idx(b[0]), name2idx(b[1]))
|
idx = (name2idx(b[0]), name2idx(b[1]))
|
||||||
|
|
||||||
if idx[0] == idx[1]:
|
if idx[0] == idx[1]:
|
||||||
|
# hopefully 0
|
||||||
pass
|
pass
|
||||||
|
|
||||||
sigma_phase_matrix[(idx[0], idx[1])] = true_phase_diffs[i]
|
sigma_phase_matrix[(idx[0], idx[1])] = lib.phase_mod(true_phase_diffs[i])
|
||||||
sigma_phase_matrix[(idx[1], idx[0])] = true_phase_diffs[i]
|
sigma_phase_matrix[(idx[1], idx[0])] = lib.phase_mod(true_phase_diffs[i])
|
||||||
|
|
||||||
# for each row j subtract the 0,j element from the whole row
|
mat_kwargs = dict(
|
||||||
# and apply phase_mod
|
norm = Normalize(vmin=-np.pi, vmax=+np.pi),
|
||||||
first_row = sigma_phase_matrix[0]
|
cmap = mpl.cm.get_cmap('Spectral_r')
|
||||||
|
)
|
||||||
|
|
||||||
sigma_phase_matrix = sigma_phase_matrix - first_row[:,np.newaxis]
|
# Show Matrix as figure
|
||||||
sigma_phase_matrix = lib.phase_mod(sigma_phase_matrix)
|
if True:
|
||||||
|
fig, ax = plt.subplots()
|
||||||
|
ax.set_title("Measured phase differences Baseline i,j")
|
||||||
|
ax.set_ylabel("Antenna no. i")
|
||||||
|
ax.set_xlabel("Antenna no. j")
|
||||||
|
|
||||||
|
im = ax.imshow(sigma_phase_matrix, interpolation='none', **mat_kwargs)
|
||||||
|
fig.colorbar(im, ax=ax)
|
||||||
|
|
||||||
|
if fig_dir:
|
||||||
|
fig.savefig(path.join(fig_dir, __file__ + f".matrix.original.pdf"))
|
||||||
|
|
||||||
|
|
||||||
|
# Modify the matrix to let each column represent multiple
|
||||||
|
# measurements of the same baseline (j,0) phase difference
|
||||||
|
if True:
|
||||||
|
# for each row j subtract the 0,j element from the whole row
|
||||||
|
# and apply phase_mod
|
||||||
|
first_row = (sigma_phase_matrix[0,:] * np.ones_like(sigma_phase_matrix)).T
|
||||||
|
|
||||||
|
# Show subtraction Matrix as figure
|
||||||
|
if True:
|
||||||
|
fig, ax = plt.subplots()
|
||||||
|
ax.set_title("Subtraction matrix i,j")
|
||||||
|
ax.set_ylabel("Antenna no. i")
|
||||||
|
ax.set_xlabel("Antenna no. j")
|
||||||
|
|
||||||
|
im = ax.imshow(first_row, interpolation='none', **mat_kwargs)
|
||||||
|
fig.colorbar(im, ax=ax)
|
||||||
|
|
||||||
|
if fig_dir:
|
||||||
|
fig.savefig(path.join(fig_dir, __file__ + f".matrix.first_row.pdf"))
|
||||||
|
|
||||||
|
sigma_phase_matrix = sigma_phase_matrix - first_row
|
||||||
|
sigma_phase_matrix = lib.phase_mod(sigma_phase_matrix)
|
||||||
|
|
||||||
# Except for the first row, these are all separate measurements
|
# Except for the first row, these are all separate measurements
|
||||||
# Condense into phase offset per antenna
|
# Condense into phase offset per antenna
|
||||||
|
@ -72,6 +110,26 @@ if __name__ == "__main__":
|
||||||
mean_sigma_phase = np.nanmean(sigma_phase_matrix[my_mask], axis=0)
|
mean_sigma_phase = np.nanmean(sigma_phase_matrix[my_mask], axis=0)
|
||||||
std_sigma_phase = np.nanstd( sigma_phase_matrix[my_mask], axis=0)
|
std_sigma_phase = np.nanstd( sigma_phase_matrix[my_mask], axis=0)
|
||||||
|
|
||||||
|
|
||||||
|
# Show resulting matrix as figure
|
||||||
|
if True:
|
||||||
|
fig, axs = plt.subplots(2,1, sharex=True)
|
||||||
|
axs[0].set_title("Modified measured phase differences Baseline 0,j")
|
||||||
|
axs[0].set_ylabel("Antenna no. 0")
|
||||||
|
axs[-1].set_xlabel("Antenna no. j")
|
||||||
|
|
||||||
|
im = axs[0].imshow(sigma_phase_matrix, interpolation='none', **mat_kwargs)
|
||||||
|
fig.colorbar(im, ax=axs)
|
||||||
|
axs[0].set_aspect('auto')
|
||||||
|
|
||||||
|
colours = [mat_kwargs['cmap'](mat_kwargs['norm'](x)) for x in mean_sigma_phase]
|
||||||
|
axs[1].set_ylabel("Mean Baseline Phase (0, j)[rad]")
|
||||||
|
axs[1].errorbar(np.arange(N_ant), mean_sigma_phase, yerr=std_sigma_phase, ls='none')
|
||||||
|
axs[1].scatter(np.arange(N_ant), mean_sigma_phase, c=colours,s=4)
|
||||||
|
|
||||||
|
if fig_dir:
|
||||||
|
fig.savefig(path.join(fig_dir, __file__ + f".matrix.modified.pdf"))
|
||||||
|
|
||||||
# write into antenna hdf5
|
# write into antenna hdf5
|
||||||
with h5py.File(antennas_fname, 'a') as fp:
|
with h5py.File(antennas_fname, 'a') as fp:
|
||||||
group = fp['antennas']
|
group = fp['antennas']
|
||||||
|
|
Loading…
Reference in a new issue