Comments (7)
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.
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.
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.
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.
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.
The problem is now solved!
from mupif.
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)
- Navigation within entity state: dot and array notation
- PyroFile & permissions HOT 8
- Wine64 CI broken (subprocess with PYTHONPATH in simplejobmanager) HOT 1
- unittest for crashing Model
- Pass workDirectory path to model __init__ HOT 1
- munin alarms HOT 1
- octree subdivides to tiny cells without limit, until recursion limit is reached HOT 1
- Octree localizer takes 10 minutes to fill for 155k-tetra mesh HOT 6
- tqdm progress bar should show chunks better HOT 1
- Safe termination of JobManager
- tools/ should be revived HOT 2
- Add Dumpable.preDumpHook
- support multiple schedulers
- Convert monitor to and other tools to mupif.monitor (exposed as JSON endpoint in the future) HOT 3
- Clean abstract field class HOT 6
- MuPIF examples HOT 2
- remote logging HOT 1
- checkpointing in workflows
- Export fields to VTK HDF (as an alternative or simplification of .h5 + xdmf)
- temporal field (for both EDM and HeavyStruct) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mupif.