Code reference¶
Module level aliases¶
For user convenience, the following objects are available at the module level.
-
class
nanite.
Indentation
¶ alias of
nanite.indent.Indentation
-
class
nanite.
IndentationGroup
¶ alias of
nanite.group.IndentationGroup
-
class
nanite.
IndentationRater
¶ alias of
nanite.rate.IndentationRater
-
class
nanite.
QMap
¶ alias of
nanite.qmap.QMap
-
nanite.
load_group
()¶ alias of
nanite.group.load_group
Force-indentation data¶
-
class
nanite.indent.
Indentation
(idnt_data)[source]¶ Force-indentation
Parameters: idnt_data (nanite.read.IndentationData) – Object holding the experimental data -
apply_preprocessing
(preprocessing=None)[source]¶ Perform curve preprocessing steps
Parameters: preprocessing (list) – A list of preprocessing method names that are stored in the IndentationPreprocessor class. If set to None, self.preprocessing will be used.
-
compute_emodulus_mindelta
(callback=None)[source]¶ Compute elastic modulus vs. mindelta
Parameters: callback (callable) – A method that is called with the emoduli and indentations as the computation proceeds every five steps. Returns: emoduli, indentations – The fitted elastic moduli and at the corresponding maximal indentation depths. Return type: 1d ndarrays Notes
The information about emodulus and mindelta is also stored in self.fit_properties with the keys “optimal_fit_E_array” and “optimal_fit_delta_array”, if self.fit_model is called with the argument search_optimal_fit set to True.
-
estimate_contact_point_index
()[source]¶ Estimate the contact point
Contact point (CP) estimation is performed with two methods and that one which returns the smallest index is returned.
Method 1: baseline deviation
- Obtain the baseline (initial 10% of the approach curve)
- Compute average and maximum deviation of the baseline
- The CP is the index of the approach curve where it exceeds twice of the maximum deviation
Method 2: sign of gradient
- Perform a median filter on the approach curve
- Compute the gradient
- Cut off trailing 10 points from the gradient (noise)
- The CP is the index of the gradient curve when the sign changes, measured from the point of maximal indentation.
If one of the methods fail, the index 0 is returned.
-
estimate_optimal_mindelta
()[source]¶ Estimate the optimal indentation depth
This is a convenience function that wraps around compute_emodulus_mindelta and IndentationFitter.compute_opt_mindelta.
-
fit_model
(**kwargs)[source]¶ Fit the approach-retract data to a model function
Parameters: - model_key (str) – A key referring to a model in nanite.model.models_available
- params_initial (instance of lmfit.Parameters or dict) – Parameters for fitting. If not given, default parameters are used.
- range_x (tuple of 2) – The range for fitting, see range_type below.
- range_type (str) –
One of:
- absolute:
- Set the absolute fitting range in values given by the x_axis.
- relative cp:
- In some cases it is desired to be able to fit a model only up until a certain indentation depth (tip position) measured from the contact point. Since the contact point is a fit parameter as well, this requires a two-pass fitting.
- preprocessing (list of str) – Preprocessing
- segment (str) – One of “approach” or “retract”.
- weight_cp (float) – Weight the contact point region which shows artifacts that are difficult to model with e.g. Hertz.
- optimal_fit_edelta (bool) – Search for the optimal fit by varying the maximal indentation depth and determining a plateau in the resulting Young’s modulus (fitting parameter “E”).
-
rate_quality
(regressor='Extra Trees', training_set='zef18', names=None, lda=None)[source]¶ Compute the quality of the obtained curve
Uses heuristic approaches to rate a curve.
Parameters: Returns: rating – A value between 0 and 10 where 0 is the lowest rating. If no fit has been performed, a rating of -1 is returned.
Return type: Notes
The rating is cached based on the fitting hash (see IndentationFitter._hash).
-
data
= None¶ All data in a Pandas DataFrame
-
fit_properties
= None¶ Fitting results, see
Indentation.fit_model()
)
-
preprocessing
= None¶ Default preprocessing steps steps, see
Indentation.apply_preprocessing()
.
-
Groups¶
-
class
nanite.group.
IndentationGroup
(path=None, callback=None)[source]¶ Group of Indentation
Parameters:
-
nanite.group.
load_group
(path, callback=None)[source]¶ Load indentation data from disk
Parameters: - path (path-like) – Path to experimental data
- callback (callable or None) – Callback function for tracking loading progress
Returns: group – Indentation group with force-indentation data
Return type: nanite.IndetationGroup
Loading data¶
-
nanite.read.
get_data_paths
(path)[source]¶ Obtain a list of data files
Parameters: path (str or pathlib.Path) – Path to a data file or a directory containing data files. Returns: paths – All supported data files found in path. If path is a file, [pathlib.Path(path)] is returned. If path has an unsupported extion, an empty list is returned. Return type: list of pathlib.Path
-
nanite.read.
load_raw_data
(path, callback=None)[source]¶ Load raw data
Parameters: - path (str or pathlib.Path) – Path to a data file or a directory containing data files. The data format is determined using the extension of the file.
- callback (callable or None) – A method that accepts a float between 0 and 1 to externally track the process of loading the data.
- ret_indentation (bool) – Return the indentation
Returns: data – A measurements list that contains the data.
Return type:
-
nanite.read.
readers
= [(<function load_jpk>, ['.jpk-force', '.jpk-force-map'])]¶ All available readers and associated file extensions
-
nanite.read.
supported_extensions
= ['.jpk-force', '.jpk-force-map']¶ All supported file extensions
Preprocessing¶
-
class
nanite.preproc.
IndentationPreprocessor
[source]¶ -
static
apply
(apret, preproc_names)[source]¶ Perform force-indentation preprocessing steps
Parameters: - apret (nanite.Indentation) – The afm data to preprocess
- preproc_names (list) – A list of names for static methods in IndentationPreprocessor that will be applied (in the order given).
Notes
This method is usually called from within the Indentation class instance. If you are using this class directly and apply it more than once, you might need to call apret.reset() before preprocessing a second time.
-
static
compute_tip_position
(apret)[source]¶ Compute the tip-sample separation
This computation correctly reproduces the column “Vertical Tip Position” as it is exported by the JPK analysis software with the checked option “Use Unsmoothed Height”.
-
static
correct_split_approach_retract
(apret)[source]¶ Split the approach and retract curves (farthest point method)
Approach and retract curves are defined by the microscope. When the direction of piezo movement is flipped, the force at the sample tip is still increasing. This can be either due to a time lag in the AFM system or due to a residual force acting on the sample due to the bent cantilever.
To repair this time lag, we append parts of the retract curve to the approach curve, such that the curves are split at the minimum height.
-
static
-
nanite.preproc.
available_preprocessors
= ['compute_tip_position', 'correct_force_offset', 'correct_split_approach_retract', 'correct_tip_offset', 'smooth_height']¶ Available preprocessors
Modeling¶
Methods and constants¶
Models¶
Each model is implemented as a submodule in nanite.model. For instance
nanite.model.model_hertz_parabolic
. Each of these modules implements
the following functions (which are not listed for each model in the
subsections below):
-
nanite.model.model_submodule.
get_parameter_defaults
()¶ Return the default parameters of the model.
-
nanite.model.model_submodule.
model
()¶ Wrap the actual model for fitting.
-
nanite.model.model_submodule.
residual
()¶ Compute the residuals during fitting.
In addition, each submodule contains the following attributes:
-
nanite.model.model_submodule.
model_doc
¶ The doc-string of the model function.
-
nanite.model.model_submodule.
model_key
¶ The model key used in the command line interface and during scripting.
-
nanite.model.model_submodule.
model_name
¶ The name of the model.
-
nanite.model.model_submodule.
parameter_keys
¶ Parameter keywords of the model for higher-level applications.
-
nanite.model.model_submodule.
parameter_names
¶ Parameter names of the model for higher-level applications.
-
nanite.model.model_submodule.
parameter_units
¶ Parameter units for higher-level applications.
conical indenter (Hertz)¶
model key | hertz_cone |
model name | conical indenter (Hertz) |
model location | nanite.model.model_conical_indenter |
-
nanite.model.model_conical_indenter.
hertz_conical
(E, delta, alpha, nu, contact_point=0, baseline=0)[source]¶ Hertz model for a conical indenter
\[F = \frac{2\tan\alpha}{\pi} \frac{E}{1-\nu^2} \delta^2\]Parameters: - E (float) – Young’s modulus [N/m²]
- delta (1d ndarray) – Indentation [m]
- alpha (float) – Half cone angle [degrees]
- nu (float) – Poisson’s ratio
- contact_point (float) – Indentation offset [m]
- baseline (float) – Force offset [N]
- negindent (bool) – If True, will assume that the indentation value(s) given by delta are negative and must be mutlitplied by -1.
Returns: F – Force [N]
Return type: Notes
These approximations are made by the Hertz model:
- The sample is isotropic.
- The sample is a linear elastic solid.
- The sample is extended infinitely in one half space.
- The indenter is not deformable.
- There are no additional interactions between sample and indenter.
Additional assumptions:
- infinitely sharp probe
References
Love (1939) [LOV39]
parabolic indenter (Hertz)¶
model key | hertz_para |
model name | parabolic indenter (Hertz) |
model location | nanite.model.model_hertz_parabolic |
-
nanite.model.model_hertz_parabolic.
hertz_paraboloidal
(E, delta, R, nu, contact_point=0, baseline=0)[source]¶ Hertz model for a paraboloidal indenter
\[F = \frac{4}{3} \frac{E}{1-\nu^2} \sqrt{R} \delta^{3/2}\]Parameters: - E (float) – Young’s modulus [N/m²]
- delta (1d ndarray) – Indentation [m]
- R (float) – Tip radius [m]
- nu (float) – Poisson’s ratio
- contact_point (float) – Indentation offset [m]
- baseline (float) – Force offset [N]
- negindent (bool) – If True, will assume that the indentation value(s) given by delta are negative and must be mutlitplied by -1.
Returns: F – Force [N]
Return type: Notes
The original model reads
\[F = \frac{4}{3} \frac{E}{1-\nu^2} \sqrt{2k} \delta^{3/2},\]where \(k\) is defined by the paraboloid equation
\[\rho^2 = 4kz.\]These approximations are made by the Hertz model:
- The sample is isotropic.
- The sample is a linear elastic solid.
- The sample is extended infinitely in one half space.
- The indenter is not deformable.
- There are no additional interactions between sample and indenter.
Additional assumptions:
- radius of spherical cell is larger than the indentation
References
Sneddon (1965) [Sne65]
pyramidal indenter, three-sided (Hertz)¶
model key | hertz_pyr3s |
model name | pyramidal indenter, three-sided (Hertz) |
model location | nanite.model.model_hertz_three_sided_pyramid |
-
nanite.model.model_hertz_three_sided_pyramid.
hertz_three_sided_pyramid
(E, delta, alpha, nu, contact_point=0, baseline=0)[source]¶ Hertz model for three sided pyramidal indenter
\[F = 0.887 \tan\alpha \cdot \frac{E}{1-\nu^2} \delta^2\]Parameters: - E (float) – Young’s modulus [N/m²]
- delta (1d ndarray) – Indentation [m]
- alpha (float) – Face angle of the pyramid [degrees]
- nu (float) – Poisson’s ratio
- contact_point (float) – Indentation offset [m]
- baseline (float) – Force offset [N]
- negindent (bool) – If True, will assume that the indentation value(s) given by delta are negative and must be mutlitplied by -1.
Returns: F – Force [N]
Return type: Notes
These approximations are made by the Hertz model:
- The sample is isotropic.
- The sample is a linear elastic solid.
- The sample is extended infinitely in one half space.
- The indenter is not deformable.
- There are no additional interactions between sample and indenter.
References
Bilodeau et al. 1992 [Bil92]
spherical indenter (Sneddon)¶
model key | sneddon_spher |
model name | spherical indenter (Sneddon) |
model location | nanite.model.model_sneddon_spherical |
-
nanite.model.model_sneddon_spherical.
delta_of_a
()¶ Compute indentation from contact area radius (wrapper)
-
nanite.model.model_sneddon_spherical.
get_a
()¶ Compute the contact area radius (wrapper)
-
nanite.model.model_sneddon_spherical.
hertz_spherical
()¶ Hertz model for Spherical indenter - modified by Sneddon
\[\begin{split}F &= \frac{E}{1-\nu^2} \left( \frac{R^2+a^2}{2} \ln \! \left( \frac{R+a}{R-a}\right) -aR \right)\\ \delta &= \frac{a}{2} \ln \! \left(\frac{R+a}{R-a}\right)\end{split}\](\(a\) is the radius of the circular contact area between bead and sample.)
Parameters: - E (float) – Young’s modulus [N/m²]
- delta (1d ndarray) – Indentation [m]
- R (float) – Tip radius [m]
- nu (float) – Poisson’s ratio
- contact_point (float) – Indentation offset [m]
- baseline (float) – Force offset [N]
- negindent (bool) – If True, will assume that the indentation value(s) given by delta are negative and must be multiplied by -1.
Returns: F – Force [N]
Return type: Notes
These approximations are made by the Hertz model:
- The sample is isotropic.
- The sample is a linear elastic solid.
- The sample is extended infinitely in one half space.
- The indenter is not deformable.
- There are no additional interactions between sample and indenter.
Additional assumptions:
- no surface forces
References
Sneddon (1965) [Sne65]
spherical indenter (Sneddon, approximative)¶
model key | sneddon_spher_approx |
model name | spherical indenter (Sneddon, approximative) |
model location | nanite.model.model_sneddon_spherical_approximation |
-
nanite.model.model_sneddon_spherical_approximation.
hertz_sneddon_spherical_approx
(E, delta, R, nu, contact_point=0, baseline=0)[source]¶ Hertz model for Spherical indenter - approximation
\[F = \frac{4}{3} \frac{E}{1-\nu^2} \sqrt{R} \delta^{3/2} \left(1 - \frac{1}{10} \frac{\delta}{R} - \frac{1}{840} \left(\frac{\delta}{R}\right)^2 + \frac{11}{15120} \left(\frac{\delta}{R}\right)^3 + \frac{1357}{6652800} \left(\frac{\delta}{R}\right)^4 \right)\]Parameters: - E (float) – Young’s modulus [N/m²]
- delta (1d ndarray) – Indentation [m]
- R (float) – Tip radius [m]
- nu (float) – Poisson’s ratio
- contact_point (float) – Indentation offset [m]
- baseline (float) – Force offset [N]
- negindent (bool) – If True, will assume that the indentation value(s) given by delta are negative and must be mutlitplied by -1.
Returns: F – Force [N]
Return type: Notes
These approximations are made by the Hertz model:
- The sample is isotropic.
- The sample is a linear elastic solid.
- The sample is extended infinitely in one half space.
- The indenter is not deformable.
- There are no additional interactions between sample and indenter.
Additional assumptions:
- no surface forces
References
Sneddon (1965) [Sne65], TODO
Fitting¶
-
class
nanite.fit.
FitProperties
[source]¶ Fit property manager class
Provide convenient access to fit properties as a dictionary and dynamically manage resets due to new initial parameters.
Dynamic properties include:
- set “params_initial” to None if the “model_key” changes
- remove all keys except those in FP_DEFAULT if a key that is in FP_DEFAULT changes (All other keys are considered to be obsolete fitting results).
Additional attributes:
- “segment_bool”: bool
- False for “approach” and True for “retract”
-
class
nanite.fit.
IndentationFitter
(data_set, **kwargs)[source]¶ Fit force-indentation curves
Parameters: - model_key (str) – A key referring to a model in nanite.model.models_available
- params_initial (instance of lmfit.Parameters) – Parameters for fitting. If not given, default parameters are used.
- range_x (tuple of 2) – The range for fitting, see range_type below.
- range_type (str) –
One of:
- absolute:
- Set the absolute fitting range in values given by the x_axis.
- relative cp:
- In some cases it is desired to be able to fit a model only up until a certain indentation depth (tip position) measured from the contact point. Since the contact point is a fit parameter as well, this requires a two-pass fitting.
- preprocessing (list of str) – Preprocessing
- segment (str) – One of “approach” or “retract”.
- weight_cp (float) – Weight the contact point region which shows artifacts that are difficult to model with e.g. Hertz.
- optimal_fit_edelta (bool) – Search for the optimal fit by varying the maximal indentation depth and determining a plateau in the resulting Young’s modulus (fitting parameter “E”).
- optimal_fit_num_samples (int) – Number of samples to use for searching the optimal fit
-
compute_emodulus_vs_mindelta
(callback=None)[source]¶ Compute elastic modulus vs. minimal indentation curve
-
static
compute_opt_mindelta
(emoduli, indentations)[source]¶ Determine the plateau of an emodulus-indentation curve
The following procedure is performed:
- Smooth the emodulus data with a Butterworth filter
- Label sequences that have similar values by binning into ten regions between the min and max.
- Ignore sequences with emodulus that is smaller than the binning size.
- Determine the longest sequence.
Rating¶
Quantitative maps¶
-
class
nanite.qmap.
QMap
(path_or_dataset, callback=None)[source]¶ Quantitative force spectroscopy map handling
Parameters: - path_or_dataset (str or nanite.IndentationGroup) – The path to the data file. The data format is determined using the extension of the file and the data is loaded with the correct method.
- callback (callable or None) – A method that accepts a float between 0 and 1 to externally track the process of loading the data.
-
get_qmap
(feature, qmap_only=False)[source]¶ Return the quantitative map for a feature
Parameters: - feature (str) – Feature to compute map for (see
QMap.features
) - qmap_only – Only return the quantitative map data, not the coordinates
Returns: - x, y (1d ndarray) – Only returned if qmap_only is False; Pixel grid coordinates along x and y
- qmap (2d ndarray) – Quantitative map
- feature (str) – Feature to compute map for (see
-
extent
¶ extent (x1, x2, y1, y2) [µm]
-
features
= None¶ Available features (see
nanite.qmap.available_features
)
-
get_coords
[source]¶ Get the qmap coordinates for each curve in QMap.ds
Parameters: which (str) – “px” for pixels or “um” for microns.
-
group
= None¶ Indentation data (instance of
nanite.IndentationGroup
)
-
shape
¶ shape of the map [px]
-
nanite.qmap.
available_features
= ['data min height', "fit young's modulus", 'meta rating', 'meta scan order']¶ Available features for quantitative maps