Batch Planetary Stacker

Queue many planetary videos and let SASpro process them one after another with the same alignment and stacking settings — ideal for an all-nighter of Jupiter or Saturn clips where you'd rather script the processing than babysit it. The engine is identical to the per-file Planetary Stacker; this dialog adds file-list management, per-batch settings inheritance, progress reporting across files, and automatic output document creation.

SASpro-exclusive tool. The Batch Planetary Stacker is an original SetiAstro Suite Pro implementation by Franklin Marek. The batch orchestration (QThread worker that runs analyze+stack sequentially per file while keeping the GUI responsive), the GUI-thread signalling pattern that lets each completed stack be pushed as a new SASpro document safely from the worker thread, the colour-coded status list with per-file + overall progress bars, the surface-anchor acquisition dialog that opens on the first file when none is set in the Viewer, and the per-batch drizzle override are all original work. The underlying stacking engine is the Planetary Stacker — see its separate help page for the alignment and integration pipeline.
Workflow
Open the dialog from the Planetary Stacker Viewer via Batch Stack… → Add Files… to populate the list with SER/AVI/MP4/MOV/MKV files → pick an Output folder → optionally change the Drizzle override for the batch → Run Batch → watch each file turn green as it completes.

1. Adding files

Click Add Files… and multi-select from the file browser. Only video containers are accepted:

Image sequences and single-frame files are skipped with a log entry naming each one (batch mode processes whole clips, not static images). The last-used folder is remembered via QSettings so the next Add Files… starts there.

If the Viewer currently has a video open, that file is pre-added to the list when you open the Batch dialog — so a common pattern is: open the first video in the Viewer, dial in your ROI, surface anchor, Keep%, and tracking mode, then open Batch, add the other files for the same target, and run.

Remove Selected removes the highlighted entries; Clear All empties the list.

2. Settings inheritance from the Viewer

Batch inherits all the setup from the Viewer at the moment you opened this dialog:

These settings are displayed read-only in the Settings panel for sanity-check. If you need to change them, close the Batch dialog, adjust them in the Viewer, and reopen the Batch dialog.

ROI and anchor must be meaningful across all files. A batch assumes the files were shot in the same framing — same target, same scope, same camera position. If one file has the planet in the top-left and another in the bottom-right of the frame, the shared ROI will clip them differently and alignment will fail on at least one. Shoot batches with a consistent framing or process the mismatched files individually.

3. Output folder

Click Choose Folder… and pick where stacked results should land. Each file in the list produces one .tif file in this folder, named <input-stem>_stack.tif. For example:

Existing files with the same name will be overwritten without prompting — the batch assumes you want fresh output.

4. Drizzle override

The only per-batch Stacker setting that's exposed in the Batch dialog is Drizzle. Options: Off (1×), 1.5×, 2×. (3× and 4× drizzle are available in the Planetary Stacker's own dialog but not here — those scales are expensive enough that it's worth checking per-file results before committing a whole batch to them.) Pixfrac, kernel, sigma, planet axial rotation, field rotation, flats, and all analyze/AP settings use the Stacker defaults for every file in the batch.

If you need per-file control over these, run those files through the Planetary Stacker individually.

5. Surface anchor acquisition on the first file

If Tracking is set to Surface and no surface anchor was defined in the Viewer, SASpro opens an Anchor Picker dialog on frame 0 of the first file when you click Run Batch. The picker shows the reference frame full-size with zoom (+ / - / Fit / 1:1 buttons, Ctrl+Wheel), and you Shift+drag a patch to define the anchor. The chosen anchor applies to every file in the batch — which is why you want files with consistent framing.

If you cancel the picker, the batch doesn't start. If you pick a tiny anchor (less than 16×16), the OK button stays disabled.

6. Running the batch

