shbhuk / barycorrpy

Python version of Barycorr
GNU General Public License v3.0
37 stars 6 forks source link

Vectorize JD to avoid calling JPL Horizons in a loop #57

Open cbender opened 1 year ago

cbender commented 1 year ago

https://github.com/shbhuk/barycorrpy/blob/4f48f89980b5e2b3ebc8030a3c98211b24688f1b/barycorrpy/barycorrpy.py#L234

As implemented, if the input to get_bc_vel is a list of JDs (as a list or Time objects), then the BC for each is computed individually. This causes problems for the reflected light section reference above, which makes 3 calls to JPL Horizons. The consequence is that a simple calculation over an array of JDs can result in hundreds of back to back calls to Horizons, which flags this as an attack and dumps the socket. The same call can be done in a vectorized manner, resulting in only 3 calls, which is fine.

Assign this to me and I will provide a patch.