예제 #1
0
def test_with_rtdc_warning():
    keys = ["area_um", "deform"]
    ddict = example_data_dict(size=8472, keys=keys)
    # legacy
    ds = dclab.new_dataset(ddict)
    ds.config["setup"]["flow rate"] = 0.16
    ds.config["setup"]["channel width"] = 30
    ds.config["setup"]["medium"] = "CellCarrier"
    ds.config["imaging"]["pixel size"] = .34
    i1 = iso.get_default()
    with warnings.catch_warnings(record=True) as w:
        # Cause all warnings to always be triggered.
        warnings.simplefilter("always")
        # Trigger a warning (temperature missing).
        i1.get_with_rtdcbase(col1="area_um",
                             col2="deform",
                             lut_identifier="LE-2D-FEM-19",
                             dataset=ds,
                             viscosity=None,
                             add_px_err=False)
        # Verify some things
        assert len(w) == 1
        assert issubclass(w[-1].category,
                          iso.IsoelasticsEmodulusMeaninglessWarning)
        assert "plotting" in str(w[-1].message)
예제 #2
0
def get_isoelastics(mm):
    isotype = mm.config["plotting"]["isoelastics"]
    xax = mm.config["plotting"]["axis x"].lower()
    yax = mm.config["plotting"]["axis y"].lower()
    if isotype == "not shown":
        # nothing to do
        isoel = None
    else:
        if "legacy" in isotype:
            method = "analytical"
            isosource = legacy_isoelastics
            add_px_err = False
            px_um = None
        else:
            method = isotype
            isosource = isoelastics.get_default()
            add_px_err = True
            px_um = mm.config["imaging"]["pixel size"]
        kwargs = dict(method=method,
                      channel_width=mm.config["setup"]["channel width"],
                      flow_rate=None,
                      viscosity=None,
                      col1=xax,
                      col2=yax,
                      add_px_err=add_px_err,
                      px_um=px_um,
                      )
        try:
            isoel = isosource.get(**kwargs)
        except KeyError:
            warnings.warn("Could not find matching isoelastics for"+
                          " Setting: x={}, y={}, method: {}".
                          format(xax, yax, kwargs["method"]))
            isoel = None
    return isoel
예제 #3
0
def test_with_rtdc():
    keys = ["area_um", "deform"]
    ddict = example_data_dict(size=8472, keys=keys)
    # legacy
    ds = dclab.new_dataset(ddict)
    ds.config["setup"]["flow rate"] = 0.16
    ds.config["setup"]["channel width"] = 30
    ds.config["setup"]["temperature"] = 23.0
    ds.config["setup"]["medium"] = "CellCarrier"
    ds.config["imaging"]["pixel size"] = .34
    i1 = iso.get_default()
    data1 = i1.get_with_rtdcbase(col1="area_um",
                                 col2="deform",
                                 lut_identifier="LE-2D-FEM-19",
                                 dataset=ds,
                                 viscosity=None,
                                 add_px_err=False)

    viscosity = emodulus.viscosity.get_viscosity(
        medium="CellCarrier",
        channel_width=ds.config["setup"]["channel width"],
        flow_rate=ds.config["setup"]["flow rate"],
        temperature=ds.config["setup"]["temperature"])
    data2 = i1.get(col1="area_um",
                   col2="deform",
                   lut_identifier="LE-2D-FEM-19",
                   channel_width=ds.config["setup"]["channel width"],
                   flow_rate=ds.config["setup"]["flow rate"],
                   viscosity=viscosity,
                   add_px_err=False,
                   px_um=ds.config["imaging"]["pixel size"])
    for d1, d2 in zip(data1, data2):
        assert np.allclose(d1, d2, atol=0, rtol=1e-14)
예제 #4
0
def test_volume_switch():
    """Switch the columns"""
    i1 = iso.get_default()
    data = i1.get(col1="deform",
                  col2="volume",
                  channel_width=20,
                  flow_rate=0.04,
                  viscosity=15,
                  lut_identifier="LE-2D-FEM-19",
                  add_px_err=False,
                  px_um=None)
    assert np.allclose(data[0][0], [4.18005e-02, 1.61819e+02, 1.08000e+00])
    assert np.allclose(data[-1][-1], [1.26408e-02, 3.16212e+03, 1.08400e+01])
예제 #5
0
def test_volume_scale_2():
    """The default values are used if set to None"""
    i1 = iso.get_default()
    data = i1.get(col1="volume",
                  col2="deform",
                  channel_width=25,
                  flow_rate=None,
                  viscosity=None,
                  lut_identifier="LE-2D-FEM-19",
                  add_px_err=False,
                  px_um=None)
    assert np.allclose(
        data[0][0],
        [1.61819e+02 * (25 / 20)**3, 4.18005e-02, 1.08000e+00 * (20 / 25)**3])
예제 #6
0
def test_volume_pxcorr():
    """Deformation is pixelation-corrected using volume"""
    i1 = iso.get_default()
    data = i1.get(col1="volume",
                  col2="deform",
                  channel_width=20,
                  flow_rate=None,
                  viscosity=None,
                  lut_identifier="LE-2D-FEM-19",
                  add_px_err=True,
                  px_um=0.34)
    ddelt = pxcorr.corr_deform_with_volume(1.61819e+02, px_um=0.34)
    assert np.allclose(data[0][0],
                       [1.61819e+02, 4.18005e-02 + ddelt, 1.08000e+00])
예제 #7
0
def test_volume_basic():
    """Reproduce exact data from simulation result"""
    i1 = iso.get_default()
    data = i1.get(col1="volume",
                  col2="deform",
                  channel_width=20,
                  flow_rate=0.04,
                  viscosity=15,
                  lut_identifier="LE-2D-FEM-19",
                  add_px_err=False,
                  px_um=None)
    assert np.allclose(data[0][0], [1.61819e+02, 4.18005e-02, 1.08000e+00])
    assert np.allclose(data[0][-1], [5.90127e+02, 1.47449e-01, 1.08000e+00])
    assert np.allclose(data[1][0], [1.61819e+02, 2.52114e-02, 1.36000e+00])
    assert np.allclose(data[-1][-1], [3.16212e+03, 1.26408e-02, 1.08400e+01])
예제 #8
0
def get_isoelastics(mm):
    isotype = mm.config["plotting"]["isoelastics"]
    xax = mm.config["plotting"]["axis x"].lower()
    yax = mm.config["plotting"]["axis y"].lower()
    if isotype == "not shown":
        # nothing to do
        isoel = None
    else:
        if "legacy" in isotype:
            method = "analytical"
            isosource = legacy_isoelastics
            add_px_err = False
            px_um = None
        else:
            method = isotype
            isosource = isoelastics.get_default()
            add_px_err = True
            px_um = mm.config["imaging"]["pixel size"]
        kwargs = dict(
            method=method,
            channel_width=mm.config["setup"]["channel width"],
            flow_rate=None,
            viscosity=None,
            col1=xax,
            col2=yax,
            add_px_err=add_px_err,
            px_um=px_um,
        )
        try:
            isoel = isosource.get(**kwargs)
        except KeyError:
            warnings.warn("Could not find matching isoelastics for" +
                          " Setting: x={}, y={}, method: {}".format(
                              xax, yax, kwargs["method"]))
            isoel = None
    return isoel