Skip to main content

读取和操作 Gromacs 能量文件

项目描述

Github Actions 构建状态 覆盖状态

此存储库托管 Pyedr 和 Panedr 包的源文件。

pyedrpanedr与 Python 3.6 及更高版本兼容。

皮德尔

Pyedr 提供了一种读取Gromacs EDR二进制 XDR 文件并将其内容作为numpy数组字典返回的方法。Pyedr 公开了以下函数:

  • edr_to_dict:返回一个由能量类型键控的 NumPy 数组字典,从给定路径到 EDR 文件。

  • read_edr:解析 EDR 文件并返回嵌套列表中的能量项

  • get_unit_dictionary:返回一个字典,其中包含在 EDR 文件中找到的每个能量项的单位。

潘德

Panedr 使用 Pyedr 库读取Gromacs EDR二进制能量 XDR 文件,并将其内容作为pandas数据帧返回。Panedr 公开了以下功能:

  • edr_to_df:获取 EDR 文件的路径并返回 pandas DataFrame。

  • get_unit_dictionary:返回一个字典,其中包含在 EDR 文件中找到的每个能量项的单位。

例子

使用pyedr

import pyedr

# Read the EDR file
path = 'ener.edr'
dic = pyedr.edr_to_dict(path)

# The `verbose` optional parameter can be set to True to display the
# progress on stderr
dic = pyedr.edr_to_dict(path, verbose=True)

# Get the average pressure after the first 10 ns
pressure_avg = dic['Pressure'][dic['Time'] > 10000].mean()

# Get the units of the EDR entries
unit_dict = pyedr.get_unit_dictionary(path)
unit_dict["Temperature"]  # returns "K"

使用panedr

import panedr

# Read the EDR file
path = 'ener.edr'
df = panedr.edr_to_df(path)

# The `verbose` optional parameter can be set to True to display the
# progress on stderr
df = panedr.edr_to_df(path, verbose=True)

# Get the average pressure after the first 10 ns
pressure_avg = df['Pressure'][df['Time'] > 10000].mean()

# Get the units of the EDR entries
unit_dict = panedr.get_unit_dictionary(path)
unit_dict["Temperature"]  # returns "K"

安装

您可以使用pip安装pyedrpanedr

pip install pyedr

# installing panedr automatically installs pyedr
pip install panedr

如果您使用condaconda-forge,您可以安装:

conda install -c conda-forge pyedr

# install panedr automatically installs pyedr
conda install -c conda-forge panedr

测试

pyedr和panedr存储库包含一系列测试。如果您从存储库下载或克隆了代码,则可以运行测试。为此,请安装pytest,然后在 panedr 源代码的目录中运行:

对于pyedr

pytest -v pyedr/pyedr/tests

对于panedr

pytest -v panedr/panedr/tests

执照

Pyedr 和 Panedr 将 Gromacs 的部分源代码翻译成 Python。因此,Panedr 在与 Gromacs 相同的 GNU Lesser General Public License 2.1 版下分发。有关更多详细信息,请参阅许可证

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

pyedr-0.7.0.tar.gz (12.2 kB 查看哈希)

已上传 source

内置分布

pyedr-0.7.0-py3-none-any.whl (21.8 kB 查看哈希

已上传 py3