Skip to content

Commit

Permalink
Breaking changes for 0.3.0: str_subset, process_1_serie, fluidimage.p…
Browse files Browse the repository at this point in the history
…iv, params.series for works
  • Loading branch information
paugier committed Feb 22, 2024
1 parent 9ba4f02 commit b7b499f
Show file tree
Hide file tree
Showing 77 changed files with 608 additions and 678 deletions.
2 changes: 1 addition & 1 deletion doc/examples/bos_with_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
params = TopologyBOS.create_default_params()

params.images.path = get_path_image_samples() / "Karman/Images"
params.images.str_slice = "1:3"
params.images.str_subset = "1:3"

params.piv0.shape_crop_im0 = 32
params.multipass.number = 2
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/experimental/image2image_await.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
params.saving.postfix = "await_im2im_recompute"


params.im2im = "fluidimage.preproc.image2image.im2im_func_example"
params.im2im = "fluidimage.image2image.im2im_func_example"
topology = TopologyImage2Image(params, logging_level="info")
image2image.complete_im2im_params_with_default(params)

Expand Down
6 changes: 3 additions & 3 deletions doc/examples/experimental/old_piv_recompute.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

from fluidimage.topologies.piv import TopologyPIV
from fluidimage.piv import Topology

params = TopologyPIV.create_default_params()
params = Topology.create_default_params()

params.series.path = "../../../image_samples/Karman/Images3"
params.series.ind_start = 1
Expand All @@ -14,7 +14,7 @@
params.saving.how = "recompute"
params.saving.postfix = "old_piv"

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

topology.compute()
6 changes: 3 additions & 3 deletions doc/examples/experimental/piv_complete.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from fluidimage.experimental.executors.executor_await import (
ExecutorAwaitMultiprocs,
)
from fluidimage.topologies.piv import TopologyPIV
from fluidimage.piv import Topology

params = TopologyPIV.create_default_params()
params = Topology.create_default_params()

params.series.path = "../../../image_samples/Karman/Images2"
params.series.ind_start = 1
Expand All @@ -18,7 +18,7 @@
params.saving.postfix = "piv_complete"


topology = TopologyPIV(params, logging_level="debug")
topology = Topology(params, logging_level="debug")
# topology.make_code_graphviz('topo.dot')

topology.compute(executer=ExecutorAwaitMultiprocs(topology), sequential=True)
4 changes: 2 additions & 2 deletions doc/examples/experimental/piv_trio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from fluidimage.experimental.no_topology_computations.base_trio import BaseAsync
from fluidimage.experimental.no_topology_computations.piv_trio import PivTrio
from fluidimage.topologies.piv import TopologyPIV
from fluidimage.piv import Topology
from fluidimage.works.piv import multipass

params = TopologyPIV.create_default_params()
params = Topology.create_default_params()

params.series.path = "../../../image_samples/Karman/Images3"

Expand Down
5 changes: 3 additions & 2 deletions doc/examples/my_example_im2im.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""


def im2im(im):
def im2im(im_path):
im, path = im_path
print("in the function im2im...")
return 2 * im
return 2 * im, path
5 changes: 3 additions & 2 deletions doc/examples/my_example_im2im_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def __init__(self, arg0, arg1):
self.arg0 = arg0
self.arg1 = arg1

def calcul(self, image):
def calcul(self, image_path):
image, path = image_path
print(f"in the function Im2Im.calcul (arg0={self.arg0})...")
return 2 * image
return 2 * image, path
4 changes: 2 additions & 2 deletions doc/examples/piv_as_real/job_piv.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import params_piv

from fluidimage.topologies.piv import TopologyPIV
from fluidimage.piv import Topology


def main(args):
Expand All @@ -26,7 +26,7 @@ def main(args):
postfix_out=args.postfix_out,
)

topology = TopologyPIV(params, nb_max_workers=int(args.nb_cores))
topology = Topology(params, nb_max_workers=int(args.nb_cores))
topology.compute(sequential=args.seq)


Expand Down
8 changes: 4 additions & 4 deletions doc/examples/piv_as_real/params_piv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from glob import glob

