Skip to content

Commit ebc8c06

Browse files
mrosseelclaude
andcommitted
fix: replace incremental comet update with full reinit
The incremental update path in do_timed_task() could never add new comets or remove stale ones. Combined with a boot-time race condition (wrong datetime before GPS lock), the initial catalog could contain wrong comets with no way to self-correct. init_comets() is already idempotent and the computation cost is identical since calc_comets() was called on every update anyway. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 03c75d5 commit ebc8c06

1 file changed

Lines changed: 11 additions & 24 deletions

File tree

python/PiFinder/comet_catalog.py

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -294,34 +294,21 @@ def add_comet(self, sequence: int, name: str, comet: Dict[str, Dict[str, float]]
294294
logger.error(f"Error adding comet {name}: {e}")
295295

296296
def do_timed_task(self):
297-
"""Update comet catalog data periodically"""
298-
# Prevent concurrent execution
297+
"""Update comet catalog data periodically.
298+
299+
Always does a full reinit rather than incremental update.
300+
The incremental path could never add new comets or remove stale ones,
301+
and a boot-time race condition (wrong datetime before GPS lock) meant
302+
the initial catalog could be wrong with no way to self-correct.
303+
init_comets() is idempotent and the computation cost is identical
304+
since calc_comets() was already called on every update.
305+
"""
299306
with self._task_lock:
300307
with Timer("Comet Catalog periodic update"):
301308
if not self.shared_state.altaz_ready():
302309
return
303310

304311
dt = self.shared_state.datetime()
305312

306-
# If catalog is empty, (re)initialize - but only if file exists
307-
if not self.get_objects():
308-
if os.path.exists(comet_file):
309-
self.init_comets(dt)
310-
return
311-
312-
# Regular update - recalculate positions
313-
comet_dict = comets.calc_comets(dt)
314-
if not comet_dict:
315-
return
316-
317-
for obj in self._get_objects():
318-
try:
319-
name = obj.names[0]
320-
if name in comet_dict:
321-
comet = comet_dict[name]
322-
obj.ra, obj.dec = comet["radec"]
323-
obj.mag = MagnitudeObject([comet["mag"]])
324-
obj.const = sf_utils.radec_to_constellation(obj.ra, obj.dec)
325-
obj.mag_str = obj.mag.calc_two_mag_representation()
326-
except (KeyError, ValueError) as e:
327-
logger.error(f"Error updating comet {name}: {e}")
313+
if os.path.exists(comet_file):
314+
self.init_comets(dt)

0 commit comments

Comments
 (0)