WCCD Automatic Helpers and Slice profiles

Persistent helper defaults with observation-local execution for finding the comet centre, measuring comparison stars and inspecting a one-pixel image profile without processing or saving the comet measurement automatically.

Implementation handoff documented This chapter follows the final WCCD Automatic Helpers integration specification. Interactive PyQt5, live JPL and live catalogue tests remain release checks.

Automatic helpers in New CCD/DSLR observation

The Automatic helpers group contains three saved dialog preferences:

  • Automatic comet finder
  • Auto star measure
  • High-precision position — JPL Horizons (requires internet connection)
  • An accepted selection becomes the default shown the next time the dialog is opened. The three values are stored through Qt QSettings.
  • Closing the dialog with Cancel does not overwrite the saved defaults.
  • The saved defaults are not shared worker state: every committed observation receives its own one-shot helper state, queue and run identity.
  • JPL Horizons can be enabled only with Automatic comet finder and is switched off automatically when the finder is disabled.
  • With every helper disabled, WCCD follows the established fully manual workflow.
New observation is transactional. KOPR commits the new observation only after the dialog is accepted and file/preflight validation succeeds. Cancellation or preflight failure preserves the previously active observation. No finder or star-measure helper starts before the new observation has been committed.

The Comet FITS is required. The Stars FITS is optional: when present it improves comet identification and provides the preferred surface for automatic star measurement; without it, supported helpers may work in a restricted single-image mode on the Comet image.

Automatic Comet Finder

The finder starts only after the new observation has been committed successfully. It runs in a worker thread and must not block the main GUI. A compact progress dialog reports the current stage and provides the existing cancellation path instead of making the application appear frozen.

It is a candidate-only helper: it proposes or accepts a centre but does not perform comet photometry.

Expected position and search radius

The expected sky position comes from the internal offline KOPR ephemeris or, when requested and available, from JPL Horizons. WCS converts the selected RA/Dec to an expected image position.

R59 uses a 120-arcsec candidate-search radius for the interactive WCCD review. The wider neighbourhood is safe because every result requires visual confirmation. The unattended complete automatic-photometry path retains its stricter 30-arcsec gate. Primary/Extended candidate classification is preserved.

Comet + Stars mode

With both images available, the finder uses the shared paired-image candidate model: ephemeris distance, local significance, centroid stability, FWHM, elongation, stellar-PSF ratio, wing excess, stellar-trail detection/projection and diagnostic ranking.

Comet-only mode

Without a Stars image, the finder searches around the expected position and evaluates significance, centroid, FWHM, elongation and wing excess. It has no independent stellar PSF and cannot distinguish trails as reliably, so visual confirmation is always required.

One comet-centroid model

R60 uses one canonical bounded 2D Gaussian comet-centroid model for manual WCCD selection, automatic finder candidates and visual M1 placement. The user click or candidate supplies the starting position; the same bounded model determines the centre offered for confirmation.

Confirmation dialog and image selection

  • Displayed automatic candidates are renumbered consecutively C1 through Cn after filtering, sorting and deduplication.
  • Select a candidate by clicking its table row or by left-clicking near its circle in the image.
  • Left-clicking another visible object creates a user-selected M1 starting position and applies the canonical bounded comet centroid.
  • The resulting manual candidate appears as a selectable row and highlighted circle.
  • Pan and zoom toolbar modes suppress image-selection clicks.

A valid WCS/ephemeris cutout is opened even when no numerical candidate survives. In that case, click the visible comet to create M1 and then confirm the resulting centre.

Confirmation changes only the centre. Confirm centre writes the selected coordinates to the Comet slot, shows the centre marker, activates the Comet image and selects Measure Comet. The accepted centre is authoritative for later Slice geometry, comet aperture photometry and ACF. Confirmation does not itself run those operations, calculate a magnitude, derive Afρ or process the observation.

Rejecting or closing the candidate dialog leaves the comet centre, aperture, reference stars and observation intact. Manual work can continue.

High-precision position — JPL Horizons

