emout
EMSES シミュレーション出力の解析・可視化 Python ライブラリ
emout でできること:
.h5グリッド出力とplasma.inp/plasma.tomlを 1 行で読み込めるファサード- データの次元に応じて最適な表示を自動選択する 1D / 2D / 3D プロット
!!key dx=...,to_c=...ヘッダーから自動生成される EMSES ⇄ SI 単位変換(30 種以上の物理量に対応)- EMSES の finbound 境界形状を Python オブジェクトとして操作できる API
- ドキュメント: ユーザーガイド (日本語/English) | API リファレンス
- ノートブック例: 月面帯電シミュレーション結果の可視化
- Agent plugins: emout Context — Codex / Claude Code 標準の plugin marketplace で導入し、repo 外でも可視化 script 作成・改善、単位変換、トラブルシュートを agent に相談できます(導入手順)
インストール
pip install emout
# PyVista による 3D 可視化も標準インストールに含まれます
# インストール済み version と PyPI の更新確認
emout version --check-update
Agent plugins
emout の emout Context plugin は、シミュレーション出力ディレクトリや別 repo で Codex / Claude Code を起動したときにも、emout の軸順序・単位変換・可視化・トラブルシュートの文脈を使えるようにします。
codex plugin marketplace add Nkzono99/emout \
--ref main \
--sparse .agents/plugins \
--sparse plugins/emout-context
codex plugin add emout-context@emout
Claude Code では次のように導入します。
claude plugin marketplace add Nkzono99/emout \
--sparse .claude-plugin plugins/emout-context
claude plugin install emout-context@emout
emout CLI をインストール済みなら、Claude Code 用は emout claude install-plugin、Codex 用は emout codex install-plugin でも導入できます。詳しい導入・更新手順は plugin 導入手順 を参照してください。
クイックスタート
import emout
data = emout.Emout("output_dir")
# 最終ステップの電位を xz 平面(y=ny/2)でプロット — これだけで SI 単位付きカラーマップ
data.phisp[-1, :, data.inp.ny // 2, :].plot()
変数名は EMSES のファイル名から自動解決されます:
data.phisp # 電位 (GridDataSeries — 時系列)
data.nd1p # 種1 数密度
data.j1x # 種1 電流密度 x成分
data.j1xy # j1x + j1y 自動結合 → 2D ベクトル
data.j1xyz # 3D ベクトル
data.icur, data.ocur, data.pbody # テキスト診断出力 (.val_si で SI 変換)
スライスの軸順序は (t, z, y, x) です。
解析・描画で元の系列と座標を保持するためのオプション:
data.phisp.time_series(32, 32, 10, skip_overlap=True) # 再開点の重複を除外
data.phisp[:].mean(axis="x", keep_metadata=True)[-1].plot() # yz 平均断面
data.phisp[-1, ::2, ::2, ::2].plot(coordinates="grid", levels=[0.0])
従来の既定動作も維持します。詳しくは クイックスタート と プロットガイド を参照してください。
周期電場の境界補間と、VTK の値・座標配置を修正するオプションも利用できます:
data = emout.Emout("output_dir", electric_relocation="periodic")
data.phisp[-1].to_vtk("phisp.vti", ordering="vtk", coordinates="grid")
穴表面の描画には consistent=True、平面の場の着色には resolution="grid" を使います。
軌跡の透明度・領域・目盛・カメラの調整は PyVista ガイド、
共有ライブラリの診断は バックトレースガイド を参照してください。
機能ガイド
各機能の詳しい使い方はユーザーガイドを参照してください。
| 機能 | できること | ガイド |
|---|---|---|
| プロット | plot() / cmap() / contour() で 1D/2D プロット |
→ プロット |
| アニメーション | gifplot() で GIF/HTML 生成、複数パネルレイアウト |
→ アニメーション |
| パラメータ | data.inp.nx, data.toml.species[0].wp |
→ パラメータ |
| 単位変換 | data.unit.v.reverse(1.0), data.phisp[-1].val_si |
→ 単位変換 |
| ベクトルデータ | .components["z"] で成分を指定、VectorData / ComponentValues で場と集計値を扱う |
→ クイックスタート |
| 境界メッシュ | data.boundaries.mesh(), plot_surfaces へのオーバーレイ |
→ 境界メッシュ |
| バックトレース | data.trace.forward(...), data.backtrace.get_probabilities(...) |
→ バックトレース |
| 3D (PyVista) | plot3d(mode="box"/"stream"/"quiver") |
→ PyVista 可視化 |
代表的な使い方
プロット
data.phisp[-1, 100, :, :].plot() # 2D カラーマップ
data.phisp[-1, 100, :, :].contour() # 等高線
data.nd1p[-1, 100, :, :].plot(norm="log", vmin=1e-3) # 対数スケール
data.j1xy[-1, 100, :, :].plot() # ストリームライン
data.phisp[-1, :, 32, 32].plot() # 1D プロファイル
アニメーション
data.phisp[:, 100, :, :].gifplot() # Jupyter インライン
data.phisp[:, 100, :, :].gifplot(action="save", filename="out.gif") # GIF 保存
単位変換
data.unit.v.trans(1.0) # SI → EMSES
data.phisp[-1].val_si # 全 3D 配列を SI [V] で取得
境界メッシュ
data.boundaries[0].mesh() # 個別境界の MeshSurface3D
data.phisp[-1].plot_surfaces( # フィールド上にオーバーレイ
ax=ax, surfaces=data.boundaries,
)
粒子データ
p4 = data.p4 # 種4
p4.vx[0].val_si.to_series().hist(bins=200) # 速度分布
追加出力の結合 / 入出力パスの分離
# 継続出力の結合
data = emout.Emout("output_dir", ad="auto")
# 入力ファイルと出力ディレクトリを分離
data = emout.Emout(input_path="/path/to/plasma.toml", output_directory="output_dir")
実験的機能(ポアソン方程式 / バックトレース)
# ポアソン方程式
from emout.utils import poisson
phi = poisson(rho, dx=dx, btypes=btypes, epsilon_0=cn.epsilon_0)
# バックトレース(要 vdist-solver-fortran)
result = data.backtrace.get_probabilities(x, y, z, vx, vy, vz, ispec=0)
result.vxvz.plot()
data.trace と data.backtrace は use_electric_field=False / use_magnetic_field=False で電場・磁場を個別に無効化できます(要 vdist-solver-fortran >= 1.7.0、既定は両方 True)。
コントリビュート
バグ報告・機能提案・PR を歓迎します。
- バグ / 質問: GitHub Issues に再現手順を添えて投稿してください
- PR:
mainから作業ブランチを切り、pytest -qがグリーンの状態で送ってください - ドキュメント:
README.md(日本語)とREADME.en.md(英語)は対応する形で維持されています。片方を更新したらもう片方にも反映してください
開発環境のセットアップやディレクトリ構成は AGENTS.md にまとまっています。
ライセンス
リンク
Metadata
Release files for emout 2.23.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| emout-2.23.1.tar.gz | 244.6 kB | Without provenance | Details for emout-2.23.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| emout-2.23.1-py3-none-any.whl | Python 3 | none | any | Details for emout-2.23.1-py3-none-any.whl |
Total release size: 504.4 kB
Release files / emout-2.23.1.tar.gz
| Download URL | emout-2.23.1.tar.gz |
|---|---|
| Size | 244.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
706a6820ad83005bc67e08fd62128f354fb41c1632f429426e17ca2212cbaf5f
|
|
BLAKE2b-256 checksum How to use checksums |
b4d4854334eb45ce5f065f6f2ddfbc98049421600643e4f3226f75c4ce53e95e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / emout-2.23.1-py3-none-any.whl
| Download URL | emout-2.23.1-py3-none-any.whl |
|---|---|
| Size | 259.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4ea276f325a556d4c5b57d06c9718cce2c8638f60832d49a205030dbd73f540
|
|
BLAKE2b-256 checksum How to use checksums |
fe3e91080c111a53b8325c524ebfb682fad255b4f973499750ba9c1cab70c771
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for emout 2.23.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.