Beispiel #1
0
    def create_default_params(cls):
        """Class method returning the default parameters."""
        params = ParamContainer(tag='params')
        params._set_child('preproc')
        params.preproc._set_child('series', attribs={'path': ''})

        PreprocTools._complete_class_with_tools(params)

        return params
Beispiel #2
0
    def create_default_params(cls):
        """Class method returning the default parameters."""
        params = ParamContainer(tag='params')
        params._set_child('preproc')
        params.preproc._set_child('series', attribs={'path': ''})

        PreprocTools._complete_class_with_tools(params)

        return params
def create_default_params():
    """Class method returning the default parameters.

    For developers: cf. fluidsim.base.params

    """
    params = ParamContainer(tag="params")

    params._set_child(
        "series",
        attribs={
            "path": "",
            "strcouple": "i:i+2",
            "ind_start": 0,
            "ind_stop": None,
            "ind_step": 1,
        },
    )

    params.series._set_doc(
        """
Parameters indicating the input series of images.

path : str, {''}

String indicating the input images (can be a full path towards an image
file or a string given to `glob`).

strcouple : 'i:i+2'

String indicating as a Python slicing how couples of images are formed.
There is one couple per value of `i`. The values of `i` are set with the
other parameters `ind_start`, `ind_step` and `ind_stop` approximately with
the function range (`range(ind_start, ind_stop, ind_step)`).

Python slicing is a very powerful notation to define subset from a
(possibly multidimensional) set of images. For a user, an alternative is to
understand how Python slicing works. See for example this page:
http://stackoverflow.com/questions/509211/explain-pythons-slice-notation.

Another possibility is to follow simple examples:

For single-frame images (im0, im1, im2, im3, ...), we keep the default
value 'i:i+2' to form the couples (im0, im1), (im1, im2), ...

To see what it gives, one can use ipython and range:

>>> i = 0
>>> list(range(10))[i:i+2]
[0, 1]

>>> list(range(10))[i:i+4:2]
[0, 2]

We see that we can also use the value 'i:i+4:2' to form the couples (im0,
im2), (im1, im3), ...

For double-frame images (im1a, im1b, im2a, im2b, ...) you can write

>>> params.series.strcouple = 'i, 0:2'

In this case, the first couple will be (im1a, im1b).

To get the first couple (im1a, im1a), we would have to write

>>> params.series.strcouple = 'i:i+2, 0'

ind_start : int, {0}

ind_step : int, {1}

int_stop : None

"""
    )

    params._set_child(
        "saving", attribs={"path": None, "how": "ask", "postfix": "piv"}
    )

    params.saving._set_doc(
        """Saving of the results.

path : None or str

Path of the directory where the data will be saved. If None, the path is
obtained from the input path and the parameter `postfix`.

how : str {'ask'}

'ask', 'new_dir', 'complete' or 'recompute'.

postfix : str

Postfix from which the output file is computed.
"""
    )

    WorkPIV._complete_params_with_default(params)

    params._set_internal_attr(
        "_value_text",
        json.dumps(
            {
                "program": "fluidimage",
                "module": "fluidimage.topologies.piv",
                "class": "TopologyPIV",
            }
        ),
    )

    params._set_child("preproc")
    image2image.complete_im2im_params_with_default(params.preproc)

    return params
Beispiel #4
0
def make_params_calibration(path_file):
    """Make a tidy parameter container from a UVmat file.

    """
    params = ParamContainer(tag="calib")

    calib_uvmat = ParamContainer(path_file=str(path_file))
    tidy_container(calib_uvmat)

    calib_uvmat = calib_uvmat["geometry_calib"]

    f = [float(n) for n in np.array(get_number_from_string(calib_uvmat.fx_fy))]
    C = np.array(get_number_from_string(calib_uvmat.cx__cy))
    kc = np.array(calib_uvmat.kc)
    T = np.array(get_number_from_string(calib_uvmat.tx__ty__tz))

    R = []
    for i in range(3):
        R = np.hstack(
            [R, get_number_from_string(calib_uvmat["r_{}".format(i + 1)])]
        )

    omc = np.array(get_number_from_string(calib_uvmat["omc"]))

    params._set_attribs({"f": f, "C": C, "kc": kc, "T": T, "R": R, "omc": omc})

    if calib_uvmat.nb_slice is not None:

        nb_slice = np.array(calib_uvmat["nb_slice"])
        zslice_coord = np.zeros([nb_slice, 3])

        if calib_uvmat.nb_slice == 1:
            zslice_coord[:] = get_number_from_string(calib_uvmat["slice_coord"])
            if (
                hasattr(calib_uvmat, "slice_angle")
                and calib_uvmat["slice_angle"] is not None
            ):
                slice_angle = np.zeros([nb_slice, 3])
                slice_angle[:] = get_number_from_string(
                    calib_uvmat["slice_angle"]
                )
            else:
                slice_angle = [0, 0, 0]
        else:
            for i in range(nb_slice):
                zslice_coord[i][:] = get_number_from_string(
                    calib_uvmat["slice_coord_{}".format(i + 1)]
                )

            if (
                hasattr(calib_uvmat, "slice_angle_1")
                and calib_uvmat["slice_angle_1"] is not None
            ):
                slice_angle = np.zeros([nb_slice, 3])
                for i in range(nb_slice):
                    slice_angle[i][:] = get_number_from_string(
                        calib_uvmat["slice_angle_{}".format(i + 1)]
                    )
            else:
                slice_angle = [0, 0, 0]

        params._set_child(
            "slices",
            attribs={
                "nb_slice": nb_slice,
                "zslice_coord": zslice_coord,
                "slice_angle": slice_angle,
            },
        )

    if hasattr(calib_uvmat, "refraction_index"):
        params._set_attrib("refraction_index", calib_uvmat.refraction_index)

    if hasattr(calib_uvmat, "interface_coord"):
        params._set_attrib(
            "interface_coord",
            get_number_from_string(calib_uvmat["interface_coord"]),
        )

    return params