<div dir="ltr">Thanks Nishad for the confirmation. I've filed a bug over at Mantis [1].<div><br></div><div>Cheers,</div><div>Nico</div><div><br></div><div>[1] <a href="http://www.vtk.org/Bug/view.php?id=15889">http://www.vtk.org/Bug/view.php?id=15889</a></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 17, 2015 at 6:39 PM Nishad Sohoni <<a href="mailto:ns451@srcf.net">ns451@srcf.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>

  
    
  
  <div text="#000000" bgcolor="#ffffff">
    Hi Nico,<br>
    <br>
    I can confirm that I see the same behavior. I added the following
    lines to the end of your script:<br>
    <br>
    '''<br>
    rdr = vtk.vtkUnstructuredGridReader()<br>
    rdr.SetFileName('test.vtk')<br>
    rdr.Update()<br>
    loc = rdr.GetOutput()<br>
    pts = numpy_support.vtk_to_numpy( loc.GetPoints().GetData() )<br>
    print pts<br>
    print pts.dtype<br>
    '''<br>
    and regardless of whether I called writer.SetFileTypeToASCII(), the
    dtype was always float64, but there was a loss in precision.<br>
    <br>
    If you can get away with writing a binary file, might I suggest
    using vtkXMLUnstructuredGridWriter? With the above code, python
    printed with the correct precision and dtype (obviously changing to
    vtkXMLUnstructuredGridReader).<br>
    <br>
    Cheers,<br>
    Nishad.</div><div text="#000000" bgcolor="#ffffff"><br>
    <br>
    <br>
    On 17/12/2015 10:40, Nico Schlömer wrote:
    </div><div text="#000000" bgcolor="#ffffff"><blockquote type="cite">
      <div dir="ltr">This smells very much like the vtk_array data being
        interpreted as single precision even though
        <div>```</div>
        <div>  Data type: double<br>
        </div>
        <div>```</div>
        <div>Cheers,</div>
        <div>Nico</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr">On Thu, Dec 17, 2015 at 2:23 AM Nico Schlömer
          <<a href="mailto:nico.schloemer@gmail.com" target="_blank">nico.schloemer@gmail.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div dir="ltr">Hi everyone,
            <div><br>
            </div>
            <div>with</div>
            <div>```</div>
            <div>
              <div>import numpy</div>
              <div>import vtk</div>
              <div>from vtk.util import numpy_support</div>
              <div><br>
              </div>
              <div>mesh = vtk.vtkUnstructuredGrid()</div>
              <div><br>
              </div>
              <div># add points to mesh</div>
              <div>points = numpy.array([</div>
              <div>    [0.123456789, 3.14159265, 0.0]</div>
              <div>    ])</div>
              <div>vtk_points = vtk.vtkPoints()</div>
              <div>vtk_array = numpy_support.numpy_to_vtk(points)</div>
              <div>vtk_points.SetData(vtk_array)</div>
              <div>mesh.SetPoints(vtk_points)</div>
              <div><br>
              </div>
              <div># write to VTK</div>
              <div>writer = vtk.vtkUnstructuredGridWriter()</div>
              <div>writer.SetFileTypeToASCII()</div>
              <div>writer.SetFileName('test.vtk')</div>
              <div>writer.SetInputData(mesh)</div>
              <div>writer.Write()</div>
            </div>
            <div>```</div>
            <div>I noticed that, although the `point` is given with some
              precision, the output `test.vtk` file only contains 6
              digits of accuracy,</div>
            <div>```</div>
            <div>0.123457 3.14159 0<br>
            </div>
            <div>```</div>
            <div>The numpy data type hosts 8 digits.</div>
            <div><br>
            </div>
            <div>Is this a bug or expected? How to mitigate?</div>
            <div><br>
            </div>
            <div>Cheers,</div>
            <div>Nico</div>
          </div>
        </blockquote>
      </div>
      </blockquote></div><div text="#000000" bgcolor="#ffffff"><blockquote type="cite"><pre>
<fieldset></fieldset>
_______________________________________________
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a>

Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a>

Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a>

Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" target="_blank">http://markmail.org/search/?q=vtkusers</a>

Follow this link to subscribe/unsubscribe:
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a>
</pre>
    </blockquote>
  </div>

_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div>