Commit ea8ec125 authored by Matheus Müller's avatar Matheus Müller

Funcao que corrige distribuicao criada, funcoes step e reta operando

parent 24a2ca54
from pylab import * 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 concent = profundidade*0
if modo == 'step': if modo == 'step':
global u for i in xy:
for i in x: for j in arange (u, i[0], step):
for j in arange (u, i, step): if j>max(xy[:,0])/2 :
concent[int(j/step)] = y[i] concent[math.ceil(j/step)] = i[1]
u = i else :
concent[math.floor(j/step)] = i[1]
u = i[0]
fix1(concent, profundidade)
if modo == 'reta': if modo == 'reta':
global u for i in xy:
for i in x: for j in arange (u, i[0], step):
for j in arange (u, i, step): if j>max(xy[:,0])/2 :
concent[int(j/step)] = (j-u)*(y[i]-y[u])/(x[i]-x[u]) concent[math.ceil(j/step)] = yu + (j-u)*(i[1] - yu)/(i[0] - u)
u = i 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) plot(profundidade, concent)
show() show()
1 1
2 0.5
3 1
4.3 0.7
4.5 1
5 0.9
6 .1
from concentracao import * from concentracao import *
from pylab import *
xy = np.loadtxt('prof.txt')
x,y = np.loadtxt('H2.py', unpack=True)
modo = 'step' modo = 'step'
modo2 = 'reta' 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!
Please register or to comment