Ejemplo n.º 1
0
def main(iargs=None):
    inps = cmdLineParse(iargs)
    # setting up the simulation parameters

    signal_phase, t = simulate_phase_timeSeries(
        time_series_length=inps.timeLength,
        acquisition_interval=inps.dt,
        signal_rate=inps.linearRate,
        std_random=inps.randomStd,
        k=inps.seasonalMode)

    corr_mat = simulate_covariance_matrix(t,
                                          signal_phase,
                                          gamma0=inps.gamma0,
                                          Tau0=inps.Tau0,
                                          method=inps.decorModel)

    print("***** Simulating the neighbothood stack ******")
    neighbor_stack = simulate_neighborhood_stack(
        corr_mat, neighborSamples=inps.neighborSamples)

    ##Estimated cov_matrix
    cov_matrix = compute_covariance_matrix(neighbor_stack)

    ##################################
    # change covariance matrix to Small temporal Baseline network
    # (Keeping only 4 nearest neighbor pairs)
    cov_matrix_SB = make_StBAS_covariance_mat(
        cov_matrix, numberOfNearestNeighbor=inps.nearestNeighborStBAS)

    ##################################
    #MLE estimation of wrapped phase time-series using Full cov matrix
    print("******************************************")
    print("MLE estimation using full cov matrix")
    ph, Gmat = mle4(cov_matrix)

    print("******************************************")
    print("MLE estimation using SB cov matrix")
    ph_SB, Gmat_SB = mle4(cov_matrix_SB)

    plot_result(t, signal_phase, ph, ph_SB, cov_matrix, cov_matrix_SB,
                corr_mat, Gmat, Gmat_SB)

    print("******************************************")

    #Change  the covarainace matrix to have the known coherence
    cov_matrix = np.abs(corr_mat) * np.exp(1.0j * np.angle(cov_matrix))

    cov_matrix_SB = make_StBAS_covariance_mat(cov_matrix,
                                              numberOfNearestNeighbor=4)

    print(
        "MLE estimation using full cov matrix (simulated known coherence is used)"
    )
    ph, Gmat = mle4(cov_matrix)

    plot_result(t, signal_phase, ph, ph_SB, cov_matrix, cov_matrix_SB,
                corr_mat, Gmat, Gmat_SB)
def Sequential_estimator_overlap(inps, t, neighbor_stack, miniStackSize=10):

    cov_matrix = compute_covariance_matrix(neighbor_stack)

    # size of mini stacks and number of mini stacks

    numMiniStacks = int(len(t) / miniStackSize)
    # 1 Initiaation
    #covarinace matrix of the first mini-stack
    Cs = cov_matrix[0:miniStackSize, 0:miniStackSize]

    # MLE estimation for the first mini-stack
    ph_ML, Gmats = mle4(Cs)

    # Preparing the transformation for SLC compression
    v_ML = np.exp(1.0j * ph_ML)
    norm_v_ML = np.dot(v_ML, np.matrix.getH(v_ML))
    v_ML = v_ML / norm_v_ML

    # compress SLCs of the first mini-stack
    Z_ML = np.dot(np.matrix.getH(v_ML), neighbor_stack[0:miniStackSize, :])

    # A matrix for compressed SLCs
    compressed_SLCs = np.zeros((numMiniStacks, inps.neighborSamples),
                               dtype=np.complex64)

    # archive the first compressed SLC for all neighborhoods
    compressed_SLCs[0, :] = Z_ML

    # A matrix for estimated sequential phase series
    sequential_phase_series = np.zeros((len(t)), dtype=np.float32)

    # store the phase series of the first mini-stack
    sequential_phase_series[0:10] = ph_ML

    for k in range(1, numMiniStacks):
        # iterate for each ministack
        Cs = cov_matrix[k * miniStackSize - 1:(k + 1) * miniStackSize,
                        k * miniStackSize - 1:(k + 1) * miniStackSize]
        ph_ML, Gmats = mle4(Cs)
        #v_ML = np.exp(1.0j*ph_ML)
        #norm_v_ML = np.dot(v_ML,np.matrix.getH(v_ML))
        #v_ML = v_ML/norm_v_ML
        #compressing SLC
        #Z_ML = np.dot(np.matrix.getH(v_ML), neighbor_stack[k*miniStackSize-1:(k+1)*miniStackSize, :])
        #compressed_SLCs[k,:] = Z_ML
        ph_ML = ph_ML + sequential_phase_series[k * miniStackSize - 1]
        sequential_phase_series[k * miniStackSize - 1:(k + 1) *
                                miniStackSize] = ph_ML

        #Datum connection
        #compute covariance matrix for the compressed SLCs
    #cov_compressed_slc = compute_covariance_matrix(compressed_SLCs)
    #ph_ML_compressed, Gmats = mle4(cov_compressed_slc)
    #for k in range(numMiniStacks):
    #    sequential_phase_series[k*miniStackSize:(k+1)*miniStackSize] = sequential_phase_series[k*miniStackSize:(k+1)*miniStackSize] + ph_ML_compressed[k]

    return sequential_phase_series
