SkyStacker
SkyStacker is a local-first command-line tool for stacking astrophotography images.
It takes a folder of night-sky exposures, detects stars, aligns the frames, combines them into useful image stacks, and can apply an automated post-processing workflow.
Stacking multiple frames dramatically improves signal-to-noise ratio and reveals faint structure (Trifid Nebula, 1 frame vs. 25 frames).
From a folder of individual exposures to aligned stacks and processed astrophotography images.

Table of Contents
Gallery
Examples of results produced with SkyStacker. More images will be added over time.

Galaxy — Andromeda (M31)
Spiral galaxy — the nearest large galaxy to the Milky Way, with visible dust lanes and companion M32.
|

Open Cluster — Pleiades (M45)
Young open star cluster surrounded by a blue reflection nebula of dust illuminated by the hot stars.
|

Nebula — Lagoon (M8)
Emission nebula and active star-forming region; the red Hα glow comes from ionized hydrogen gas.
|

Wide-field — North America Nebula region
Rich Milky Way field in Cepheus showing the North America Nebula (NGC 7000) and surrounding dust lanes.
|
What does SkyStacker do?
Astrophotography sessions usually produce many individual exposures of the same region of the sky. Even when the camera or mount moves slightly between exposures, the stars should occupy the same positions in the final combined image.
SkyStacker automates the core workflow:
- Discovers input frames in a session directory.
- Decodes the images and prepares their pixel data in linear floating-point precision.
- Optionally calibrates light frames using dark, flat, and bias frames.
- Detects stars and selects a reference frame.
- Registers the frames by matching star patterns and estimating geometric transformations.
- Resamples and aligns the exposures before combining them.
- Creates image stacks using the selected statistical method, plus maximum- and minimum-pixel combinations.
- Optionally post-processes the resulting image to improve its background, colour, contrast, and detail.
- Writes outputs and a processing report to a results directory.
The aim is to provide a transparent, reproducible, and resource-conscious workflow that runs locally, without requiring a cloud service.
Scope & Architecture
- Single-binary, static Go CLI: the executable is built from the package root (
main.go + donations.go), three first-party modules (goPureRaw/ for CR2, goDiagnostics/ for system reports, goTiff/ for typed TIFF I/O) and one small MIT-licensed third-party module (github.com/skip2/go-qrcode) used only to render donation QR codes in the terminal. CGO_ENABLED=0 static cross-platform builds remain.
- Linear float32 pipeline: Accumulates and processes image data in IEEE 754
float32 precision end-to-end.
- Current boundaries:
- CLI-only: No GUI is included.
- External RAW decoding: Native JPEG and native FITS decoding (with ImageMagick fallback) are built in; CR2 decoding is built in (pure Go, lossless JPEG/SOF3); CR3 still uses
dcraw/dcraw_emu or ImageMagick at runtime.
- Drizzle & SIP resampling: Drizzle and Bayer drizzle are not wired. SIP order-2 is applied in WCS forward/inverse helpers (
wcsTanForward, wcsTanInverseSIP) used by plate-solve/diagnostics, and optionally in the stacking resampler via --resample-sip (requires a stored plate_solution.json with SIP coefficients).
- Plate solving with blind fallback: the internal Gaia solver uses
--plate-center or FITS RA/DEC when available; without a seed it falls back to a real blind solve via astrometry.net (local solve-field or the nova web API), so no EXIF coordinates are needed. The old 3×3 nside=64 scan is no longer the only blind path.
Main Capabilities & Algorithms
Frame Registration
- Automatic star detection: Identifies 8-connected components above
sigma * noise (default 5.0σ, with automatic multi-sigma retries at 4.0, 3.5, and 3.0 if fewer than 20 stars are found), where noise is the MAD of a high-pass residual (box blur radius clamp(min(W,H)/200, 8, 24)).
- Reference-frame selection: Automatically picks the frame with the highest number of detected stars, or uses an external image with
--reference-crop.
- Reference-frame crop (
--reference-crop): Detects stars in the supplied reference image, matches each light by triangle pattern, and warps it in memory into the reference pixel frame. The output has exactly the reference dimensions; source files are never modified. Works with rotation and scale differences (0.5×–2×), and with a single light (--limit 1) to produce a standalone cropped frame. This is the automatic counterpart of Fitswork’s manual two-star crop.
- Triangle-based pattern matching: Constructs triangles from the top 40 brightest stars using scale-invariant side-ratio descriptors
(short/long, mid/long) bucketed on a 0.01 grid with 0.02 tolerance.
- Geometric transform estimation: Computes a closed-form similarity transform (rotation, scale, translation) via least squares with RANSAC-style inlier filtering, plus optional full 6-DOF affine refinement (retained only when residual error drops by ≥ 10% with ≥ 15 inliers).
- Sub-pixel resampling & safe crop: Uses bilinear sub-pixel resampling and computes the largest fully valid overlapping rectangle (
findSafeCrop, maximal-rectangle-in-histogram).
- Fallback & diagnostics: Frames that cannot be registered are logged in
report.txt (with limiter flags such as LOW QUALITY < 30, LOW BOX% < 50%, and LARGE OFFSET |drift| > 10% of reference dimensions) and excluded from the registered stack while still contributing to the unregistered mean.
Calibration
Calibration frames can be supplied explicitly:
- Dark frames help correct sensor dark signal and hot pixels.
- Flat frames help correct illumination variation and vignetting.
- Bias frames can be used with flat calibration.
You can pass individual calibration paths (--dark, --flat, --bias) or use --calib-root to let SkyStacker auto-discover Bias/Darks/Flats/<filter> subfolders under a common directory.
- Calibration frame QA: when 3+ dark subframes are found, per-frame median/MAD/hot-pixel statistics reject >3-sigma drifted or light-leaked darks before master construction (automatic;
testCalibrationQA).
- Exporting masters (
--export-masters): Writes each loaded calibration product as master_<kind>.f32raw (scientific float32 format with the same header as _work files) plus a master_<kind>.jpg preview. The preview maps the 1st…99.5th luminance percentile linearly to 0..255 and is intended for inspection only.
- Synthetic self-flat (
--self-flat): Derives a relative illumination map from at least 15 registered dithered lights.
- v1 (
--self-flat-model=registered): Built in reference coordinates and applied after registration, so it corrects mosaic-level vignetting rather than sensor-level fixed-pattern noise; a loaded flat always wins. Because a flat built from lights can absorb extended structures common to every frame (for example a large nebula—reaching a ratio near 1.9 around M42 on Orion-135mm), inspect the crop-sized master_self_flat.f32raw (using the crop rectangle in report.txt) before trusting the correction. Only the registered stack is corrected.
- Sensor-space grid (
--self-flat-model=grid, default): Full-frame estimator built from unregistered frames and applied before resampling. It uses a local-contrast source mask (so extended emission is not masked like a star), a SExtractor-style cell mode with a low-quantile consistency check, 5x5 median/MAD cell rejection, and a degree-4 Chebyshev fit refined by asymmetric Huber IRLS. report.txt includes the fit RMS, an ordinary least-squares RMS, a radial-model RMS, the IRLS iteration count, min/max, and the coefficients. Phase 4 of research/04-calibration-and-self-flat.md is complete; the registered model is the default. A loaded master flat still wins.
Stacking Methods
| Method |
Execution Model |
Purpose |
mean |
Streaming (single buffer per frame, divided by valid pixel count) |
Arithmetic average of registered frames; minimal disk overhead. |
median |
Tiled, out-of-core via _work/_spill1 and _work/_spill2 (~256 MB tile cap) |
Median combination, useful for rejecting transient features. |
sigma (default) |
Tiled MAD-based rejection (σ = 1.4826 × MAD), quality-weighted |
Rejects outliers (` |
SkyStacker also calculates maximum-pixel and minimum-pixel combinations in Pass 1 across all accepted frames. These are useful for inspecting transient features (e.g., meteors/satellites) and background behaviour, though they are diagnostic combinations rather than substitutes for a normal integration.
Frame Normalization (Optional)
Sessions where individual frames have different sky brightness or transparency benefit from background normalization before stacking (requires registration; no-op when --no-register is set):
--normalize: Per-frame global scale + offset matching each frame’s background luminance (median, MAD)—computed on a 1024-bin histogram with 4× subsampling—to the reference frame (scale = ref.MAD / frame.MAD clamped to [0.5, 2.0], offset = ref.median - scale * frame.median). Takes ~1 ms/frame and handles uniform sky-glow drift and transparency swings.
--local-normalize: Per-tile scale + offset with bilinear interpolation across tile centers (--ln-tile-size, default 256 px). Handles spatially varying gradients (light pollution, changing vignetting direction). Implies --normalize.
The reference frame itself is never normalized; every other frame is matched to its background prior to accumulation or spilling.
Post-Processing Pipeline
SkyStacker includes an 8-step automated post-processing workflow (plus optional flag-gated stages):
- Background removal: Robust 2nd-degree 2D polynomial fit (
--bg-degree 1–3) to 32×32 block samples (20th percentile per channel) with 3 iterations of outlier rejection above 2σ. --mask-bg excludes pixels above 0.1 luminance.
- Star removal: High-pass star detection replaced by the median of an annulus scaled by star radius (
--star-radius, --star-sigma).
- Black-point shift: Subtracts the
--bg-percentile luminance percentile (default 10), held in memory for step 4.
- STF/MTF auto-stretch: PixInsight-style Screen Transfer Function / Midtone Transfer Function (
--stf-shadows default -2.8, --stf-target default 0.25; --stf-linked applies a single shared transform across RGB channels).
- Guided-filter denoise: Per-channel self-guided filter (He et al. 2010) for
--denoise-strength passes (radius --denoise-radius, default 3), followed by a two-scale chroma-only pass (radii 24 and 96, eps = 0.005) to suppress low-frequency colour blotches (--denoise-chroma).
- Curves: Applies
x' = clamp((x - black) / (1 - black), 0, 1); out = x'^gamma (--curves-black default 0.03, --curves-gamma default 1.20) identically per channel.
- HDR blend: Combines stretched and linear-background detail via
out = clamp(step6 + hdrBlendFactor * step1, 0, 1) (--hdr-blend-factor default 1.0).
- Weighted mix & diffraction spikes: Produces 4 preview variants
w*step1 + (1-w)*step7 for w ∈ {0.90, 0.80, 0.70, 0.60} (unless --no-hdr-mix), and optionally renders additive diffraction spikes on bright stars (ON by default; disable with --no-spikes).
Additional optional stages can be toggled via CLI flags: chromatic-aberration reduction (--post-ca), colour calibration (--post-color), vignette/background flattening (--post-flatten), unsharp-mask sharpening (--post-sharpen), HDR local-contrast enhancement (--post-hdr), and three-level contrast stretching (--post-stretch). Run skystacker --help for the exact options in your build.
Astrometric Plate Solving & Gaia DR3 Layer
- WCS solver (
--plate-solve): Solves a TAN WCS astrometric solution after stacking using star pattern matching against Gaia DR3, writing plate_solution.json (including fitted SIP order-2 distortion coefficients). Supply --plate-center RA,DEC in decimal degrees or rely on the reference frame’s FITS RA/DEC header keywords; otherwise --plate-solver auto tries the native Gaia quad-index solver (--blind-catalog), then local astrometry.net (--astrometry-cmd), ASTAP (--astap-cmd) and the nova web API (--astrometry-api-key or AN_API_KEY). External WCS results are re-fitted against Gaia at the solved centre. With --post-only, the solver runs on stars detected in _work/stacked_mean.f32raw; a temporary JPEG is generated for the blind backend.
- HEALPix & TAP client: Implements the HEALPix nested scheme (
nside power of 2 from 2 to 8192, default 64 at ~0.84 deg² per tile) and queries ESA’s Gaia TAP /sync endpoint with a 180 s per-attempt timeout, 5 s progress heartbeat, automatic retries (2 s / 4 s backoff on 5xx/network errors), and 1 req/sec rate limiting.
- Persistent tile cache: Since Gaia DR3 is a frozen catalogue, downloaded tiles are cached permanently in your OS user cache directory (
~/.cache/skystacker/gaia_cache/ on Linux, ~/Library/Caches/skystacker/gaia_cache/ on macOS), enabling offline operation with --gaia-offline.
SkyStacker currently discovers these file extensions:
.jpg and .jpeg (decoded natively via Go’s standard image packages)
.png (decoded natively)
.fit and .fits (decoded natively with ImageMagick fallback)
.ser (FireCapture/Lucam SER; expanded to one frame per #frame=N)
.cr2 and .cr3 (decoded via external dcraw, dcraw_emu, or ImageMagick at runtime)
On Debian/Ubuntu, install ImageMagick:
sudo apt update
sudo apt install imagemagick
For Canon RAW files, SkyStacker prefers dcraw or dcraw_emu when available in PATH. Install a compatible RAW decoder if your system does not already provide one.
Note: Exact RAW/FITS decoding capabilities depend on the ImageMagick delegates and RAW decoder installed on your system. A file extension alone does not guarantee that a particular camera file can be decoded.
System Requirements
- Go 1.27.4 or later (to compile from source;
go.mod pins toolchain go1.27.4).
- Runtime decoders: ImageMagick and/or
dcraw / dcraw_emu for RAW/fallback FITS ingestion.
- Memory & Disk: Sufficient RAM and scratch disk space for the session’s frame count and image dimensions (see Pre-Flight Resource Checks).
Build & Verification
Clone the repository and build the executable:
git clone [https://github.com/computerphysicslab/skystacker.git](https://github.com/computerphysicslab/skystacker.git)
cd skystacker
go build -ldflags "-X main.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o skystacker .
Run the embedded unit & integration self-tests (authoritative count printed at runtime; runSelfTests in main.go is the source of truth). Go 1.25+ also enables a deterministic testing/synctest check of the Gaia rate limiter via go test ./...:
./skystacker --selftest
go test ./...
Print the version or command-line help:
./skystacker --version
./skystacker --help
Startup Banner
On every run, SkyStacker prints a one-line banner to standard error:
SkyStacker 0.6.1 | [https://github.com/computerphysicslab/skystacker](https://github.com/computerphysicslab/skystacker) | built 2026-11-15T00:00:00Z
To embed the real build time when building from the package root:
go build -ldflags "-X main.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o skystacker .
Without -ldflags, SkyStacker falls back to the VCS commit timestamp embedded by Go when building from a Git checkout, or prints unknown.
Quick Start & Examples
Basic Stacking
Place the light frames from an imaging session into a directory:
M31-session/
├── light_001.jpg
├── light_002.jpg
├── light_003.jpg
└── ...
Run the default workflow (sigma clipping + full post-processing):
./skystacker ./M31-session
By default, results are written to M31-session/0_skystacker_results/.
Common workflow variations:
# Choose a stacking method (mean, median, or sigma)
./skystacker --method mean ./M31-session
./skystacker --method median ./M31-session
./skystacker --method sigma ./M31-session
# Specify a custom output directory and allow overwriting existing outputs
./skystacker --output ./results/M31 --overwrite ./M31-session
# Search subdirectories recursively
./skystacker --recursive ./M31-session
# Stack frames only (skip post-processing)
./skystacker --stack-only ./M31-session
# Re-run post-processing on existing _work/stacked_mean.f32raw without re-stacking
./skystacker --post-only ./M31-session
Calibration Example
Organize light and calibration frames in separate directories:
M31-session/
├── lights/
│ ├── light_001.cr2
│ ├── light_002.cr2
│ └── ...
└── calibration/
├── darks/
├── flats/
└── bias/
Supply calibration files or folders explicitly:
./skystacker \
--dark ./M31-session/calibration/darks/master-dark.fit \
--flat ./M31-session/calibration/flats/master-flat.fit \
--bias ./M31-session/calibration/bias/master-bias.fit \
./M31-session/lights
Or let SkyStacker auto-discover Bias/, Darks/, and Flats/ subdirectories under --calib-root:
./skystacker \
--calib-root ./M31-session/calibration \
./M31-session/lights
Tip: Match calibration frames to your light frames in camera model, sensor temperature, exposure duration, ISO/gain, and optical train.
Reference-Frame Crop Example
# Stack a session but keep exactly the framing of a reference image.
./skystacker \
--reference-crop ./reference/M31-framing.jpg \
./M31-session/lights
# Crop one image to the reference frame without stacking a session.
./skystacker \
--reference-crop ./reference/M31-framing.jpg \
--limit 1 \
--stack-only \
./single-exposure
The reference image is star-matched automatically; the light frames are warped in memory and the originals are never modified. The frame-exact result is also written as reference_crop.f32raw and reference_crop.jpg.
Normalization & Plate Solving Example
./skystacker \
--local-normalize \
--plate-solve \
--plate-center 10.6847,41.2747 \
--tiff \
--png \
./M31-session/lights
Layered Annotation Example (bundled M31 lights)
The five JPGs in assets/2024-08-07-Riofrio-M31-refr150/ are a complete
light-frame session. Stack them, solve the plate offline against the cached
Gaia tiles and emit the layered SVG 2 map plus its raster twin:
./skystacker \
--output /tmp/skystacker-m31-demo --overwrite \
--plate-solve --plate-center 10.6847,41.2690 --gaia-offline \
--annotate --sky-map \
--annotation-layers grid-radec,grid-galactic,constellations,scale-bar,finder-chart,legend \
--annotation-cache /tmp/skystacker-m31-demo/vo-cache \
--no-donation \
assets/2024-08-07-Riofrio-M31-refr150
Results in /tmp/skystacker-m31-demo/: plate_solution.json, plus two
subfolders — maps/ with stacked_annotated.jpg (legacy overlay),
stacked_sky_map.svg (legacy map), stacked_annotated.svg (SVG 2 layers),
stacked_annotated.png, annotation_provenance.json, anomalies.json and
catalog_matches.json, and survey/ with the DSS cutouts, mosaics and
survey_rgb_synthetic.* plus stacked_mean_survey_matched.jpg. This example
uses --gaia-offline, so it can
only read tiles already in the Gaia cache; if part of the frame has no cached
tile it will be empty. The provenance report now makes that explicit with a
gaia_coverage block and a warning (on a fresh cache this field reports
42/81 frame samples, 1 tile, 39 missing). Omit --gaia-offline — the
default — to fetch every missing tile crossing the frame (for M31: 81/81
samples, 4 tiles, no empty region). Gaia stars have no proper names in the cache, so each one now gets a unique
coordinate designation such as Gaia J004245+411630. In an online run
--annotation-names auto queries SIMBAD over the full field and, if SIMBAD is
unreachable, falls back to AllWISE through IRSA; close matches replace the
designation with the catalog identifier (for example WISE J004057.98+414350.8) and the number of matches is recorded in
annotation_provenance.json (name_matches). Use --annotation-names simbad,
irsa or off to force a catalog, the fallback only, or designations only.
Bright Gaia stars additionally receive an SAO n identifier (with HD,
DM and GC cross-IDs in the provenance) from a compact embedded V<=8.0 SAO
subset; proper names and Bayer/Flamsteed labels always win a positional tie, and
--annotation-sao=false disables this fallback. Gaia positions are propagated
to --annotation-epoch (default 2024.6, the plate epoch for the bundled M31
frames) with proper motion before projection; high-proper-motion foreground
stars that leave the frame are filtered, so SAO labels only appear for stars
still in frame. Use --annotation-epoch 2016 (the Gaia catalog epoch) to keep
catalog positions and label high-proper-motion stars where they were recorded. To compare a solved frame with
the sky survey it was taken from, --survey-cutout --survey-source dss --survey-reproject downloads a STScI/MAST DSS plate and resamples it onto the
target WCS, producing a pixel-registered *_aligned.fits plus JPG and a
provenance JSON that records the plate, its copyright and the CC BY-NC-SA 4.0
licence (DSS is free for scientific/educational/non-profit use, not public
domain). Pass --dss-survey poss2ukstu_red,poss2ukstu_blue to fetch two plates
in one run (their products get _<survey> suffixes); full-frame DSS cutouts
are about 18 MB and need --survey-timeout 300, or --survey-timeout 0 to
select the automatic 300 s budget. Rotated fields wider than 60 arcmin on the
sky are split into overlapping tiles and merged with a validity mask, so the
whole stacked frame is covered. --survey-rgb builds a documented synthetic
colour image from three plates: red -> R, quickv (V band, since DSS has no
green plate) -> G and blue -> B; --survey-rgb-fallback names ordered plates
that fill uncovered channel pixels (default poss2ukstu_ir). The result is
survey_rgb_synthetic.png/.jpg/.fits plus a provenance JSON with per-channel
plate IDs, copyright, tile counts and fallback counts. When the synthetic RGB
composite is produced, stacked_mean.jpg is also matched to the survey
histogram and written as survey/stacked_mean_survey_matched.jpg
(luminance-only tone curve, preserves the original colour cast) and
survey/stacked_mean_survey_RGB_matched.jpg (independent per-channel curves,
matches the survey colour balance). Both LUT anchor sets are recorded in the
same provenance JSON (stacked_stretch and stacked_rgb_stretch). CDS
HiPS remains the
default source; its service was unreachable from this machine during
verification, which is reported as an external outage.
Add --annotation-vo simbad,vizier to
enrich the same model from VO services; network failures only add a redacted
warning and keep the offline sources. Layered annotations also embed a
field-filtered deep-sky catalogue of 19,292 unique objects built from OpenNGC
(CC BY-SA 4.0) and public HEASARC dumps of Messier, LBN, LDN, Sh2, Magakian,
planetary nebulae, Green SNRs and open/globular clusters. It is enabled by
default with --annotation-deep-sky and can be disabled with =false; only
objects inside the solved frame are loaded, cross-identifiers are merged, and
the bundle duplicate (M 31) is suppressed. docs/catalog-attribution.md
records every source and licence. Star markers use renderer-safe literal
colours (white → amber → brown by magnitude) with matching opacity, so the SVG
stays visible in browsers, librsvg and ImageMagick instead of rendering
black-on-black. Extended sources use an atlas-style vocabulary shared by both
outputs: a solid ellipse for a galaxy, a deterministic irregular contour for a
diffuse nebula, supernova remnant or dark cloud, a ring plus core for a
planetary nebula and a dashed circle for a cluster. Catalog variable and
double flags (explicit JSON fields, SIMBAD object types or metadata aliases)
draw a dashed surrounding ring or a resolved pair of stars. Every marker carries
a stable data-symbol attribute, and the legend layer draws the same
ATLAS KEY panel in the SVG and PNG. The root <svg class="skystacker-atlas-map">
advertises the vocabulary in data-symbol-families; adding a
skystacker-hide-<family> class to that root hides both the map markers and the
matching key swatch using pure CSS (for example skystacker-hide-variable). Each
swatch also has a skystacker-key-<family> class, a data-key-symbol and an
accessible <title>. The key covers all seven map families: galaxy, nebula,
planetary nebula, cluster, star, variable and double.
Point-source markers can also be tinted from a colour index (B-V, BP-RP,
G-R) or spectral_class metadata using an Okabe-Ito colour-blind-safe
palette; magnitude still controls radius and opacity, and Gaia’s G passband
deliberately keeps the magnitude-only fallback. Indexed markers expose
data-spectral and data-colour-mode="index". When a VO row supplies major,
minor and position-angle columns, those catalog axes drive the shared atlas
contour; annotation_provenance.json records geometry.catalog and
geometry.fallback counts. The motion layer adds deterministic 50-year
proper-motion arrows and compact variability brackets sized from amplitude
or min_mag/max_mag, with overlays counts in the provenance report.
Both sky maps union every tile crossing the frame, cached or
fetched when online, not only the CRVAL tile. Local adaptive star
detection (box-blur high pass) is already used by the solver and stack.
The offline bundle also carries 3,241 bright-star proper names, Bayer letters and
Flamsteed designations (V <= 6.5, BSD-2-Clause attribution in
docs/catalog-attribution.md); a readable name wins
a cross-match inside the positional tolerance, while unique Gaia J...
designations remain the offline fallback. A compact NED-derived PGC table also
names four dense-field galaxies; PGC/LEDA aliases are normalised and
anonymous galaxies are matched spatially with priority 80, below M31 (90) but
above anonymous survey identifiers, with counts in pgc_matches.
Labels carry a dark contrast collar by default; use
--annotation-label-collar=false for plain text. For the open-circle stars in
the vendor sample, add --annotation-star-style open: ordinary point sources
become the toggleable open-star family while variable and double stars keep
their scientific markers. Both styles are mirrored in SVG and raster without
moving any labels.
Comet Tracking Example
# Pixel mode (reference frame coordinates, EXIF times)
./skystacker --comet-center 1200,800 --comet-rate 0.02,-0.01 ./lights
# RA/Dec rate mode (requires plate solve)
./skystacker --plate-solve --comet-radec 83.822,22.0145 --comet-sky-rate-arcsec 2.5,-0.3 ./lights
# Ephemeris file (lines: ISO8601 RA_deg Dec_deg; # comments allowed)
./skystacker --plate-solve --comet-target ./comet_ephem.txt ./lights
comet_ephem.txt example:
# time UTC RA_deg Dec_deg
2026-01-01T00:00:00Z 83.800 22.010
2026-01-01T00:30:00Z 83.805 22.012
Comet-aligned outputs are written as stacked_comet.f32raw/stacked_comet.jpg when enabled (if EXIF DateTimeOriginal is missing for a frame, reference time is used with a warning unless --comet-ephem-strict-exif is set, in which case the run fails).
Command-Line Options
skystacker [flags] [input-directory]
The input directory defaults to .. Flags may be passed before or after the positional input directory. Value-taking flags are discovered from the registered flag set, so new flags do not need a parser change; --flag=value, -flag value and a trailing -- are also supported.
Core & Execution
| Flag |
Description |
Default |
--config file.json |
Load flags from a JSON object (keys without --); explicit CLI flags win |
— |
--resume |
If the output dir already has a stacked float32 image, continue with post-processing instead of re-stacking |
false |
--drizzle-upsample N / --drizzle-pixfrac F |
Diagnostic drizzled N× upsample (stacked_drizzled.f32raw/.jpg), N=1 off |
off / 1.0 |
--output string |
Output directory |
<input>/0_skystacker_results |
--method string |
Stacking method: mean, median, or sigma (default; asserted by testParseArgs) |
sigma |
--workers int |
Maximum number of concurrent worker goroutines |
Number of CPUs |
--recursive |
Search input subdirectories recursively |
false |
--overwrite |
Permit replacing existing files in the output directory |
false |
--no-register |
Disable star-based registration |
false |
--reference-crop string |
Warp every light into the star-matched pixel frame of this reference image; output size equals the reference size |
— |
--scale int |
Downscaling factor (2 halves each dimension, 4 quarters it) |
1 |
--force |
Bypass pre-flight out-of-memory and disk-space safety checks (not recommended) |
false |
--no-exif |
Skip EXIF exposure summary in report.txt |
false |
--clean |
Remove _work directory after a successful run |
false |
Calibration
| Flag |
Description |
Default |
--dark string |
Dark frame file or directory path |
— |
--flat string |
Flat frame file or directory path |
— |
--bias string |
Bias frame file or directory path |
— |
--calib-root string |
Root directory containing Bias/Darks/Flats folders |
— |
--export-masters |
Write master_<kind>.f32raw + .jpg preview for loaded calibration products |
false |
--bpm-auto |
Derive a bad-pixel map from the master dark (or bias) via median + N*sigma*MAD |
false |
--bpm-auto-sigma float |
Sigma threshold for --bpm-auto |
5.0 |
--self-flat |
Derive a relative illumination flat from ≥ 15 dithered lights (auto when no flat loaded) |
true (auto) |
--self-flat-model string |
Self-flat model: grid (default, Phase-3 sensor-space with IRLS) or registered (v1 compatibility) |
grid |
--self-flat-linear-srgb |
Experimental: apply grid self-flat in linear light via sRGB EOTF (approximation; off by default) |
off |
--hfr-quality |
Use median star HFR (FWHM ≈ 1.995·HFR) instead of blob size for advanced frame-quality weighting |
false |
--annotate |
Project cached Gaia stars through the plate solution into stacked_annotated.jpg; write unmatched detections to anomalies.json (offline) |
false |
--annotation-catalogs LIST |
Comma-separated JSON catalogs (RA/Dec degrees; optional name/type/mag/major/minor/pa) for multi-catalog cross-match |
— |
--annotation-layers LIST |
Comma-separated SVG 2 annotation layers: grid-radec, grid-galactic, grid-ecliptic, constellations, scale-bar, finder-chart, legend/key (plus grid, gaia-stars/stars, extended-objects/dso, sso-vectors) |
all |
--annotation-vo LIST |
Optional online VO services for layered annotations: simbad, vizier (offline bundle by default) |
— |
--annotation-deep-sky |
Use the embedded 19,292-object OpenNGC/HEASARC deep-sky catalogue in layered annotations (=false disables it) |
true |
--annotation-cache DIR |
Disk cache directory for VO annotation queries |
Gaia cache dir |
--annotation-label-collar |
Draw a dark contrast stroke behind annotation labels (=false for plain labels) |
true |
--annotation-star-style MODE |
Point-source markers: filled or open |
filled |
--starless |
Write stacked_starless/stacked_stars .f32raw + .jpg from the post-processing star-removal step |
false |
--json-report |
Write report.json alongside report.txt (same processingReport data) |
false |
--verify-solution |
Report-only whole-frame WCS verification against cached Gaia |
false |
--validate-blind-catalogs |
Verify checksums/sizes of local published blind catalogs |
false |
--transformation-report |
Report-only AAVSO-style photometric coefficients |
false |
--extinction-report |
Report-only Rayleigh coefficients per RGB channel (forces report.json) |
false |
--provenance |
Write provenance.json with an IVOA ProvenanceDM-style entity/activity/agent graph |
false |
--diagnose |
Collect a host/runtime diagnostic snapshot (diagnostics.txt) and exit |
false |
--diagnose-json |
Also write diagnostics.json |
false |
--diagnose-quick |
Faster subset: no package inventory, smaller directory walk |
false |
--diagnose-integrated |
During a normal run, write diagnostics next to the report |
false |
--diagnose-timeout N / --diagnose-top N |
Collection timeout in seconds / number of top processes |
5 / 10 |
--diagnose-updates |
Include installed packages/hotfixes (local inventory only, no network) |
false |
--frame-metrics PATH / --include-list PATH |
Per-frame quality CSV and frame culling by list |
— |
--keep-sharpest N |
Keep only the sharpest N% of frames by median star HFR |
0 |
--calib-library PATH |
Match calibration masters by exposure/temperature/ISO/gain |
— |
--comet-combine |
Recombine comet and stars stacks into stacked_comet_combined |
false |
--batch FILE |
Run a JSON queue of CLI invocations sequentially |
— |
--starless-psf |
Per-star HFR/eccentricity radii for star removal |
false |
--wavelets / --wavelet-scales N / --wavelet-sigma F |
À trous wavelet denoise on linear data |
false / 3 / 3.0 |
--deconvolve-wiener |
FFT Wiener deconvolution (uses --deconv-sigma) |
false |
--photometry |
Ensemble Gaia aperture photometry → photometry.csv/.json |
false |
--no-donation |
Suppress the rotating thank-you/donation footer after a successful full run |
false |
--no-donation-qr |
Print the footer without terminal QR codes |
false |
--donation |
Print the rotating message and both QR codes, then exit (no image processing) |
false |
--rejection MODE |
Auto/mean/median/sigma rejection heuristic by stack size |
"" |
--post-preset NAME |
default or detail-last (detail enhancement after denoise) |
default |
--wavelet-adaptive |
Per-tile MAD thresholds with --wavelets |
false |
--dark-scale-entropy |
Scale master dark per light by minimising residual entropy |
false |
--cosmic-reject |
Single-frame cosmic-ray rejection on linear lights |
false |
--streak-detect |
Detect linear satellite streaks and write stacked_streak_mask.f32raw |
false |
--sky-map |
Write stacked_sky_map.svg with Gaia sources in the solved frame |
false |
--annotate --sky-map |
Also write the unified layered products stacked_annotated.svg, stacked_annotated.png and annotation_provenance.json |
false |
--survey-cutout |
Fetch a CDS HiPS FITS cutout matching the solved frame geometry (frames above the 50 Mpix service limit are refused locally) |
false |
--survey-hips ID / --survey-timeout N |
HiPS survey and HTTP timeout for --survey-cutout; 0 selects auto (DSS full frames 300 s, small cutouts 120 s, HiPS 30 s) |
CDS/P/DSS2/color / 30 |
--survey-source hips|dss / --dss-survey LIST |
Survey service and DSS plate survey(s), comma-separated for several plates in one run (poss2ukstu_red, poss2ukstu_blue, poss2ukstu_ir, poss1_red, poss1_blue, quickv, phase2_gsc2, phase2_gsc1); multi-plate stems get a _<survey> suffix |
hips / poss2ukstu_red |
--survey-reproject |
Resample the cutout onto the solved frame WCS; writes *_aligned.fits (target WCS, SIP), *_aligned.jpg and *_alignment.json with plate ID, copyright and CC BY-NC-SA 4.0 licence. Fields above 60 arcmin use overlapping tiles merged with validity masks |
false |
--survey-rgb / --survey-rgb-surveys R,G,B |
Build a synthetic RGB image from three DSS plates (survey_rgb_synthetic.png/.jpg/.fits plus provenance); default mapping red, Quick-V, blue |
false / poss2ukstu_red,quickv,poss2ukstu_blue |
--survey-rgb-fallback LIST |
Ordered DSS plates used to fill uncovered RGB channel pixels, recorded per channel in the provenance JSON; empty disables |
poss2ukstu_ir |
--process-image PATH[,PATH...] |
Process existing JPG/PNG/FITS images without stacking; resize also accepts a directory |
— |
--image-op OP |
resize, blur, sharpen, background, stretch, denoise, deconvolve, starless, sum, subtract, average, median, min, max, measure-transform, measure-quality, sky-map, survey-cutout, plate-solve (blind-capable) |
— |
--image-output DIR |
Output directory for image-mode products |
image_processing |
Apart from resize --overwrite, image mode writes <basename>_<op>.f32raw +
JPEG (and JSON metadata), never modifies the inputs, and reuses the same
plate-solve/Gaia/HiPS helpers as the stacking products.
To shrink a whole folder in place (JPG/PNG, EXIF kept in JPGs):
skystacker --process-image assets/2024-08-07-Riofrio-M31-refr150 \
--image-op resize --scale 3 --overwrite
Without --overwrite, each input produces <name>_resize.<ext> in
--image-output; existing outputs are refused unless --overwrite is set.
measure-transform/measure-quality write image_measurements.csv/.json.
| --bg-multiscale | Remove a coarse 20th-percentile background grid before the polynomial fit | false |
| --deconvolve | Richardson-Lucy deconvolution with Gaussian PSF after background removal (CPU-heavy) | false |
| --deconvolve-grid / --deconv-grid-size N | Local PSF from star HFR over a 3×3/4×4 grid instead of one global sigma | false / 3 |
| --deconv-sigma float / --deconv-iters int | PSF sigma (px) and RL iterations | 1.5 / 3 |
| --narrowband M + --nb-a/--nb-b/--nb-c | HOO/SHO mapping from three mono .f32raw stacks (_work/stacked_narrowband.f32raw written) | — |
| --wavesharp / --wave-gains | Classical multi-scale Gaussian detail enhancement (coarse-to-fine gains, BXT-like baseline) | false / 0.25,0.15,0.08 |
| --external-bge CMD | User-supplied external AI background-extraction CLI, invoked through a private 32-bit float FITS sidecar | — |
| --external-denoise CMD | External AI linear denoise CLI (GraXpert -cmd denoising, NoiseXTerminator, …) | — |
| --external-deconv CMD | External AI linear deconvolution CLI (GraXpert -cmd deconv-obj, BlurXTerminator, …) | — |
| --external-starless CMD | External AI starless CLI (StarNet2, StarXTerminator, …); replaces built-in star removal | — |
| --external-allow-nonlinear | Permit external denoise/deconv on nonlinear data (unsafe for models trained on linear stacks) | false |
| --external-timeout N | Per-stage timeout in seconds (0 disables) | 1800 |
| --resample-sip | Apply stored order-2 SIP distortion in the stacking resampler (needs plate_solution.json with SIP) | false |
CMD is a whitespace-separated argv list (no shell interpolation) that must
contain {input} and {output} placeholders. Example:
--external-denoise "/opt/GraXpert/GraXpert -cli -cmd denoising -gpu false -i {input} -o {output}".
The input is a big-endian BITPIX=-32, NAXIS=3 RGB FITS with the plate-solution
WCS; the output must have the same dimensions, and its WCS is restored from the
input if the tool drops or alters it. Results are also saved as
_work/external_<stage>.f32raw. Denoise/deconv stages are blocked on nonlinear
frames unless --external-allow-nonlinear is given.
Normalization
| Flag |
Description |
Default |
--normalize |
Per-frame global scale + offset background match to reference (requires registration) |
false |
--local-normalize |
Per-tile scale + offset with bilinear interpolation; implies --normalize |
false |
--normalize-mode string |
scale-offset (default), additive (median shift), or multiplicative (clamped median ratio) |
scale-offset |
--normalize-per-channel |
Independent per-channel normalization (global only; overrides local) |
false |
--ln-tile-size int |
Tile size in pixels for --local-normalize |
256 |
Stacking & Cache
| Flag |
Description |
Default |
--sigma-clip float |
MAD sigma-clipping rejection threshold (0 disables) |
3.0 |
--sigma-clip-iters int |
Number of sigma-clipping iterations |
2 |
--sigma-clip-low float |
Asymmetric low-side sigma threshold (0 = use --sigma-clip) |
0 |
--sigma-clip-high float |
Asymmetric high-side sigma threshold (0 = use --sigma-clip) |
0 |
--tile-size int |
Tile side length in pixels for median/sigma (0 = auto, capped at ~256 MB) |
0 |
--no-cache |
Disable reading/writing the star and transform cache |
false |
--cache-dir string |
Directory for star/transform cache |
<output>/_work/cache |
Workflow Control
| Flag |
Description |
Default |
--stack-only |
Stack frames and skip post-processing |
false |
--no-postprocess |
Alias for --stack-only |
false |
--post-only |
Run post-processing on existing _work/stacked_mean.f32raw |
false |
Post-Processing: Background, Stars & Stretch
| Flag |
Description |
Default |
--mask-bg |
Mask bright objects (luminance > 0.1) during background extraction |
false |
--bg-degree int |
Background polynomial degree (1–3) |
2 |
--bg-percentile float |
Luminance percentile used for black-point shift (0 disables) |
10 |
--star-radius int |
Star-removal annulus radius in pixels (0 selects automatic sizing) |
0 |
--star-sigma float |
Star-detection threshold in sigma units for star removal |
4 |
--stretch float |
Asinh stretch factor |
10 |
--no-auto-stretch |
Skip the final STF/MTF auto-stretch |
false |
--stf-shadows float |
STF shadow clip point in sigma units |
-2.8 |
--stf-target float |
STF target background median level |
0.25 |
--stf-linked |
Link RGB channels during STF auto-stretch (preserves colour balance) |
false |
--stretch-color-preserving |
Stretch luminance only and preserve linear RGB ratios |
false |
--psf-auto |
Fit Gaussian/Moffat per star and keep the lower-residual centroid |
false |
Post-Processing: Denoise, Curves, HDR & Optional Stages
| Flag |
Description |
Default |
--no-denoise |
Skip guided-filter denoise |
false |
--denoise-strength float |
Guided-filter denoise passes (0 = skip, N = iterations, max 10) |
4.0 |
--denoise-radius int |
Guided-filter denoise kernel radius in pixels |
3 |
--denoise-chroma float |
Two-scale chroma denoise iterations (0 disables) |
1.0 |
--no-curves |
Skip the tone curves step |
false |
--curves-black float |
Curves shadow crush point in [0, 0.5) |
0.03 |
--curves-gamma float |
Curves midtone gamma (> 1 darkens midtones) |
1.20 |
--no-hdr-blend |
Skip step-7 HDR blend |
false |
--hdr-blend-factor float |
HDR blend amount: step6 + F · step1 |
1.0 |
--no-hdr-mix |
Skip generating the 4 step-8 weighted-mix preview variants |
false |
--post-ca |
Enable chromatic-aberration reduction |
false |
--post-color |
Enable colour calibration |
false |
--post-flatten |
Enable vignette/background flattening |
false |
--post-sharpen |
Enable unsharp-mask sharpening |
false |
--post-hdr |
Enable HDR local contrast |
false |
--post-stretch |
Enable the three-level contrast stretch |
false |
--no-color-calib |
Skip colour calibration |
false |
--no-sharpen |
Skip sharpening |
false |
--sharpen-amount float |
Unsharp-mask amount |
0.8 |
--sharpen-radius float |
Unsharp-mask radius in pixels |
1.5 |
--hdr-amount float |
HDR local-contrast amount |
0.5 |
Post-Processing: Diffraction Spikes (Step 8 Overlay)
| Flag |
Description |
Default |
--spikes |
Add additive diffraction spikes to bright stars |
true |
--no-spikes |
Disable diffraction spikes |
false |
--spikes-percent float |
Percentage of detected stars to spike (0–50) |
0.2 |
--spikes-length float |
Spike arm half-length in pixels |
10 |
--spikes-intensity float |
Peak additive spike brightness |
0.3 |
--spikes-arms int |
Number of spike arms (4 = cross, 6 = hex) |
4 |
--spikes-softness float |
Intensity falloff exponent (flux/maxFlux)^softness |
0.5 |
--spikes-min-ratio float |
Minimum intensity floor for the faintest spiked star |
0.2 |
--spikes-length-softness float |
Length falloff exponent (flux/maxFlux)^lengthSoftness |
1.0 |
--spikes-length-min-ratio float |
Minimum length floor for the faintest spiked star |
0.03 |
--spikes-min-count int |
Minimum number of stars to spike |
5 |
Plate Solving & Gaia DR3 Data Layer
| Flag |
Description |
Default |
--plate-solve |
Run TAN WCS plate solve after stacking or on the existing stack with --post-only; writes plate_solution.json |
false |
--plate-center RA,DEC |
Optional pointing seed in decimal degrees (falls back to FITS RA/DEC) |
— |
--plate-solver MODE |
auto (seeded Gaia, then native quad index/astrometry.net/ASTAP/web), gaia, astrometry-local, astap, native, astrometry-web |
auto |
--blind-catalog ID |
published Gaia quad catalog (mag07, mag10, mag10deep); see catalogs/ and docs/plate-solving.md |
— |
--astap-cmd CMD |
local ASTAP blind-solver command (needs D05–D80 database) |
astap |
--cone-catalog NAME / --cone-radius N |
external VOTable cone search added to annotations (sdss, irsa, vizier; arcsec) |
— / 60 |
--annotation-names MODE |
Gaia label names: auto (SIMBAD over the whole field, AllWISE fallback), simbad, irsa or off |
auto |
--annotation-sao |
Bright-star SAO/HD/DM/GC labels from the embedded V<=8.0 SAO subset; use =false to disable |
on |
--annotation-label-collar |
Dark contrast stroke behind labels; use =false for plain text |
on |
--annotation-star-style MODE |
open adds the toggleable open-star family (variable/double markers remain distinct) |
filled |
--blind-benchmark DIR / --benchmark-solvers LIST |
head-to-head blind-solve CSV over a corpus |
— |
--astrometry-cmd CMD / --astrometry-api-key KEY |
local solve-field command / nova API key (AN_API_KEY also read) |
solve-field / — |
--solve-field-args ARGS |
extra quoted argv for local solve-field (no shell) |
— |
--astrometry-url URL / --astrometry-timeout N |
nova API base URL / solve timeout in seconds |
nova / 180 |
--solver-focal-length MM / --solver-pixel-size UM |
optional plate-scale hint and post-solve sanity check |
— |
--gaia-mirror string |
Gaia TAP mirror URL |
https://gea.esac.esa.int/tap-server/tap |
--gaia-async / --gaia-maxrec N / --gaia-verbosity N / --vo-registry URL |
Async TAP polling, explicit limits and VO registry discovery |
false / 2000 / 0 / — |
--wcs-refine |
Iteratively refine the stored WCS against Gaia residuals |
false |
--archive-adapters LIST / --mast-token TOKEN |
MAST/ESASky/IRSA MOST opt-in archive queries |
— |
--gaia-cache-dir string |
Gaia HEALPix tile cache directory |
OS user cache dir (~/.cache/skystacker/gaia_cache) |
--gaia-nside int |
HEALPix nside resolution (power of 2, 2–8192) |
64 |
--gaia-mag-limit float |
Gaia G-band faint magnitude limit (0–20) |
14.0 |
--gaia-offline |
Treat cache misses as hard errors; disable network requests |
false |
--gaia-cache-refresh |
Re-download tiles even if cached (mutually exclusive with --gaia-offline) |
false |
| Flag |
Description |
Default |
--tiff |
Write optional TIFF sum output in TIFF/ |
false |
--tiff-compression none|packbits|lzw|deflate |
Compression for the goTiff writer (all --tiff/--bigtiff output) |
none |
--tiff-depth 8|16|32f|64f |
Sample depth for the goTiff writer (all --tiff/--bigtiff output) |
32f |
--tiff-astro |
Write FITS WCS into Astro-TIFF tag 270 |
false |
--tiff-tiles / --tiff-predictor |
Tiled TIFF / horizontal predictor for LZW-Deflate |
false |
--fits |
Write stacked_sum.fits + stacked_mean.fits (big-endian IEEE float32, BITPIX=-32, NAXIS=3; TAN WCS when plate-solved) |
false |
--xisf |
Write stacked_sum.xisf + stacked_mean.xisf (monolithic XISF 1.0, planar Float32) |
false |
--xisf-rev2 |
With --xisf: SHA3-256 block checksum, strict sample-mapping checks, corrupt-block rejection |
false |
--bigtiff |
Write stacked_sum.bigtif + stacked_mean.bigtif with 64-bit offsets (>4 GiB) |
false |
--png |
Write lossless stacked_mean.png alongside JPEGs (same gamma 0.5 LUT) |
false |
--bmp |
Write uncompressed 24-bit stacked_mean.bmp alongside JPEGs (BGR, bottom-up) |
false |
--test-gaia RA,DEC |
One-shot Gaia DR3 tile query diagnostic; prints nside, ipix, first 5 stars, and exits |
— |
--export-stars FILE |
Export detected stars of --process-image as flux-sorted JSON/CSV; no --image-op required |
— |
--export-votable FILE |
Export cone/annotation catalogs as VOTable 1.3 BINARY2 |
— |
--classify-objects FILE |
Report-only diffuse-object morphology (CAS/Gini/M20) and IVOA object-type JSON; no --image-op required |
— |
--test-debayer PATH |
One-shot FITS debayer diagnostic; writes <base>.jpg and <base>_raw.jpg |
— |
--check-survey-fits FILE |
Report-only check of survey FITS WCS/header caveats; writes report.txt/report.json |
— |
--selftest |
Run embedded self-tests and exit |
— |
--version |
Print version and exit |
— |
--help |
Print command-line help and exit |
— |
For the authoritative list and defaults in your checked-out build, run:
./skystacker --help
Output Structure
By default, SkyStacker writes all outputs into <input>/0_skystacker_results/ (or the path specified with --output):
0_skystacker_results/
├── TIFF/
│ └── *.tif # Uncompressed little-endian RGB IEEE float32 single-strip TIFFs
├── stacked_sum.fits # Optional big-endian float32 FITS sum, BITPIX=-32, NAXIS=3 (--fits)
├── stacked_mean.fits # Optional float32 FITS mean stack (--fits)
├── stacked_sum.xisf # Optional monolithic XISF 1.0 sum, planar Float32 (--xisf)
├── stacked_mean.xisf # Optional XISF 1.0 mean stack (--xisf)
├── stacked_mean.jpg # 8-bit gamma-0.5 display preview (plus post-processed & weighted mix JPEGs)
├── stacked_mean.png # Optional lossless gamma-0.5 PNG (--png)
├── stacked_mean.bmp # Optional uncompressed 24-bit BMP (--bmp)
├── stacked_rejection_map.jpg # Cosmic-ray / hot-pixel outlier map (registered stack, gamma 0.5)
├── stacked_weight_map.jpg # Per-pixel accumulated weight map (registered stack, gamma 0.5)
├── stacked_unregistered_rejection_map.jpg # Full-frame rejection map (when registration succeeds)
├── stacked_unregistered_weight_map.jpg # Full-frame weight map (when registration succeeds)
├── stacked_coverage_map.jpg # Full-frame linear-mapped per-pixel registered coverage fraction
├── plate_solution.json # Solved TAN WCS + SIP order-2 coefficients (--plate-solve)
├── report.txt # Command line, resolved flags, EXIF summary, per-frame metrics & crop notes
└── _work/ # Intermediate working files (removable with --clean)
├── stacked_mean.f32raw # Linear float32 stack (uint32 w, uint32 h, float32 RGB) used by --post-only
└── cache/ # Cached star detections & geometric transforms (--no-cache disables)
report.txt is the primary audit log for any session: it records the exact CLI invocation, resolved parameters, exposure summary, crop geometry, and per-frame diagnostics (stars, inliers, scale, rotation, offset, bounding box, BoxPct, IntrQ, Weight, and limiter warnings).
Processing Pipeline at a Glance
Astrophotography session
│
▼
Discover JPG / JPEG / CR2 / CR3 / FIT / FITS
│
▼
Decode frames & run pre-flight RAM / disk checks
│
▼
Optional dark / flat / bias calibration (or --self-flat)
│
▼
Detect stars & choose reference frame (or load from _work/cache)
│
▼
Match triangle patterns (top 40 stars) & RANSAC registration
│
▼
Sub-pixel bilinear resampling, safe crop & optional normalization
│
▼
Mean / Median / Sigma-clipped quality-weighted stacking
│
├── Maximum-pixel diagnostic stack
├── Minimum-pixel diagnostic stack
├── Rejection, weight & coverage maps
├── Optional TIFF / PNG / BMP outputs
└── Optional TAN WCS plate solve (plate_solution.json)
│
▼
8-step automated post-processing pipeline
│
▼
Display JPEGs + scientific float32 outputs + report.txt
Pre-Flight Resource Checks & Error Handling
Before Pass 1 begins, SkyStacker estimates resource usage and validates inputs:
- Memory check:
mean estimates frameMB * 5. median/sigma model the buffers that are simultaneously live: pass 1 keeps max/min, validCount, the plain sum and one decoded frame; both the unregistered and registered reductions keep sumPix + meanPix + rejPix + wgtPix, plus the capped 256 MB tile buffer. A 1.6 × naive + 2000 MB peak margin is compared against available RAM (/proc/meminfo MemAvailable). After the run the actual peak RSS (VmHWM) is logged next to the estimate. The old formula (frameMB * 4 + 256 MB, called “real peak” after 1.5x) reported 2031 MB for the five-frame M31 sigma session while the process really peaked at 4168–4912 MB; the corrected model reports 4658 MB.
- Disk check (
median/sigma only): Verifies frames * frameBytes * 2 + 500 MB headroom for temporary spill files against available filesystem blocks. (mean performs no disk spill.)
- Time estimation: Reports a calibrated runtime estimate based on frame count, megapixels, RAW conversion overhead (~12 s/frame for CR2/CR3), and post-processing settings.
- Fault tolerance:
- Corrupt or unreadable files are soft-rejected during discovery and logged in
report.txt; processing continues unless every file fails.
- Dimension mismatches fail fast with the conflicting resolution groups named in the error message.
- All output files use atomic writes (
.tmp + rename) so failed writes never leave partial files behind.
--post-only verifies that _work/stacked_mean.f32raw exists before starting.
- Use
--force only if you intentionally need to bypass memory and disk pre-flight guards.
Development Status & Recently Implemented (v0.6.1)
SkyStacker is under active development as a Go package (main.go + donations.go, plus first-party modules) (current source version: 0.6.1, 326 registered self-tests). Feature sets, output filenames, and CLI options may evolve between revisions; treat the checked-out source and skystacker --help as authoritative. The authoritative milestone tracker is ROADMAP.md (170 items; latest pass promoted 26 new items from a multi-provider code audit — see audits/benchmarks.md and audits/roadmap-update.md).
The following capabilities have been implemented through 0.6.1:
- Frame quality weighting: Registered frames are weighted by
computeFrameQuality × computeIntrinsicQuality / 100; unregistered frames by intrinsic quality alone. Per-frame scores appear in report.txt under the IntrQ and Weight columns. Detected stars carry a flux-weighted half-flux radius (HFR) and eccentricity for future PSF-based quality refinement (testStarHFR).
- Per-frame global normalization (
--normalize): Scales each frame’s sky background (median + MAD) to match the reference frame.
- Local normalization correction (
--local-normalize): Applies tile-based scale + offset normalization with bilinear interpolation across the field to handle spatially varying gradients and transparency shifts.
- Star / transform cache: Re-runs skip Pass 1 star detection and Pass 2 registration using cached JSON metadata under
<output>/_work/cache/ (override with --cache-dir, disable with --no-cache). Each load logs [cache hit] or [cache miss] <light> (mtime, size or detection settings changed), so a modified light is visibly re-detected rather than silently served from the stale entry.
- Adaptive rejection & diagnostic maps: MAD-based sigma clipping (default
3.0σ, 2 iterations) alongside per-pixel rejection and weight maps (stacked_rejection_map.jpg, stacked_weight_map.jpg, plus unregistered counterparts and full-frame stacked_coverage_map.jpg) for cosmic-ray and hot-pixel inspection.
- Gaia DR3 data-access layer & TAN WCS plate solving: HEALPix nested geometry (verified against
healpy up to nside=256; reference fixtures in assets/testdata/healpix_reference.json), ESA Gaia TAP client with 180 s timeout and 5 s heartbeat, persistent OS user cache (gaia_cache/), --test-gaia RA,DEC diagnostic, and --plate-solve writing plate_solution.json.
- Reference-frame crop:
--reference-crop PATH detects stars in the reference image, matches each light by triangle pattern, and warps it in memory into the reference pixel frame. The output is exactly the reference dimensions, including rotation and scale differences. A single light (--limit 1) yields one cropped frame. Test: testReferenceCropAlignment.
- SER video input:
.ser is discovered and expanded to one frame per #frame=N. readSERHeader / decodeSERFrame support 8/16-bit mono, Bayer-as-gray and RGB/BGR. Test: testSERDecode.
- Comet tracking: pixel mode
--comet-center X,Y --comet-rate dX,dY (reference pixels/sec, EXIF DateTimeOriginal). RA/Dec mode --comet-radec RA,DEC --comet-sky-rate-arcsec dRA*,dDec (decimal degrees, arcsec/sec; requires --plate-solve, TAN WCS). Ephemeris mode --comet-target PATH: file with lines ISO8601 RA_deg Dec_deg (#/blank ignored), requires --plate-solve; position interpolated linearly by EXIF DateTimeOriginal (reference time as base). If a frame has no EXIF time, reference time is used with a warning. Outputs stacked_comet.f32raw/.jpg when used; star stack unchanged. Test: testCometTranslation.
- Bad-pixel map:
--bpm PATH loads a FITS or x,y text map and marks those pixels invalid before stacking. --bpm-auto derives a map from the master dark (or bias) using median + N*sigma*MAD (--bpm-auto-sigma, default 5). Tests: testBPMMasksPixels, testBPMAuto.
- Scientific output formats:
--fits (stacked_sum.fits, big-endian BITPIX=-32 with TAN WCS keywords when plate-solved) and --xisf (minimal monolithic XISF 1.0). Tests: testFITSWriterRoundTrip, testXISFWrite.
- Portable diagnostics: the root
goDiagnostics/ folder is an independent stdlib-only Go module (goDiagnostics, Go 1.22 baseline) that collects OS/runtime/CPU/memory/disk/process/tool/installed-package data with redaction (including process command lines) and bounded timeouts. The Linux /proc scan is capped and context-aware, and the package inventory is exposed as packages rather than updates. Linux processes report lifetime_cpu_share_pct (ticks since boot), never an instantaneous CPU percentage. SkyStacker uses it via --diagnose; it can be copied into other Go projects with the require+replace lines documented in goDiagnostics/README.md. Tests: testDiagnosticsCollect, testDiagnosticsReportRedaction.
- Catalog annotation (offline, basic):
--annotate projects cached Gaia stars through plate_solution.json into stacked_annotated.jpg and lists unmatched detections in anomalies.json. Test: testCatalogAnnotationSkip.
- Star/starless layers (basic):
--starless writes stacked_starless/stacked_stars float32 + JPEG from the post-processing star-removal step. Test: testPipelineStarless.
- Extended controls:
--comet-ephem-strict-exif, --plate-solve in --post-only, --hfr-quality, --sigma-clip-low/high, and SIP order-2 in WCS forward/inverse helpers. Tests: testCometEphemerisParse, testPlateSolvePostOnlyNoStars, testHFRQuality, testSigmaClipAsymmetric, testWCSSIP.
- Star catalog export:
--export-stars FILE emits a flux-sorted JSON/CSV list of detected stars for a single --process-image input, with 0-based centroids, flux, size, eccentricity and HFR. Test: TestExportStarsFluxSorted.
- Diffuse-object classification:
--classify-objects FILE writes a report-only JSON catalogue of star-masked components
README 内容过长,已截取前 64 KB。完整内容请前往 GitHub 仓库查看。
评论