0

I am using python for trajectory comparison calculations that require a lot of great circle computations. These calculations require a lot of trigonometric functions and the script is currently very slow with the regular math.atan2 etc. implementation. Is there any python library that performs time efficient approximations? I really prefer efficiency over accuracy here.

Any pointers to implement this myself are also much welcomed.

  • 1
    Did you profile the code to see what is the bottleneck? This looks like a shot in the dark – JBernardo Jul 08 '13 at 08:19
  • @JBernardo When I changed from simplistic Euclidean calculations to great circle, the run time went from nearly instant (<1.0s) to minutes for the same data. I thus do not really see how this is a shot in the dark – user1960897 Jul 08 '13 at 08:28
  • 2
    Without profiling it's mostly a shot in the dark. Also it's really important to get a rough idea about the execution times of parts of your script, so give it a try; it's a common way. You can do it quite easily with the module `cProfile`, which is included in python. – tamasgal Jul 08 '13 at 08:35
  • Perhaps you can find something useful [here](http://stackoverflow.com/questions/17411274/how-to-find-the-nearest-points-to-given-coordinates-with-matlab/17419323#17419323). If you want to go with the trig approach, why not use a rough lookup table? Compute the (inverse) sine/cosine/tangent of 100 points in the interval 0-2pi. Then, for every angle mod 2pi, you have a (rough) lookup table for all (inverse) trig functions of that angle. In cases where the lookup is indecisive, just compute the "real" values (in python+numpy, I doubt that this will be faster though...) – Rody Oldenhuis Jul 08 '13 at 14:03

1 Answers1

1

Depending on what you are doing. If you have data in matrix/vector format and want to pefrorm same operation on many elements you can use numpy.

data = np.array([...])
sines = np.sin(data)

This should speed up things quite a bit

Blaž Šnuderl
  • 328
  • 4
  • 11