Skip to content

fix: anchor observing night date to action start time and local noon boundary#131

Merged
ppp-one merged 2 commits intoppp-one:mainfrom
dgegen:fix/observing-night-noon-boundary
Mar 24, 2026
Merged

fix: anchor observing night date to action start time and local noon boundary#131
ppp-one merged 2 commits intoppp-one:mainfrom
dgegen:fix/observing-night-noon-boundary

Conversation

@dgegen
Copy link
Copy Markdown
Collaborator

@dgegen dgegen commented Mar 23, 2026

Pull Request

Description
Replace sun-altitude-based observing night calculation with a simpler local-noon boundary (longitude-offset UTC), and use action.start_time instead of datetime.now() in from_action so images are always assigned to the correct night even when called after midnight or sunrise.

Related Issue
Closes #127

Changes Made

  • get_observing_night_date: replaced astropy sun-altitude lookup with a longitude-offset local noon boundary — times before local noon → previous night, times from local noon onward → tonight
  • from_action: use action.start_time instead of datetime.now() to anchor the observing night to when the action was scheduled, not when the handler was constructed
  • Removed get_default_observing_date as it is not used in production code.
  • Updated tests

How to Test

  • Run uv run pytest tests/test_image_handler.py
  • Verify that images taken after midnight but before local noon are filed under the previous calendar date

Checklist

  • Code follows project style guidelines
  • Tests added/updated
  • Documentation updated (if needed)
  • All checks pass

…boundary

Replace sun-altitude-based observing night calculation with a simpler
local-noon boundary (longitude-offset UTC), and use action.start_time
instead of datetime.now() in from_action so images are always assigned
to the correct night even when called after midnight or sunrise.
Copilot AI review requested due to automatic review settings March 23, 2026 21:48

This comment was marked as resolved.

- Raise ValueError with helpful message when LAT-OBS/LONG-OBS/ALT-OBS
  are missing in __init__ and from_action, instead of an opaque KeyError
- Add tests for both missing-location-key paths
- Remove test_save_image_no_header_raises (header=None is a type violation)
- Fix stale save_image docstring: correct header type, add sequence_counter,
  clarify image_directory behaviour, remove hardcoded filename format examples
- Fix stale set_image_dir docstring: remove references to removed parameters
@ppp-one
Copy link
Copy Markdown
Owner

ppp-one commented Mar 24, 2026

Sweet - works locally too.

@ppp-one ppp-one merged commit 5470e03 into ppp-one:main Mar 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

question about UTC offset

3 participants