How can I digitise a complex pressure contour plot?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I am trying to digitise a pressure contour plot obtained at a jet engine inlet. My approach is manually tracing each contour using a digitising tool "Engauge" and creating a csv file which is then used in a MATLAB code to convert it into a vtk format. The catch is that the code can only read these contours when each line in the csv file is represented using the same x-coordinates for each line. Below is an example of what I'm digitising.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1297880/image.png)
This works fine when the pressure distribution is vertically stratified as shown, however, when the flow becomes more turbulent at high angles of attack (example below) my digitising tool is unable to create an accurate representation in this format.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1297885/image.png)
I tried different digitising tools but none of them are capable of creating the same x-coordinates for each line and instead they create separate x and y coordinates. Below is a section of the code used to convert the csv file into a vtk file.
% set up radial sweep of points
rad = [1/200:1/200:1];
theta = [0:0.5:360];
% Added zrad for vtkwrite
for k = 1:length(theta)
xrad(:,k) = rad.*cos(theta(k)*pi/180);
yrad(:,k) = rad.*sin(theta(k)*pi/180);
zrad(:,k) = rad.*sin(theta(k)*pi/180)*0;
cpt = zeros(size(xrad));
end
% Read in digitized file (csv)
% First column is X values, the next columns are the y-values of the
% DeltaCpt levels
rawcsvmap = dlmread('simu-cruise4d.csv',';',2,0);
xcontours = rawcsvmap(:,1);
ycp(:,:) = rawcsvmap(:,2:length(rawcsvmap(1,:)));
cptvalues = [ -0.1:-0.1:-0.7 ];
for z=1:length(theta)
for q = 1:length(xrad(:,1))
[ minxdist(q), xidx(q) ] = min(abs(xrad(q,z)-xcontours(:)));
for v = 1:length(cptvalues)
if yrad(q,z) <= ycp(xidx(q),v);cpt(q,z) = cptvalues(v);end
end
end
end
figure;pcolor(xrad,yrad,cpt),shading flat,axis equal tight, colorbar,caxis([-1. 0]),colormap pink;
This is the output for the first case when pressure is evenly distributed:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1297890/image.png)
I was thinking of adjusting the code to accept different x and y values but I'm not sure how to go about it. I'm guessing there are other ways of going about digitising such a plot in MATLAB as well but any help would be appreciated.
Thank you in advance.
1 Kommentar
Walter Roberson
am 3 Mär. 2023
Did you look in the File Exchange for contributions with the tag "digitize"?
Antworten (1)
Vijeta
am 3 Mär. 2023
Hi Jakub,
Based on the code you provided, it seems like you are plotting a pressure contour map on a cylindrical coordinate system.
To modify this code to accept different “x “and “y” values for each contour line, you will need to modify the section of the code that interpolates the contour values onto the mesh. Currently, the code uses the "minxdist" and "xidx" arrays to find the closest x-coordinate in the "xcontours" array for each point in the mesh. You will need to modify this section of the code to handle the case where each contour line has different x-coordinates.
One approach could be to loop over each contour line in the CSV file, and interpolate the contour values onto a mesh defined by the x and y values for that line. You could then combine the interpolated values for each line into a single mesh, and plot the resulting contour map.
Here is some sample code that demonstrates this approach:
% Read in digitized file (csv)
% First column is X values, the next columns are the y-values of the
% DeltaCpt levels
rawcsvmap = dlmread('simu-cruise4d.csv',';',2,0);
% Loop over each contour line
cptvalues = [-0.1:-0.1:-0.7];
cptmesh = zeros(length(rad), length(theta));
for i = 1:size(rawcsvmap, 2)-1
% Get x and y coordinates for this contour line
xcontours = rawcsvmap(:, 1);
ycp = rawcsvmap(:, i+1);
% Interpolate contour values onto mesh
xi = xcontours;
yi = ycp;
[XI, YI] = meshgrid(xi, yi);
ZI = repmat(cptvalues, length(xi), 1);
F = scatteredInterpolant(XI(:), YI(:), ZI(:), 'linear', 'none');
[XI, YI] = meshgrid(xrad(:, 1), yrad(1, :));
ZI = F(XI, YI);
% Add interpolated values to combined mesh
cptmesh = cptmesh + ZI;
end
% Plot contour map
figure;
pcolor(xrad, yrad, cptmesh);
shading flat;
axis equal tight;
colorbar;
caxis([-1, 0]);
colormap pink;
0 Kommentare
Siehe auch
Kategorien
Mehr zu Contour Plots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!