nanoCAT.recipes.mol_filter
Recipes for filtering molecules.
Index
|
Return the distance between atom and the atom in mol which it is furthest removed from. |
|
Filter mol_list and data based on elements from mol_list. |
|
Filter mol_list and data based on elements from data. |
API
- nanoCAT.recipes.get_mol_length(mol, atom)[source]
Return the distance between atom and the atom in mol which it is furthest removed from.
Examples
Use the a molecules length for filtering a list of molecules:
>>> from CAT.recipes import get_mol_length, filter_mol >>> from scm.plams import Molecule >>> mol_list = [Molecule(...), ...] >>> data = [...] >>> filter = lambda mol: get_mol_length(mol, mol.properties.get('anchor')) < 10 >>> mol_dict = filter_mol(mol_list, data, filter=filter)
- Parameters:
mol (
Molecule
ornumpy.ndarray
) – A PLAMS molecule or a 2D numpy array with a molecules Cartesian coordinates.atom (
Atom
ornumpy.ndarray
) – A PLAMS atom or a 1D numpy array with an atoms Cartesian coordinates.
- Returns:
The largest distance between atom and all other atoms mol.
- Return type:
See also
filter_mol()
Filter mol_list and data based on elements from mol_list.
- nanoCAT.recipes.filter_mol(mol_list, data, filter)[source]
Filter mol_list and data based on elements from mol_list.
Examples
>>> from scm.plams import Molecule >>> from CAT.recipes import filter_mol >>> mol_list = [Molecule(...), ...] >>> data = [...] >>> mol_dict1 = filter_mol(mol_list, data, filter=lambda n: n < 10) >>> prop1 = [...] >>> prop2 = [...] >>> prop3 = [...] >>> multi_data = zip([prop1, prop2, prop3]) >>> mol_dict2 = filter_mol(mol_list, multi_data, filter=lambda n: n < 10) >>> keys = mol_dict1.keys() >>> values = mol_dict1.values() >>> mol_dict3 = filter_mol(keys, values, filter=lambda n: n < 5)
- Parameters:
mol_list (
Iterable
[Molecule
]) – An iterable of the, to-be filtered, PLAMS molecules.data (
Iterable[T]
) – An iterable which will be assigned as values to the to-be returned dict. These parameters will be filtered in conjunction with mol_list. Note that mol_list and data should be of the same length.filter (
Callable[[Molecule], bool]
) – A callable for filtering the distance vector. An example would belambda n: max(n) < 10
.
- Returns:
A dictionary with all (filtered) molecules as keys and elements from data as values.
- Return type:
See also
filter_data()
Filter mol_list and data based on elements from data.
- nanoCAT.recipes.filter_data(mol_list, data, filter)[source]
Filter mol_list and data based on elements from data.
Examples
See
filter_mol()
for a number of input examples.- Parameters:
mol_list (
Iterable
[Molecule
]) – An iterable of the, to-be filtered, PLAMS molecules.data (
Iterable[T]
) – An iterable which will be assigned as values to the to-be returned dict. These parameters will be filtered in conjunction with mol_list. Note that mol_list and data should be of the same length.filter (
Callable[[T], bool]
) – A callable for filtering the elements of data. An example would belambda n: n < 10
.
- Returns:
A dictionary with all (filtered) molecules as keys and elements from data as values.
- Return type:
See also
filter_mol()
Filter mol_list and data based on elements from mol_list.