资源简介
使用tecplot的官方接口,实现二维流场图自动生成,python语言实现
代码片段和文件信息
# coding: utf-8
import logging
import sys
import os
import shutil
import tecplot as tp
import numpy as np
import pyodbc
import datetime
from PIL import Image
from tecplot.constant import \
PlotTypeColorValueLocationArrowheadstyleReadDataOption\
LinePatternVectorTypeBorderLocationEdgeTypeExportRegion
logging.basicConfig(stream=sys.stdout level=logging.INFO)
#源数据文件所在的根路径
CONFIGPATH = ‘D:\TecplotData‘
#查看目录下是否有新的数据,并保存路径和时间信息
filename = []
filelist = []
timelist = []
images = [] #存储生成的图片,用于生成GIF
starttime = 0
filerootpath = ‘‘
for dir in os.listdir(CONFIGPATH):
if os.path.isdir(os.path.join(CONFIGPATHdir)):
if dir.startswith(‘src-‘):
starttime = datetime.datetime.strptime(dir[4:]‘%Y-%m-%d‘)
filerootpath = os.path.join(CONFIGPATHdir)
for file in os.listdir(os.path.join(CONFIGPATHdir)):
if os.path.splitext(file)[1] == ‘.dat‘:
filename.append(int(os.path.splitext(file)[0]))
filename.sort()
for file in filename:
filelist.append(os.path.join(filerootpath str(file)+‘.dat‘))
time = starttime + datetime.timedelta(seconds=file)
timelist.append(time.strftime(“%Y-%m-%d %H:%M:%S“))
#打开数据库连接
cursor = conn.cursor()
#对每个数据文件执行tecplot处理过程
for i in range(len(filelist)):
#初始化参数
infilepath = filelist[i]
time = timelist[i]
#加载数据
tp.data.load_tecplot(infilepathread_data_option=ReadDataOption.Replace)
#设置frame、dataset、plot
frame = tp.active_frame()
dataset = frame.dataset
plot = frame.plot(PlotType.Cartesian2D)
plot.activate()
#连接数据库,查询兴趣点POI坐标,查找对应的属性值
cursor.execute(‘select IDXY from hhg_poipoint‘)
rows = cursor.fetchall()
insertValues = []
for row in rows:
probeat = tp.data.query.probe_at_position(row.X row.Y)
value = dataset.VariablesNamedTuple(*probeat.data)
insertValues.append((row.ID time value.bn value.d value.u value.v))
#保存POI值到数据库
conn.commit()
#添加文字--不支持中文
frame.add_text(time (2.31406 96.4344) bold=True)
frame.add_text(‘CaoFeidian‘(45.3899 86.2237) bold=True)
frame.add_text(‘TiJin‘(9.66144 74.8784) bold=True)
frame.add_text(‘HuangHua‘(10.958 23.5008) bold=True)
frame.add_text(‘BinZhou‘(35.8815 8.10373) bold=True)
frame.add_text(‘1m/s‘(2.6022 4.86224) bold=True)
#设置坐标轴、视窗
#x轴
xaxis = plot.axes.x_axis
xaxis.title.show = False
xaxis.ticks.show = False
xaxis.tick_labels.show = False
xaxis.min = 539555.567504
xaxis.max = 691335.966177
#y轴
yaxis = plot.axes.y_axis
yaxis.title.show = False
yaxis.ticks.show = False
yaxis.tick_labels.show = False
yaxis.min = 4209133.69477
yaxis.max = 4347647.3623
#视窗
plot.axes.viewport.left = 0
plot.axes.viewport.right = 100
plot.axes.viewport.top = 100
plot.axes.viewport.bottom = 0
相关资源
- [『编程语言』] 小甲鱼零基础入门学
- 区块链入门学习代码 含完整挖矿、
- 随机森林做泰坦尼克号案例的Python实
- 基于Python的SVM解决异或问题
- Tensorflow笔记-中国大学全部讲义源代码
- Python识别深圳信用网验证码的完整代
- C4.5决策树算法的Python代码和数据样本
- python音乐播放+滤波器
- 树莓派利用python、opencv、PyALPR识别车
- python 数独游戏源码
- 爬取某块区域的实时交通态势数据,
- Anaconda3-5.3.1-Windows-x86_64 (Python3.x版本
- DS_Store文件泄漏利用python脚本
- ArcGIS10.1中利用python语言批量实现遥感
- 用自己的数据制作python版本cifar10数据
- python遗传算法求函数极值.py
- Python教程.rar
- python数据挖掘分类聚类回归关联算法
- Python爬虫源码—爬取猫途鹰官方旅游
- 密度聚类(Density peaks Clustering)Pyth
- python摄像头视频显示到TK窗口
- 国际麻将AI-根据向听数计算最优操作
- 爬取瓜子二手车.py
- 人脸识别UI Pythone+pyq5+opencv 多线程模式
- pcap-1.1.win32-py2.7.exe
- Python制作的汉诺塔演示小脚本
- python django+bootstrap实现用户管理系统
- python+MySQL+bootstrap+ajax项目
- 基于Python的双路视频传输及双显示系
- python模型restful接口
评论
共有 条评论