Exemple #1
0
def main(args):

    params = params_piv.make_params_piv(args.exp,
                                        savinghow=args.saving_how,
                                        postfix_in=args.postfix_in,
                                        postfix_out=args.postfix_out)

    topology = TopologyPIV(params, nb_max_workers=int(args.nb_cores))
    topology.compute(sequential=args.seq)
Exemple #2
0
class ActionPIV(ActionBase):
    """Compute the average and save as a png file."""

    def __init__(self, instructions, args):
        self.instructions = instructions
        self.params = params_piv_from_uvmat_xml(instructions, args)
        logger.info("Initialize fluidimage computations with parameters:")
        logger.info(self.params._make_xml_text())
        self.topology = TopologyPIV(self.params)

    def compute(self):
        t = time()
        self.topology.compute(sequential=False)
        t = time() - t
        print("ellapsed time: {}s".format(t))
Exemple #3
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
Exemple #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)
Exemple #5
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
Exemple #6
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()
Exemple #7
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
instructions = ParamContainer(path_file=xml_file)
instructions.Action.ActionName
tidy_uvmat_instructions(instructions)

params = params_from_uvmat_xml(instructions)

params.series.ind_start = 0

params.saving.path = os.path.split(os.path.dirname(xml_file))[0].replace(
    '.civ', '.piv')

try:
    nb_cores = int(sys.argv[-1])
except ValueError:
    nb_cores = None
else:
    params.saving.path += '_{}cores'.format(nb_cores)

params.saving.how = 'recompute'

# params.multipass.subdom_size = 100

print('params.multipass.subdom_size = ', params.multipass.subdom_size)

params.multipass.use_tps = True

topology = TopologyPIV(params, logging_level='info', nb_max_workers=None)

topology.compute()
Exemple #9
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()
Exemple #10
0
from fluidimage.topologies.piv import TopologyPIV
from fluidimage import path_image_samples

params = TopologyPIV.create_default_params()

params.series.path = path_image_samples / 'Karman/Images'
params.series.ind_start = 1
params.series.ind_step = 2

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

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

params.saving.how = 'recompute'
params.saving.postfix = 'piv_example'

# we use the light versatile preprocessing feature:
params.preproc.im2im = 'my_example_im2im_class.Im2Im'
params.preproc.args_init = ('arg0', 'arg1')

# Here, the class will be imported with the statement
# `from my_example_im2im_class import Im2Im`

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

# To produce a graph of the topology
topology.make_code_graphviz('topo.dot')
Exemple #11
0
from fluidimage.topologies.piv import TopologyPIV

from fluidimage.run_from_xml import params_from_uvmat_xml, ParamContainer

base = '/fsnet/project/meige/2016/16FLUIDIMAGE/samples/Bicouche'

host = socket.gethostname()

instructions = ParamContainer(
    path_file=base + '/Dalsa1.civ_bench_cluster_xml/0_XML/img_1-161.xml')

params = params_from_uvmat_xml(instructions)

params.saving.path = base + '/Dalsa1.piv_bench_' + host

try:
    nb_cores = int(sys.argv[-1])
except ValueError:
    nb_cores = None
else:
    params.saving.path += '_{}cores'.format(nb_cores)

params.saving.how = 'complete'

params.multipass.subdom_size = 500

topology = TopologyPIV(params)

# topology.compute()
Exemple #12
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
Exemple #13
0
 def __init__(self, instructions, args):
     self.instructions = instructions
     self.params = params_piv_from_uvmat_xml(instructions, args)
     logger.info("Initialize fluidimage computations with parameters:")
     logger.info(self.params._make_xml_text())
     self.topology = TopologyPIV(self.params)
import pstats
import cProfile

import os

from path_images import get_path

from fluidimage.topologies.piv import TopologyPIV

path = os.path.join(get_path('2005C'), 'c*.bmp')

params = TopologyPIV.create_default_params()

params.series.path = path
params.series.strcouple = 'i, 0:2'
# params.series.ind_start = 48
params.series.ind_stop = 20

params.piv0.shape_crop_im0 = 64
params.piv0.grid.overlap = 0.5

params.multipass.number = 3
params.multipass.use_tps = False

params.fix.displacement_max = 3
params.fix.correl_min = 0.1
params.fix.threshold_diff_neighbour = 3

params.saving.how = 'recompute'

topology = TopologyPIV(params)