用后处理软件处理的云图会出现这样或那样的不满意,其实我们可以将求解数据导出以后,借助python定制云图。

我们以fluent为例

求解完成之后,我们将我们需要做云图的物理量以ASCII导出

如下的python脚本

代码如下:

# -*- coding: utf-8 -*-

import numpy as np

import csv

import matplotlib.pyplot as plt

from scipy.interpolate import griddata

#==============================

#该段代码来支持在图片中显示中文

#==============================

plt.rcParams['font.sans-serif'] = ['SimHei']

plt.rcParams['axes.unicode_minus']=False

#保存x坐标

x=[]

#保存y坐标

y=[]

#保存导出的速度

velocity=[]

#读取csv文件,当然也可以读取类似txt之类的文件

with open(r'/home/dell/new/contour/new','r')  as  csvfile:

#指定分隔符为",",因为我们刚才导出时就是逗号

plots=csv.reader(csvfile,delimiter=',')

#循环读取到的文件

for row in plots:

#为了跳过文件前面的非数据行

if plots.line_num == 1:

continue

x.append(float(row[1]))

y.append(float(row[2]))

velocity.append(float(row[3]))

#如果数值过小,则视为0,防止出现非数的情况

y[y<1e-10]=0

xi=np.linspace(min(x),max(x),10000)

yi=np.linspace(min(y),max(y),10000)

#x,y坐标必须维数一致,且为二维

[X,Y]=np.meshgrid(xi,yi)

#对x,y的速度进行插值,插值的方法有'cubic','linear','nearest'

#注意传入的坐标参数需要以元组的形式成对传入

#当然matplotlib也自带griddata插值函数,该函数每个坐标是一个参数

#但matplotlib自带的griddata插值函数只能使用默认的linear插值

# Velocity=griddata((x,y),velocity,(X,Y),method='cubic')

# Velocity=griddata((x,y),velocity,(X,Y),method='nearest')

Velocity=griddata((x,y),velocity,(X,Y),method='linear')

#画出云图

#20为几条等值线,alpha为透明度,cmap对应的色彩风格

im=plt.contourf(X,Y,Velocity,20,alpha=0.75,cmap=plt.cm.jet)

#画出等值线

#color为等值线的颜色,linewidth为等值线的宽度

isoline=plt.contour(X,Y,Velocity,20,color='black',linewidth=0.1)

#在等值线上标上对应的数值

#inline表示是否将数值标在等值线上,fontsize为等值线上数值的字体的大小

plt.clabel(isoline,inline=True,fontsize=10)

#输出云图的legend

#orientation表示legend的位置,默认值为vertical,横置为horizontal

cbar=plt.colorbar(im, orientation='vertical', shrink=0.8)

#设置legend的标题

cbar.set_label('m/s')

#设置legend的范围

cbar.set_ticks(np.linspace(0,0.114,10))

#云图的标题

plt.title(u"速度云图")

#显示云图

plt.show()​

最新文章

  1. ArcGIS Engine开发之图形查询
  2. 重温 w3cshool css3
  3. 阅读《LEARNING HARD C#学习笔记》知识点总结与摘要四
  4. Visual Studio Professional 2015 key
  5. ExtJS的MessageBox总结
  6. mac svn的替代品CornerStone
  7. ssh连接失败解决方法
  8. MySQL字符串函数
  9. [转载]监控 Linux 性能的 18 个命令行工具
  10. Android - 错: java.lang.IllegalStateException: Already attached
  11. java 多线程访问同一个对象数据保护的问题
  12. C# -- FTP上传下载
  13. Matrix [POJ3685] [二分套二分]
  14. 论文笔记:Decoders Matter for Semantic Segmentation: Data-Dependent Decoding Enables Flexible Feature Aggregation
  15. jmeter导入DB数据再优化
  16. 脑残式网络编程入门(六):什么是公网IP和内网IP?NAT转换又是什么鬼?
  17. maven五:查找jar包坐标,选择jar包版本
  18. GRADLE下运行main函数/执行测试用例
  19. SQL Server--疑难杂症之坑爹的Windows故障转移群集
  20. Android 仿微信的朋友圈发布(1)

热门文章

  1. number与string的转换
  2. vue watch 的简单使用
  3. centos 7.6 安装php70
  4. 【Java】锁机制
  5. yum [Errno 12] Timeout on
  6. wampserver环境配置局域网访问
  7. linux系统编程面试题
  8. node+express 搭建本地服务
  9. P2756 飞行员配对方案问题[二分图最大匹配]
  10. 《少年先疯队》第八次团队作业:Alpha冲刺第四天