Skip to main content

Lang: 日本語 | English

emout

PyPI version Python Docs CodeQL License: MIT

EMSES シミュレーション出力の解析・可視化 Python ライブラリ

emout でできること:

  • .h5 グリッド出力と plasma.inp / plasma.toml を 1 行で読み込めるファサード
  • データの次元に応じて最適な表示を自動選択する 1D / 2D / 3D プロット
  • !!key dx=...,to_c=... ヘッダーから自動生成される EMSES ⇄ SI 単位変換(30 種以上の物理量に対応)
  • EMSES の finbound 境界形状を Python オブジェクトとして操作できる API


インストール

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 にまとまっています。


ライセンス

MIT License

リンク

Metadata

Release files for emout 2.23.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for emout 2.23.0
File Size Uploaded Provenance Actions
emout-2.23.0.tar.gz 240.5 kB Without provenance Details for emout-2.23.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for emout 2.23.0
File Interpreter ABI Platform Actions
emout-2.23.0-py3-none-any.whl Python 3 none any Details for emout-2.23.0-py3-none-any.whl

Total release size: 498.7 kB

Release files / emout-2.23.0.tar.gz

Download URL emout-2.23.0.tar.gz
Size 240.5 kB
Tags Source
SHA-256 checksum
How to use checksums
96478ee7b0106b456caf9d69bfee9dff2a622e3f18f2622d7c4c323a9e2be8b1
BLAKE2b-256 checksum
How to use checksums
78823b7a354e59121058536ed3a9e70d03eee5604433558d42eea34d6869198a
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.0-py3-none-any.whl

Download URL emout-2.23.0-py3-none-any.whl
Size 258.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47be3f5b89db12390f1abf8f2d98f472279a629ce39aaffc34bc405d98539917
BLAKE2b-256 checksum
How to use checksums
30efb6b22fd1e958bfeecd52580de4b8603f549a5b066482b131755de2161c7c
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.0

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.

Release history Release notifications | RSS feed

This release

2.23.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page