什么数据格式可以从 Java (Clojure) 写入并由 Paraview 读取?

发布于 2024-12-02 00:10:13 字数 157 浏览 2 评论 0原文

我有一些 Clojure 代码,可以生成常规 3D 数据网格(体素)。我想将其写入一个文件,以便以后可以由 Paraview(以及可能的其他分析/可视化程序)读取。最简单的方法是什么?我的首要任务是简单性,但我也希望它能够很好地扩展,以便我可以将它用于大型数据集。我不需要处理比常规网格更复杂的东西。

I have some Clojure code that generates a regular 3D grid of data (voxels). I want to write this to a file that can be later read by Paraview (and, possibly, other analysis/visualisation programs). What is the simplest way to do this? My main priority is simplicity, but I would also like this to also scale well, so that I can use it for large datasets. I do not need to handle anything more complex than a regular grid.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月亮邮递员 2024-12-09 00:10:13

Paraview 有一个“原始”输入格式,它只是一个二进制值序列,其中 X 变化最快,Z 最慢。以下 Clojure 代码将以这种格式写入双精度序列:

(defn write-doubles [voxels path]
  "write raw data stream - for paraview x must vary fastest."
  (let [out (java.io.DataOutputStream.
              (java.io.BufferedOutputStream.
                (java.io.FileOutputStream. path)))]
    (dorun (map (fn [v] (.writeDouble out v)) voxels))
    (.close out)))

然后,您可以通过选择文件(使用 .raw 扩展名)并输入元数据(原点、步长、范围)将其读入 Paraview对于轴。这不是一个很好的解决方案 - 最好在文件中也包含元数据 - 但它非常简单。它有效。

[注意 - DataOutputStream 生成大端格式的数据]

Paraview has a "raw" input format, which is simply a sequence of binary values, with X varying fastest, Z slowest. The following Clojure code will write a sequence of doubles in this format:

(defn write-doubles [voxels path]
  "write raw data stream - for paraview x must vary fastest."
  (let [out (java.io.DataOutputStream.
              (java.io.BufferedOutputStream.
                (java.io.FileOutputStream. path)))]
    (dorun (map (fn [v] (.writeDouble out v)) voxels))
    (.close out)))

You can then read this into Paraview by selecting the file (use a .raw extension) and entering the metadata (origin, step, range) for the axes. It's not a great solution - it would be better to have the metadata in the file too - but it's very simple. And it works.

[Note - DataOutputStream generates data in big-endian format]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文