Skip to content

ILS correction crashes with cryptic pandas error when Input Path contains only calibration images (no flight images) #77

Description

@BeesualDrone

Related to support ticket #48665.
Bug: Error during correction: Cannot set a DataFrame with multiple columns to the single column ils_scaling_factor
Root cause: In compute_reflectance_correction (corrections.py), when ils_present=True:
pythonband_avg_ils = image_df.groupby("band").ILS.mean().reset_index()
band_df["ils_scaling_factor"] = band_df.merge(band_avg_ils, on="band").apply(
_get_ils_scaling, axis=1
)
If image_df is empty after the calibration/non-calibration split in io.create_cal_df — which happens whenever the Input Path contains only calibration panel images and no non-calibration flight images — band_avg_ils ends up with 0 rows, the merge produces 0 rows, and DataFrame.apply(axis=1) on the resulting 0-row, multi-column frame returns the original multi-column DataFrame instead of an empty Series, causing the column-assignment to fail with this error.
Reproduction: Point Input Path at a folder containing only DJI M3M calibration panel shots (cal_in_path=False sensor, panel detected via ArUco marker — sensor_defs.py). 100% reproducible regardless of panel shot count, calibration_id, UInt16 setting, or v2.1.2 vs v2.1.3.
Confirmed fix: including any non-panel flight images in the same Input Path resolves it completely — image_df is no longer empty, the pipeline completes (Corrections complete!).
Suggested improvement: raise a clear, actionable error earlier instead of the pandas internals leaking through, mirroring the existing pattern a few lines above for calibration_df.empty:
pythonif ils_present:
if image_df.empty:
raise FileNotFoundError(
"ILS correction requires non-calibration images to compute the average "
"scene ILS, but none were found in the input path. Either include flight "
"images alongside the calibration panel images, or disable ILS Correction."
)
band_avg_ils = image_df.groupby("band").ILS.mean().reset_index()
...
Happy to open a PR with this if useful.
— Elio Ruppel Rojo, Beesual Drone

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions