Ejemplo n.º 1
0
def pp_fig(name, root=level2_root):
    file_list = os.listdir(layer_root)
    files = [
        file for file in file_list if file.find(name) >= 0
        and file.find('distribution') < 0 and file.find('npy') > 0
    ]
    data = np.load(layer_root + files[0])
    a = Lc.imp(data)
    a1 = a.dB(data)
    min_d = -30
    max_d = 0
    img = (a1 - min_d) * 255 / (max_d - min_d)
    img[img > 255] = 255
    img[img < 0] = 0
    rows, cols = a1.shape
    dpi = 100
    fig = plt.figure(figsize=(cols / dpi, rows / dpi), dpi=dpi)
    ax = fig.add_subplot(111)
    ax.imshow(img, cmap='gray')
    rows, cols = img.shape
    cs = np.ones(rows, dtype=np.int)
    rs = np.ones(cols, dtype=np.int)
    cstd = np.arange(rows, dtype=np.int)
    rstd = np.arange(cols, dtype=np.int)
    for r in range(0, rows, 150):
        plt.plot(rstd, rs * r, 'b')
    for c in range(0, cols, 150):
        plt.plot(cs * c, cstd, 'b')
    plt.savefig(root + 'add_grid-' + name + '.png')
    plt.close()
Ejemplo n.º 2
0
def save_fig(name, r, c, u, v, root=level2_root):
    file_list = os.listdir(layer_root)
    files = [
        file for file in file_list if file.find(name) >= 0
        and file.find('distribution') < 0 and file.find('npy') > 0
    ]
    data = np.load(layer_root + files[0])
    a = Lc.imp(data)
    a1 = a.dB(data)
    min_d = -30
    max_d = 0
    img = (a1 - min_d) * 255 / (max_d - min_d)
    img[img > 255] = 255
    img[img < 0] = 0
    rows, cols = a1.shape
    dpi = 100
    fig = plt.figure(figsize=(cols / dpi, rows / dpi), dpi=dpi)
    ax = fig.add_subplot(111)
    ax.imshow(img, cmap='gray')
    norm = mcolor.Normalize(vmin=0, vmax=20)
    m = [np.sqrt(u[i]**2 + v[i]**2) for i in range(len(r))]
    q = ax.quiver(c,
                  r,
                  u,
                  v,
                  m,
                  width=0.001,
                  headwidth=1,
                  cmap='bwr',
                  norm=norm)
    # q = ax.quiver(c,r,u,v, m,cmap = 'bwr', norm = norm)
    fig.colorbar(q, ax=ax)
    plt.savefig(root + name + '.png')
    plt.close()
Ejemplo n.º 3
0
Archivo: T1.py Proyecto: JieweiL92/P1
def DrawMap(name, layer, alpha, vmin, vmax):
    data = np.load('D:/Academic/MPS/Internship/Data/Sentinel/Level1/Layer/Layer40-20180518.npy')
    a = Lc.imp(data)
    a1 = a.dB(data)
    min_d, max_d = -30, 0
    img = (a1 - min_d) * 255 / (max_d - min_d)
    img[np.isnan(img)] = 255
    img[img > 255] = 255
    img[img < 0] = 0
    del a, a1
    rows, cols = img.shape
    dpi = 100
    fig = plt.figure(figsize=(cols / dpi, rows / dpi), dpi=dpi)
    ax = fig.add_subplot(111)
    ax.imshow(img, cmap='gray')
    cover = ax.imshow(layer.astype(np.float_), cmap = 'seismic', vmin =vmin, vmax = vmax, alpha = alpha)
    cbar = plt.colorbar(cover, fraction = 0.025, pad = 0.08)
    plt.gca().set_axis_off()
    plt.title(name, fontdict={'fontsize':36}, pad = 2.2)
    return None