question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOC: avoid iteration for light travel time of lots of objects

See original GitHub issue

In our user survey, @stargaser mentioned they had issues at ZTF when calculating light travel times for tens of thousands of sources in a degree patch of the sky. It might be worth a section in the performance area of the Time documentation comparing run times of the following approaches:

import numpy as np
import astropy.coordinates as coord
import astropy.units as u
from astropy.time import Time

ra = np.random.normal(0.0, 1.0, 50000)
dec = np.random.normal(0.0, 1.0, 50000)

coos = coord.SkyCoord(ra, dec, unit=u.deg)
observatory = coord.EarthLocation.of_site('lapalma')

%time time.light_travel_time(coos, location=observatory)
CPU times: user 56 ms, sys: 3.21 ms, total: 59.2 ms
Wall time: 58.2 ms
<TimeDelta object: scale='tdb' format='jd' value=[ 0.00497521  0.00495056  0.00497048 ...,  0.00499594  0.0049838
  0.00502038]>

%time ltts = [time.light_travel_time(coo, location=coos.location) for coo in coos]
CPU times: user 16min 45s, sys: 5.08 s, total: 16min 50s
Wall time: 16min 58s

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
YasPHPcommented, Sep 1, 2020

Gotcha, ok thanks!

0reactions
kakirasterncommented, Sep 1, 2020

I think it is still open, as @SG004’s PR #8461 dealing with the issue has been closed by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Time travel is possible – but only if you have an object with ...
Time travel is possible – but only if you have an object with infinite mass. The concept of time travel has always captured...
Read more >
How to iterate over a JavaScript object? - Stack Overflow
I want to use a for loop to get its properties. And I want to iterate it in parts (not all object properties...
Read more >
Light travel time toward and away from a massive object
Gravitation is caused by diffrence in time frames plus curved space due to the distance between the 2 masses (in this case between...
Read more >
If we travel at the speed of light, does time stop? What ... - Quora
First of all, an object with some mass can never reach the speed of light as it's inertial mass will keep increasing and...
Read more >
for...in - JavaScript | MDN - MDN Web Docs
Description. The loop will iterate over all enumerable properties of the object itself and those the object inherits from its prototype chain ( ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found