from __future__ import division
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('ggplot')
dem = pd.read_table('DemCorr.txt', header=None, skiprows=6, delim_whitespace=True, na_values=-9999)
plt.figure('dem')
plt.grid(False)
plt.imshow(dem)
plt.show()
pend = pd.read_table('Pend.txt', header=None, skiprows=6, delim_whitespace=True, na_values=-9999)
plt.figure('pend')
plt.grid(False)
plt.imshow(pend)
plt.show()
n_manning = 0.05 * np.ones(dem.shape)
h_med = 0.001 * np.ones(dem.shape)
v_med = 1/n_manning * h_med**(2/3) * pend**0.5
v_mayor_1 = pd.DataFrame(np.ones(dem.shape))
cond_1 = v_med > 1
cond_2 = dem > 600
cond = cond_1 & cond_2
v_mayor_1[cond] = v_med[cond]
plt.figure('v_mayor_1')
plt.grid(False)
plt.imshow(v_mayor_1)
plt.show()
n_manning_dist = pd.read_table('n_Manning.txt', header=None, skiprows=6, delim_whitespace=True, na_values=-9999)
v_med_2 = 1 / n_manning_dist * h_med**(2/3) * pend**0.5
cond_dist = v_med_2 > 2
v_med_2[cond_dist] = 2
v_med_2_hist = v_med_2.stack().dropna()
plt.figure('histograma')
plt.hist(v_med_2_hist, 100)
plt.show()
plt.figure('dem_perfil')
plt.grid(False)
plt.imshow(dem)
plt.hlines(200, 0, dem.shape[1])
plt.show()
plt.figure('perfil')
plt.plot(dem.iloc[200, :], color='b')
plt.show()