Name | emout JSON |
Version |
1.3.3
JSON |
| download |
home_page | None |
Summary | Emses output manager |
upload_time | 2024-11-28 11:27:58 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | MIT License Copyright (c) 2020 Nkzono99 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
visualization
simulation
emses
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# emout
EMSESの出力ファイルを取り扱うパッケージ
* Documentation: https://nkzono99.github.io/emout/
## Installation
```
pip install emout
```
## Example code
- [Visualization of simulation results for lunar surface charging](https://nbviewer.org/github/Nkzono99/examples/blob/main/examples/emout/example.ipynb)
## Usage
以下のようなフォルダ構成の場合の使い方.
```
.
└── output_dir
├── plasma.inp
├── phisp00_0000.h5
├── nd1p00_0000.h5
├── nd2p00_0000.h5
├── j1x00_0000.h5
├── j1y00_0000.h5
...
└── bz00_0000.h5
```
### データをロードする
``` python
>>> import emout
>>> data = emout.Emout('output_dir')
>>> data.phisp # data of "phisp00_0000.h5"
>>> len(data.phisp)
11
>>> data.phisp[0].shape
(513, 65, 65)
>>> data.j1x # data from "j1x00_0000.h5"
>>> data.bz # data from "bz00_0000.h5"
>>> data.j1xy # vector data object from "j1x00_0000.h5" and "j1y00_0000.h5"
>>> data.rex # data from "rex00_0000.h5", created by relocating 'ex00_0000.h5'
>>> data.icur # data from "icur" as pandas.DataFrame
>>> data.pbody # data from "pbody" as pandas.DataFrame
```
### パラメータファイル(plasma.inp)を取得する
```python
>>> data.inp # namelist of 'plasma.inp'
>>> data.inp['tmgrid']['nx'] # inp[group_name][parameter_name]
64
>>> data.inp['nx'] # can omit group name
64
>>> data.inp.tmgrid.nx # can access like attribute
>>> data.inp.nx # can also omit group name
```
### データをプロットする
```python
>>> x, y, z = 32, 32, 100
>>> data.phisp[-1, z, :, :].plot() # plot xy-plane at z=100
>>> data.phisp[-1, :, y, x].plot() # plot center line along z-axis
>>> data.phisp[-1, z, :, :].plot(use_si=True) # can plot with SI-unit (such as x[m], y[m], phisp[V])
>>> data.phisp[-1, z, :, :].plot() # use_si=True by default
>>> data.phisp[-1, z, :, :].plot(show=True) # to view the plot on the fly (same as matplotlib.pyplot.show())
>>> data.phisp[-1, z, :, :].plot(savefilename='phisp.png') # to save to the file
>>> data.j1xy[-1, z, :, :].plot() # can plot vector data as a streamline
```
### データのアニメーションを作成する
```python
>>> x, y, z = 32, 32, 100
>>> data.phisp[:, z, :, :].gifplot() # can generate time-series animation
>>> data.phisp[:, z, :, :].gifplot(axis=0) # Selectable data axes to animate
# (if axis=0, the first axis, i.e. the time axis, is selected, by default axis=0)
>>> data.phisp[:, z, :, :].gifplot(action='save', filename='phisp.gif') # for save on a file
>>> data.phisp[:, z, :, :].gifplot(action='to_html') # for display on jupyter
# If you want to annimation several data at once,
# prepare multiple frame update objects for each data at first.
>>> updater0 = data.phisp[:, z, :, :].gifplot(action='frames', mode='cmap')
>>> updater1 = data.phisp[:, z, :, :].build_frame_updater(mode='cont') # == gifplot(action='frames', mode='cont')
>>> updater2 = data.nd1p[:, z, :, :].build_frame_updater(mode='cmap', vmin=1e-3, vmax=20, norm='log')
>>> updater3 = data.nd2p[:, z, :, :].build_frame_updater(mode='cmap', vmin=1e-3, vmax=20, norm='log')
>>> updater4 = data.j2xy[:, z, :, :].build_frame_updater(mode='stream')
>>> layout = [[[updater0, updater1], [updater2], [updater3, updater4]]]
>>> animator = updater0.to_animator(layout=layout) # create animator object from frame object (phisp: cmap+cont, nd1p: cmap, nd2p: cmap+current-stream)
>>> animator.plot(action='to_html') # write plot function like gifplot
```
### 単位変換を行う
> [!NOTE]
> パラメータファイル (plasma.inp) の一行目に以下を記述している場合のみ、EMSES単位からSI単位系への変換がサポートされます。
>
> ```
> !!key dx=[0.5],to_c=[10000.0]
> ```
>
> ```dx```: グリッド幅 [m]
> ```to_c```: EMSES内部での光速の規格化された値
``` python
>>> data.unit.v.trans(1) # velocity: Physical unit to EMSES unit
3.3356409519815205e-05
>>> data.unit.v.reverse(1) # velocity: EMSES unit to Physical unit
29979.2458
```
### SI単位系への変換
> [!NOTE]
> パラメータファイル (plasma.inp) の一行目に以下を記述している場合のみ、EMSES単位からSI単位系への変換がサポートされます。
>
> ```
> !!key dx=[0.5],to_c=[10000.0]
> ```
>
> ```dx```: グリッド幅 [m]
> ```to_c```: EMSES内部での光速の規格化された値
``` python
>>> # SI単位系に変換した値を取得する
>>> phisp_volt = data.phisp[-1, :, :, :].val_si
>>> j1z_A_per_m2 = data.j1z[-1, :, :, :].val_si
>>> nd1p_per_cc = data.nd1p[-1, :, :, :].val_si
```
### 継続したシミュレーション結果を扱う
``` python
>>> import emout
>>> data = emout.Emout('output_dir', append_directories=['output_dir_2', 'output_dir_3'])
>>>
>>> data = emout.Emout('output_dir', ad='auto') # = emout.Emout('output_dir', append_directories=['output_dir_2', 'output_dir_3'])
```
### データマスクを適用する
``` python
>>> # masking below average values
>>> data.phisp[1].masked(lambda phi: phi < phi.mean())
>>>
>>> # above code does the same as this code
>>> phi = data.phisp[1].copy()
>>> phi[phi < phi.mean()] = np.nan
```
### 3次元電荷分布から3次元電位分布を計算する. (Poisson's equation solver)
``` python
>>> from emout import poisson
>>> import scipy.constants as cn
>>> data = emout.Emout()
>>> dx = data.inp.dx # Grid width [m]
>>> btypes = ["pdn"[i] for i in data.inp.mtd_vbnd] # boundary conditions
>>> rho = data.rho[-1].val_si # Charge distribution [C/m^3]
>>> phisp = poisson(data.rho[-1].val_si, dx=dx, btypes, epsilon_0=cn.epsilon_0)
>>> np.allclose(phisp, data.phisp[-1])
True # (maybe True because there may be slight numerical errors...)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "emout",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "Nkzono99 <j-nakazono@stu.kobe-u.ac.jp>",
"keywords": "Visualization, Simulation, EMSES",
"author": null,
"author_email": "Nkzono99 <j-nakazono@stu.kobe-u.ac.jp>",
"download_url": "https://files.pythonhosted.org/packages/5f/ff/cb87225c9db9c9e5db62c8ef4afdd924b8065e9e7c554920344d91b8b152/emout-1.3.3.tar.gz",
"platform": null,
"description": "# emout\nEMSES\u306e\u51fa\u529b\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u308a\u6271\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\n\n* Documentation: https://nkzono99.github.io/emout/\n\n## Installation\n```\npip install emout\n```\n\n## Example code\n\n- [Visualization of simulation results for lunar surface charging](https://nbviewer.org/github/Nkzono99/examples/blob/main/examples/emout/example.ipynb)\n\n## Usage\n\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d5\u30a9\u30eb\u30c0\u69cb\u6210\u306e\u5834\u5408\u306e\u4f7f\u3044\u65b9.\n```\n.\n\u2514\u2500\u2500 output_dir\n \u251c\u2500\u2500 plasma.inp\n \u251c\u2500\u2500 phisp00_0000.h5\n \u251c\u2500\u2500 nd1p00_0000.h5\n \u251c\u2500\u2500 nd2p00_0000.h5\n \u251c\u2500\u2500 j1x00_0000.h5\n \u251c\u2500\u2500 j1y00_0000.h5\n ...\n \u2514\u2500\u2500 bz00_0000.h5\n```\n\n### \u30c7\u30fc\u30bf\u3092\u30ed\u30fc\u30c9\u3059\u308b\n``` python\n>>> import emout\n>>> data = emout.Emout('output_dir')\n\n>>> data.phisp # data of \"phisp00_0000.h5\"\n>>> len(data.phisp)\n11\n>>> data.phisp[0].shape\n(513, 65, 65)\n>>> data.j1x # data from \"j1x00_0000.h5\"\n>>> data.bz # data from \"bz00_0000.h5\"\n>>> data.j1xy # vector data object from \"j1x00_0000.h5\" and \"j1y00_0000.h5\"\n\n>>> data.rex # data from \"rex00_0000.h5\", created by relocating 'ex00_0000.h5'\n\n>>> data.icur # data from \"icur\" as pandas.DataFrame\n>>> data.pbody # data from \"pbody\" as pandas.DataFrame\n```\n\n### \u30d1\u30e9\u30e1\u30fc\u30bf\u30d5\u30a1\u30a4\u30eb(plasma.inp)\u3092\u53d6\u5f97\u3059\u308b\n```python\n>>> data.inp # namelist of 'plasma.inp'\n>>> data.inp['tmgrid']['nx'] # inp[group_name][parameter_name]\n64\n>>> data.inp['nx'] # can omit group name\n64\n>>> data.inp.tmgrid.nx # can access like attribute\n>>> data.inp.nx # can also omit group name\n```\n\n### \u30c7\u30fc\u30bf\u3092\u30d7\u30ed\u30c3\u30c8\u3059\u308b\n```python\n>>> x, y, z = 32, 32, 100\n>>> data.phisp[-1, z, :, :].plot() # plot xy-plane at z=100\n>>> data.phisp[-1, :, y, x].plot() # plot center line along z-axis\n\n>>> data.phisp[-1, z, :, :].plot(use_si=True) # can plot with SI-unit (such as x[m], y[m], phisp[V])\n>>> data.phisp[-1, z, :, :].plot() # use_si=True by default\n\n>>> data.phisp[-1, z, :, :].plot(show=True) # to view the plot on the fly (same as matplotlib.pyplot.show())\n>>> data.phisp[-1, z, :, :].plot(savefilename='phisp.png') # to save to the file\n\n>>> data.j1xy[-1, z, :, :].plot() # can plot vector data as a streamline\n```\n\n### \u30c7\u30fc\u30bf\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\n```python\n>>> x, y, z = 32, 32, 100\n>>> data.phisp[:, z, :, :].gifplot() # can generate time-series animation\n\n>>> data.phisp[:, z, :, :].gifplot(axis=0) # Selectable data axes to animate\n# (if axis=0, the first axis, i.e. the time axis, is selected, by default axis=0)\n\n>>> data.phisp[:, z, :, :].gifplot(action='save', filename='phisp.gif') # for save on a file\n\n>>> data.phisp[:, z, :, :].gifplot(action='to_html') # for display on jupyter\n\n# If you want to annimation several data at once,\n# prepare multiple frame update objects for each data at first.\n>>> updater0 = data.phisp[:, z, :, :].gifplot(action='frames', mode='cmap')\n>>> updater1 = data.phisp[:, z, :, :].build_frame_updater(mode='cont') # == gifplot(action='frames', mode='cont')\n>>> updater2 = data.nd1p[:, z, :, :].build_frame_updater(mode='cmap', vmin=1e-3, vmax=20, norm='log')\n>>> updater3 = data.nd2p[:, z, :, :].build_frame_updater(mode='cmap', vmin=1e-3, vmax=20, norm='log')\n>>> updater4 = data.j2xy[:, z, :, :].build_frame_updater(mode='stream')\n>>> layout = [[[updater0, updater1], [updater2], [updater3, updater4]]]\n>>> animator = updater0.to_animator(layout=layout) # create animator object from frame object (phisp: cmap+cont, nd1p: cmap, nd2p: cmap+current-stream)\n>>> animator.plot(action='to_html') # write plot function like gifplot \n```\n\n### \u5358\u4f4d\u5909\u63db\u3092\u884c\u3046\n> [!NOTE]\n> \u30d1\u30e9\u30e1\u30fc\u30bf\u30d5\u30a1\u30a4\u30eb (plasma.inp) \u306e\u4e00\u884c\u76ee\u306b\u4ee5\u4e0b\u3092\u8a18\u8ff0\u3057\u3066\u3044\u308b\u5834\u5408\u306e\u307f\u3001EMSES\u5358\u4f4d\u304b\u3089SI\u5358\u4f4d\u7cfb\u3078\u306e\u5909\u63db\u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u307e\u3059\u3002\n> \n> ```\n> !!key dx=[0.5],to_c=[10000.0]\n> ```\n> \n> ```dx```: \u30b0\u30ea\u30c3\u30c9\u5e45 [m]\n> ```to_c```: EMSES\u5185\u90e8\u3067\u306e\u5149\u901f\u306e\u898f\u683c\u5316\u3055\u308c\u305f\u5024\n\n``` python\n>>> data.unit.v.trans(1) # velocity: Physical unit to EMSES unit\n3.3356409519815205e-05\n>>> data.unit.v.reverse(1) # velocity: EMSES unit to Physical unit\n29979.2458\n```\n\n### SI\u5358\u4f4d\u7cfb\u3078\u306e\u5909\u63db\n> [!NOTE]\n> \u30d1\u30e9\u30e1\u30fc\u30bf\u30d5\u30a1\u30a4\u30eb (plasma.inp) \u306e\u4e00\u884c\u76ee\u306b\u4ee5\u4e0b\u3092\u8a18\u8ff0\u3057\u3066\u3044\u308b\u5834\u5408\u306e\u307f\u3001EMSES\u5358\u4f4d\u304b\u3089SI\u5358\u4f4d\u7cfb\u3078\u306e\u5909\u63db\u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u307e\u3059\u3002\n> \n> ```\n> !!key dx=[0.5],to_c=[10000.0]\n> ```\n> \n> ```dx```: \u30b0\u30ea\u30c3\u30c9\u5e45 [m]\n> ```to_c```: EMSES\u5185\u90e8\u3067\u306e\u5149\u901f\u306e\u898f\u683c\u5316\u3055\u308c\u305f\u5024\n\n``` python\n>>> # SI\u5358\u4f4d\u7cfb\u306b\u5909\u63db\u3057\u305f\u5024\u3092\u53d6\u5f97\u3059\u308b\n>>> phisp_volt = data.phisp[-1, :, :, :].val_si\n>>> j1z_A_per_m2 = data.j1z[-1, :, :, :].val_si\n>>> nd1p_per_cc = data.nd1p[-1, :, :, :].val_si\n```\n\n### \u7d99\u7d9a\u3057\u305f\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u7d50\u679c\u3092\u6271\u3046\n``` python\n>>> import emout\n>>> data = emout.Emout('output_dir', append_directories=['output_dir_2', 'output_dir_3'])\n>>>\n>>> data = emout.Emout('output_dir', ad='auto') # = emout.Emout('output_dir', append_directories=['output_dir_2', 'output_dir_3'])\n```\n\n### \u30c7\u30fc\u30bf\u30de\u30b9\u30af\u3092\u9069\u7528\u3059\u308b\n``` python\n>>> # masking below average values\n>>> data.phisp[1].masked(lambda phi: phi < phi.mean())\n>>>\n>>> # above code does the same as this code\n>>> phi = data.phisp[1].copy()\n>>> phi[phi < phi.mean()] = np.nan\n```\n\n### 3\u6b21\u5143\u96fb\u8377\u5206\u5e03\u304b\u30893\u6b21\u5143\u96fb\u4f4d\u5206\u5e03\u3092\u8a08\u7b97\u3059\u308b. (Poisson's equation solver)\n``` python\n>>> from emout import poisson\n>>> import scipy.constants as cn\n>>> data = emout.Emout()\n\n>>> dx = data.inp.dx # Grid width [m]\n>>> btypes = [\"pdn\"[i] for i in data.inp.mtd_vbnd] # boundary conditions\n>>> rho = data.rho[-1].val_si # Charge distribution [C/m^3]\n\n>>> phisp = poisson(data.rho[-1].val_si, dx=dx, btypes, epsilon_0=cn.epsilon_0)\n\n>>> np.allclose(phisp, data.phisp[-1])\nTrue # (maybe True because there may be slight numerical errors...)\n```\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2020 Nkzono99 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Emses output manager",
"version": "1.3.3",
"project_urls": {
"Repository": "https://github.com/Nkzono99/emout.git"
},
"split_keywords": [
"visualization",
" simulation",
" emses"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e206c57561148044d3855a93325dab52f7e86cdd249d183554cc33bdd49de55a",
"md5": "71bcc4022426f65294d7b3807b50a908",
"sha256": "13074ce4d3e629dcfbad9d6f2c8dd48784c0a54fcbbd6c3a0d9274cca7c525d7"
},
"downloads": -1,
"filename": "emout-1.3.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "71bcc4022426f65294d7b3807b50a908",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 43587,
"upload_time": "2024-11-28T11:27:57",
"upload_time_iso_8601": "2024-11-28T11:27:57.138130Z",
"url": "https://files.pythonhosted.org/packages/e2/06/c57561148044d3855a93325dab52f7e86cdd249d183554cc33bdd49de55a/emout-1.3.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5fffcb87225c9db9c9e5db62c8ef4afdd924b8065e9e7c554920344d91b8b152",
"md5": "c7d232e68d969aa6dea6b77723f44d07",
"sha256": "27d8813f93c937088579cc9857b93abb702243dcebcedebb613913919436a611"
},
"downloads": -1,
"filename": "emout-1.3.3.tar.gz",
"has_sig": false,
"md5_digest": "c7d232e68d969aa6dea6b77723f44d07",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 39233,
"upload_time": "2024-11-28T11:27:58",
"upload_time_iso_8601": "2024-11-28T11:27:58.864484Z",
"url": "https://files.pythonhosted.org/packages/5f/ff/cb87225c9db9c9e5db62c8ef4afdd924b8065e9e7c554920344d91b8b152/emout-1.3.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-28 11:27:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Nkzono99",
"github_project": "emout",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "emout"
}