Beispiel #1
0
def timeseries2ifgram(ts_sim,
                      date_list,
                      date12_list,
                      wvl=0.055,
                      display=False):
    range2phase = -4.0 * np.pi / wvl
    num_ifgram = len(date12_list)
    ifgram_sim = np.zeros((num_ifgram, 1), np.float32)
    for i in range(num_ifgram):
        m_date, s_date = date12_list[i].split('_')
        m_idx = date_list.index(m_date)
        s_idx = date_list.index(s_date)
        ifgram_sim[i] = ts_sim[s_idx] - ts_sim[m_idx]
    ifgram_sim *= range2phase

    if display:
        ifgram_sim_mat = pnet.coherence_matrix(date12_list, ifgram_sim)
        plt.figure()
        plt.imshow(ifgram_sim_mat, cmap='jet')
        plt.xlabel('Image number')
        plt.ylabel('Image number')
        cbar = plt.colorbar()
        cbar.set_label('Phase (radian)')
        plt.title('Interferometric Phase')
        plt.show()
    return ifgram_sim
Beispiel #2
0
def simulate_decorrelation_noises(date12_list, cohs, L=20, size:int=1, display=False, scale=1.0):
    '''Simuate decorrelation phase noise for input interferometric pairs
    Inputs:
        date12_list - list of string in YYMMDD-YYMMDD format, indicating pairs configuration
        cohs - 2D np.array in size of (ifgram_num,1)
        L    - int, multilook number
    Output:
        decorNoises - 2D np.array in size of (ifgram_num, 1)
    Example:
        from pysar.utils import network as pnet
        date12_list_all = pnet.get_date12_list('ifgram_list_all.txt')
        cohs = pnet.simulate_coherence(date12_list_all, decor_time=1000, coh_resid=0.2, display=True, inc_angle=22.8)
        decorNoises = simulate_decorrelation_noises(date12_list_all, cohs, L=20, display=True)
    '''
    ifgram_num = len(cohs)
    decorNoises = np.zeros((ifgram_num, size), np.float32)
    for i in range(ifgram_num):
        decorNoises[i, :] = sample_decorrelation_phase(int(L), cohs[i], size=size, scale=scale)

    if display:
        decorNoisesMat = pnet.coherence_matrix(date12_list, decorNoises)
        plt.figure()
        #plt.imshow(decorNoisesMat, vmin=-np.pi, vmax=np.pi, cmap='jet')
        plt.imshow(decorNoisesMat, cmap='jet')
        plt.xlabel('Image number')
        plt.ylabel('Image number')
        cbar = plt.colorbar()
        cbar.set_label('Decorrelation Phase Noise (radian)')
        plt.title('Decorrelation Noise')
        plt.show()
    return decorNoises
