Skip to content

Commit eb89707

Browse files
committed
Add logging of elapsed time for major steps in solving cameras
1 parent e9de813 commit eb89707

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

src/lvmguider/guider.py

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -436,21 +436,27 @@ async def solve_camera(
436436
basename = file.name.replace(".fits.gz", "").replace(".fits", "")
437437
astrometrynet_output_root = str(file.parent / "astrometry" / basename)
438438

439-
solution: AstrometrySolution = await run_in_executor(
440-
solve_camera_with_astrometrynet,
441-
sources,
442-
ra=ra,
443-
dec=dec,
444-
solve_locs_kwargs={"output_root": astrometrynet_output_root},
445-
)
439+
with elapsed_time(self.command, "solve cameras with astrometry.net"):
440+
solution: AstrometrySolution = await run_in_executor(
441+
solve_camera_with_astrometrynet,
442+
sources,
443+
ra=ra,
444+
dec=dec,
445+
solve_locs_kwargs={"output_root": astrometrynet_output_root},
446+
)
446447

447448
# Now match with Gaia.
448449
if solution.solved:
449-
# TODO: this should run in an executor.
450-
matched_sources, _ = match_with_gaia(solution.wcs, sources, concat=True)
451-
sources = matched_sources
452-
matched = True
453-
wcs = solution.wcs
450+
with elapsed_time(self.command, "match sources with Gaia"):
451+
# TODO: this should run in an executor.
452+
matched_sources, _ = match_with_gaia(
453+
solution.wcs,
454+
sources,
455+
concat=True,
456+
)
457+
sources = matched_sources
458+
matched = True
459+
wcs = solution.wcs
454460
else:
455461
self.command.warning(
456462
f"Failed solving camera {camname} with astrometry.net."
@@ -469,12 +475,13 @@ async def solve_camera(
469475

470476
# Here we match with Gaia first, then use those matches to
471477
# define the WCS.
472-
matched_sources, nmatches = match_with_gaia(
473-
ref_wcs,
474-
sources,
475-
concat=True,
476-
max_separation=5,
477-
)
478+
with elapsed_time(self.command, "match sources with Gaia"):
479+
matched_sources, nmatches = match_with_gaia(
480+
ref_wcs,
481+
sources,
482+
concat=True,
483+
max_separation=5,
484+
)
478485

479486
sources = matched_sources
480487
matched = True
@@ -487,12 +494,14 @@ async def solve_camera(
487494
)
488495
return await self.solve_camera(file, force_astrometry_net=True)
489496
else:
490-
wcs = wcs_from_gaia(matched_sources)
491-
wcs = wcs
497+
with elapsed_time(self.command, "creating WCS from Gaia sources"):
498+
wcs = wcs_from_gaia(matched_sources)
499+
wcs = wcs
492500

493501
# Get zero-point. This is safe even if it did not solve.
494-
zp = estimate_zeropoint(data, sources)
495-
sources.update(zp)
502+
with elapsed_time(self.command, "estimating zero point"):
503+
zp = estimate_zeropoint(data, sources)
504+
sources.update(zp)
496505

497506
solve_time = round(time.time() - t0, 3)
498507

0 commit comments

Comments
 (0)