Пример #1
0
def test_open_dat_without_spring_constant():
    # There are data files without spring constant but with force in nN.
    # nanite requires the spring constant for computation of the tip
    # position which we check for here.
    tmp = tempfile.mkdtemp(prefix="test_nanite_group")
    shutil.copy(data_path / "fmt-afm-workshop-fd_single_2021-10-22_14.16.csv",
                tmp)

    # try without explicit metadata
    with pytest.raises(MissingMetaDataError, match="spring constant"):
        load_group(tmp)

    # try with metadata
    grp = load_group(tmp, meta_override={"spring constant": 20})
    assert grp[0].metadata["spring constant"] == 20
Пример #2
0
def test_subgroup():
    tmp = tempfile.mkdtemp(prefix="test_nanite_group")
    shutil.copy(datadir / "map-data-reference-points.jpk-force-map", tmp)
    shutil.copy(datadir / "map2x2_extracted.jpk-force-map", tmp)
    shutil.copy(datadir / "flipsign_2015.05.22-15.31.49.352.jpk-force", tmp)

    grp = load_group(tmp)
    exp = pathlib.Path(tmp) / "map2x2_extracted.jpk-force-map"
    subgrp = grp.subgroup_with_path(path=exp)
    assert len(grp) == 8
    assert len(subgrp) == 4
    assert subgrp[0].path == exp

    shutil.rmtree(tmp, ignore_errors=True)
Пример #3
0
def test_plotting():
    # use temporary file
    _, name = tempfile.mkstemp(suffix=".png", prefix="test_nanite_plotting_")
    name = pathlib.Path(name)

    grp = load_group(jpkfile)
    idnt = grp[0]
    idnt.apply_preprocessing(["compute_tip_position", "correct_force_offset"])
    idnt.fit_model(model_key="hertz_para",
                   params_initial=None,
                   x_axis="tip position",
                   y_axis="force",
                   weight_cp=False,
                   segment="retract")
    plotting.plot_data(idnt=idnt, path=name)
    assert name.stat().st_size > 90000
Пример #4
0
"""Fitting and rating

This example uses a force-distance curve of a zebrafish spinal cord
section to illustrate basic data fitting and rating with nanite.
The dataset is part of a study on spinal cord stiffness in zebrafish
:cite:`Moellmert2019`.
"""
import matplotlib.gridspec as gridspec
import matplotlib.pylab as plt

import nanite

# load the data
group = nanite.load_group("data/zebrafish-head-section-gray-matter.jpk-force")
idnt = group[0]  # this is an instance of `nanite.Indentation`
# apply preprocessing
idnt.apply_preprocessing(["compute_tip_position",
                          "correct_force_offset",
                          "correct_tip_offset"])
# set the fit model ("sneddon_spher_approx" is faster than "sneddon_spher"
# and sufficiently accurate)
idnt.fit_properties["model_key"] = "sneddon_spher_approx"
# get the initial fit parameters
params = idnt.get_initial_fit_parameters()
# set the correct indenter radius
params["R"].value = 18.64e-06
# perform the fit with the edited parameters
idnt.fit_model(params_initial=params)
# obtain the Young's modulus
emod = idnt.fit_properties["params_fitted"]["E"].value
# obtain a rating for the dataset