Exemplo n.º 1
0
def Baseline_timeseries(igramsFile):
    h5file = h5py.File(igramsFile,'r')
    k=h5file.keys()
    if 'interferograms' in k: k[0] = 'interferograms'
    elif 'coherence'    in k: k[0] = 'coherence'
    igramList = h5file[k[0]].keys()
    Bp_igram=[]
    for igram in igramList:
        Bp_igram.append((float(h5file[k[0]][igram].attrs['P_BASELINE_BOTTOM_HDR'])+\
                         float(h5file[k[0]][igram].attrs['P_BASELINE_TOP_HDR']))/2)
  
    A,B=design_matrix(h5file)
    dateList       = ptime.date_list(igramsFile)
    tbase,dateDict = ptime.date_list2tbase(dateList)
    dt = np.diff(tbase)
  
    Bp_rate=np.dot(np.linalg.pinv(B),Bp_igram)
    zero = np.array([0.],np.float32)
    Bperp = np.concatenate((zero,np.cumsum([Bp_rate*dt])))
    h5file.close()
    
    return Bperp
Exemplo n.º 2
0
def igram_pairs(igramFile):
    ## Read Igram file
    h5file = h5py.File(igramFile)
    k = h5file.keys()
    if "interferograms" in k:
        k[0] = "interferograms"
    elif "coherence" in k:
        k[0] = "coherence"
    if k[0] not in ["interferograms", "coherence", "wrapped"]:
        print "Only interferograms / coherence / wrapped are supported."
        sys.exit(1)

    dateList = ptime.date_list(igramFile)
    dateList6 = ptime.yymmdd(dateList)

    pairs = []
    igramList = h5file[k[0]].keys()
    for igram in igramList:
        date12 = h5file[k[0]][igram].attrs["DATE12"].split("-")
        pairs.append([dateList6.index(date12[0]), dateList6.index(date12[1])])

    return pairs
Exemplo n.º 3
0
def read_igram_pairs(igramFile):
    ## Read Igram file
    h5file = h5py.File(igramFile,'r')
    k = h5file.keys()
    if 'interferograms' in k: k[0] = 'interferograms'
    elif 'coherence'    in k: k[0] = 'coherence'
    if k[0] not in  ['interferograms','coherence','wrapped']:
        print 'Only interferograms / coherence / wrapped are supported.';  sys.exit(1)

    dateList  = ptime.date_list(igramFile)
    dateList6 = ptime.yymmdd(dateList)

    pairs = []
    igramList=h5file[k[0]].keys()
    for igram in igramList:
        date12 = h5file[k[0]][igram].attrs['DATE12'].split('-')
        pairs.append([dateList6.index(date12[0]),dateList6.index(date12[1])])
    h5file.close()

    pairs = pair_sort(pairs)

    return pairs
Exemplo n.º 4
0
def main(argv):

    ## Global Variables
    global fontSize, lineWidth, markerColor, markerSize

    ## Default Values
    fontSize = 12
    lineWidth = 2
    markerColor = "orange"
    markerSize = 16
    saveFig = "no"
    dispFig = "yes"
    saveList = "no"

    if len(sys.argv) > 2:
        try:
            opts, args = getopt.getopt(argv, "h:b:f:s:w:l:m:c:o:", ["save", "nodisplay", "list"])
        except getopt.GetoptError:
            Usage()
            sys.exit(1)

        for opt, arg in opts:
            if opt in ("-h", "--help"):
                Usage()
                sys.exit()
            elif opt == "-b":
                baselineFile = arg
            elif opt == "-f":
                igramsFile = arg
            elif opt == "-l":
                listFile = arg
            elif opt == "-s":
                fontSize = int(arg)
            elif opt == "-w":
                lineWidth = int(arg)
            elif opt == "-m":
                markerSize = int(arg)
            elif opt == "-c":
                markerColor = arg
            # elif opt == '-o':        figName2  = arg;   saveFig = 'yes'
            elif opt == "--save":
                saveFig = "yes"
            elif opt == "--nodisplay":
                dispFig = "no"
                saveFig = "yes"
            elif opt == "--list":
                saveList = "yes"

        try:
            igramsFile
        except:
            try:
                baselineFile
            except:
                Usage()
                sys.exit(1)

    elif len(sys.argv) == 2:
        igramsFile = argv[0]
    else:
        Usage()
        sys.exit(1)

    ##### Output figure name
    figName1 = "BperpHist.pdf"
    figName2 = "Network.pdf"
    try:
        igramsFile
        if "Modified" in igramsFile:
            figName1 = "BperpHist_Modified.pdf"
            figName2 = "Network_Modified.pdf"
    except:
        pass

    ############# Read Time and Bperp ################
    print "\n******************** Plot Network **********************"
    try:
        igramsFile
        atr = readfile.read_attributes(igramsFile)
        k = atr["FILE_TYPE"]
        if k not in ["interferograms", "coherence", "wrapped"]:
            print "Only interferograms / coherence / wrapped are supported."
            sys.exit(1)

        print "reading date and perpendicular baseline from " + k
        dateList = ptime.date_list(igramsFile)
        dateList6 = ptime.yymmdd(dateList)
        print "number of acquisitions: " + str(len(dateList))
        Bp = ut.Baseline_timeseries(igramsFile)
    except:
        baselineFile
        print "reading date and perpendicular baseline from " + baselineFile
        dateList, Bp = pnet.read_baseline_file(baselineFile)[0:2]
        dateList6 = ptime.yymmdd(dateList)

    ############# Read Pairs Info ####################
    print "reading pairs info"
    try:
        listFile
        pairs = pnet.read_pairs_list(listFile, dateList)
    except:
        pairs = pnet.read_igram_pairs(igramsFile)
    print "number of pairs       : " + str(len(pairs))

    if saveList == "yes":
        pnet.write_pairs_list(pairs, dateList, "Pairs.list")
        print "save pairs info to Pairs.list"

    ############# Read Unwrapping Error Info #######################
    ## For simulated interferograms only
    ## To plot the interferograms with unwrapping errors with a different color
    # N_unw_err=0
    # try:
    #  for ifgram in  ifgramList:
    #    if h5file[k[0]][ifgram].attrs['unwrap_error']=='yes':
    #       N_unw_err=N_unw_err+1
    # except: pass
    #
    # if N_unw_err>0:
    #   pairs_ue=np.zeros([N_unw_err,2],np.int)
    #   i=0
    #   for ifgram in  ifgramList:
    #     if h5file[k[0]][ifgram].attrs['unwrap_error']=='yes':
    #       date1,date2 = h5file[k[0]][ifgram].attrs['DATE12'].split('-')
    #       pairs_ue[i][0]=dateList6.index(date1)
    #       pairs_ue[i][1]=dateList6.index(date2)
    #       i=i+1
    #

    ############### Fig 1 - Interferogram Network ##################
    fig1 = plt.figure(1)
    fig1 = plot_network(fig1, pairs, dateList, Bp)

    if saveFig == "yes":
        plt.savefig(figName2, bbox_inches="tight")
        print "save figure to " + figName2

    ############## Fig 2 - Baseline History ###################
    fig2 = plt.figure(2)
    fig2 = plot_bperp_hist(fig2, dateList, Bp)

    if saveFig == "yes":
        plt.savefig(figName1, bbox_inches="tight")
        print "save figure to " + figName1

    if dispFig == "yes":
        plt.show()