Click ▶ Run Batch to start processing. SASpro locks the file-list and settings controls (so you can't modify them mid-run), shows two progress bars (per-file and overall), and lights up each file in turn:

StatusColourIconMeaning
PendingGrey⏳ (hourglass)Queued, not yet processed.
RunningBlue🔄 (reload arrows)Currently being analyzed and stacked.
DoneGreen✅ (check)Finished successfully; output TIFF saved and opened as a SASpro document.
FailedRed❌ (cross)Something went wrong; see the Log for the error.

Below the list, the phase label shows the current pipeline phase (Quality, SSD Refine, Stack, Drizzle) with a percentage, and the overall label shows N / Total files done. The log window at the bottom records every file-start, file-done and file-failed event with the output path or error message.

7. Canceling mid-batch

Click Cancel during a batch run to stop after the current file finishes. The already-done files keep their output TIFFs; files that were still pending stay pending (grey) and are not processed. The dialog becomes editable again, so you can tweak and re-run just the remaining files if you want.

Cancel is a cooperative signal: SASpro checks it between the Analyze and Stack phases of each file, so a cancel during Analyze will still let that file's Analyze finish before stopping. There's no mid-phase abort — this avoids leaving partial state behind.

8. Results

When each file completes, two things happen:

  1. The float32 result is saved to <output-folder>/<input-stem>_stack.tif as a 32-bit floating-point TIFF.
  2. The same result is pushed as a new SASpro document named <input-stem>_stack, opened in a sub-window, ready for stretch and post-processing.

By the end of a 20-file batch you'll have 20 TIFFs on disk and 20 open sub-windows in SASpro. On completion, a message box tells you how many succeeded and how many failed, plus the output path.

9. Technical details

The batch orchestration architecture.

9.1 Threading model

Each run spawns a single _BatchWorker QThread that iterates over the file list sequentially. Each file goes through:

  1. analyze_ser on that file's SERStackConfig → produces an AnalyzeResult.
  2. stack_ser with that result → produces the stacked float32 array.
  3. Save to TIFF via SASpro's shared save_image (with a tifffile.imwrite fallback if that import fails).
  4. Emit file_done(index, path, array) back to the GUI thread.

Only the worker thread does Analyze/Stack work; the GUI thread stays responsive for progress updates, cancel clicks, and the mandatory step of pushing each result as a new SASpro document (which must happen on the GUI thread for Qt safety).

9.2 Why document creation goes through a signal

SASpro's document system is Qt-based, and creating a new QWidget sub-window from a background thread is undefined behaviour in Qt. The worker therefore does not create documents directly — it emits file_done(index, path, array) and the GUI-thread slot _on_file_done calls _push_as_new_doc safely on the main thread. This signal-slot pattern is why the result array is marshalled through the signal payload rather than being written to disk and immediately re-read.

9.3 Per-file config isolation

Before running, SASpro builds one SERStackConfig per file by copying the base keyword set (inherited from the Viewer) and setting the per-file source. Each file's config carries its own copy, so modifying one in-flight (which doesn't happen, but conceptually) wouldn't bleed into others. Drizzle scale is set per batch from the dropdown and applied uniformly to all configs.

9.4 Anchor picker implementation

The _AnchorPickerDialog is a self-contained modal dialog that loads the first file's frame 0 (via open_planetary_source with a 2-frame cache), displays it as a mono preview with 1–99.5 percentile stretch, and lets you Shift+drag a rectangle on it. The result is stored in ROI-space coordinates (so if the Viewer's ROI is active, the anchor stays sensible when the Stacker crops to the ROI). On OK the anchor becomes the batch's surface anchor for every file; on Cancel the batch doesn't start.

Credits. The Batch Planetary Stacker — the batch orchestration (QThread worker iterating sequentially while keeping the GUI responsive), the GUI-thread signalling pattern that lets each completed stack be pushed as a new SASpro document safely from the background thread, the colour-coded four-state status list (pending/running/done/failed) with per-file and overall progress bars, the Anchor Picker dialog that acquires a surface anchor from the first file when none is set in the Viewer, and the per-batch Drizzle override — is original work by Franklin Marek for SetiAstro Suite Pro. The underlying stacking engine — quality scoring, reference frame construction, AP autoplace and editing, phase-correlation and SSD alignment, field rotation search, chromatic dispersion correction, planet axial derotation, drizzle resampling, quality-weighted integration and flat-field calibration — is the Planetary Stacker engine documented separately on its own help page, with full credits for OpenCV, Numba, Astropy, NumPy, PyQt6, FFmpeg and the standard algorithms (drizzle: Fruchter & Hook 2002; phase correlation: Kuglin & Hines 1975; log-polar Fourier-Mellin: De Castro & Morandi 1987; MAD-based outlier rejection: Rousseeuw & Croux convention). Output TIFF writing uses SASpro's shared save_image helper with tifffile as a fallback. The Planetary Stacker Viewer, which feeds this batch processor its base settings, is also documented separately.