Mapping.SimpleMapper#
Mapping.SimpleMapperpy
- compute_mapping_coverage(x, y, slope, intercept, debug=False)#
Compute the coverage ratio of the mapping from x to y. The coverage ratio is defined as the ratio of the overlapping range of the mapped x values and the y values to the total range of x values.
- Parameters:
x (array-like) – The x values.
y (array-like) – The y values.
slope (float) – The slope of the mapping line.
intercept (float) – The intercept of the mapping line.
debug (bool, optional) – If True, print debug information.
- Returns:
coverage_ratio – The coverage ratio of the mapping.
- Return type:
float
- estimate_slope_reliability(xr_curve, x, uv_curve, y, coverage_ratio, debug=False)#
Estimate the reliability of the slope based on coverage ratio and peak ratio. This is particularly important when there is only one peak in the curves.
- Parameters:
xr_curve (Curve) – The X-ray curve.
x (array-like) – The x values of the peak (mean - std, mean, mean + std).
uv_curve (Curve) – The UV curve.
y (array-like) – The y values of the peak (mean - std, mean, mean + std).
coverage_ratio (float) – The coverage ratio of the mapping.
debug (bool, optional) – If True, print debug information.
- Returns:
reliable – True if the slope is considered reliable, False otherwise.
- Return type:
bool
- compute_mapping_by_full_coverage(xr_curve, xr_peaks, uv_curve, uv_peaks, debug=False)#
Compute the mapping by using the full coverage of the curves. This is used when there is only one peak in the curves. The mapping is computed by linear regression using three points:
(mean - std, mean, mean + std)
The peak point is given more weight than the edges. The peak point is determined by the first peak in the curves:
- Parameters:
- Returns:
mapping – The computed mapping information.
- Return type:
- estimate_mapping_for_matching_peaks(xr_curve, xr_peaks, uv_curve, uv_peaks, retry=True, debug=False)#
Estimate the mapping between xr_curve and uv_curve using the given peak positions. The mapping is computed by linear regression using the peak positions. If the coverage ratio is not acceptable, it retries with corrected curves. :param xr_curve: The X-ray curve. :type xr_curve: Curve :param xr_peaks: The peak positions in the X-ray curve. :type xr_peaks: list of int :param uv_curve: The UV curve. :type uv_curve: Curve :param uv_peaks: The peak positions in the UV curve. :type uv_peaks: list of int :param retry: If True, retries with corrected curves if the coverage ratio is not acceptable.
Default is True.
- Parameters:
debug (bool, optional) – If True, print debug information.
- Returns:
mapping – The estimated mapping information.
- Return type:
- estimate_mapping_impl(xr_curve, uv_curve, debug=False)#
Estimate the mapping between xr_curve and uv_curve. The mapping is computed by identifying groupable peaks in both curves, matching them, and then performing linear regression on the matched peaks.
- Parameters:
- Returns:
mapping – The estimated mapping information.
- Return type: