Commit 1233f230 authored by Emmanuel Roubin's avatar Emmanuel Roubin
Browse files

Fix time series writer (tiff->vtk)

parent 44f3a2bc
Pipeline #63159 canceled with stages
in 13 minutes and 40 seconds
...@@ -20,7 +20,8 @@ fi ...@@ -20,7 +20,8 @@ fi
if [ "$1" == "coverage" ] if [ "$1" == "coverage" ]
then then
python setup.py install python setup.py install
coverage run setup.py test coverage run -m pytest
coverage combine && coverage report
coverage html coverage html
fi fi
......
# If you're changing this, consider relaunching:
# https://gricad-gitlab.univ-grenoble-alpes.fr/ttk/docker-ttk/-/pipelines
numpy==1.19.5 # Python >=3.6
scipy==1.5.4 # Python >=3.6
scikit-image==0.17.2 # Python >=3.6
tifffile==2020.8.25 # Python >=3.6
matplotlib==3.3.4 # Python >=3.6
SimpleITK==2.0.2
progressbar==2.5
gmsh==4.8.0
meshio==4.3.11 # Python >=3.6
# Anything later than this causes an abort at the end of sphinx 3.5.2 build
pybind11==2.5.0 # Python !=3.0, !=3.1, !=3.2, !=3.3, !=3.4, >=2.7
# multigrid solver for random walker segmentation
pyamg==4.0.0
############
# Optional #
############
# mpi
# mpi4py==3.0.3
# Jupyter
#ipykernel==5.5.0 # Python >=3.5
ipython==7.16.1 # Python >=3.6
# R (correlated random field)
rpy2==3.2.2
#############
# Graphical #
#############
#PyQt5==5.15.4 # Python >=3.6
#PyQt5-sip==12.8.1 # Python >=3.5
#qimage2ndarray==1.8.3
...@@ -17,6 +17,7 @@ progressbar==2.5 ...@@ -17,6 +17,7 @@ progressbar==2.5
gmsh==4.8.0 gmsh==4.8.0
meshio==4.3.11 # Python >=3.6 meshio==4.3.11 # Python >=3.6
h5py==3.2.1 # Python >=3.7
# Anything later than this causes an abort at the end of sphinx 3.5.2 build # Anything later than this causes an abort at the end of sphinx 3.5.2 build
pybind11==2.5.0 # Python !=3.0, !=3.1, !=3.2, !=3.3, !=3.4, >=2.7 pybind11==2.5.0 # Python !=3.0, !=3.1, !=3.2, !=3.3, !=3.4, >=2.7
......
...@@ -17,6 +17,7 @@ progressbar==2.5 ...@@ -17,6 +17,7 @@ progressbar==2.5
gmsh==4.8.0 gmsh==4.8.0
meshio==4.3.11 # Python >=3.6 meshio==4.3.11 # Python >=3.6
h5py==3.1.0 # Python >=3.6
# Anything later than this causes an abort at the end of sphinx 3.5.2 build # Anything later than this causes an abort at the end of sphinx 3.5.2 build
pybind11==2.5.0 # Python !=3.0, !=3.1, !=3.2, !=3.3, !=3.4, >=2.7 pybind11==2.5.0 # Python !=3.0, !=3.1, !=3.2, !=3.3, !=3.4, >=2.7
......
...@@ -528,11 +528,11 @@ def TIFFtoVTK(fileName, voxelSize=1.0): ...@@ -528,11 +528,11 @@ def TIFFtoVTK(fileName, voxelSize=1.0):
if len(fileName) == 1: if len(fileName) == 1:
meshio.write_points_cells(f"{f}.vtk", points, {"hexahedron": cells}, cell_data={"grey": [im.T.ravel()]}) meshio.write_points_cells(f"{f}.vtk", points, {"hexahedron": cells}, cell_data={"grey": [im.T.ravel()]})
else: else:
writer = meshio.XdmfTimeSeriesWriter(f"{f}.xmf") with meshio.xdmf.TimeSeriesWriter(f"{f}.xmf") as writer:
writer.write_points_cells(points, {"hexahedron": cells}) writer.write_points_cells(points, [("hexahedron", cells)])
for i, name in enumerate(fileName): for i, name in enumerate(fileName):
im = tifffile.imread(name) im = tifffile.imread(name)
writer.write_data(i, cell_data={"grey": [im.T.ravel()]}) writer.write_data(i, cell_data={"grey": [im.T.ravel()]})
#@jit(nopython=True) #@jit(nopython=True)
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function
import unittest import unittest
import numpy import numpy
import os import os
...@@ -15,11 +13,12 @@ class testAll(unittest.TestCase): ...@@ -15,11 +13,12 @@ class testAll(unittest.TestCase):
try: try:
# pass # pass
os.remove("./spam.vtk") os.remove("./spam.vtk")
os.remove("./tmpsnow.tif") os.remove("./snow-1.tif")
os.remove("./tmpsnow.vtk") os.remove("./snow-2.tif")
#os.remove("tools/data/snow/snow.vtk") os.remove("./snow-3.tif")
#os.remove("tools/data/snow/snow.h5") os.remove("./snow-1.vtk")
#os.remove("tools/data/snow/snow.xmf") os.remove("./snow-1.h5")
os.remove("./snow-1.xmf")
except OSError: except OSError:
pass pass
...@@ -64,6 +63,10 @@ class testAll(unittest.TestCase): ...@@ -64,6 +63,10 @@ class testAll(unittest.TestCase):
tensor = numpy.random.rand(4, 5, 6, 3, 3) tensor = numpy.random.rand(4, 5, 6, 3, 3)
spam.helpers.writeStructuredVTK(pointData={'c': tensor}) spam.helpers.writeStructuredVTK(pointData={'c': tensor})
# write field with wrong format
dummy = numpy.random.rand(4, 5, 6, 3, 2)
spam.helpers.writeStructuredVTK(pointData={'d': dummy})
# write 2 point and 2 cell # write 2 point and 2 cell
cellScalars = numpy.random.rand(4, 5, 6) cellScalars = numpy.random.rand(4, 5, 6)
cellVectors = numpy.random.rand(4, 5, 6, 3) cellVectors = numpy.random.rand(4, 5, 6, 3)
...@@ -129,13 +132,19 @@ class testAll(unittest.TestCase): ...@@ -129,13 +132,19 @@ class testAll(unittest.TestCase):
spam.helpers.writeGlyphsVTK(coordinates, pointData) spam.helpers.writeGlyphsVTK(coordinates, pointData)
def test_TIFFtoVTK(self): def test_TIFFtoVTK(self):
im = spam.datasets.loadSnow()[0:20, 0:20, 0:20]
# Make it smaller because this takes a long time # Make it smaller because this takes a long time
im1 = spam.datasets.loadSnow()[0:20, 0:20, 0:20]
im2 = spam.datasets.loadSnow()[0:20, 0:20, 2:22]
im3 = spam.datasets.loadSnow()[0:20, 0:20, 4:24]
import tifffile import tifffile
tifffile.imsave("./tmpsnow.tif", im) tifffile.imsave("./snow-1.tif", im1)
spam.helpers.TIFFtoVTK("./tmpsnow.tif") tifffile.imsave("./snow-2.tif", im2)
tifffile.imsave("./snow-3.tif", im3)
spam.helpers.TIFFtoVTK("./snow-1.tif")
# VTK = spam.helpers.readStructuredVTK("tmpsnow.vtk") # can't read binary # VTK = spam.helpers.readStructuredVTK("tmpsnow.vtk") # can't read binary
# spam.helpers.TIFFtoVTK(["tmpsnow.tif", "tmpsnow.tif"]) spam.helpers.TIFFtoVTK(["snow-1.tif", "snow-2.tif", "snow-3.tif"])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment