Added scale (blocksize) parameter for view_map.py

This commit is contained in:
Gael-de-Sailly 2020-11-10 13:19:20 +01:00
parent 9475b49b8d
commit 30136bf60a

View File

@ -5,21 +5,21 @@ import zlib
import matplotlib.colors as mcol import matplotlib.colors as mcol
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
def view_map(dem, lakes, rivers): def view_map(dem, lakes, rivers, scale):
plt.subplot(1,3,1) plt.subplot(1,3,1)
plt.pcolormesh(dem, cmap='viridis') plt.pcolormesh(np.arange(dem.shape[0]+1)*scale, np.arange(dem.shape[1]+1)*scale, dem, cmap='viridis')
plt.gca().set_aspect('equal', 'box') plt.gca().set_aspect('equal', 'box')
plt.colorbar(orientation='horizontal') plt.colorbar(orientation='horizontal')
plt.title('Raw elevation') plt.title('Raw elevation')
plt.subplot(1,3,2) plt.subplot(1,3,2)
plt.pcolormesh(lakes, cmap='viridis') plt.pcolormesh(np.arange(lakes.shape[0]+1)*scale, np.arange(lakes.shape[1]+1)*scale, lakes, cmap='viridis')
plt.gca().set_aspect('equal', 'box') plt.gca().set_aspect('equal', 'box')
plt.colorbar(orientation='horizontal') plt.colorbar(orientation='horizontal')
plt.title('Lake surface elevation') plt.title('Lake surface elevation')
plt.subplot(1,3,3) plt.subplot(1,3,3)
plt.pcolormesh(rivers, cmap='Blues', norm=mcol.LogNorm()) plt.pcolormesh(np.arange(rivers.shape[0]+1)*scale, np.arange(rivers.shape[1]+1)*scale, rivers, cmap='Blues', norm=mcol.LogNorm())
plt.gca().set_aspect('equal', 'box') plt.gca().set_aspect('equal', 'box')
plt.colorbar(orientation='horizontal') plt.colorbar(orientation='horizontal')
plt.title('Rivers flux') plt.title('Rivers flux')
@ -29,8 +29,12 @@ def view_map(dem, lakes, rivers):
if __name__ == "__main__": if __name__ == "__main__":
import sys import sys
import os import os
scale = 1
if len(sys.argv) > 1: if len(sys.argv) > 1:
os.chdir(sys.argv[1]) os.chdir(sys.argv[1])
if len(sys.argv) > 2:
scale = int(sys.argv[2])
def load_map(name, dtype, shape): def load_map(name, dtype, shape):
dtype = np.dtype(dtype) dtype = np.dtype(dtype)
@ -45,4 +49,4 @@ if __name__ == "__main__":
lakes = load_map('lakes', '>i2', shape) lakes = load_map('lakes', '>i2', shape)
rivers = load_map('rivers', '>u4', shape) rivers = load_map('rivers', '>u4', shape)
view_map(dem, lakes, rivers) view_map(dem, lakes, rivers, scale)