Giter Club home page Giter Club logo

Comments (7)

vit-smilauer avatar vit-smilauer commented on May 28, 2024

Hi Grauchs,
I enhanced field2VTKData() and field2Image2D() for Tensors. The example is under Example10-stacTM-local/TensorFieldTest.py. I checked generated VTK files in paraview and it works. Note that tensors need 3x3 list in each vertex (cell), which is what expects pyvtk module at the end.

from mupif.

grauchs avatar grauchs commented on May 28, 2024

When I run TensorFieldTest.py from Example 10, I get the following error message:
Traceback (most recent call last):
File "TensorFieldTest.py", line 17, in
g.field2VTKData().tofile('Tensors')
File "/usr/local/lib/python3.6/site-packages/pyvtk/init.py", line 203, in tofile
f.write(self.to_string(format))
File "/usr/local/lib/python3.6/site-packages/pyvtk/init.py", line 187, in to_string
ret.append(self.point_data.to_string(format))
File "/usr/local/lib/python3.6/site-packages/pyvtk/Data.py", line 46, in to_string
ret += [a.to_string(format) for a in self.data]
File "/usr/local/lib/python3.6/site-packages/pyvtk/Data.py", line 46, in
ret += [a.to_string(format) for a in self.data]
File "/usr/local/lib/python3.6/site-packages/pyvtk/Tensors.py", line 29, in to_string
return '\n'.join(ret)
TypeError: sequence item 1: expected str instance, bytes found

I work under Linux Centos6, with python3.6, pyvtk0.5.18 and mupif 1.1.6.
Could the problem be related to this issue:
https://stackoverflow.com/questions/33054527/python-3-5-typeerror-a-bytes-like-object-is-required-not-str-when-writing-t

from mupif.

vit-smilauer avatar vit-smilauer commented on May 28, 2024

Dear Grauchs,
this problem is related to pyvtk module under Python3 and partially missing conversion from strings to bytes. Python2 works OK. I submitted this bug&fix to developers, however, you can fix it easily by modifying Tensors.py (mine is /usr/local/lib/python3.5/dist-packages/pyvtk/Tensors.py). Add bold text so it looks like:

def to_string(self,format='ascii'):
t = self.get_datatype(self.tensors)
ret = [('TENSORS %s %s'%(self.name,t)).encode(),
self.seq_to_string(self.tensors,format,t)]
return b'\n'.join(ret)

Regards. Vit.

from mupif.

grauchs avatar grauchs commented on May 28, 2024

After switching from mupif 1 to the most recent version of mupif version 2, I got the following warnings and error messages when using Field.toVTK2 with tensors. Note that for scalars and vectors the field output with Field.2toVTK2 works flawlessly. There seems to be again an issue with the tensor format 3 x 3 values versus 1 * 9 values. For the error message, I have got no real clue! Could it be related to the unit I give to getField?

2017-12-11 09:47:51 WARNING:common.py:178 expected 3-sequence but got 9-<class 'tuple'>

2017-12-11 09:47:51 WARNING:common.py:178 expected 3-sequence but got 9-<class 'tuple'>

2017-12-11 09:47:51 WARNING:common.py:178 expected 3-sequence but got 9-<class 'tuple'>

Traceback (most recent call last):
File "testrun-v4.py", line 66, in
res3.toVTK2('testoutput-s',format='ascii')
File "/usr/local/lib/python3.6/site-packages/mupif-1.1.6-py3.6.egg/mupif/Field.py", line 703, in toVTK2
self.field2VTKData().tofile(filename=fileName,format=format)
File "/usr/local/lib/python3.6/site-packages/mupif-1.1.6-py3.6.egg/mupif/Field.py", line 406, in field2VTKData
pyvtk.PointData(pyvtk.Tensors(self.value,**vectorsKw),lookupTable),'Unstructured Grid Example')
File "/usr/local/lib/python3.6/site-packages/pyvtk/init.py", line 167, in init
raise ValueError('DataSet (size=%s) and PointData (size=%s) have different sizes'%(s,s1))
ValueError: DataSet (size=60) and PointData (size=1) have different sizes

from mupif.

vit-smilauer avatar vit-smilauer commented on May 28, 2024

Hi,
tensors should be fixed now in dev-2.0 version. If you wait a few more days, dev-2.0 and master will be merged together and there will be master git version only. (The tensor problem emerged due to separate branches, merging would solve it later).

from mupif.

grauchs avatar grauchs commented on May 28, 2024

The problem is now solved!

from mupif.

grauchs avatar grauchs commented on May 28, 2024

I installed mupif-2.0.0. Now, all problems which reappeared when I switched to mupif-dev-2.0 have disappeared, as you predicted.

from mupif.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.