The optional online service provides only J2000 right ascension and declination for locating the expected pixel position. It uses the topocentric location of the active KOPR observatory and selects the nearest matching apparition when a periodic-comet designation is ambiguous.

JPL does not replace the observation ephemeris for heliocentric distance, geocentric distance, altitude, magnitude, Afρ, ICQ output or other photometric values.

Network failure is non-destructive. If JPL, the internet connection or the optional astroquery package is unavailable, the user may continue with the internal KOPR position. The observation remains open.

Auto Star Measure

When enabled for the committed observation, Auto Star Measure starts on the first entry into Measure Stars. It runs once per observation rather than on every mode switch.

  • With a Stars stack, measurement occurs on the Stars image.
  • Without one, measurement occurs on the Comet image and masks/excludes the comet region when a centre or expected position is available.

R55 keeps one Automatic Star Measure pipeline for ordinary and crowded fields; there is no separate crowded-field mode. Catalogue routing, colour conditions, basic WCS matching, saturation provenance, coma masks, the S/N sequence, iterative individual-zero-point clipping and the R50 final warning/failure limits remain unchanged. R55 improves how projected sources, masked centroid regions, stellar profiles, the global PSF scale, blends and partially masked backgrounds are handled.

Stellar shape policy

ElongationDecision
≤ 2.2Accepted as a standard comparison star.
> 2.2 and ≤ 2.7Accepted with quality flag moderate_elongation.
> 2.7Rejected as probably non-stellar or strongly deformed.

Common-aperture calibration sorts standard-shape stars first. Moderately elongated stars are used only when they are needed to reach the available calibrator set. This policy is separate from, and does not relax, basic WCS catalogue-to-image alignment.

Projection and mask-aware centroid

Before centroiding, KOPR checks that the catalogue projection is finite and inside the image, that its central science pixel is valid and that a minimum configurable centroid region with enough valid pixels can be formed. This lightweight precheck does not require the entire later search box to be valid.

The centroid calculation uses only finite science-valid pixels. NaN values are not replaced by zero and never enter the weight normalization. The algorithm separately checks valid coverage of the search region, near-complete validity of the central core, sufficient local-background samples, finite moments and validity of every iterated position.

Stellar profile and robust FWHM

The centroid search radius is used only to locate the star. FWHM and elongation are then remeasured in a smaller adaptive profile around the result, so a distant neighbour in the search box does not automatically broaden the target. The preferred profile is a local two-dimensional Gaussian fit to the compact positive component; masked compact second moments are the fallback.

The global stellar FWHM is derived from quality, unsaturated, significant, shape-accepted and catalogue-isolated sources. A compact isolated distribution uses its robust median. If the distribution has a strong high-FWHM tail, or too few isolated stars are available, the lower 30% of acceptable profile widths provides the guarded fallback. The final report shows both the raw median and robust FWHM, its method and source count, plus the 25/50/75% profile-width percentiles.

Common stellar aperture and final blend check

The robust median curve-of-growth plateau remains preferred. A plateau must be supported by the requested following stable increments; the terminal sample alone cannot prove stability. Growth-curve radii, calibrator isolation and the fallback are all tied to the robust stellar FWHM rather than a raw median contaminated by blends.

If no valid plateau exists, Auto Star Measure continues with a fallback radius of 3.5 × robust FWHM, clipped to the supported aperture-factor interval and never exceeding 4.0 × robust FWHM. The fallback is a warning, not a bypass: image coverage, saturation, masks, background, positive flux, S/N, zero point and final scatter are still checked normally.

After the actual aperture is known, every candidate is checked again for catalogue neighbours. The final blend gate is at least aperture radius + 0.75 × robust FWHM and never smaller than the original blend radius. The report records the gate, neighbours inside the aperture and post-aperture blend rejections.

Strict aperture validity and background

Any non-finite or masked pixel with a non-zero fractional aperture weight above the numerical tolerance causes invalid_aperture. Missing stellar flux is never replaced, interpolated or treated as zero.

