我有一个 python 脚本,可以从我的 odb 文件中提取温度,但是我希望它将温度输出从华氏度转换为摄氏度。我们输入所有内容为英制单位,然后我们的客户想要摄氏度。我该如何修改以下脚本自动将我的输出转换为摄氏度?
from odbAccess import *
import sys
# Open output file for writing
outputFile = open('OutputFileName.txt','w')
# Define odb file names
odbNameList = ('JobName.odb',)
# Define instance name and set name
instanceNameList = ('INSTANCE-1','INSTANCE-2',)
setName = 'SET-1'
# Process odb files
for odbName in odbNameList:
# Open file for reading
odb = openOdb(path=odbName)
# Process steps
for stepName in odb.steps.keys():
# Get field output objects for variables TEMPERATURE and ELEMENT VOLUME
temperatureField = odb.steps[stepName].frames[-1].fieldOutputs['NT11']
for instanceName in instanceNameList:
setData = odb.rootAssembly.instances[instanceName].nodeSets[setName]
tempField = temperatureField.getSubset(region=setData, position=NODAL)
tempValues = tempField.values
tmax = 0
for v in tempValues:
if v.data > tmax:
tmax = v.data
outputFile.write('%s %s %s %6.3f\n' % (odbName, stepName, instanceName, tmax))
# Close odb file
odb.close()
# Close output file
outputFile.close()