Beispiel #3
0
def plot_coherence_matrix(ax, date12List, cohList, date12List_drop=[], plot_dict={}):
    """Plot Coherence Matrix of input network

    if date12List_drop is not empty, plot KEPT pairs in the upper triangle and
                                           ALL  pairs in the lower triangle.
    """
    # Figure Setting
    if not 'fontsize'    in plot_dict.keys():   plot_dict['fontsize']    = 12
    if not 'linewidth'   in plot_dict.keys():   plot_dict['linewidth']   = 2
    if not 'markercolor' in plot_dict.keys():   plot_dict['markercolor'] = 'orange'
    if not 'markersize'  in plot_dict.keys():   plot_dict['markersize']  = 16
    if not 'disp_title'  in plot_dict.keys():   plot_dict['disp_title']  = True
    if not 'cbar_label'  in plot_dict.keys():   plot_dict['cbar_label']  = 'Coherence'

    date12List = ptime.yyyymmdd_date12(date12List)
    coh_mat = pnet.coherence_matrix(date12List, cohList)

    if date12List_drop:
        # Date Convert
        m_dates = [i.split('_')[0] for i in date12List]
        s_dates = [i.split('_')[1] for i in date12List]
        dateList = sorted(list(set(m_dates + s_dates)))
        # Set dropped pairs' value to nan, in upper triangle only.
        for date12 in date12List_drop:
            idx1, idx2 = [dateList.index(i) for i in date12.split('_')]
            coh_mat[idx1, idx2] = np.nan

    # Show diagonal value as black, to be distinguished from un-selected interferograms
    diag_mat = np.diag(np.ones(coh_mat.shape[0]))
    diag_mat[diag_mat == 0.] = np.nan
    im = ax.imshow(diag_mat, cmap='gray_r', vmin=0.0, vmax=1.0, interpolation='nearest')
    im = ax.imshow(coh_mat, cmap='jet', vmin=0.0, vmax=1.0, interpolation='nearest')

    date_num = coh_mat.shape[0]
    if date_num < 30:
        tick_list = list(range(0, date_num, 5))
    else:
        tick_list = list(range(0, date_num, 10))
    ax.get_xaxis().set_ticks(tick_list)
    ax.get_yaxis().set_ticks(tick_list)
    ax.set_xlabel('Image Number', fontsize=plot_dict['fontsize'])
    ax.set_ylabel('Image Number', fontsize=plot_dict['fontsize'])

    if plot_dict['disp_title']:
        ax.set_title('Coherence Matrix')

    # Colorbar
    divider = make_axes_locatable(ax)
    cax = divider.append_axes("right", "3%", pad="3%")
    cbar = plt.colorbar(im, cax=cax)
    cbar.set_label(plot_dict['cbar_label'], fontsize=plot_dict['fontsize'])

    # Legend
    if date12List_drop:
        ax.plot([], [], label='Upper: used ifgrams')
        ax.plot([], [], label='Lower: all ifgrams')
        ax.legend(handlelength=0)

    return ax
Beispiel #4
0
def plot_coherence_history(ax, date12List, cohList, plot_dict={}):
    """Plot min/max Coherence of all interferograms for each date"""
    # Figure Setting
    if not 'fontsize'    in plot_dict.keys():   plot_dict['fontsize']    = 12
    if not 'linewidth'   in plot_dict.keys():   plot_dict['linewidth']   = 2
    if not 'markercolor' in plot_dict.keys():   plot_dict['markercolor'] = 'orange'
    if not 'markersize'  in plot_dict.keys():   plot_dict['markersize']  = 16
    if not 'disp_title'  in plot_dict.keys():   plot_dict['disp_title']  = True
    if not 'every_year'  in plot_dict.keys():   plot_dict['every_year']  = 1

    # Get date list
    date12List = ptime.yyyymmdd_date12(date12List)
    m_dates = [date12.split('_')[0] for date12 in date12List]
    s_dates = [date12.split('_')[1] for date12 in date12List]
    dateList = sorted(ptime.yyyymmdd(list(set(m_dates + s_dates))))

    dates, datevector = ptime.date_list2vector(dateList)
    bar_width = ut.most_common(np.diff(dates).tolist())*3/4
    x_list = [i-bar_width/2 for i in dates]

    coh_mat = pnet.coherence_matrix(date12List, cohList)

    ax.bar(x_list, np.nanmax(coh_mat, axis=0), bar_width.days, label='Max Coherence')
    ax.bar(x_list, np.nanmin(coh_mat, axis=0), bar_width.days, label='Min Coherence')

    if plot_dict['disp_title']:
        ax.set_title('Coherence History of All Related Interferograms')

    ax = auto_adjust_xaxis_date(ax, datevector, plot_dict['fontsize'],
                                every_year=plot_dict['every_year'])[0]
    ax.set_ylim([0.0, 1.0])

    ax.set_xlabel('Time [years]', fontsize=plot_dict['fontsize'])
    ax.set_ylabel('Coherence', fontsize=plot_dict['fontsize'])
    ax.legend(loc='lower right')

    return ax