The square background annulus excludes NaN and masked pixels statistically while retaining absolute usable-pixel, usable-fraction, quadrant-coverage, asymmetry, sector-consistency, radial-gradient and coma-contamination checks. A mildly cropped annulus can pass only with stricter usable coverage and at least three representative quadrants. If the square annulus fails only because of geometry or spatial coverage, KOPR tries the balanced_boxes fallback with its own sector-consistency and gradient checks.

Zero point and result policy

  • Fewer than 3 stars after clipping: FAILED.
  • 3–7 stars: valid solution with a prominent WARNING.
  • 8 or more stars: normal continuation.
  • Rejecting more than 40% of candidates during unchanged iterative median/MAD clipping records a warning and diagnostics, but is not a failure by itself.
  • Final robust scatter ≤ 0.08 mag: normal.
  • Scatter > 0.08 and ≤ 0.15 mag: retained with warning.
  • Scatter > 0.15 mag: hard failure. The computed zero point and scatter remain visible in diagnostics.

Saturation checks

Auto Star Measure uses the shared saturation resolver for the image role being measured. A complete, shape-compatible WStack NSATVAL map is authoritative. Without a complete map, the established automatic base is converted by an integer multiplier into an effective image-domain threshold that is never below the finite image maximum; the observed maximum itself is never adopted as the threshold.

If the user explicitly edits Saturation level, that role switches to a manual base and intentionally bypasses the source-frame map. The same resolver converts the manual base into the effective image-domain threshold, so an identical automatic or manual base yields an identical result. Comet and Stars state remains independent and is reset only when the corresponding FITS is replaced.

Unavailable source provenance is non-fatal when scalar resolution succeeds. SATCOMP=NONE and a missing source-frame peak provider remain visible in diagnostics but do not reject every comparison star or prevent common-aperture selection. Flat-top and bleeding morphology remain independent clipping vetoes.

Final diagnostic dialog

The selectable, read-only result remains open until the user closes it. Its summary follows the processing order: projected catalogue candidates; detected/centroided objects; WCS/shape acceptance; raw and robust FWHM with method, source count and percentiles; common aperture and its plateau/fallback source; final blend gate and post-aperture rejections; successfully measured stars; S/N acceptance; zero-point outliers; final-star count; final zero point; final scatter; background method; and OK, WARNING or FAILED. Warnings follow the summary, then rejection counts by precise centroid/background reason.

Atomic transfer to WCCD

Only a result that passes all hard gates is committed. Accepted stars, catalogue magnitudes, fluxes, local backgrounds, actual apertures, quality flags and display diagnostics are transferred together. The user can then remove, add or inspect stars with the normal WCCD controls.

No partial commit: catalogue/WCS failure, fewer than three final stars, saturation, an invalid aperture pixel, unusable background, final scatter above 0.15 mag or internal-commit failure preserves the previous manual stars and observation state. Warning states such as moderate elongation, a fallback aperture, 3–7 final stars, more than 40% clipping or scatter up to 0.15 mag may still commit after every downstream safety check passes.
Workflow isolation: the R55 mask-aware stellar profile is used by Automatic Star Measure only. Comet Finder candidate scoring and stellar-trail contamination measurements retain their established centroid/PSF convention.

Coordination of finder and star measurement

Auto Star Measure cannot run while the Automatic Comet Finder worker is active or while its confirmation dialog is open.

  • Entering Measure Stars during finder work queues star measurement.
  • The queued job starts after confirmation, rejection or definitive finder failure only when Measure Stars is still active.
  • If the user leaves Measure Stars, the request remains pending and starts on the next entry.
  • Reset or a new observation cancels/invalidates old workers, clears the helper queue, closes foreground helper windows and removes obsolete one-observation state.

Every asynchronous result verifies observation ID, source identity, run token, process state and target slot. A cancelled or stale worker cannot commit data or open a review/candidate dialog after the observation has changed.

Named measurement modes

The measurement selector contains stable named modes:

  • Measure Comet
  • Measure Tail
  • Measure Stars
  • Slice Through Comet
  • Slice Between Points
  • Fix Astrometry

