Example #1
0
    def test_piv_new_multiproc(self):
        params = TopologyPIV.create_default_params()

        params.series.path = str(self.path_Jet)
        params.series.ind_start = 60
        params.series.ind_step = 1
        params.series.strcouple = "i, 0:2"

        params.piv0.shape_crop_im0 = 128
        params.multipass.number = 2
        params.multipass.use_tps = True

        params.saving.how = "recompute"
        params.saving.postfix = self.postfix

        topology = TopologyPIV(params, logging_level="info")
        topology.compute()

        topology = TopologyPIV(params, logging_level="info")
        topology.compute(nb_max_workers=2)

        # remove one file to test params.saving.how = "complete"
        path_files = list(Path(topology.path_dir_result).glob("piv*"))

        if not path_files:
            sleep(0.2)
            path_files = list(Path(topology.path_dir_result).glob("piv*"))

        path_files[0].unlink()

        params.saving.how = "complete"
        topology = TopologyPIV(params, logging_level="debug")
        topology.compute("exec_sequential")

        assert len(topology.results) == 1
Example #2
0
def params_piv_from_uvmat_xml(instructions, args):
    params = TopologyPIV.create_default_params()

    params.series.path = instructions.path_file_input

    params.series.strcouple = instructions.strcouple
    params.series.ind_stop = instructions.ind_stop
    params.series.ind_start = instructions.ind_start

    params.saving.path = instructions.path_dir_output

    n0 = int(instructions.action_input.civ1.search_box_size.split("\t")[0])
    if n0 % 2 == 1:
        n0 -= 1

    params.piv0.shape_crop_im0 = n0

    if hasattr(instructions.action_input, "patch2"):
        params.multipass.subdom_size = (
            instructions.action_input.patch2.sub_domain_size
        )
    else:
        params.multipass.use_tps = False

    if hasattr(instructions.action_input, "civ2"):
        params.multipass.number = 2

    modif_fluidimage_params(params, args)

    return params
Example #3
0
def make_params_piv(iexp, savinghow='recompute',
                    postfix_in='pre', postfix_out='piv'):

    path = get_path(iexp)

    if postfix_in is not None and postfix_in != '':
        path += '.' + postfix_in

    params = TopologyPIV.create_default_params()
    params.series.path = path

    print('path', path)
    str_glob = path + '/c*.png'
    paths = glob(str_glob)
    if len(paths) == 0:
        raise ValueError(
            'No images detected from the string "' + str_glob + '"')

    pathim = paths[0]
    if pathim.endswith('a.png') or pathim.endswith('b.png'):
        params.series.strcouple = 'i, 0:2'
    else:
        params.series.strcouple = 'i:i+2'
    params.series.ind_start = 60
    params.series.ind_stop = None

    params.piv0.shape_crop_im0 = 48
    params.piv0.method_correl = 'fftw'
    params.piv0.displacement_max = 3

    params.mask.strcrop = ':, 50:'

    params.multipass.number = 2
    params.multipass.use_tps = 'last'
    params.multipass.smoothing_coef = 10.
    params.multipass.threshold_tps = 0.1

    params.fix.correl_min = 0.07
    params.fix.threshold_diff_neighbour = 1

    params.saving.how = savinghow
    params.saving.postfix = postfix_out

    return params
Example #4
0
def piv_from_png(save_path, image_folder):

    correl_val = 0.3
    overlap_val = 0.5
    window_size_val = 128

    path_src = save_path + image_folder

    save_path = (
        save_path +
        f"piv_correl{correl_val}_overlap{overlap_val}_window_size{window_size_val}"
    )

    if os.path.isdir(save_path) is False:
        os.mkdir(save_path)
    os.chmod(save_path, 0o774)

    postfix = datetime.datetime.now().isoformat()

    params = TopologyPIV.create_default_params()

    params.series.path = path_src
    params.series.ind_start = 1
    params.series.ind_step = 1
    params.series.strcouple = "i:i+2"

    params.piv0.shape_crop_im0 = window_size_val
    params.piv0.grid.overlap = overlap_val
    params.multipass.number = int(log(window_size_val, 2) -
                                  4)  # last window is 32x32
    params.multipass.use_tps = "True"
    params.fix.correl_min = correl_val

    params.saving.how = "recompute"
    params.saving.path = save_path
    params.saving.postfix = postfix

    topology = TopologyPIV(params)
    topology.compute(sequential=False)

    paths = Path(save_path).glob("*.h5")
    for path in paths:
        os.chmod(path, 0o774)
Example #5
0
    def test_piv_new(self):
        params = TopologyPIV.create_default_params()

        params.series.path = str(self.path_Oseen)
        params.series.ind_start = 1
        params.series.ind_step = 1

        params.piv0.shape_crop_im0 = 32
        params.multipass.number = 2
        params.multipass.use_tps = True

        # params.saving.how has to be equal to 'complete' for idempotent jobs
        # (on clusters)
        params.saving.how = "recompute"
        params.saving.postfix = self.postfix

        topology = TopologyPIV(params, logging_level="info")

        topology.make_code_graphviz(topology.path_dir_result / "topo.dot")
        topology.compute()
Example #6
0
    def __init__(self, path_image, path_save):

        self.path_images = path_image
        self.path_save = path_save
        self.img_tmp = None
        self.params = TopologyPIV.create_default_params()
        self.workpiv = WorkPIV(self.params)
        self.params.series.path = self.path_images
        self.params.series.ind_start = 1

        self.params.piv0.shape_crop_im0 = 32
        self.params.multipass.number = 2
        self.params.multipass.use_tps = True

        self.params.multipass.use_tps = True

        # params.saving.how has to be equal to 'complete' for idempotent jobs
        self.params.saving.how = "complete"
        self.params.saving.postfix = "piv_complete_async"

        self.loop = asyncio.get_event_loop()

        self._log_file = None
Example #7
0
from fluidimage.topologies.piv import TopologyPIV
import os

params = TopologyPIV.create_default_params()

params.series.path = '../../image_samples/Karman/Images'
params.series.ind_start = 1

params.piv0.shape_crop_im0 = 32
params.multipass.number = 2
params.multipass.use_tps = True

# params.saving.how has to be equal to 'complete' for idempotent jobs
# (on clusters)
params.saving.how = 'complete'
params.saving.postfix = 'piv_complete'

topology = TopologyPIV(params, logging_level='info')
#topology.make_code_graphviz('topo.dot')

topology.compute()