Refactor/align stack phase1#1
Merged
Merged
Conversation
added 9 commits
May 30, 2026 16:04
There was a problem hiding this comment.
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.pyintoalign_utils.py. - Introduced
scripts/compare_outputs.pyto compare baseline vs candidate output directories (file presence + PNG/MSEED heuristics). - Added
.gitignoreentries 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 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 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 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 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
align_stackrefactor with behavior-preserving extraction.Changes:
run_pipeline()/main()flow in align_stack.pyTimingStateValidation:
/opt/anaconda3/envs/vidale_main/bin/python compare_outputs.py <baseline> <candidate>No regressions detected under current comparison rules.Scope notes:
Commits:
b4ae9c8Refactor align_stack into explicit run_pipeline entrypointbea5675Extract core alignment utilities into align_utils module9be3b88Add output regression comparison scriptea521f5Ignore Python bytecode and cache files2ce2d78Extract timing helpers into align_utils TimingStateb2d53b9Extract payload and output-dir helpers into align_utils6055407Extract event/station metadata loaders into align_utils048477fExtract reference-station helpers into align_utils58a56c3Extract phase travel-time helper into align_utils