The GUI stores stable identifiers in Qt itemData. Application logic does not depend on the visual order or numeric combobox index.

Slice Through Comet

  1. Establish a comet centre with the finder or manual measurement.
  2. Select Slice Through Comet.
  3. Right-click a point that defines direction and half-length.
  4. KOPR joins the point to the comet centre and extends the same distance on the opposite side.
  5. If the line would leave the image, both sides are shortened symmetrically so the comet remains at the profile centre.

Without a known comet centre, KOPR displays a warning and creates no slice.

Slice Between Points

  1. The first right-click sets the start point.
  2. The second right-click sets the end point and creates the profile.
  3. A third right-click starts a new selection.

This mode does not require a comet centre. If the known centre lies on the selected line, its profile position is marked.

Slice mathematics and output

KOPR uses an integer Bresenham line. Every profile sample is one actually visited image pixel. There is no bilinear interpolation, multi-pixel width, perpendicular-strip mean or median.

The profile opens in an independent non-modal window, so the main WCCD image remains interactive while the profile is visible. The Slice window remains available until the user closes it or the observation is reset/replaced; reset also clears the obsolete Slice selection and closes its foreground window safely.

Graph elementMeaning
X axisPixel along slice, indexed from 0 to N−1.
Y axisPixel value, the original image value.
Comet markerOptional vertical line at the comet-centre sample.

Slice performs no background subtraction, magnitude conversion, angular conversion, calibration or interpretation. NaN remains NaN. It can support visual inspection of coma asymmetry, structures, fragments, condensations or possible disruption signatures, but does not identify any physical process automatically.

Slice needs no aperture and changes neither comet measurement, ACF, reference stars, final magnitude nor ICQ output.

Persistent Review comet ACF lifecycle

Review belongs to the last successful ACF comet measurement, not to the current GUI view. It remains available while the Stars image is shown and after changes to measurement mode, reference stars, filter, magnitude source, catalogue, photometric correction, extinction, displayed aperture value or Stars stack.

Apply always writes to the Comet slot, updates its ACF context and measurement, appends the Comet FITS HISTORY record and refreshes the comet aperture display.

  • A cancelled or failed new measurement preserves the previous valid Review context.
  • A new successful ACF measurement replaces it.
  • A new successful non-ACF measurement disables Review.
  • New observation, observation reset, a different Comet FITS or a structurally incompatible context invalidates it.

See the detailed ACF and Review lifecycle guide.

Scientific and Compact compatibility

Automatic Comet Finder, candidate confirmation, Auto Star Measure, Slice and Review use physical float32 image values after FITS scaling. Scientific and Compact storage therefore share the same numerical GUI workflows. The amount of available diagnostic metadata may depend on the input provenance contract, but the selected storage mode does not create a different algorithm.

Fallback and error scenarios

ScenarioExpected behaviour
JPL unavailable, no internet or no astroqueryOffer/retain the internal KOPR position; keep the observation open.
Ambiguous JPL objectUse the nearest matching apparition when resolved; otherwise report failure and allow internal/manual continuation.
Expected position outside image or invalid WCSDo not commit a centre; allow manual selection or Fix Astrometry.
No candidate / candidate rejectedOpen the valid review cutout even with zero numerical candidates; click the visible comet to create an M1 starting position for the canonical bounded centroid. Rejecting/closing commits nothing.
No Stars stackUse restricted Comet-only finder/star mode where supported and report reduced reliability.
Catalogue/WCS failure, fewer than 3 final stars, saturation, invalid background or scatter > 0.15 magCommit no automatic star result; preserve manual state. Warning-only states may continue after all safety checks.
Observation changes while a worker runsDiscard the stale result.
Slice Through Comet without a centreShow a warning and create no profile.

When the observation is otherwise valid, every helper failure leaves a manual route available.

Related chapters

Process CCD Obs. · ACF Review lifecycle · Scientific/Compact FITS · Troubleshooting · Developer architecture