ai2_kit.tool.dpdata module#
- class ai2_kit.tool.dpdata.DpdataTool(verbose=False, systems: list | None = None)[source]#
Bases:
object
- eval(dp_model: str)[source]#
Use deepmd model to label energy, force and viral
- Parameters:
dp_model – path to deepmd frozen model
- filter(lambda_expr: str)[source]#
filter data with lambda expression
- Parameters:
lambda_expr – lambda expression to filter data
- read(*file_path_or_glob: str, **kwargs)[source]#
read data from multiple paths, support glob pattern default format is deepmd/npy
- Parameters:
file_path_or_glob – path or glob pattern to locate data path
fmt – format to read, default is deepmd/npy
label – default is True, use dpdata.LabeledSystem if True, else use dpdata.System
kwargs – arguments to pass to dpdata.System or dpdata.LabeledSystem
- sample(size: int, method: Literal['even', 'random', 'truncate'] = 'even', **kwargs)[source]#
sample data
- Parameters:
size – size of sample, if size is larger than data size, return all data
method – method to sample, can be ‘even’, ‘random’, ‘truncate’, default is ‘even’
seed – seed for random sample, only used when method is ‘random’
Note that by default the seed is length of input list, if you want to generate different sample each time, you should set random seed manually
- set_fparam(fparam)[source]#
Set fparam for all systems
- Parameters:
fparam – fparam to set, should be a scalar or vector, e.g. 1.0 or [1.0, 2.0]
- slice(expr: str)[source]#
slice systems by python slice expression, for example 10:, :10, ::2, etc
- Parameters:
start – start index
stop – stop index
step – step
- write(out_path: str, fmt='deepmd/npy', merge: bool = True)[source]#
write data to specific path, support deepmd/npy, deepmd/raw, deepmd/hdf5 formats :param out_path: path to write data :param fmt: format to write, default is deepmd/npy :param merge: if True, merge all data use dpdata.MultiSystems, else write data without merging
- ai2_kit.tool.dpdata.read(*file_path_or_glob: str, **kwargs)[source]#
read data from multiple paths, support glob pattern default format is deepmd/npy
- Parameters:
file_path_or_glob – path or glob pattern to locate data path
fmt – format to read, default is deepmd/npy
label – default is True, use dpdata.LabeledSystem if True, else use dpdata.System
kwargs – arguments to pass to dpdata.System or dpdata.LabeledSystem
- Parse ignore_error:
if True, ignore error when read data, default is False