def plot_coherence_matrix4pixel(self, yx): """Plot coherence matrix for one pixel Parameters: yx : list of 2 int """ # read coherence box = (yx[1], yx[0], yx[1]+1, yx[0]+1) coh = readfile.read(self.ifgram_file, datasetName='coherence', box=box)[0] # prep metadata plotDict = {} plotDict['fig_title'] = 'Y = {}, X = {}'.format(yx[0], yx[1]) plotDict['colormap'] = self.colormap plotDict['disp_legend'] = False # plot coh_mat = pp.plot_coherence_matrix(self.ax_mat, date12List=self.date12_list, cohList=coh.tolist(), date12List_drop=self.ex_date12_list, plot_dict=plotDict)[1] self.fig.canvas.draw() # status bar def format_coord(x, y): row, col = int(y+0.5), int(x+0.5) date12 = sorted([self.date_list[row], self.date_list[col]]) date12 = ['{}-{}-{}'.format(i[0:4], i[4:6], i[6:8]) for i in date12] return 'x={}, y={}, v={:.3f}'.format(date12[0], date12[1], coh_mat[row, col]) self.ax_mat.format_coord = format_coord # info vprint('-'*30) vprint('pixel: yx = {}'.format(yx)) vprint('min/max coherence: {:.2f} / {:.2f}'.format(np.min(coh), np.max(coh))) return
def main(iargs=None): inps = cmd_line_parse(iargs) inps = read_network_info(inps) # Plot if not inps.disp_fig: plt.switch_backend('Agg') inps.cbar_label = 'Average Spatial Coherence' figNames = [i+inps.fig_ext for i in ['BperpHistory', 'CoherenceMatrix', 'CoherenceHistory', 'Network']] # Fig 1 - Baseline History fig, ax = plt.subplots(figsize=inps.fig_size) ax = pp.plot_perp_baseline_hist(ax, inps.dateList, inps.pbaseList, vars(inps), inps.dateList_drop) if inps.save_fig: fig.savefig(figNames[0], bbox_inches='tight', transparent=True, dpi=inps.fig_dpi) print('save figure to {}'.format(figNames[0])) if inps.cohList is not None: # Fig 2 - Coherence Matrix fig, ax = plt.subplots(figsize=inps.fig_size) ax = pp.plot_coherence_matrix(ax, inps.date12List, inps.cohList, inps.date12List_drop, plot_dict=vars(inps))[0] if inps.save_fig: fig.savefig(figNames[1], bbox_inches='tight', transparent=True, dpi=inps.fig_dpi) print('save figure to {}'.format(figNames[1])) # Fig 3 - Min/Max Coherence History fig, ax = plt.subplots(figsize=inps.fig_size) ax = pp.plot_coherence_history(ax, inps.date12List, inps.cohList, plot_dict=vars(inps)) if inps.save_fig: fig.savefig(figNames[2], bbox_inches='tight', transparent=True, dpi=inps.fig_dpi) print('save figure to {}'.format(figNames[2])) # Fig 4 - Interferogram Network fig, ax = plt.subplots(figsize=inps.fig_size) ax = pp.plot_network(ax, inps.date12List, inps.dateList, inps.pbaseList, vars(inps), inps.date12List_drop) if inps.save_fig: fig.savefig(figNames[3], bbox_inches='tight', transparent=True, dpi=inps.fig_dpi) print('save figure to {}'.format(figNames[3])) if inps.disp_fig: print('showing ...') plt.show()
def main(iargs=None): inps = cmd_line_parse(iargs) # Plot inps.cbar_label = 'Average Spatial Coherence' figNames = [i+'.pdf' for i in ['BperpHistory', 'CoherenceMatrix', 'CoherenceHistory', 'Network']] # Fig 1 - Baseline History fig, ax = plt.subplots(figsize=inps.fig_size) ax = pp.plot_perp_baseline_hist(ax, inps.dateList, inps.pbaseList, vars(inps), inps.dateList_drop) if inps.save_fig: fig.savefig(figNames[0], bbox_inches='tight', transparent=True, dpi=inps.fig_dpi) print('save figure to {}'.format(figNames[0])) if inps.cohList is not None: # Fig 2 - Coherence Matrix fig, ax = plt.subplots(figsize=inps.fig_size) ax = pp.plot_coherence_matrix(ax, inps.date12List, inps.cohList, inps.date12List_drop, plot_dict=vars(inps))[0] if inps.save_fig: fig.savefig(figNames[1], bbox_inches='tight', transparent=True, dpi=inps.fig_dpi) print('save figure to {}'.format(figNames[1])) # Fig 3 - Min/Max Coherence History fig, ax = plt.subplots(figsize=inps.fig_size) ax = pp.plot_coherence_history(ax, inps.date12List, inps.cohList, plot_dict=vars(inps)) if inps.save_fig: fig.savefig(figNames[2], bbox_inches='tight', transparent=True, dpi=inps.fig_dpi) print('save figure to {}'.format(figNames[2])) # Fig 4 - Interferogram Network fig, ax = plt.subplots(figsize=inps.fig_size) ax = pp.plot_network(ax, inps.date12List, inps.dateList, inps.pbaseList, vars(inps), inps.date12List_drop) if inps.save_fig: fig.savefig(figNames[3], bbox_inches='tight', transparent=True, dpi=inps.fig_dpi) print('save figure to {}'.format(figNames[3])) if inps.disp_fig: print('showing ...') plt.show()
def plot_coherence_matrix4pixel(self, yx): """Plot coherence matrix for one pixel Parameters: yx : list of 2 int """ self.ax_mat.cla() # read coherence box = (yx[1], yx[0], yx[1]+1, yx[0]+1) coh = readfile.read(self.ifgram_file, datasetName='coherence', box=box)[0] # ex_date for pixel-wise masking during network inversion ex_date12_list = self.ex_date12_list[:] #local copy if self.min_coh_used > 0.: ex_date12_list += np.array(self.date12_list)[coh < self.min_coh_used].tolist() ex_date12_list = sorted(list(set(ex_date12_list))) # prep metadata plotDict = {} plotDict['fig_title'] = 'Y = {}, X = {}'.format(yx[0], yx[1]) # display temporal coherence value of the pixel if self.tcoh_file: tcoh = self.tcoh[yx[0], yx[1]] plotDict['fig_title'] += ', tcoh = {:.2f}'.format(tcoh) plotDict['colormap'] = self.colormap plotDict['cmap_vlist'] = self.cmap_vlist plotDict['disp_legend'] = False # plot coh_mat = pp.plot_coherence_matrix(self.ax_mat, date12List=self.date12_list, cohList=coh.tolist(), date12List_drop=ex_date12_list, plot_dict=plotDict)[1] self.ax_mat.annotate('ifgrams\navailable', xy=(0.05, 0.05), xycoords='axes fraction', fontsize=12) self.ax_mat.annotate('ifgrams\nused', ha='right', xy=(0.95, 0.85), xycoords='axes fraction', fontsize=12) # status bar def format_coord(x, y): row, col = int(y+0.5), int(x+0.5) date12 = sorted([self.date_list[row], self.date_list[col]]) date12 = ['{}-{}-{}'.format(i[0:4], i[4:6], i[6:8]) for i in date12] return 'x={}, y={}, v={:.3f}'.format(date12[0], date12[1], coh_mat[row, col]) self.ax_mat.format_coord = format_coord # info msg = 'pixel in yx = {}, '.format(tuple(yx)) msg += 'min/max spatial coherence: {:.2f} / {:.2f}, '.format(np.min(coh), np.max(coh)) if self.tcoh_file: msg += 'temporal coherence: {:.2f}'.format(tcoh) vprint(msg) self.fig.canvas.draw() return
def plot_network_info(inps): if not inps.disp_fig: plt.switch_backend('Agg') out_fig_name = os.path.join(inps.out_dir, 'network{}'.format(inps.figext)) log('plot network / pairs to file: ' + os.path.basename(out_fig_name)) fig1, ax1 = plt.subplots(figsize=inps.fig_size) ax1 = pp.plot_network(ax1, inps.date12_list, inps.date_list, inps.pbase_list, p_dict=vars(inps), print_msg=False) plt.savefig(out_fig_name, bbox_inches='tight', dpi=inps.figdpi) out_fig_name = os.path.join(inps.out_dir, 'bperpHistory{}'.format(inps.figext)) log('plot baseline history to file: ' + os.path.basename(out_fig_name)) fig2, ax2 = plt.subplots(figsize=inps.fig_size) ax2 = pp.plot_perp_baseline_hist(ax2, inps.date_list, inps.pbase_list) plt.savefig(out_fig_name, bbox_inches='tight', dpi=inps.figdpi) out_fig_name = os.path.join(inps.out_dir, 'coherenceMatrix{}'.format(inps.figext)) if inps.cohList: log('plot predicted coherence matrix to file: ' + os.path.basename(out_fig_name)) fig3, ax3 = plt.subplots(figsize=inps.fig_size) ax3 = pp.plot_coherence_matrix(ax3, inps.date12_list, inps.cohList, p_dict=vars(inps))[0] plt.savefig(out_fig_name, bbox_inches='tight', dpi=inps.figdpi) if inps.disp_fig: plt.show() return
def main(iargs=None): inps = cmd_line_parse(iargs) # read / calculate inps = read_network_info(inps) # Plot settings inps = check_colormap(inps) if inps.dsetName == 'coherence': inps.ds_name = 'Coherence' figNames = [ i + '.pdf' for i in ['bperpHistory', 'coherenceMatrix', 'coherenceHistory', 'network'] ] elif inps.dsetName == 'offsetSNR': inps.ds_name = 'SNR' figNames = [ i + '.pdf' for i in ['bperpHistory', 'SNRMatrix', 'SNRHistory', 'network'] ] inps.cbar_label = 'Average Spatial {}'.format(inps.ds_name) # Fig 1 - Baseline History fig, ax = plt.subplots(figsize=inps.fig_size) ax = pp.plot_perp_baseline_hist(ax, inps.dateList, inps.pbaseList, vars(inps), inps.dateList_drop) if inps.save_fig: fig.savefig(figNames[0], bbox_inches='tight', transparent=True, dpi=inps.fig_dpi) print('save figure to {}'.format(figNames[0])) if inps.cohList is not None: # Fig 2 - Coherence Matrix fig, ax = plt.subplots(figsize=inps.fig_size) ax = pp.plot_coherence_matrix(ax, inps.date12List, inps.cohList, inps.date12List_drop, p_dict=vars(inps))[0] if inps.save_fig: fig.savefig(figNames[1], bbox_inches='tight', transparent=True, dpi=inps.fig_dpi) print('save figure to {}'.format(figNames[1])) # Fig 3 - Min/Max Coherence History fig, ax = plt.subplots(figsize=inps.fig_size) ax = pp.plot_coherence_history(ax, inps.date12List, inps.cohList, p_dict=vars(inps)) if inps.save_fig: fig.savefig(figNames[2], bbox_inches='tight', transparent=True, dpi=inps.fig_dpi) print('save figure to {}'.format(figNames[2])) # Fig 4 - Interferogram Network fig, ax = plt.subplots(figsize=inps.fig_size) ax = pp.plot_network(ax, inps.date12List, inps.dateList, inps.pbaseList, vars(inps), inps.date12List_drop) if inps.save_fig: fig.savefig(figNames[3], bbox_inches='tight', transparent=True, dpi=inps.fig_dpi) print('save figure to {}'.format(figNames[3])) if inps.disp_fig: print('showing ...') plt.show() else: plt.close() return