concentracao.py 1.4 KB
 Matheus Müller committed Oct 14, 2011 1 2 ``````from pylab import * `````` Matheus Müller committed Oct 17, 2011 3 4 ``````##################################################################################################### # Funcoes que corrigem erros de arredondamento `````` Matheus Müller committed Oct 14, 2011 5 `````` `````` Matheus Müller committed Oct 17, 2011 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ``````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) `````` Matheus Müller committed Oct 14, 2011 28 29 30 `````` concent = profundidade*0 if modo == 'step': `````` Matheus Müller committed Oct 17, 2011 31 32 `````` for i in xy: for j in arange (u, i[0], step): `````` Matheus Müller committed Oct 24, 2011 33 `````` if j>max(xy[:,0])/2 and j<=len(xy) : `````` Matheus Müller committed Jan 06, 2012 34 `````` concent[int(j/step)] = i[1] `````` Matheus Müller committed Oct 17, 2011 35 36 37 38 `````` else : concent[math.floor(j/step)] = i[1] u = i[0] fix1(concent, profundidade) `````` Matheus Müller committed Oct 14, 2011 39 40 `````` if modo == 'reta': `````` Matheus Müller committed Oct 17, 2011 41 `````` for i in xy: `````` Matheus Müller committed Dec 09, 2011 42 `````` for j in arange (u, round(i[0],3), step): `````` Matheus Müller committed Oct 24, 2011 43 44 `````` concent[round(j/step)] = yu + (j-u)*(i[1] - yu)/(i[0] - u) u = round(i[0],2) `````` Matheus Müller committed Oct 17, 2011 45 46 `````` yu = i[1] fix2(concent, profundidade) `````` Matheus Müller committed Oct 14, 2011 47 `````` `````` Matheus Müller committed Oct 24, 2011 48 `````` return concent `````` Matheus Müller committed Oct 17, 2011 49