Skip to content

Refactor/align stack phase1#1

Merged
JohnVidale merged 9 commits into
mainfrom
refactor/align-stack-phase1
May 31, 2026
Merged

Refactor/align stack phase1#1
JohnVidale merged 9 commits into
mainfrom
refactor/align-stack-phase1

Conversation

@JohnVidale

Copy link
Copy Markdown
Owner

PR text you can paste:

Title:
Refactor align_stack phase 1: extract utilities and add regression checks

Executive Summary:

Phase 1 refactor completed with behavior-preserving extractions from align_stack.py into align_utils.py.
Added regression checker compare_outputs.py and used baseline comparisons after each batch.
No regressions detected under current comparison rules.
Changes are now split into smaller helpers, reducing script complexity while leaving high-coupling core blocks for a later phase.

Description:
Summary:

  • Completes phase 1 of align_stack refactor with behavior-preserving extraction.
  • Introduces a utility module and output regression checker.
  • Keeps runtime outputs stable against baseline checks.

Changes:

  • Refactored script entrypoint:
    • Added explicit run_pipeline() / main() flow in align_stack.py
  • Added utility module:
    • Created align_utils.py
    • Moved low/medium-risk helpers out of align_stack.py, including:
      • alignment/math helpers
      • component/key/payload helpers
      • event/station metadata loaders
      • reference-station selection/summary helpers
      • phase travel-time helper
      • timing helpers with TimingState
  • Added regression tooling:
    • New compare_outputs.py to compare baseline vs candidate outputs
  • Repository hygiene:
    • Added /.gitignore rules for Python bytecode/cache files

Validation:

  • Repeated baseline comparisons run with:
    • /opt/anaconda3/envs/vidale_main/bin/python compare_outputs.py <baseline> <candidate>
  • Result for each checkpoint:
    • No regressions detected under current comparison rules.

Scope notes:

  • This PR intentionally avoids high-coupling extraction of core plotting/orchestration internals.
  • Remaining heavy blocks stay in align_stack.py for a future phase-2 branch to reduce regression risk.

Commits:

  • b4ae9c8 Refactor align_stack into explicit run_pipeline entrypoint
  • bea5675 Extract core alignment utilities into align_utils module
  • 9be3b88 Add output regression comparison script
  • ea521f5 Ignore Python bytecode and cache files
  • 2ce2d78 Extract timing helpers into align_utils TimingState
  • b2d53b9 Extract payload and output-dir helpers into align_utils
  • 6055407 Extract event/station metadata loaders into align_utils
  • 048477f Extract reference-station helpers into align_utils
  • 58a56c3 Extract phase travel-time helper into align_utils

Copilot AI review requested due to automatic review settings May 31, 2026 00:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors align_stack (phase 1) by extracting a set of reusable helpers into align_utils.py and adding a standalone output-regression comparison script to help validate behavior remains stable across refactor checkpoints.

Changes:

  • Extracted timing, alignment/windowing, metadata-loading, and plotting helpers from align_stack.py into align_utils.py.
  • Introduced scripts/compare_outputs.py to compare baseline vs candidate output directories (file presence + PNG/MSEED heuristics).
  • Added .gitignore entries for Python bytecode/cache and macOS .DS_Store.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 6 comments.

File Description
scripts/compare_outputs.py Adds a regression-check tool to compare output directory contents and basic file stats.
align_utils.py New utility module holding extracted helper functions/classes used by align_stack.py.
align_stack.py Updates script to import helpers, use TimingState, and adds run_pipeline()/main() structure.
.gitignore Ignores Python bytecode/cache and .DS_Store.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread align_stack.py
Comment on lines +642 to +648
# ===================== Main loop =====================
# Storage for three-component mode
if process_as_three_comp:
all_component_data = {}
horizontal_window_cache = {}
horizontal_raw_limits_cache = {}

Comment on lines +119 to +120
if check_hash and sha256_file(b) != sha256_file(c):
lines.append(f"PNG hash changed: {rel}")
Comment thread align_utils.py
Comment on lines +139 to +144
def make_event_output_dir(base_prefix: str, eve_id: str) -> Path:
"""Create and return output directory for one event."""
save_path = Path(base_prefix + "output")
save_dir = save_path / eve_id
save_dir.mkdir(parents=True, exist_ok=True)
return save_dir
Comment thread align_stack.py
Comment on lines +642 to +648
# ===================== Main loop =====================
# Storage for three-component mode
if process_as_three_comp:
all_component_data = {}
horizontal_window_cache = {}
horizontal_raw_limits_cache = {}

Comment on lines +119 to +120
if check_hash and sha256_file(b) != sha256_file(c):
lines.append(f"PNG hash changed: {rel}")
Comment thread align_utils.py
Comment on lines +139 to +144
def make_event_output_dir(base_prefix: str, eve_id: str) -> Path:
"""Create and return output directory for one event."""
save_path = Path(base_prefix + "output")
save_dir = save_path / eve_id
save_dir.mkdir(parents=True, exist_ok=True)
return save_dir
@JohnVidale JohnVidale merged commit 44af8fb into main May 31, 2026
1 check passed
@JohnVidale JohnVidale deleted the refactor/align-stack-phase1 branch May 31, 2026 00:36
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.

2 participants