Probleme pour utiliser les fonctions en python
bonjour,
Je débute en Python : J'ai crée une fonction (balancedtan ) dans un fichier module , dans un fichier script je fais appel à cette fonction de mon fichier mais les variables en sortie de la fonction ne sont accessible depuis mon fichier script. Une solution ???? Merci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| def balancedtan(MD1,HAZ1,WD1,MD2,HAZ2,WD2) :
"""fonction permettant de transformer des mesures de déviations de sondage en coordonnées cartésiennes x,y,z à partir de la méthode balanced_tangential """
## INPUT
## MD1 = measured depth at top of course (feet or meters)
## MD2 = measured depth at bottom of course (feet or meters)
## HAZ1 = hole azimuth at top of course (degrees)
## HAZ2 = hole azimuth at bottom of course (degrees)
## WD1 = well deviation at top of course (degrees)
## WD2 = well deviation at bottom of course (degrees)
## OUTPUT
##East = easterly displacement (feet or meters) - negative = West
##North = northerly displacement (feet or meters) - negative = South
##TVD = true vertical depth (feet or meters)
return
North=(MD2-MD1)/2*(math.sin(WD2)*math.cos(HAZ1)+math.sin(WD2)*math.cos(HAZ2))
East=(MD2-MD1)/2*(math.sin(WD1)*math.sin(HAZ1)+math.sin(WD2)*math.sin(HAZ2))
TVD=(MD2-MD1)/2*(math.cos(WD2)+math.cos(WD1)) |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| # -*-coding:Latin-1 -*
import os
import geolmath
# test de la fonction geolmath
f= open("AFAW_5034_1.txt","r")
Depth=[];
Trend=[];
Dip=[];
ligne = f.readline()
ligne = f.readline()
holeid=ligne.split(';')[0]
x=(ligne.split(';')[1])
print x
y=(ligne.split(';')[2])
z=(ligne.split(';')[3])
compte =-1
Xdevia=0.
while 1 :
compte=compte+1
if ligne =='':
break
if ligne!='#':
Depth.append(ligne.split(';')[3])
Trend.append(ligne.split(';')[4])
Dip.append(ligne.split(';')[5])
if compte>3 :
geolmath.balancedtan(float(Depth[compte-1]),float(Trend[compte-1]),float(Dip[compte-1]),float(Depth[compte]),float(Trend[compte]),float(Dip[compte]))
print x
XDevia=float(x)+North
YDevia=float(y)+East
Zdevia=float(z)+TVD
x=Xdevia
y=Ydevia
z=ZDevia
print (str(x),str(y),str(z))
ligne = f.readline() |