from fluidimage.topologies.piv import TopologyPIV
from fluidimage.piv import Topology


def get_path(iexp):
Expand All @@ -27,7 +27,7 @@ def make_params_piv(
if postfix_in is not None and postfix_in != "":
path += "." + postfix_in

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

print("path", path)
Expand All @@ -38,9 +38,9 @@ def make_params_piv(

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

Expand Down
8 changes: 4 additions & 4 deletions doc/examples/piv_as_real/params_pre.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def make_params_pre(iexp, savinghow="recompute", postfix_out="pre"):
pathim = paths[0]
double_frame = pathim.endswith("a.png") or pathim.endswith("b.png")
if double_frame:
params.preproc.series.strcouple = "i:i+1, 0"
params.preproc.series.str_subset = "i:i+1, 0"
else:
params.preproc.series.strcouple = "i:i+1"
params.preproc.series.str_subset = "i:i+1"

params.preproc.series.ind_start = 60
params.preproc.series.ind_stop = 62
Expand All @@ -63,8 +63,8 @@ def make_params_pre(iexp, savinghow="recompute", postfix_out="pre"):
if double_frame:
# for 'b.png' images
params2 = deepcopy(params)
params2.preproc.series.strcouple = (
params.preproc.series.strcouple[:-1] + "1"
params2.preproc.series.str_subset = (
params.preproc.series.str_subset[:-1] + "1"
)
return [params, params2]
else:
Expand Down
12 changes: 2 additions & 10 deletions doc/examples/piv_as_real/try_piv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import params_piv

from fluidimage import SeriesOfArrays
from fluidimage.works.piv import WorkPIV
from fluidimage.piv import WorkPIV

try:
reload
Expand All @@ -32,16 +32,8 @@

work = WorkPIV(params=params)

pathin = params.series.path

series = SeriesOfArrays(
pathin, params.series.strcouple, ind_start=params.series.ind_start
)

# c060a.png and c060b.png
serie = series.get_serie_from_index(params.series.ind_start)

piv = work.calcul(serie)
piv = work.process_1_serie(params.series.ind_start)

# piv.piv0.display(show_interp=True, scale=0.05, show_error=True)

Expand Down
14 changes: 6 additions & 8 deletions doc/examples/piv_try_params.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""To be run in IPython to find a good set of parameters"""

from fluidimage import SeriesOfArrays
from fluidimage.works.piv import WorkPIV
from fluidimage.piv import WorkPIV

params = WorkPIV.create_default_params()

Expand All @@ -15,15 +14,14 @@

params.mask.strcrop = "30:250, 100:"

work = WorkPIV(params=params)

path = "../../image_samples/Oseen/Images"
# path = '../../image_samples/Karman/Images'
series = SeriesOfArrays(path, "i+1:i+3")
# we select the serie corresponding to i = 0
serie = series.get_serie_from_index(0)
params.series.path = path
params.series.str_subset = "i+1:i+3"

work = WorkPIV(params=params)

piv = work.calcul(serie)
piv = work.process_1_serie()

# piv.display(show_interp=True, scale=0.3, show_error=True)
piv.display(show_interp=False, scale=1, show_error=True)
Expand Down
17 changes: 9 additions & 8 deletions doc/examples/piv_try_params_with_im2im_preproc.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from fluidimage import SeriesOfArrays
from fluidimage.preproc.image2image import apply_im2im_filter
from fluidimage.works.piv import WorkPIV
from fluidimage.image2image import apply_im2im_filter
from fluidimage.piv import Work

params = WorkPIV.create_default_params()
params = Work.create_default_params()

params.multipass.number = 2
params.multipass.use_tps = True
Expand All @@ -14,12 +13,14 @@

params.mask.strcrop = "30:250, 100:"

work = WorkPIV(params=params)

path = "../../image_samples/Oseen/Images"
# path = '../../image_samples/Karman/Images'
series = SeriesOfArrays(path, "i+1:i+3")
serie = series.get_serie_from_index(0)
params.series.path = path
params.series.str_subset = "i+1:i+3"

work = Work(params=params)

serie = work.get_serie()

# "image to image" filter
serie = apply_im2im_filter(serie, im2im="my_example_im2im.im2im")
Expand Down
6 changes: 3 additions & 3 deletions doc/examples/piv_with_topo_and_preproc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fluidimage import get_path_image_samples
from fluidimage.topologies.piv import TopologyPIV
from fluidimage.piv import Topology

params = TopologyPIV.create_default_params()
params = Topology.create_default_params()

params.series.path = get_path_image_samples() / "Karman/Images"
params.series.ind_start = 1
Expand All @@ -22,7 +22,7 @@
# Here the "image to image" function will be imported with the statement
# `from my_example_im2im import im2im`

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

# To produce a graph of the topology
topology.make_code_graphviz("topo.dot")
Expand Down
6 changes: 3 additions & 3 deletions doc/examples/piv_with_topo_and_preproc_class.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fluidimage import get_path_image_samples
from fluidimage.topologies.piv import TopologyPIV
from fluidimage.piv import Topology

params = TopologyPIV.create_default_params()
params = Topology.create_default_params()

params.series.path = get_path_image_samples() / "Karman/Images"
params.series.ind_start = 1
Expand All @@ -23,7 +23,7 @@
# Here, the class will be imported with the statement
# `from my_example_im2im_class import Im2Im`

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

# To produce a graph of the topology
topology.make_code_graphviz("topo.dot")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

from fluidimage.topologies.piv import TopologyPIV
from fluidimage.piv import Topology

params = TopologyPIV.create_default_params()
params = Topology.create_default_params()

params.series.path = "../../image_samples/Karman/Images"
params.series.ind_start = 1
Expand All @@ -16,7 +16,7 @@
params.saving.how = "complete"
params.saving.postfix = "piv_complete"

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

topology.compute()
6 changes: 3 additions & 3 deletions doc/examples/piv_with_topology.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fluidimage import get_path_image_samples
from fluidimage.topologies.piv import TopologyPIV
from fluidimage.piv import Topology

params = TopologyPIV.create_default_params()
params = Topology.create_default_params()

params.series.path = get_path_image_samples() / "Karman/Images"
params.series.ind_start = 1
Expand All @@ -16,7 +16,7 @@
# params.saving.how = 'complete'
params.saving.postfix = "piv_example"

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

# To produce a graph of the topology
# topology.make_code_graphviz('topo.dot')
Expand Down
8 changes: 4 additions & 4 deletions doc/examples/pivchallenge/bench_piv_2005C.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

from path_images import get_path

from fluidimage.topologies.piv import TopologyPIV
from fluidimage.piv import Topology

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

params = TopologyPIV.create_default_params()
params = Topology.create_default_params()

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

Expand All @@ -28,7 +28,7 @@

params.saving.how = "recompute"

topology = TopologyPIV(params)
topology = Topology(params)

serie = topology.series.serie

Expand Down
8 changes: 4 additions & 4 deletions doc/examples/pivchallenge/piv_2001A_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from path_images import get_path

from fluidimage.topologies.piv import TopologyPIV
from fluidimage.piv import Topology

params = TopologyPIV.create_default_params()
params = Topology.create_default_params()

path = os.path.join(get_path("2001A"), "A*")

params.series.path = path
params.series.strcouple = "i, 1:3"
params.series.str_subset = "i, 1:3"
params.series.ind_start = 1

params.piv0.shape_crop_im0 = 32
Expand All @@ -19,7 +19,7 @@

params.saving.how = "recompute"

topology = TopologyPIV(params)
topology = Topology(params)

serie = topology.series.serie

Expand Down
2 changes: 1 addition & 1 deletion doc/examples/pivchallenge/piv_2001A_work.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from path_images import get_path

from fluidimage import SeriesOfArrays
from fluidimage.works.piv import WorkPIV
from fluidimage.piv import WorkPIV

params = WorkPIV.create_default_params()

Expand Down
Loading

0 comments on commit b7b499f

Please sign in to comment.