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 manual_select_pairs_to_remove(stackFile): """Manually select interferograms to remove""" print('\n-------------------------------------------------------------') print('Manually select interferograms to remove') print('1) click two dates/points to select one pair of interferogram') print('2) repeat until you select all pairs you would like to remove') print('3) close the figure to continue the program ...') print('-------------------------------------------------------------\n') obj = ifgramStack(stackFile) obj.open() date12ListAll = obj.date12List pbase = obj.get_perp_baseline_timeseries(dropIfgram=False) dateList = obj.dateList datesNum = mdates.date2num(np.array(ptime.date_list2vector(dateList)[0])) date12ListKept = obj.get_date12_list(dropIfgram=True) date12ListDropped = sorted(list(set(date12ListAll) - set(date12ListKept))) # Display the network fig = plt.figure() ax = fig.add_subplot(111) ax = pp.plot_network(ax, date12ListAll, dateList, list(pbase), date12List_drop=date12ListDropped) print('display the network of interferogram of file: ' + stackFile) date_click = [] date12_click = [] def onclick(event): idx = nearest_neighbor(event.xdata, event.ydata, datesNum, pbase) print('click at ' + dateList[idx]) date_click.append(dateList[idx]) if len(date_click) % 2 == 0 and date_click[-2] != date_click[-1]: [mDate, sDate] = sorted(date_click[-2:]) mIdx = dateList.index(mDate) sIdx = dateList.index(sDate) date12 = mDate + '_' + sDate if date12 in date12ListAll: print('select date12: ' + date12) date12_click.append(date12) ax.plot([datesNum[mIdx], datesNum[sIdx]], [pbase[mIdx], pbase[sIdx]], 'r', lw=4) else: print(date12 + ' is not existed in input file') plt.draw() cid = fig.canvas.mpl_connect('button_press_event', onclick) plt.show() if not ut.yes_or_no('Proceed to drop the ifgrams/date12?'): date12_click = None return date12_click
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 manual_select_pairs_to_remove(stackFile): """Manually select interferograms to remove""" print('\n-------------------------------------------------------------') print('Manually select interferograms to remove') print('1) click two dates/points to select one pair of interferogram') print('2) repeat until you select all pairs you would like to remove') print('3) close the figure to continue the program ...') print('-------------------------------------------------------------\n') obj = ifgramStack(stackFile) obj.open() date12ListAll = obj.date12List pbase = obj.get_perp_baseline_timeseries(dropIfgram=False) dateList = obj.dateList datesNum = mdates.date2num(np.array(ptime.date_list2vector(dateList)[0])) date12ListKept = obj.get_date12_list(dropIfgram=True) date12ListDropped = sorted(list(set(date12ListAll) - set(date12ListKept))) # Display the network fig = plt.figure() ax = fig.add_subplot(111) ax = pp.plot_network(ax, date12ListAll, dateList, list(pbase), date12List_drop=date12ListDropped) print('display the network of interferogram of file: '+stackFile) date_click = [] date12_click = [] def onclick(event): idx = nearest_neighbor(event.xdata, event.ydata, datesNum, pbase) print('click at '+dateList[idx]) date_click.append(dateList[idx]) if len(date_click) % 2 == 0 and date_click[-2] != date_click[-1]: [mDate, sDate] = sorted(date_click[-2:]) mIdx = dateList.index(mDate) sIdx = dateList.index(sDate) date12 = mDate+'_'+sDate if date12 in date12ListAll: print('select date12: '+date12) date12_click.append(date12) ax.plot([datesNum[mIdx], datesNum[sIdx]], [pbase[mIdx], pbase[sIdx]], 'r', lw=4) else: print(date12+' is not existed in input file') plt.draw() cid = fig.canvas.mpl_connect('button_press_event', onclick) plt.show() if not ut.yes_or_no('Proceed to drop the ifgrams/date12?'): date12_click = None return date12_click
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