HeavyEdge-Features documentation#
HeavyEdge-Features is a Python package for quantifying shape features from coating edge profiles.
Usage#
HeavyEdge-Features can be used either as a command line program or as a Python module.
Command line#
Command line interface provides pre-defined subroutines for training and prediction. It can be invoked by:
heavyedge features-global <args>
heavyedge features-local <args>
Refer to help message of each command for their arguments.
Python module#
The Python module heavyedge_features provides functions and classes for Python runtime.
Refer to Runtime API section for high-level interface.
Module reference#
This section provides reference for heavyedge_features Python module.
Runtime API#
High-level Python runtime interface.
- heavyedge_features.api.global_deviation(soft_labels, target_indices, logger=<function <lambda>>)[source]#
Compute global shape deviations using probabilistic classification labels.
Negative values indicaete profiles are within the desired classes. Larger values mean more deviation from the desired classes.
- Parameters:
- soft_labelsnp.ndarray
Probabilistic classification labels for the profiles.
- target_indiceslist of int
Indices of target classes to compute values for.
- loggercallable, optional
Logger function which accepts a progress message string.
- Returns:
- valuesnp.ndarray
Array containing global shape deviations for each profile.
Examples
>>> import numpy as np >>> from heavyedge_classify.samples import get_sample_path >>> from heavyedge_features.api import global_deviation >>> soft_labels = np.load(get_sample_path("labels-pred.npy")) >>> global_deviation(soft_labels, [0]).shape (75,)
- heavyedge_features.api.edge_height(profiles, logger=<function <lambda>>)[source]#
Dimensionless edge height of edge profiles.
- Parameters:
- profilesheavyedge.ProfileData
Open h5 file of profiles.
- loggercallable, optional
Logger function which accepts a progress message string.
- Returns:
- heightsnp.ndarray
Array containing edge height values for each profile.
Examples
>>> from heavyedge import ProfileData >>> from heavyedge_features.samples import get_sample_path as features_sample >>> from heavyedge_features.api import edge_height >>> edge_height(ProfileData(features_sample("Profiles.h5"))).shape (75,)
- heavyedge_features.api.edge_width(profiles, hard_labels, wet_thicknesses, sigma, type1_indices, type2_indices, type3_indices, logger=<function <lambda>>)[source]#
Detect edge with of profiles using profile data and classification labels.
- Parameters:
- profilesheavyedge.ProfileData
Open h5 file of profiles.
- hard_labelsnp.ndarray
Hard classification labels for the profiles.
- wet_thicknessesnp.ndarray
Wet thickness values for the profiles.
- sigmascalar
Standard deviation of Gaussian filter for smoothing. Using the same value as the one used for preprocessing is recommended.
- type1_indices, type2_indices, type3_indiceslist of int
Lists of indices of Type 1, 2, and 3 classes from trained labels, respectively.
- loggercallable, optional
Logger function which accepts a progress message string.
- Returns:
- widthsnp.ndarray
Array containing edge width values for each profile.
Examples
>>> from heavyedge import ProfileData >>> from heavyedge_classify.samples import get_sample_path as classify_sample >>> from heavyedge_features.samples import get_sample_path as features_sample >>> from heavyedge_features.api import edge_width >>> import numpy as np >>> profiles = ProfileData(features_sample("Profiles.h5")) >>> hard_labels = np.load(classify_sample("labels-pred.npy")).argmax(axis=1) >>> wet_thicknesses = np.full(hard_labels.shape, 0.25) >>> sigma = 32 >>> edge_width(profiles, hard_labels, wet_thicknesses, sigma, [0], [1], [2]).shape (75,)
Low-level API#
Information projection to allowed classes.
- heavyedge_features.iproj.signed_iproj(p, target_indices)[source]#
Signed information projection distance to allowed classes.
- Parameters:
- parray-like, shape (K,)
Probability distribution over K classes.
- target_indiceslist of int
List of target class indices to project onto.
- Returns:
- signed_distancefloat
Signed information projection distance to the allowed classes.
- projected_distributionarray-like, shape (K,)
Probability distribution after projection.
Examples
>>> import numpy as np >>> from heavyedge_features.iproj import signed_iproj >>> p = np.array([0.1, 0.7, 0.2]) >>> target_indices = [0, 2] >>> dist, q = signed_iproj(p, target_indices) >>> dist np.float64(0.164...) >>> q array([0.117..., 0.441..., 0.441...])
Edge width by edge type.
- heavyedge_features.edge_width.width_type0(x, Y, L, wt)[source]#
Edge width for type 0 profiles.
- Parameters:
- xarray of shape (M,)
X grid of profiles.
- Yarray of shape (M,)
Height data of profile.
- Lint
Length of profile before contact point in number of points.
- wtscalar
Wet thickness of the profile.
- Returns:
- scalar
Edge width of the profile.
- heavyedge_features.edge_width.width_type1(x, Y, L, wt)[source]#
Edge width for type 1 profiles.
- Parameters:
- xarray of shape (M,)
X grid of profiles.
- Yarray of shape (M,)
Height data of profile.
- Lint
Length of profile before contact point in number of points.
- wtscalar
Wet thickness of the profile.
- Returns:
- scalar
Edge width of the profile.
Examples
>>> from heavyedge import get_sample_path, ProfileData >>> from heavyedge_features.edge_width import width_type1 >>> with ProfileData(get_sample_path("Prep-Type1.h5")) as data: ... x = data.x() ... Y, L, _ = data[0] >>> wt = 0.25 >>> b = width_type1(x, Y, L, wt) >>> import matplotlib.pyplot as plt ... plt.plot(x, Y, color="gray", alpha=0.5) ... plt.axhline(wt, ls="--", label="Wet thickness") ... plt.axvline(x[L - 1] - b, color="red", ls="--", label="Edge boundary") ... plt.legend()
- heavyedge_features.edge_width.width_type2(x, Y, L, sigma)[source]#
Edge width for type 2 profiles.
- Parameters:
- xarray of shape (M,)
X grid of profiles.
- Yarray of shape (M,)
Height data of profile.
- Lint
Length of profile before contact point in number of points.
- sigmascalar
Standard deviation of Gaussian filter for smoothing.
- Returns:
- scalar
Edge width of the profile.
Examples
>>> from heavyedge import get_sample_path, ProfileData >>> from heavyedge_features.edge_width import width_type2 >>> with ProfileData(get_sample_path("Prep-Type2.h5")) as data: ... x = data.x() ... Y, L, _ = data[0] >>> sigma = 32.0 >>> b = width_type2(x, Y, L, sigma) >>> import matplotlib.pyplot as plt ... plt.plot(x, Y, color="gray", alpha=0.5) ... plt.axvline(x[L - 1] - b, color="red", ls="--", label="Edge boundary") ... plt.legend()
- heavyedge_features.edge_width.width_type3(x, Y, L, sigma)[source]#
Edge width for type 3 profiles.
- Parameters:
- xarray of shape (M,)
X grid of profiles.
- Yarray of shape (M,)
Height data of profile.
- Lint
Length of profile before contact point in number of points.
- sigmascalar
Standard deviation of Gaussian filter for smoothing.
- Returns:
- scalar
Edge width of the profile.
Examples
>>> from heavyedge import get_sample_path, ProfileData >>> from heavyedge_features.edge_width import width_type3 >>> with ProfileData(get_sample_path("Prep-Type3.h5")) as data: ... x = data.x() ... Y, L, _ = data[0] >>> sigma = 32.0 >>> b = width_type3(x, Y, L, sigma) >>> import matplotlib.pyplot as plt ... plt.plot(x, Y, color="gray", alpha=0.5) ... plt.axvline(x[L - 1] - b, color="red", ls="--", label="Edge boundary") ... plt.legend()