|
[Sponsors] |
Any way to extract data from contour plots using paraView? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 26, 2010, 19:28 |
Any way to extract data from contour plots using paraView?
|
#1 |
New Member
|
Hi all,
I have a newbie question about how to extract x, y coordinates of interpolation points on a contour and their interpolated field values by using paraView? Thanks. Angela |
|
October 27, 2010, 06:25 |
|
#2 |
Senior Member
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25 |
after contour
choose : Filters -> Data analysis -> integrate Variables then a new window will open, then in "showing" tab , choose "contour" if you want to save data in ".csv" you can choose : file -> save data |
|
October 27, 2010, 13:13 |
|
#3 |
New Member
|
||
July 5, 2016, 12:13 |
|
#4 |
Senior Member
Alex
Join Date: Jan 2014
Posts: 126
Rep Power: 12 |
I have also exported my contour data and the export seems fine. However, I plan to plot the contour with tikz.
It seems that the contour data is highly unsorted. Thus, the tikz plots don't look like they should. Is there any way to pre-sort the contour lines before exporting or do I have to manually piece the points together? Cheers Alex |
|
November 29, 2017, 02:55 |
|
#5 | |
Member
Join Date: Apr 2012
Location: Trivandrum
Posts: 37
Rep Power: 14 |
Quote:
Thanks |
||
November 29, 2017, 05:42 |
|
#6 | |
Senior Member
Alex
Join Date: Jan 2014
Posts: 126
Rep Power: 12 |
Quote:
Hey, what's up? yes, I have managed to sort the contours by coding an octave file that reads in all the unsorted contours and builds a matrix that compares the vector length difference of all points to the current and reconstructs the contours. You might have to do a little tweaking depending on your columns of the .csv output file. This code currently sorts velocity contours I think. You can possibly also run this in matlab although I am not sure if matlab recognizes all the octave syntax correctly. Proof picture below so you know what it actually looks like afterwards in tikz (or gnuplot, whatever) Code:
#!/usr/bin/octave -qf format short filename = 'yourfile.csv'; M = dlmread(filename,',',1,0); %read in original matrix % [p U1 U2 U3 N0 N1 N2 x y z] M = [M(:,6) M(:,7) M(:,8) M(:,5)]; %reduce Matrix to important info % [x y z u] M = sortrows(M,2); %sort Matrix Y axis M = M([(end/2+1):end],:); %isolate positive Y-Values M(:,2) = []; %delete Y-column % [x z u] %M(:,3) = M(:,3) * 1.205; %Calculate real pressure from incompressible M = sortrows(M,3); %sortieren pressure fields p = -10^10; n = 1; nContours = 1; % Datei öffnen ISOPlot = fopen('pressureIsoLines.txt', 'w'); fprintf(ISOPlot, ' x y p \n'); do if (M(n,3) != p) nContours++; n0 = n; p = M(n,3); do n++; if (n == rows(M)) break; endif until (M(n+1,3) != p) n1 = n; MTemp = M([n0:n1],:); %Temporäre Matrix Pressure-Isoline MTemp = sortrows(MTemp,1); %approx. average of matrix MTempInit = MTemp; MTIso = []; MdTemp = []; rRef = MTemp(ceil(end/2),:); %start ref point MTemp(ceil(end/2),:) = []; %delete ref MdTemp = [sqrt((MTemp(:,1)-rRef(1)).^2 + (MTemp(:,2) - rRef(2)).^2) MTemp]; MdTemp = sortrows(MdTemp,1); %Matrix: vector differences from ref point MTIso = [0 rRef]; MTIso = [MdTemp(1,:) ; MTIso]; rRef = MdTemp(1,(2:end)); %new ref point for i = 1:rows(MTemp) if (MTemp(i,:) == rRef) MTemp(i,:) = []; break; endif endfor escape = 0; do rRef1 = MTIso(1,(2:end)); %new ref point rRef2 = MTIso(end,(2:end)); MTempRef = MTemp; for i = 1:rows(MTempRef) if (MTempRef(i,:) == rRef1) MTempRef(i,:) = []; break; endif endfor for i = 1:rows(MTempRef) if (MTempRef(i,:) == rRef2) MTempRef(i,:) = []; break; endif endfor MdTemp1 = [sqrt((MTempRef(:,1)-rRef1(1)).^2 + (MTempRef(:,2) - rRef1(2)).^2) MTempRef]; MdTemp1 = sortrows(MdTemp1,1); %new vector diff matrix if (rows(MdTemp1)>0) dCheck1 = MdTemp1(1,1); else dCheck1 = 10e3; endif MdTemp2 = [sqrt((MTempRef(:,1)-rRef2(1)).^2 + (MTempRef(:,2) - rRef2(2)).^2) MTempRef]; MdTemp2 = sortrows(MdTemp2,1); %new vector diff matrix if (rows(MdTemp2)>0) dCheck2 = MdTemp2(1,1); else dCheck2 = 10e3; endif if (dCheck1 < dCheck2) if (rows(MdTemp1) > 0) MTIso = [MdTemp1(1,:) ; MTIso]; rRef = rRef1; %new ref point endif else if (rows(MdTemp1) > 0) MTIso = [MTIso ; MdTemp2(1,:)]; rRef = rRef2; %new ref point endif endif if (rows(MTemp) > 2) %delete ref point for i = 1:rows(MTemp) if (MTemp(i,:) == rRef) MTemp(i,:) = []; break; endif endfor else MTemp = []; escape = 1; endif until (escape == 1) endif if (n < rows(M)) n++; endif for i = (1:rows(MTIso)) fprintf(ISOPlot, ' %f %f %f \n', MTIso(i,2:end)'); if (MTIso(i,1) >= 0.15) fprintf(ISOPlot, '\n'); endif endfor fprintf(ISOPlot, '\n'); until (n == rows(M)) fclose(ISOPlot); |
||
November 29, 2017, 20:02 |
|
#7 | |
Member
Join Date: Apr 2012
Location: Trivandrum
Posts: 37
Rep Power: 14 |
Quote:
Thanks for the code! I have been searching yesterday and trying to tackle with a matlab code 'points2contour', which I found in mathworks website. I will try to modify your code as per my data and let you know the results. Also, I use octave, not comfortable with matlab. Your reply and willingness to help is really appreciated. Thanks |
||
November 30, 2017, 10:42 |
|
#8 | |
Senior Member
Alex
Join Date: Jan 2014
Posts: 126
Rep Power: 12 |
Quote:
Cheers |
||
December 2, 2017, 22:54 |
|
#9 | |
Member
Join Date: Apr 2012
Location: Trivandrum
Posts: 37
Rep Power: 14 |
Quote:
Thanks for the detailed info. I have used the code without much modifications, though I faced some minor issues. I noticed that an iso-contour from paraview bears not exactly same contour values, minor deviations in the order of 0.001 were present. So, I had to re-export the data from paraview with precision set to 4, and thus able to sort most of the contours. Still,some repetitions and random jumps were there. But, I managed to edit the output file manually without much headache. Please see the figure attached. Thanks again for the help! Jabir |
||
December 3, 2017, 05:27 |
|
#10 | |
Senior Member
Alex
Join Date: Jan 2014
Posts: 126
Rep Power: 12 |
Quote:
looks good so far some minor manipulation of the output was also necessary for me. Instead of lowering the output resolution you could have also put in another threshold for the p value in form of changing: Code:
do if (M(n,3) != p) nContours++; n0 = n; p = M(n,3); Code:
do if (M(n,3) < 0.99 * p || M(n,3) > 1.01 * p) nContours++; n0 = n; p = M(n,3); Best wishes for the rest of your project Alex |
||
December 3, 2017, 21:37 |
|
#11 | |
Member
Join Date: Apr 2012
Location: Trivandrum
Posts: 37
Rep Power: 14 |
Quote:
That's a cool idea to give some tolerance to the contour magnitude. I will definitely try this next time. Thanks for your help. I really appreciate it. Jabir |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to extract data for contour plot? | Farid | CFX | 9 | April 3, 2017 20:07 |
[OpenFOAM] extracting data from paraview | tharem | ParaView | 1 | January 18, 2011 00:45 |
Extract data we want from Techplot to a data file | vetnav | Main CFD Forum | 0 | July 28, 2010 21:17 |
How to update polyPatchbs localPoints | liu | OpenFOAM Running, Solving & CFD | 6 | December 30, 2005 18:27 |
drawing of contour plots | chinthakindi | Main CFD Forum | 1 | April 27, 2004 05:33 |