上海市做网站的公司,珠海哪里学网站开发,快速仿站网站建设,网站制作厦门# -*- coding: utf-8 -*-Created on Wed Sep 20 20:40:30 2023
联系QQ:3123575367#xff0c;专业SCR脱硝仿真。
该程序用来处理fluent通过export-solution-ASCII-Space导出的数据#xff0c;可计算标准偏差SD、相对标准偏差RSD,适用于求解平面的相对均匀…# -*- coding: utf-8 -*-Created on Wed Sep 20 20:40:30 2023
联系QQ:3123575367专业SCR脱硝仿真。
该程序用来处理fluent通过export-solution-ASCII-Space导出的数据可计算标准偏差SD、相对标准偏差RSD,适用于求解平面的相对均匀度
author: PS
import chardet #识别文件的编码格式#确定文件编码格式
def check_code(text):#detect函数只需要一个 非unicode字符串参数返回一个字典。该字典包括判断到的编码格式及判断的置信度。with open(text, rb) as f: adchar chardet.detect(f.read()) # adchar chardet.detect(text)# 由于windows系统的编码有可能是Windows-1254,打印出来后还是乱码,所以不直接用adchar[encoding]编码if adchar[encoding] gbk or adchar[encoding] GBK or adchar[encoding] GB2312:return GB2312else:return utf-8#读取文件并进行计算
def read_file_text(file_url):with open(file_url, r,encodingcheck_code(file_url)) as f0:row_nul 1for i in range(row_nul):next(f0)#跳行f0_word f0.readlines()ls []x[]y[]#将文本数据按照行整理到列表中for line in f0_word:line line.strip(\n)#将每段的回车替换为空格line line.replace(),)words line.split()#将字符串以空格分开ls.append(words)#将列表中的数据按照列提取出来for lin in ls:for l in range(len(lin)):lin[l] lin[l].strip(()#去掉左右的while in lin:#将空格字符串删除lin.remove()#最后一列为空值需要跳过if lin ls[-1]:breakx.append(float(lin[0]))#保存文本的第0列数据y.append(float(lin[4]))#保存文本的第4列数据#计算# print(y)#计算含0的数据mean sum(y)/len(y)qh []for num in y:qh.append(pow(num-mean,2))qv pow(sum(qh)/(len(qh)-1),0.5) #标准偏差 cv qv/mean #相对标准偏差print(未操作数据 )print(f平均值为{round(mean,4)})print(f标准偏差SD为{round(qv*100,4)} %\n相对标准偏差RSD为{round(cv*100,4)} %)#计算去除0后的数据y_no_zero [i for i in y if i! 0] #去除0元素mean_no_zero sum(y_no_zero)/len(y_no_zero)qh_no_zero [pow(num-mean_no_zero,2) for num in y_no_zero]qv_no_zero pow(sum(qh_no_zero)/(len(qh_no_zero)-1),0.5)cv_no_zero qv_no_zero/mean_no_zeroprint(------------去除 0 数据------------)print(f平均值为{round(mean_no_zero,4)})print(f标准偏差SD为{round(qv_no_zero*100,4)} %\n相对标准偏差RSD为{round(cv_no_zero*100,4)} %)read_file_text(rF:\1\t) #只需要更改此处输入
与之前的区别在于一个是通过xyplot导出的一个是export两者计算差距较小https://blog.csdn.net/weixin_43245453/article/details/133220734。 截图输出如下