5. Tonatiuh's output files format (输出文件格式)
根据导出配置,Tonatiuh会生成不同格式的输出文件。
5.1 二进制文件格式
文件结构组成:
- ASCII描述文件:包含参数定义和元数据
- 二进制数据文件:包含实际的光子数据
图8: ASCII描述文件格式示例,显示参数定义区域、表面信息区域和每光子功率值
ASCII描述文件结构:
START PARAMETERS
id # 光子ID
x # x坐标
y # y坐标
z # z坐标
side # 表面侧面标识
surface_ID # 表面标识符
END PARAMETERS
START SURFACES
1 //SunNode/RootNode/Tower/Target/TargetRotationNode/TargetSurface
END SURFACES
1.91072e-06 # 每光子功率值
5.2 数据后处理
Mathematica代码示例:
mathematica
(* 读取Tonatiuh二进制结果文件 *)
ReadTonatiuhResults[filename_] := BinaryReadList[filename, "Real64", ByteOrdering -> +1];
(* 创建光子数据元组 *)
nElementsPerPhoton = Length[parameters];
photonMapAll = Partition[ReadTonatiuhResults[filename], nElementsPerPhoton];
R语言代码示例:
r
# 读取二进制文件并创建光子数据矩阵
ReadTonatiuhData <- function(tonatiuhDataFile, nParameters){
fileName <- file(tonatiuhDataFile, "rb")
fileSize <- file.info(tonatiuhDataFile)$size
photonData <- readBin(fileName, what="numeric", n=(fileSize)/8, endian="big")
close(fileName)
nPhotons <- length(photonData)/nParameters
photonMap <- photonData
dim(photonMap) <- c(nParameters, nPhotons)
photonMap <- t(photonMap)
return(photonMap)
}