Closed DinoBektesevic closed 2 months ago
I've added the invert and fixed the docstring. I added some basic tests too. @ColinOrionChandler if this is good for you then I'll merge.
I did change the order of parameters - this might break some of your scripts, so that I can make the default assumption be geocenter instead of some observatory I think you mentioned that this is useful to you, but it required flipping obsgeoloc and timestamp I think.
I'm merging this, since it's not the default behaviour anywhere so you and Colin can use it from KBMOD instead of copying it elsewhere. We can hash out the details of the interface some other PR. Thanks for all the reviews today!
This is a vectorized solution to the same problem. Here are some timings:
The real gains can be gotten the more SkyCoords we have. For all the pointings in DEEP
This example takes in ra, dec, obstime and obsgeoloc as arguments because I'm testing from joined DEEP joined collection, so this includes the cost of creating the initial coords object (the current implementation expect a coord object).
The test of the current
correct_parallax_geometrically
function can't take multiple pointings and times, so they need to be iterated over:which doesn't scale well to many coordinates. Hopefully I'm just not seeing somethign obvious and missusing it. I think it's possible to adapt the function rather easily to take a list of SkyCoords, but there are some corner-cases - it wont' work with different timestamps.
There are no tests etc. in this PR, because I am mostly looking for some guidance on what the interface logic:
Generally coordinates admit the addition of a timestamp to them, as well as obsgeoloc, I could rework the current implementation in two ways:
In the first case the change is to go from function calls to
coord, time, point_on_earth
tocoord
and then throw an error if it does not have obstime and obsgeoloc attached. Sort out batches per timestamp, pre-fetch earth ephemeris, and return all corrected. This seems very practical because any kinds of coordinates can be given at any timestamp and obsgeoloc.It's faster than per-coordinate iteration but it'll also be faster for very large numbers of coordinates than the second potential solution.
Second approach vectorizes the current implementation, but just assumes they are all taken at the same time. Then it's on the user to figure out and do the iterations from solution A, but for not-so-very-large-number of coordinates this can potentially be faster since there are less obsgeolocs and obstimes being copied during initial transformation to gcrs. Speedups here are hard to measure without making sure apples-to-apples are being compared.
For large number of coordinates the benefit of first approach is that there's less memory allocations alltogether (one big los_earth_obj is created only and edited in-place. At the low end the execution time is measured in ms, so unless they're run in many loops I don't think it'll ultimately matter whichever one we pick.