Batch conversion of elevation/azimuth to equatorial coordinates

550 Views Asked by At

Is there a way in PyEphem to efficiently convert a large number of apparent coordinates to Equatorial Right Ascension/Declination without using a python loop? Any hint appreciated, thanks!

1

There are 1 best solutions below

1
On BEST ANSWER

You can hide the for loop inside of a function so that you don't need to think about the loop out in your main code. Or you could use a list comprehension to move the loop inside of an expression so that the loop does not need to be out at the level of a statement, like changing:

a = [1,2,3]
b = []
for n in a:
    b.append(n*n)

to an expression like:

a = [1,2,3]
b = [n*n for n in a]

But, no, PyEphem does not provide its own syntax — like a library like numpy provides — for doing vector operations (which are always, of course, loops underneath whatever pretty syntax is on top).

PyEphem would have to rebuild its calculations on top of numpy instead of implementing them in C for a true vector toolchain approach. That might be a good idea anyway, someday, because of how fast numpy is becoming when combined with pypy; but for now PyEphem is a wrapper around a C library "libastro" that continues to be maintained and improved, so PyEphem has not yet branched out into implementing many calculations itself.