Commit ea8ec125 by Matheus Müller

### Funcao que corrige distribuicao criada, funcoes step e reta operando

parent 24a2ca54
 from pylab import * u = 0 #xy0 = np.loadtxt('H2.py') def montaperfil( x, y , step, modo): ##################################################################################################### # Funcoes que corrigem erros de arredondamento profundidade = arange(0, len(x), step) def fix1(y, x): for k in arange(1, (len(y)-1)): if y[k] == 0: if y[k-1] and y[k+1] != 0: y[k] = y[k-1] def fix2(y, x): for k in arange(1, (len(y)-1)): if y[k] == 0: if y[k-1] and y[k+1] != 0: if y[k-1] == y[k+1]: y[k] = y[k-1] else: y[k] = (y[k+1]+y[k-1])/2 ##################################################################################################### def montaperfil( xy , step, modo): u = 0. yu = 0. profundidade = arange(0, max(xy[:,0]), step) concent = profundidade*0 if modo == 'step': global u for i in x: for j in arange (u, i, step): concent[int(j/step)] = y[i] u = i for i in xy: for j in arange (u, i[0], step): if j>max(xy[:,0])/2 : concent[math.ceil(j/step)] = i[1] else : concent[math.floor(j/step)] = i[1] u = i[0] fix1(concent, profundidade) if modo == 'reta': global u for i in x: for j in arange (u, i, step): concent[int(j/step)] = (j-u)*(y[i]-y[u])/(x[i]-x[u]) u = i for i in xy: for j in arange (u, i[0], step): if j>max(xy[:,0])/2 : concent[math.ceil(j/step)] = yu + (j-u)*(i[1] - yu)/(i[0] - u) else : concent[math.floor(j/step)] = yu + (j-u)*(i[1] - yu)/(i[0] - u) u = i[0] yu = i[1] fix2(concent, profundidade) print concent plot(profundidade, concent) show()
prof.txt 0 → 100644
 1 1 2 0.5 3 1 4.3 0.7 4.5 1 5 0.9 6 .1
 from concentracao import * from pylab import * xy = np.loadtxt('prof.txt') x,y = np.loadtxt('H2.py', unpack=True) modo = 'step' modo2 = 'reta' montaperfil( x, y, 0.05, modo) #montaperfil( x, y, 0.05, modo2) montaperfil( xy, 0.02, modo) #montaperfil( xy, 0.02, modo2)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!