ppcpy.calibration.rayleighfit#
Functions
Recursive implementation of the Douglas-Peucker algorithm. |
|
Simplify signal according to Douglas-Peucker algorithm. |
|
CHI2FIT Chi-2 fitting. |
|
Search the clean region with rayleigh fit algorithm. |
|
Calculate the perpendicular distance between pointM and the line connecting pointS and pointE. |
|
- ppcpy.calibration.rayleighfit.DouglasPeucker(signal, height, epsilon, heightBase, heightTop, maxHThick, window_size=1)[source]#
Simplify signal according to Douglas-Peucker algorithm.
- Parameters:
signal (array) – Molecule corrected signal. [MHz]
height (array) – Height. [m]
epsilon (float) – Maximum distance.
heightBase (float) – Minimum height for the algorithm. [m]
heightTop (float) – Maximum height for the algorithm. [m]
maxHThick (float) – Maximum spatial thickness of each segment. [m]
window_size (int) – Size of the average smooth window.
- Returns:
Index of the signal that stands for different segments of the signal.
- Return type:
sigIndx (array)
References
https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
- History:
2017-12-29: First edition by Zhenping.
2018-07-29: Add the height range for the searching instead of SNR restriction.
2018-07-31: Add the maxHThick argument to control the maximum thickness of each output segment.
2024-12-20: Direct translated from matlab with ai
- ppcpy.calibration.rayleighfit.DP_algorithm(pointList, epsilon, maxHThick)[source]#
Recursive implementation of the Douglas-Peucker algorithm.
- Parameters:
pointList (list) – List of points [[x1, y1], [x2, y2], …].
epsilon (float) – Maximum distance.
maxHThick (float) – Maximum thickness for each segment.
- Returns:
Indices of simplified points.
- Return type:
sigIndx (list)
- ppcpy.calibration.rayleighfit.my_dist(pointM, pointS, pointE)[source]#
Calculate the perpendicular distance between pointM and the line connecting pointS and pointE.
- Parameters:
pointM (list) – Middle point [x, y].
pointS (list) – Start point [x, y].
pointE (list) – End point [x, y].
- Returns:
Distance.
- Return type:
d (float)
- ppcpy.calibration.rayleighfit.chi2fit(x, y, measure_error)[source]#
CHI2FIT Chi-2 fitting. All the code are translated from the exemplified code in Numerical Recipes in C (2nd Edition). Great help comes from Birgit Heese.
- USAGE:
a, b, sigmaA, sigmaB, chi2, Q = chi2fit(x, y, measure_error)
- INPUTS:
- x: array
The length of x should be larger than 1.
- y: array
The measured signal.
- measure_error: array
Measurement errors for the y values.
- OUTPUTS:
- a: float
Intercept of the linear regression.
- b: float
Slope of the linear regression.
- sigmaA: float
Uncertainty of the intercept.
- sigmaB: float
Uncertainty of the slope.
- chi2: float
Chi-square value.
- Q: float
Goodness of fit.
- HISTORY:
2018-08-03: First edition by Zhenping.
Authors: - zhenping@tropos.de
- ppcpy.calibration.rayleighfit.fit_profile(height, sig_aer, pc, bg, sig_mol, dpIndx, layerThickConstrain, slopeConstrain, SNRConstrain, flagShowDetail=False)[source]#
Search the clean region with rayleigh fit algorithm.
- Parameters:
height (array_like) – height [m]
sig_aer (array_like) – range corrected signal
pc (array_like) – photon count signal
bg (array_like) – background
sig_mol (array_like) – range corrected molecular signal
dpIndx (array_like) – index of the region calculated by Douglas-Peucker algorithm
layerThickConstrain (float) – constrain for the reference layer thickness [m]
slopeConstrain (float) – constrain for the uncertainty of the regressed extinction coefficient
SNRConstrain (float) – minimum SNR for the signal at the reference height
flagShowDetail (bool, optional) – if True, calculation information will be printed (default: False)
- Returns:
(hBIndx, hTIndx) - indices of bottom and top of searched region Returns (nan, nan) if region not found
- Return type:
tuple