[Paraview] [EXTERNAL] RE: Saving as csv data

Moreland, Kenneth kmorel at sandia.gov
Mon Oct 9 17:15:35 EDT 2017


Teng,

GetCellData is a function. You have to call the function by adding parentheses to the call. Specifically, change

data_cell = rawData.GetCellData

to

data_cell = rawData.GetCellData()

That will return a class from which you can pull the data array for the stress field. (For example, data_cell.GetArray(0).)

-Ken

From: Li, Teng [mailto:tengli2 at illinois.edu]
Sent: Monday, October 9, 2017 2:23 PM
To: Moreland, Kenneth <kmorel at sandia.gov>; paraview at paraview.org
Subject: [EXTERNAL] RE: [Paraview] Saving as csv data

Hi Moreland,

Thank you for your detailed explanation and two specific solutions.

In order not to lose the accuracy, I will first try to save the stress data as the point data and then process it.

Also, I am searching ways to process the vtk data directly by using python shell. I have been searching the codes to get access to the real data, here are some codes I have:

>>> a =GetActiveSource()                            # First highlight the stress vtk file in pipeline.
>>> a
<paraview.servermanager.LegacyVTKReader object at 0x0000006D080174E0>
>>> a.UpdatePipeline()
>>> rawData = servermanager.Fetch(a)
>>> data_cell = rawData.CELL_DATA_FIELD
>>> data_cell
>>> data_cell = rawData.GetCellData
>>> data_cell
<built-in method GetCellData of vtkCommonDataModelPython.vtkUnstructuredGrid object at 0x0000006D08060648>
>>> print data_cell
<built-in method GetCellData of vtkCommonDataModelPython.vtkUnstructuredGrid object at 0x0000006D08060648>

However, I just have the data information, not the real stress data I need to process. And there are 118 time steps, thus 118 vtk files of my problem. I hope there is a way to process the data in python shell once and the results in all the files will change accordingly. That means I can process the stress component as the data array and do some calculations. And then save them in the old vtk file and visualize them again. That is the idea in my mind now.

And actually, since the csv file records all the stress data (cell data). If I can just print all the data arrays in the csv file and store them as variables in the python shell, I can process them and save as new csv files.

So actually, my question is how I can print out the data, no matter in the vtk files or the csv files by using python shell.

Best,
Teng


Teng Li

Master Candidate in Structures

Department of Civil and Environmental Engineering

University of Illinois at Urbana-Champaign

205 North Mathews Ave, Urbana, IL. 61801

Phone:(217)8196210, Email: tengli2 at illinois.edu<mailto:tengli2 at illinois.edu>





________________________________
From: Moreland, Kenneth [kmorel at sandia.gov]
Sent: Monday, October 09, 2017 1:47 PM
To: Li, Teng; paraview at paraview.org<mailto:paraview at paraview.org>
Subject: RE: [Paraview] Saving as csv data
Teng,

The issue is that your stress field data is associated with the cells and you are writing out the point data in your csv file. Thus, the stress data is not being written. There are two solutions, both with flaws:

Solution 1: When you get the dialog box labeled "Configure Writer (DataSetCSVWriter)" (after you choose a filename), change the option "Field Association" from "Points" to "Cells". If you do this option, you will only get the x, y, and z for the stress (labeled "stress:0", "stress:1", and "stress:2"). You will not get the x, y, z information for the placement of the points.

Solution 2: Before writing out the csv file, run the "Cell Data to Point Data" filter. Then write out the csv file with point data as you have been doing. You will get the x, y, and z for the stress (labeled "stress:0", "stress:1", and "stress:2") and you will also get the positional x, y, and z (labeled "Points:0", "Points:1", and "Points:2"). The problem with this solution is that it will alter the stress data slightly by averaging values of adjacent cells to points.

Also note that neither of these options will automatically write out the magnitude of the stress. To write out the stress magnitude, first run the "Calculator" filter to compute the magnitude of the stress vectors.

-Ken

From: ParaView [mailto:paraview-bounces at paraview.org] On Behalf Of Li, Teng
Sent: Monday, October 9, 2017 11:17 AM
To: paraview at paraview.org<mailto:paraview at paraview.org>
Subject: [EXTERNAL] [Paraview] Saving as csv data

Hi all,

I have a question about saving vtk data in a csv file. Please find the following link for the vtk file:

https://drive.google.com/file/d/0B-Dmy2O1v21NbGlfTm9odlZpa2M/view?usp=sharinghttps://drive.google.com/file/d/0B-Dmy2O1v21NbGlfTm9odlZpa2M/view?usp=sharing

I expected to see 7 components in the csv file I saved: x, y, z, stress_x, stress_y, stress_z, stress_magnitude. However, in the csv file I saved, there are only three columns of data. Please find the csv file I saved:

https://drive.google.com/file/d/0B-Dmy2O1v21NeWZnejVqbHEzME0/view?usp=sharinghttps://drive.google.com/file/d/0B-Dmy2O1v21NeWZnejVqbHEzME0/view?usp=sharing

I saved the vtk file by first highlighting the vtk file in the pipeline, and then click save data. Then I used the default settings. Is there anything wrong in my saving process?

Thanks!

Best,
Teng


Teng Li

Master Candidate in Structures

Department of Civil and Environmental Engineering

University of Illinois at Urbana-Champaign

205 North Mathews Ave, Urbana, IL. 61801

Phone:(217)8196210, Email: tengli2 at illinois.edu<mailto:tengli2 at illinois.edu>




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20171009/6bf6e9dc/attachment-0001.html>


More information about the ParaView mailing list