def realize_simulation(inps, signal_phase, t, corr_mat):

    print("***** Simulating the neighbothood stack ******")
    neighbor_stack = simulate_neighborhood_stack(
        corr_mat, neighborSamples=inps.neighborSamples)

    ##Estimated cov_matrix
    cov_matrix = compute_covariance_matrix(neighbor_stack)

    ## Theoretical accuracy based on the Cramer Rao Lower Bound
    FIM = Fisher_Information_Matrix(corr_mat, inps.neighborSamples)
    CRLB = Cramer_Rao_Lower_Bound(FIM, len(t))

    ##################################
    # change covariance matrix to Small temporal Baseline network
    # (Keeping only 4 nearest neighbor pairs)
    cov_matrix_SB = make_StBAS_covariance_mat(
        cov_matrix, numberOfNearestNeighbor=inps.nearestNeighborStBAS)

    ##################################
    #MLE estimation of wrapped phase time-series using Full cov matrix
    print("******************************************")
    print("MLE estimation using full cov matrix")
    ph_MLE, Gmat = mle4(cov_matrix)

    ##################################
    # The first eigen value is also a very close estimate of the the phase series
    w, v = np.linalg.eigh(Gmat)
    ph_Eig = np.angle(v[:, 0])
    ph_Eig = wrap_phase(ph_Eig - ph_Eig[0])

    #print("******************************************")
    #print("MLE estimation using SB cov matrix")
    ph_SB, Gmat_SB = mle4(cov_matrix_SB)

    #plot_result(t, signal_phase, ph, ph_SB, cov_matrix, cov_matrix_SB, corr_mat, Gmat, Gmat_SB)

    print("******************************************")
    print("Sequential estimator")
    sequential_phase_series = Sequential_estimator(inps,
                                                   t,
                                                   neighbor_stack,
                                                   miniStackSize=10)
    sequential_phase_series_overlap = Sequential_estimator_overlap(
        inps, t, neighbor_stack, miniStackSize=10)
    #Sequential
    return ph_Eig, ph_MLE, ph_SB, sequential_phase_series, sequential_phase_series_overlap
