Skip to content
Snippets Groups Projects
Commit 73be0165 authored by Alexander Kutkin's avatar Alexander Kutkin
Browse files

better plotting soulutions; some config adjustments

parent ef7a1a10
Branches
No related tags found
No related merge requests found
...@@ -241,47 +241,54 @@ def phase_shift(msin, new_center, msout=None): ...@@ -241,47 +241,54 @@ def phase_shift(msin, new_center, msout=None):
def view_sols(h5param, outname=None): def view_sols(h5param, outname=None):
""" read and plot the gains """ """ read and plot the gains """
path = os.path.split(os.path.abspath(h5param))[0]
def plot_sols(h5param, key): def plot_sols(h5param, key):
print('AAA')
figs = []
axs = []
with h5py.File(h5param, 'r') as f: with h5py.File(h5param, 'r') as f:
grp = f['sol000/{}'.format(key)] grp = f['sol000/{}'.format(key)]
data = grp['val'][()] data = grp['val'][()]
time = grp['time'][()] time = grp['time'][()]
print(data.shape)
ants = ['RT2','RT3','RT4','RT5','RT6','RT7','RT8','RT9','RTA','RTB','RTC','RTD'] ants = ['RT2','RT3','RT4','RT5','RT6','RT7','RT8','RT9','RTA','RTB','RTC','RTD']
for ipol, pol in enumerate(['XX', 'YY']):
fig = plt.figure(figsize=[20, 15]) fig = plt.figure(figsize=[20, 15])
fig.suptitle('Freq. averaged {} gain solutions'.format(key.rstrip('000'))) fig.suptitle('Freq. averaged {} gain solutions ({})'.format(key.rstrip('000'), pol))
print(dict(f['sol000/amplitude000/val'].attrs.items())) # h5 attributes
for i, ant in enumerate(ants): for i, ant in enumerate(ants):
ax = fig.add_subplot(4, 3, i+1) ax = fig.add_subplot(4, 3, i+1)
ax.set_title(ant) ax.set_title(ant)
if len(data.shape) == 5: # several directions gavg = np.nanmean(data, axis=1)[...,ipol] # average by frequency
# a = ax.imshow(data[:,:,i,1,0].T, aspect='auto') if key.startswith('phase'):
# plt.colorbar(a) ax.plot((time-time[0])/3600.0, gavg[:, i,]*180.0/np.pi, alpha=0.7)
gavg = np.nanmean(data, axis=1) ax.set_ylim([-180,180])
ax.plot((time-time[0])/60.0, gavg[:, i, :, 0], alpha=0.7) else:
elif len(data.shape) == 4: # a single direction ax.plot((time-time[0])/3600.0, gavg[:, i,], alpha=0.7)
ax.plot((time-time[0])/3600.0, data[:, 0, i, 0], alpha=0.7) if key.startswith('amplitude'):
ax.set_ylim([-0.1,2.1])
if i == 0: if i == 0:
ax.legend(['c{}'.format(_) for _ in range(data.shape[-2])]) ax.legend(['c{}'.format(_) for _ in range(data.shape[-2])])
if i == 10: if i == 10:
ax.set_xlabel('Time (hrs)') ax.set_xlabel('Time (hrs)')
return fig, ax
if outname is not None: figs.append(fig)
axs.append(ax)
return figs, axs
try: try:
fig1, ax1 = plot_sols(h5param, 'amplitude000') (fig1, fig2), (ax1, ax2) = plot_sols(h5param, 'amplitude000')
fig1.savefig(f'{outname}_amp.png') if outname is not None:
fig1.savefig(f'{outname}_amp_XX.png')
fig2.savefig(f'{outname}_amp_YY.png')
except: except:
logging.error('No amplitude solutions found') logging.error('No amplitude solutions found')
try: try:
fig2, ax2 = plot_sols(h5param, 'phase000') (fig1, fig2), (ax1, ax2) = plot_sols(h5param, 'phase000')
fig2.savefig(f'{outname}_phase.png') if outname is not None:
fig1.savefig(f'{outname}_phase_XX.png')
fig2.savefig(f'{outname}_phase_YY.png')
except: except:
logging.error('No phase solutions found') logging.error('No phase solutions found')
# plt.show()
def remove_model_components_below_level(model, level=0.0, out=None): def remove_model_components_below_level(model, level=0.0, out=None):
""" """
...@@ -359,6 +366,8 @@ def main(msin, outbase=None, cfgfile='imcal.yml'): ...@@ -359,6 +366,8 @@ def main(msin, outbase=None, cfgfile='imcal.yml'):
if (not os.path.exists(ms_split)) and (cfg['split1']['startchan'] or cfg['split1']['nchan']): if (not os.path.exists(ms_split)) and (cfg['split1']['startchan'] or cfg['split1']['nchan']):
ms_split = split_ms(msin, msout_path=ms_split, **cfg['split1']) ms_split = split_ms(msin, msout_path=ms_split, **cfg['split1'])
else:
ms_split = msin
# Clean + DIcal # Clean + DIcal
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
####################### IMAGING ####################### ####################### IMAGING #######################
split1: split1:
startchan: 0 # start channel to split from startchan: 40 # start channel to split from
nchan: 0 # 0 means till the end nchan: 0 # 0 means till the end
clean0: # initial clean clean0: # initial clean
...@@ -44,7 +44,7 @@ clean2: ...@@ -44,7 +44,7 @@ clean2:
autothresh: 5 autothresh: 5
multiscale: True multiscale: True
clip_model_level: null clip_model_level: null
kwstring: '-use-wgridder -parallel-deconvolution 1400 -parallel-gridding 8 -deconvolution-channels -weight briggs 0.0' kwstring: '-use-wgridder -parallel-deconvolution 1400 -parallel-gridding 8 -deconvolution-channels 3 -weight briggs 0.0'
dical2: dical2:
solint: 1 solint: 1
...@@ -103,10 +103,10 @@ clean5: ...@@ -103,10 +103,10 @@ clean5:
imagesize: 3072 imagesize: 3072
pixelsize: 3 pixelsize: 3
multifreq: 8 multifreq: 8
# automask: 0 automask: 4
autothresh: 1.0 autothresh: 0.5
multiscale: True multiscale: True
fitsmask: 'mask2.fits' fitsmask: null
clip_model_level: null clip_model_level: null
kwstring: '-use-wgridder -parallel-deconvolution 1400 -parallel-gridding 8 -deconvolution-channels 3 -weight briggs -1.5' kwstring: '-use-wgridder -parallel-deconvolution 1400 -parallel-gridding 8 -deconvolution-channels 3 -weight briggs -1.5'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment