コード例 #1
0
def make_loop_png(unw12, unw23, unw13, loop_ph, png, titles4, cycle):
    cmap_wrap = tools_lib.get_cmap('SCM.romaO')
    cmap_loop = tools_lib.get_cmap('SCM.vik')

    ### Settings
    plt.rcParams['axes.titlesize'] = 10
    data = [unw12, unw23, unw13]

    length, width = unw12.shape
    if length > width:
        figsize_y = 10
        figsize_x = int((figsize_y-1)*width/length)
        if figsize_x < 5: figsize_x = 5
    else:
        figsize_x = 10
        figsize_y = int(figsize_x*length/width+1)
        if figsize_y < 3: figsize_y = 3

    ### Plot
    fig = plt.figure(figsize = (figsize_x, figsize_y))

    ## 3 ifgs
    for i in range(3):
        data_wrapped = np.angle(np.exp(1j*(data[i]/cycle))*cycle)
        ax = fig.add_subplot(2, 2, i+1) #index start from 1
        im = ax.imshow(data_wrapped, vmin=-np.pi, vmax=+np.pi, cmap=cmap_wrap,
                  interpolation='nearest')
        ax.set_title('{}'.format(titles4[i]))
        ax.set_xticklabels([])
        ax.set_yticklabels([])
        cax = plt.colorbar(im)
        cax.set_ticks([])

    ## loop phase
    ax = fig.add_subplot(2, 2, 4) #index start from 1
    im = ax.imshow(loop_ph, vmin=-np.pi, vmax=+np.pi, cmap=cmap_loop,
              interpolation='nearest')
    ax.set_title('{}'.format(titles4[3]))
    ax.set_xticklabels([])
    ax.set_yticklabels([])
    cax = plt.colorbar(im)

    plt.tight_layout()
    plt.savefig(png)
    plt.close()
コード例 #2
0
                sys.exit(2)

        ### Read data
        if os.path.getsize(infile) == length * width:
            print('File format: uint8')
            data = io_lib.read_img(infile,
                                   length,
                                   width,
                                   np.uint8,
                                   endian=endian)
        else:
            data = io_lib.read_img(infile, length, width, endian=endian)
            data[data == nodata] = np.nan

    #%% Get cmap, set cyclic and color range
    cmap = tools_lib.get_cmap(cmap_name, n_color)

    if cmap_name == 'cm_insar' or \
            cmap_name == 'cm_isce' or \
            (cmap_name.startswith('SCM') and 'O' in cmap_name) or \
            'GMT.cyclic' in cmap_name or \
            'cmocean.phase' in cmap_name or \
            (cmap_name.startswith('colorcet') and
             re.search(r'C[1-5]', cmap_name) is not None):
        print('\n{} is a cyclic cmap.'.format(cmap_name))
        cyclic = True
        data = np.angle(np.exp(1j * (data / cycle)) * cycle)
        cmin = -np.pi
        cmax = np.pi
        interp = 'nearest'
    else:
コード例 #3
0
                dmax = float(a)
            elif o == '--auto_crange':
                auto_crange = float(a)
            elif o == '--ylen':
                ylen = float(a)
            elif o == '--ts_png':
                ts_pngfile = a

    except Usage as err:
        print("\nERROR:", file=sys.stderr, end='')
        print("  " + str(err.msg), file=sys.stderr)
        print("\nFor help, use -h or --help.\n", file=sys.stderr)
        sys.exit(2)

    #%% Set cmap
    cmap = tools_lib.get_cmap(cmap_name)

    #%% Set files
    ### cumfile
    if not cumfile:  ## if not given
        if os.path.exists('cum_filt.h5'):
            cumfile = 'cum_filt.h5'
        elif os.path.exists('cum.h5'):
            cumfile = 'cum.h5'
        else:
            print('\nNo cum_filt.h5/cum.h5 found!', file=sys.stderr)
            print('Use -i option or change directory.')
            sys.exit(2)
    else:  ##if given
        if not os.path.exists(cumfile):
            print('\nNo {} found!'.format(cumfile), file=sys.stderr)