Ejemplo n.º 4
0
def main(iargs=None):
    inps = cmdLineParse(iargs)
    # setting up the simulation parameters

    signal_phase, t = simulate_phase_timeSeries(time_series_length=inps.timeLength, acquisition_interval=inps.dt, signal_rate=inps.linearRate, std_random=inps.randomStd, k=inps.seasonalMode)

    corr_mat = simulate_covariance_matrix(t, signal_phase, gamma0 = inps.gamma0, Tau0 = inps.Tau0, method=inps.decorModel)

    print("***** Simulating the neighbothood stack ******")
    neighbor_stack = simulate_neighborhood_stack(corr_mat, neighborSamples = inps.neighborSamples)

    ##Estimated cov_matrix
    cov_matrix = compute_covariance_matrix(neighbor_stack)

    ## Theoretical accuracy based on the Cramer Rao Lower Bound
    FIM = Fisher_Information_Matrix(corr_mat, inps.neighborSamples)
    CRLB = Cramer_Rao_Lower_Bound(FIM, len(t))
    
    #fig = plt.figure()
    #ax = fig.add_subplot(1,2,1)
    #ax.imshow(FIM)
    #ax = fig.add_subplot(1,2,2)
    #ax.plot(CRLB)
    #ax.set_ylim([0, 2])
    #plt.show()

    ##################################
    # change covariance matrix to Small temporal Baseline network
    # (Keeping only 4 nearest neighbor pairs)
    cov_matrix_SB = make_StBAS_covariance_mat(cov_matrix, numberOfNearestNeighbor=inps.nearestNeighborStBAS)

    ##################################
    #MLE estimation of wrapped phase time-series using Full cov matrix
    print("******************************************")
    print("MLE estimation using full cov matrix")
    ph_MLE, Gmat = mle4(cov_matrix)

    #print("******************************************")
    #print("MLE estimation using SB cov matrix")
    ph_SB, Gmat_SB = mle4(cov_matrix_SB)

    #plot_result(t, signal_phase, ph, ph_SB, cov_matrix, cov_matrix_SB, corr_mat, Gmat, Gmat_SB)

    print("******************************************")
    print("Sequential estimator")
    #Sequential

    # size of mini stacks and number of mini stacks
    miniStackSize = 10
    numMiniStacks = int(len(t)/miniStackSize)
    # 1 Initiaation
    #covarinace matrix of the first mini-stack
    Cs = cov_matrix[0:miniStackSize, 0:miniStackSize]

    # MLE estimation for the first mini-stack
    ph_ML, Gmats = mle4(Cs)

    # Preparing the transformation for SLC compression
    v_ML = np.exp(1.0j*ph_ML)
    norm_v_ML = np.dot(v_ML,np.matrix.getH(v_ML))
    v_ML = v_ML/norm_v_ML

    # compress SLCs of the first mini-stack
    Z_ML = np.dot(np.matrix.getH(v_ML), neighbor_stack[0:miniStackSize,:])
    
    # A matrix for compressed SLCs
    compressed_SLCs = np.zeros((numMiniStacks, inps.neighborSamples), dtype=np.complex64) 

    # archive the first compressed SLC for all neighborhoods
    compressed_SLCs[0,:] = Z_ML

    # A matrix for estimated sequential phase series
    sequential_phase_series = np.zeros((len(t)), dtype=np.float32)

    # store the phase series of the first mini-stack
    sequential_phase_series[0:10] = ph_ML

    for k in range(1,numMiniStacks):
        # iterate for each ministack
        Cs = cov_matrix[k*miniStackSize:(k+1)*miniStackSize, k*miniStackSize:(k+1)*miniStackSize]
        ph_ML, Gmats = mle4(Cs)
        v_ML = np.exp(1.0j*ph_ML)
        norm_v_ML = np.dot(v_ML,np.matrix.getH(v_ML))
        v_ML = v_ML/norm_v_ML
        #compressing SLC
        Z_ML = np.dot(np.matrix.getH(v_ML), neighbor_stack[k*miniStackSize:(k+1)*miniStackSize, :])
        compressed_SLCs[k,:] = Z_ML
        sequential_phase_series[k*miniStackSize:(k+1)*miniStackSize] = ph_ML

    #Datum connection
    #compute covariance matrix for the compressed SLCs
    cov_compressed_slc = compute_covariance_matrix(compressed_SLCs)
    ph_ML_compressed, Gmats = mle4(cov_compressed_slc)
    for k in range(numMiniStacks):
        sequential_phase_series[k*miniStackSize:(k+1)*miniStackSize] = sequential_phase_series[k*miniStackSize:(k+1)*miniStackSize] + ph_ML_compressed[k]
    
    
    plot_result(t, signal_phase, ph_MLE, ph_SB, sequential_phase_series, corr_mat, cov_matrix, Gmat)