Advertisement
Guest User

lmfit problem

a guest
Jul 23rd, 2014
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. from lmfit import minimize, Parameters
  2. import numpy
  3.  
  4.  
  5. station1 = numpy.array((779.000,818.390,-100,148.977))
  6. station2 = numpy.array((876.010,921.300,-110,99.610))
  7. station3 = numpy.array((978.910,824.290,-120,62.104))
  8. station4 = numpy.array((881.910,721.380,-130,130.883))
  9. #station5 = numpy.array((881.910,721.380,-130,130.883))
  10.  
  11. stationarray = numpy.array((station1,station2,station3,station4))
  12.  
  13. # position = 926.349 , 837.748 , 89.794
  14. #ranges = numpy.array((148.977,99.610,62.104,130.883))
  15.  
  16.  
  17. def residualfunct(params, stationarray):
  18.  
  19.     X = params['solutionX'].value
  20.     Y = params['solutionY'].value
  21.     Z = params['solutionZ'].value
  22.     result = numpy.array([s[3] - linalg.norm(array((X,Y,Z))-array((s[0],s[1],s[2]))) for s in stationarray])
  23.     print result
  24.     return result
  25.  
  26.  
  27.  
  28. params = Parameters()
  29. params.add('solutionX',value=0)
  30. params.add('solutionY',value=0)
  31. params.add('solutionZ',value=0)
  32.  
  33.  
  34. position = minimize(residualfunct, params, args=(stationarray))
  35.  
  36.  
  37. print position
  38. print report
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement