Commit be20d46d authored by Shang, Yingrui's avatar Shang, Yingrui
Browse files

Merge branch 'negative_scaling_0414' into 'next'

Negative scaling 0414

Closes #898

See merge request sns-hfir-scse/sans/sans-backend!955
parents 596e3ac5 298acd5b
Loading
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -58,9 +58,14 @@ def stitch_profiles(profiles, overlaps, target_profile_index=0):
            to_target.mod_q[good_values],
            to_target.intensity[good_values],
        )
        return sum(target_profile.intensity[indexes_in_overlap]) / sum(
            to_target_interpolated
        )
        scale = sum(target_profile.intensity[indexes_in_overlap]) / \
            sum(to_target_interpolated)
        if scale <= 0:
            raise ValueError(
                f"Scale number: {scale}. The scaling number for stitching cannot be negative. "
                + "Please check the stitching range or profile pattern")
        else:
            return scale

    # We begin stitching to the target profile the neighboring profile with lower Q-values, then proceed until we
    # run out of profiles with lower Q-values than the target profile