Skip to content

Pipeline ​

The search, end to end on a list of FITS files (The pipeline, step by step).

AsteroidPipeline._check_frame_quality Method
julia
_check_frame_quality(path, n_detections, n_reference_stars) -> Float64

Warn when a frame holds far more sources at refine_wcs's threshold (10σ) than reference stars in its field — the signature of defective detector cells (speckled noise, gradients) rather than a crowded field: good sets show a few hundred to ~900, a defective one 20,000 or more. Returns the ratio.

source
AsteroidPipeline._detect_all_frames Method
julia
_detect_all_frames(fits_paths; timestamp_key, threshold, box_size, aperture_radius,
                    reference, psf_threshold, psf_min_separation,
                    quality_max_std, plate_solve_api_key)
    -> (detections_per_frame, wcs_per_frame, timestamps, n_gated, astrometric_rms_px)

The per-frame detection stage shared by run_pipeline and search_field, so both use one pass over fits_paths. See run_pipeline for the keywords. On the raw path each frame's GAIN header keyword (default 1.0) goes to detect_sources, so flux_err includes shot noise, which find_variable_sources's chi-squared test needs.

n_gated is how many frames the quality_max_std gate excluded (always 0 on the raw path): both callers lower their min_frames default by it. astrometric_rms_px is the median refined-astrometry residual in pixels (NaN without refine_astrometry).

source
AsteroidPipeline._drop_detector_fixed Method
julia
_drop_detector_fixed(per_frame, radius, timestamps) -> Vector

Each frame's detections (own pixel grid) minus those with a detection at the same pixel, within radius, in two or more other frames. A moving object can't sit on one detector pixel for three exposures; a hot pixel or bad column does, and only seems to move on the sky because the telescope dithers between exposures — so the difference images don't cancel it. The frames it recurs in must also cover half the sequence's time span: in exposures seconds apart, a slow mover stays within radius of itself in the frames next to it.

source
AsteroidPipeline._drop_dipoles Method
julia
_drop_dipoles(detections, difference, mask, max_negative) -> table

detections minus those with an unmasked pixel below -max_negative (σ) within 4 px in the normalized difference. A moving object is absent from the sequence's median, so it leaves only a positive source; a star that a frame's misalignment or seeing subtracts badly leaves a positive and a negative lobe side by side.

source
AsteroidPipeline._drop_on_bright_background Method
julia
_drop_on_bright_background(detections, image, mask, max_excess) -> table

detections minus those whose surroundings in the raw image — the median of an 8-20 px annulus, in units of the frame's own sky noise — sit more than max_excess above the sky. Real moving objects are found on clean sky; what a difference image leaves near a very bright star is its halo, an optical ghost, or a diffraction spike that turns between exposures, all of which can move just plausibly enough to link. Real objects on IASC sets sit within ±0.12σ; ghosts and spikes reached 1.7-2.4σ.

source
AsteroidPipeline._to_common_grid Method
julia
_to_common_grid(detections_per_frame, wcs_per_frame) -> Vector

Every frame's detections re-expressed in the first frame's pixel grid (through each frame's own WCS, then the first frame's inverse), so the whole raw-path sequence shares one coordinate system — afterwards the first frame's WCS applies to every frame's detections.

link_candidates and find_variable_sources compare positions in pixels on one shared grid; without it, each frame's pointing offset bends a straight track. Only the frames' relative WCS accuracy matters: an error common to all of them cancels.

x/y become the transformed position rounded to whole pixels; xcen/ycen keep it at full precision.

source
AsteroidPipeline.run_pipeline Method
julia
run_pipeline(fits_paths::AbstractVector{<:AbstractString};
             timestamp_key::Union{Nothing,AbstractString}=nothing,
             threshold::Real=5.0, box_size::NTuple{2,<:Integer}=(5, 5),
             aperture_radius::Real=3.0, max_speed::Real=Inf,
             match_radius::Real=2.0, min_frames::Union{Nothing,Integer}=nothing,
             reference=nothing, psf_threshold::Real=20.0, psf_min_separation::Real=40.0,
             quality_max_std::Real=1.5, plate_solve_api_key::Union{Nothing,AbstractString}=nothing,
             photometric_outlier_threshold::Real=0.2,
             mask_fill_values::Bool=false, difference_stack::Bool=false,
             refine_astrometry::Bool=false, reference_stars=nothing,
             min_speed::Real=0.0, max_flux_ratio::Real=Inf, max_residual::Real=Inf,
             min_sharpness::Real=-Inf, exptime_key::Union{Nothing,AbstractString}="EXPTIME",
             subpixel_alignment::Bool=false, max_background_excess::Real=Inf,
             detector_artifact_radius::Real=0.0, max_negative::Real=Inf)

Run the local stages of the pipeline — detection, linking, and astrometric calibration — on a time-ordered sequence of FITS frames from the same field.

For each frame, the primary header supplies the WCS (via load_wcs) and the epoch, a UTC Julian Date at mid-exposure, from frame_epoch with timestamp_key and exptime_key. Detections are linked across frames with link_candidates and calibrated to sky coordinates with astrometric_calibrate.

If reference is nothing (the default), detect_sources runs directly on each frame. Passing a deep reference stack — an (image, sigma, mask, psf, wcs) named tuple, with image/sigma/mask from build_reference, wcs the target_wcs it was built on and psf from estimate_psf(image) — switches to ZOGY difference imaging (zogy_subtract): each frame is reprojected onto reference's grid, subtracted, and detected on the resulting S_corr, which reaches below the single-frame noise floor. threshold is then a significance in sigma, and every frame is calibrated with reference.wcs. Each frame's PSF is estimated after reprojection, on the pixels zogy_subtract differences, and bright stars in the frame and the reference are passed as n_sources/r_sources for its astrometric-noise term.

On the reference path, a frame whose S_corr standard deviation (over its valid region) exceeds quality_max_std is treated as having found nothing, with a warning. The plain std is deliberate: a MAD-based spread misses a frame whose excess is a few hundred bright residuals. The default 1.5 was set on ZTF data (good frames ~1.1-1.2); tune it per survey. With min_frames=nothing (the default), linking requires every frame that was not gated; pass min_frames to set it explicitly.

On the raw path, a frame whose photometric_scale factor deviates from the median by more than photometric_outlier_threshold (20%) gets a warning, never an exclusion. It catches a uniform flux-scale change (transparency, focus); a thin passing cloud can leave it unchanged.

A frame whose header has no WCS is solved from its pointing (solve_wcs, against Gaia DR3 stars fetched once per field); if that fails, with plate_solve_api_key (a nova.astrometry.net API key) it is solved by plate_solve instead.

These options, all off by default and all on the raw path only, are what IASC/Pan-STARRS1 sets need:

  • mask_fill_values: mask constant-valued plateaus (the gaps between detector cells; see fill_value_mask) before detection.

  • refine_astrometry: replace each frame's header WCS with one fitted to reference stars in all frames together (refine_wcs_set), against reference_stars if given, else Gaia DR3 stars covering the first frame (gaia_reference_stars, a network request). A frame whose detections far outnumber the reference stars gets a warning (_check_frame_quality).

  • difference_stack: detect on each frame minus the median of the whole sequence (stack_difference): static sources cancel, so threshold can go much lower. Needs at least 3 frames. A fast object's trail is merged into one detection, satellite trails and saturated-star residuals dropped (see _merge_clusters).

  • subpixel_alignment (difference path): align frames by fractional offsets, with interpolation (see stack_difference's subpixel).

  • min_speed (pixels per day), max_flux_ratio and max_residual (pixels) filter tracklets after linking, per IASC's "true signature" tests (see _filter_tracklets); max_flux_ratio=2.5 is IASC's 1-magnitude limit. With refine_astrometry, max_residual is raised to three times the frames' typical astrometric residual (at most 2 px): a straight line can't be checked more finely than the positions are measured.

  • detector_artifact_radius (pixels; difference path): drop a detection that recurs at the same detector pixel in two or more other frames — a hot pixel or bad column (see _drop_detector_fixed).

  • max_background_excess (σ; difference path): drop a detection whose surroundings in the raw frame sit more than this far above the sky — a bright star's halo, ghost or spike (see _drop_on_bright_background).

  • max_negative (σ; difference path): drop a detection with a pixel this far below zero beside it in the difference — half of what a star leaves when a frame is misaligned or its seeing changes (see _drop_dipoles).

  • min_sharpness: drop single-pixel spikes — cosmic rays, hot pixels — at detection (see detect_sources); 0.3 on IASC data.

fits_paths must be in time order. psf_threshold and psf_min_separation go to estimate_psf for each frame's PSF (reference path only). All other keyword arguments are forwarded to detect_sources and link_candidates.

Returns the candidate table from astrometric_calibrate (columns id, frame, x, y, ra, dec, epoch), ready for crossmatch_catalog, which is left to the caller since it needs the network and a choice of catalog.

source
AsteroidPipeline.search_field Method
julia
search_field(fits_paths; <run_pipeline's keywords through photometric_outlier_threshold>,
             variability_position_tolerance::Real=2.0,
             variability_min_frames::Union{Nothing,Integer}=nothing,
             variability_chi2_threshold::Real=10.0,
             variability_normalize::Bool=(reference === nothing),
             variability_max_relative_error::Real=0.10,
             variability_systematic_error_fraction::Real=0.03)
    -> (movers=<table>, variables=<table>)

Run run_pipeline's mover search and find_variable_sources's variable search on one shared detection pass over fits_paths (_detect_all_frames).

Keywords through photometric_outlier_threshold are run_pipeline's; the variability_* ones go to find_variable_sources without the prefix. variability_min_frames=nothing means every non-gated frame, as for min_frames. variability_normalize is off on the ZOGY path, where S_corr isn't on a flux scale.

Returns (movers=..., variables=...), each an astrometric_calibrate table (columns id, frame, x, y, ra, dec, epoch); variables is ready for crossmatch_catalog(...; :vsx).

source
AsteroidPipeline.set_quality Method
julia
set_quality(fits_paths; reference_stars=nothing) -> (reliable, ratios)

Whether a same-field set is clean enough to trust its candidates: each frame's count of 10σ sources (fill-value gaps masked) over the number of reference stars in its field — Gaia DR3 stars from gaia_reference_stars if reference_stars isn't given (a live request). reliable is false if any frame exceeds _MAX_DETECTIONS_PER_REFERENCE_STAR (see _check_frame_quality, whose warning run_pipeline emits on the same test). A cheap check to run before reporting a set's candidates.

source