Skip to content

Update calculators for image metrics #278

Description

@johnwhobbs

Required Changes

1. Fix HFD Double-Background Subtraction & Centroid Mismatch

  • Current Problem: DAOStarFinder(data - median) is used for detection, but _calculate_hfd(data, sources, median) passes the raw, un-subtracted data array and manually subtracts the background in a local slice.
  • Update Needed:
    • Calculate bg_subtracted_data = data - median globally right after computing sigma_clipped_stats.
    • Pass bg_subtracted_data directly into DAOStarFinder.
    • Update the signature of _calculate_hfd to accept bg_subtracted_data and remove the background_median argument entirely. Slices inside _calculate_hfd must come directly from this pre-subtracted array.

2. Upgrade Color Channel Reduction to True Luminance (CIE Weights)

  • Current Problem: data = data.mean(axis=channel_axis) weighs Red, Green, and Blue channels uniformly, which degrades star profiles on color frames.
  • Update Needed: Replace uniform averaging with a standard CIE luminance dot product ($Y = 0.299R + 0.587G + 0.114B$) when processing a 3-channel array. If the channel axis is at index 0, properly reorient or handle the axis shift before applying the matrix weights.

3. Update Star Roundness to Track Maximum Asymmetry

  • Current Problem: The code concatenates roundness1 and roundness2 and takes the uniform np.mean(), which dilutes and hides directional tracking errors (like a sudden wind gust or periodic error along one axis).
  • Update Needed: Change the aggregation logic from np.mean() to np.max(). The final star_roundness metric must reflect the maximum absolute asymmetry detected across the profiles to ensure strict quality control on tracking.

4. General Cleanup & Performance Guardrails

  • Ensure that clipping negative pixels to zero (cutout[cutout < 0] = 0) happens safely on an explicit copy of the array slice inside _calculate_hfd to prevent modifying or raising warnings on view slices.
  • Ensure type casting to standard Python floats/ints remains intact before writing to the database dictionary wrapper.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions