Index
Top-level exports:
AtomSelection
module-attribute
Polars expression selecting a subset of atoms.
Can be used with many Atoms
methods.
CoordinateFrame
module-attribute
CoordinateFrame: TypeAlias = Literal[
"cell",
"cell_frac",
"cell_box",
"ortho",
"ortho_frac",
"ortho_box",
"linear",
"local",
"global",
]
A coordinate frame to use.
cell
: Real-space units along crystal axescell_frac
: Fraction of unit cellscell_box
: Fraction of cell boxortho
: Real-space units along orthogonal cellortho_frac
: Fraction of orthogonal cellortho_box
: Fraction of orthogonal boxlinear
: Angstroms in local coordinate system (without affine transformation)local
: Angstroms in local coordinate system (with affine transformation)global
: Angstroms in global coordinate system (with all transformations)
For more information, see the documentation at Coordinate systems,
or the example notebook at examples/coords.ipynb
.
Atoms
Bases: AtomsIOMixin
, HasAtoms
A collection of atoms, absent any implied coordinate system.
Implemented as a wrapper around a polars.DataFrame
.
Must contain the following columns:
- coords: array of
[x, y, z]
positions, float - elem: atomic number, int
- symbol: atomic symbol (may contain charges)
In addition, it commonly contains the following columns:
- i: Initial atom number
- wobble: Isotropic Debye-Waller mean-squared deviation (\(\left<u^2\right> = B \cdot \frac{3}{8 \pi^2}\), dimensions of [Length^2])
- frac_occupancy: Fractional occupancy, in the range [0., 1.]
- mass: Atomic mass, in g/mol (approx. Da)
- velocity: array of
[x, y, z]
velocities, float, dimensions of length/time - type: Numeric atom type, as used by programs like LAMMPS
Source code in atomlib/atoms.py
968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 |
|
columns
property
dtypes
property
dtypes: List[DataType]
schema
property
Return the schema of self
.
RETURNS | DESCRIPTION |
---|---|
Schema
|
A dictionary of column names and |
describe
describe(
percentiles: Union[Sequence[float], float, None] = (
0.25,
0.5,
0.75,
),
*,
interpolation: RollingInterpolationMethod = "nearest"
) -> DataFrame
Return summary statistics for self
. See DataFrame.describe
for more information.
PARAMETER | DESCRIPTION |
---|---|
percentiles
|
List of percentiles/quantiles to include. Defaults to 25% (first quartile), 50% (median), and 75% (third quartile).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
A dataframe containing summary statistics (mean, std. deviation, percentiles, etc.) for each column. |
Source code in atomlib/atoms.py
with_columns
Return a copy of self
with the given columns added.
Source code in atomlib/atoms.py
insert_column
insert_column(index: int, column: Series) -> DataFrame
get_column
get_column(name: str) -> Series
Get the specified column from self
, raising polars.ColumnNotFoundError
if it's not present.
Source code in atomlib/atoms.py
get_columns
get_columns() -> List[Series]
Return all columns from self
as a list of Series
.
Source code in atomlib/atoms.py
get_column_index
Get the index of a column by name, raising polars.ColumnNotFoundError
if it's not present.
group_by
group_by(
*by: Union[IntoExpr, Iterable[IntoExpr]],
maintain_order: bool = False,
**named_by: IntoExpr
) -> GroupBy
Start a group by operation. See DataFrame.group_by
for more information.
Source code in atomlib/atoms.py
pipe
pipe(
function: Callable[Concatenate[HasAtomsT, P], T],
*args: args,
**kwargs: kwargs
) -> T
Apply function
to self
(in method-call syntax).
clone
drop
filter
filter(
*predicates: Union[
None,
IntoExprColumn,
Iterable[IntoExprColumn],
bool,
List[bool],
ndarray,
],
**constraints: Any
) -> Self
Filter self
, removing rows which evaluate to False
.
Source code in atomlib/atoms.py
sort
sort(
by: Union[IntoExpr, Iterable[IntoExpr]],
*more_by: IntoExpr,
descending: Union[bool, Sequence[bool]] = False,
nulls_last: bool = False
) -> DataFrame
Sort the atoms in self
by the given columns/expressions.
Source code in atomlib/atoms.py
slice
head
head(n: int = 5) -> DataFrame
tail
tail(n: int = 5) -> DataFrame
drop_nulls
drop_nulls(
subset: Union[str, Collection[str], None] = None
) -> DataFrame
Drop rows that contain nulls in any of columns subset
.
fill_null
fill_null(
value: Any = None,
strategy: Optional[FillNullStrategy] = None,
limit: Optional[int] = None,
matches_supertype: bool = True,
) -> DataFrame
Fill null values in self
, using the specified value or strategy.
Source code in atomlib/atoms.py
fill_nan
concat
classmethod
concat(
atoms: Union[
HasAtomsT,
IntoAtoms,
Iterable[Union[HasAtomsT, IntoAtoms]],
],
*,
rechunk: bool = True,
how: ConcatMethod = "vertical"
) -> HasAtomsT
Concatenate multiple Atoms
together, handling metadata appropriately.
Source code in atomlib/atoms.py
partition_by
partition_by(
by: Union[str, Sequence[str]],
*more_by: str,
maintain_order: bool = True,
include_key: bool = True,
as_dict: bool = False
) -> Union[List[Self], Dict[Any, Self]]
Group by the given columns and partition into separate dataframes.
Return the partitions as a dictionary by specifying as_dict=True
.
Source code in atomlib/atoms.py
select
Select exprs
from self
, and return as a polars.DataFrame
.
Expressions may either be columns or expressions of columns.
Source code in atomlib/atoms.py
select_schema
select_schema(schema: SchemaDict) -> DataFrame
Select columns from self
and cast to the given schema.
Raises TypeError
if a column is not found or if it can't be cast.
Source code in atomlib/atoms.py
select_props
Select exprs
from self
, while keeping required columns.
RETURNS | DESCRIPTION |
---|---|
Self
|
A |
Self
|
specified properties (as well as required columns). |
Source code in atomlib/atoms.py
try_select
try_select(
*exprs: Union[IntoExpr, Iterable[IntoExpr]],
**named_exprs: IntoExpr
) -> Optional[DataFrame]
Try to select exprs
from self
, and return as a polars.DataFrame
.
Expressions may either be columns or expressions of columns. Returns None
if any
columns are missing.
Source code in atomlib/atoms.py
try_get_column
Try to get a column from self
, returning None
if it doesn't exist.
bbox_atoms
bbox_atoms() -> BBox3D
transform_atoms
transform_atoms(
transform: IntoTransform3D,
selection: Optional[AtomSelection] = None,
*,
transform_velocities: bool = False
) -> Self
Transform the atoms in self
by transform
.
If selection
is given, only transform the atoms in selection
.
Source code in atomlib/atoms.py
round_near_zero
round_near_zero(tol: float = 1e-14) -> Self
Round atom position values near zero to zero.
Source code in atomlib/atoms.py
crop
crop(
x_min: float = -inf,
x_max: float = inf,
y_min: float = -inf,
y_max: float = inf,
z_min: float = -inf,
z_max: float = inf,
) -> Self
Crop, removing all atoms outside of the specified region, inclusive.
Source code in atomlib/atoms.py
deduplicate
deduplicate(
tol: float = 0.001,
subset: Iterable[str] = ("x", "y", "z", "symbol"),
keep: UniqueKeepStrategy = "first",
maintain_order: bool = True,
) -> Self
De-duplicate atoms in self
. Atoms of the same symbol
that are closer than tolerance
to each other (by Euclidian distance) will be removed, leaving only the atom specified by
keep
(defaults to the first atom).
If subset
is specified, only those columns will be included while assessing duplicates.
Floating point columns other than 'x', 'y', and 'z' will not by toleranced.
Source code in atomlib/atoms.py
with_bounds
with_bounds(
cell_size: Optional[VecLike] = None,
cell_origin: Optional[VecLike] = None,
) -> "AtomCell"
Return a periodic cell with the given orthogonal cell dimensions.
If cell_size is not specified, it will be assumed (and may be incorrect).
Source code in atomlib/atoms.py
coords
coords(
selection: Optional[AtomSelection] = None,
*,
frame: Literal["local"] = "local"
) -> NDArray[float64]
Return a (N, 3)
ndarray of atom coordinates (dtype numpy.float64
).
Source code in atomlib/atoms.py
x
y
z
velocities
velocities(
selection: Optional[AtomSelection] = None,
) -> Optional[NDArray[float64]]
Return a (N, 3)
ndarray of atom velocities (dtype numpy.float64
).
Source code in atomlib/atoms.py
types
types() -> Optional[Series]
Returns a Series
of atom types (dtype polars.Int32
).
Source code in atomlib/atoms.py
masses
masses() -> Optional[Series]
Returns a Series
of atom masses (dtype polars.Float32
).
Source code in atomlib/atoms.py
add_atom
add_atom(
elem: Union[int, str],
/,
x: Union[ArrayLike, float],
y: Optional[float] = None,
z: Optional[float] = None,
**kwargs: Any,
) -> Self
Return a copy of self
with an extra atom.
By default, all extra columns present in self
must be specified as **kwargs
.
Try to avoid calling this in a loop (Use HasAtoms.concat
instead).
Source code in atomlib/atoms.py
pos
pos(
x: Union[Sequence[Optional[float]], float, None] = None,
y: Optional[float] = None,
z: Optional[float] = None,
*,
tol: float = 1e-06,
**kwargs: Any
) -> Expr
Select all atoms at a given position.
Formally, returns all atoms within a cube of radius tol
centered at (x,y,z)
, exclusive of the cube's surface.
Additional parameters given as kwargs
will be checked
as additional parameters (with strict equality).
Source code in atomlib/atoms.py
with_index
with_index(index: Optional[AtomValues] = None) -> Self
Returns self
with a row index added in column 'i' (dtype polars.Int64
).
If index
is not specified, defaults to an existing index or a new index.
Source code in atomlib/atoms.py
with_wobble
with_wobble(wobble: Optional[AtomValues] = None) -> Self
Return self
with the given displacements in column 'wobble' (dtype polars.Float64
).
If wobble
is not specified, defaults to the already-existing wobbles or 0.
Source code in atomlib/atoms.py
with_occupancy
with_occupancy(
frac_occupancy: Optional[AtomValues] = None,
) -> Self
Return self with the given fractional occupancies (dtype polars.Float64
).
If frac_occupancy
is not specified, defaults to the already-existing occupancies or 1.
Source code in atomlib/atoms.py
apply_wobble
Displace the atoms in self
by the amount in the wobble
column.
wobble
is interpretated as a mean-squared displacement, which is distributed
equally over each axis.
Source code in atomlib/atoms.py
apply_occupancy
For each atom in self
, use its frac_occupancy
to randomly decide whether to remove it.
Source code in atomlib/atoms.py
with_type
with_type(types: Optional[AtomValues] = None) -> Self
Return self
with the given atom types in column 'type'.
If types
is not specified, use the already existing types or auto-assign them.
When auto-assigning, each symbol is given a unique value, case-sensitive.
Values are assigned from lowest atomic number to highest.
For instance: ["Ag+", "Na", "H", "Ag"]
=> [3, 11, 1, 2]
Source code in atomlib/atoms.py
with_mass
Return self
with the given atom masses in column 'mass'
.
If mass
is not specified, use the already existing masses or auto-assign them.
Source code in atomlib/atoms.py
with_symbol
with_symbol(
symbols: ArrayLike,
selection: Optional[AtomSelection] = None,
) -> Self
Return self
with the given atomic symbols.
Source code in atomlib/atoms.py
with_coords
with_coords(
pts: ArrayLike,
selection: Optional[AtomSelection] = None,
*,
frame: Literal["local"] = "local"
) -> Self
Return self
replaced with the given atomic positions.
Source code in atomlib/atoms.py
with_velocity
with_velocity(
pts: Optional[ArrayLike] = None,
selection: Optional[AtomSelection] = None,
) -> Self
Return self
replaced with the given atomic velocities.
If pts
is not specified, use the already existing velocities or zero.
Source code in atomlib/atoms.py
read
classmethod
read(path: FileOrPath, ty: FileType) -> HasAtomsT
read(
path: FileOrPath, ty: Optional[FileType] = None
) -> HasAtomsT
Read a structure from a file.
Supported types can be found in the io module.
If no ty
is specified, it is inferred from the file's extension.
Source code in atomlib/mixins.py
read_cif
classmethod
read_cif(
f: Union[FileOrPath, CIF, CIFDataBlock],
block: Union[int, str, None] = None,
) -> HasAtomsT
Read a structure from a CIF file.
If block
is specified, read data from the given block of the CIF file (index or name).
Source code in atomlib/mixins.py
read_xyz
classmethod
read_xyz(f: Union[FileOrPath, XYZ]) -> HasAtomsT
read_xsf
classmethod
read_xsf(f: Union[FileOrPath, XSF]) -> HasAtomsT
read_cfg
classmethod
read_cfg(f: Union[FileOrPath, CFG]) -> HasAtomsT
read_lmp
classmethod
read_lmp(
f: Union[FileOrPath, LMP],
type_map: Optional[Dict[int, Union[str, int]]] = None,
) -> HasAtomsT
Read a structure from a LAAMPS data file.
Source code in atomlib/mixins.py
write_cif
write_cif(f: FileOrPath)
write_xyz
write_xyz(f: FileOrPath, fmt: XYZFormat = 'exyz')
write_xsf
write_xsf(f: FileOrPath)
write_cfg
write_cfg(f: FileOrPath)
write_lmp
write_lmp(f: FileOrPath)
write
write(path: FileOrPath, ty: FileType)
write(path: FileOrPath, ty: Optional[FileType] = None)
Write this structure to a file.
A file type may be specified using ty
.
If no ty
is specified, it is inferred from the path's extension.
Source code in atomlib/mixins.py
empty
staticmethod
empty() -> Atoms
get_atoms
with_atoms
bbox
bbox() -> BBox3D
HasAtoms
Bases: ABC
Abstract class representing any (possibly compound) collection of atoms.
Source code in atomlib/atoms.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 |
|
columns
property
dtypes
property
dtypes: List[DataType]
schema
property
Return the schema of self
.
RETURNS | DESCRIPTION |
---|---|
Schema
|
A dictionary of column names and |
get_atoms
abstractmethod
Get atoms contained in self
. This should be a low cost method.
PARAMETER | DESCRIPTION |
---|---|
frame
|
Coordinate frame to return atoms in. For a plain
TYPE:
|
Return
The contained atoms
Source code in atomlib/atoms.py
with_atoms
abstractmethod
Return a copy of self with the inner Atoms
replaced.
PARAMETER | DESCRIPTION |
---|---|
atoms
|
TYPE:
|
frame
|
Coordinate frame inside atoms are in. For a plain
TYPE:
|
Return
A copy of self
updated with the given atoms
Source code in atomlib/atoms.py
describe
describe(
percentiles: Union[Sequence[float], float, None] = (
0.25,
0.5,
0.75,
),
*,
interpolation: RollingInterpolationMethod = "nearest"
) -> DataFrame
Return summary statistics for self
. See DataFrame.describe
for more information.
PARAMETER | DESCRIPTION |
---|---|
percentiles
|
List of percentiles/quantiles to include. Defaults to 25% (first quartile), 50% (median), and 75% (third quartile).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
A dataframe containing summary statistics (mean, std. deviation, percentiles, etc.) for each column. |
Source code in atomlib/atoms.py
with_columns
Return a copy of self
with the given columns added.
Source code in atomlib/atoms.py
insert_column
insert_column(index: int, column: Series) -> DataFrame
get_column
get_column(name: str) -> Series
Get the specified column from self
, raising polars.ColumnNotFoundError
if it's not present.
Source code in atomlib/atoms.py
get_columns
get_columns() -> List[Series]
Return all columns from self
as a list of Series
.
Source code in atomlib/atoms.py
get_column_index
Get the index of a column by name, raising polars.ColumnNotFoundError
if it's not present.
group_by
group_by(
*by: Union[IntoExpr, Iterable[IntoExpr]],
maintain_order: bool = False,
**named_by: IntoExpr
) -> GroupBy
Start a group by operation. See DataFrame.group_by
for more information.
Source code in atomlib/atoms.py
pipe
pipe(
function: Callable[Concatenate[HasAtomsT, P], T],
*args: args,
**kwargs: kwargs
) -> T
Apply function
to self
(in method-call syntax).
clone
drop
filter
filter(
*predicates: Union[
None,
IntoExprColumn,
Iterable[IntoExprColumn],
bool,
List[bool],
ndarray,
],
**constraints: Any
) -> Self
Filter self
, removing rows which evaluate to False
.
Source code in atomlib/atoms.py
sort
sort(
by: Union[IntoExpr, Iterable[IntoExpr]],
*more_by: IntoExpr,
descending: Union[bool, Sequence[bool]] = False,
nulls_last: bool = False
) -> DataFrame
Sort the atoms in self
by the given columns/expressions.
Source code in atomlib/atoms.py
slice
head
head(n: int = 5) -> DataFrame
tail
tail(n: int = 5) -> DataFrame
drop_nulls
drop_nulls(
subset: Union[str, Collection[str], None] = None
) -> DataFrame
Drop rows that contain nulls in any of columns subset
.
fill_null
fill_null(
value: Any = None,
strategy: Optional[FillNullStrategy] = None,
limit: Optional[int] = None,
matches_supertype: bool = True,
) -> DataFrame
Fill null values in self
, using the specified value or strategy.
Source code in atomlib/atoms.py
fill_nan
concat
classmethod
concat(
atoms: Union[
HasAtomsT,
IntoAtoms,
Iterable[Union[HasAtomsT, IntoAtoms]],
],
*,
rechunk: bool = True,
how: ConcatMethod = "vertical"
) -> HasAtomsT
Concatenate multiple Atoms
together, handling metadata appropriately.
Source code in atomlib/atoms.py
partition_by
partition_by(
by: Union[str, Sequence[str]],
*more_by: str,
maintain_order: bool = True,
include_key: bool = True,
as_dict: bool = False
) -> Union[List[Self], Dict[Any, Self]]
Group by the given columns and partition into separate dataframes.
Return the partitions as a dictionary by specifying as_dict=True
.
Source code in atomlib/atoms.py
select
Select exprs
from self
, and return as a polars.DataFrame
.
Expressions may either be columns or expressions of columns.
Source code in atomlib/atoms.py
select_schema
select_schema(schema: SchemaDict) -> DataFrame
Select columns from self
and cast to the given schema.
Raises TypeError
if a column is not found or if it can't be cast.
Source code in atomlib/atoms.py
select_props
Select exprs
from self
, while keeping required columns.
RETURNS | DESCRIPTION |
---|---|
Self
|
A |
Self
|
specified properties (as well as required columns). |
Source code in atomlib/atoms.py
try_select
try_select(
*exprs: Union[IntoExpr, Iterable[IntoExpr]],
**named_exprs: IntoExpr
) -> Optional[DataFrame]
Try to select exprs
from self
, and return as a polars.DataFrame
.
Expressions may either be columns or expressions of columns. Returns None
if any
columns are missing.
Source code in atomlib/atoms.py
try_get_column
Try to get a column from self
, returning None
if it doesn't exist.
bbox_atoms
bbox_atoms() -> BBox3D
transform_atoms
transform_atoms(
transform: IntoTransform3D,
selection: Optional[AtomSelection] = None,
*,
transform_velocities: bool = False
) -> Self
Transform the atoms in self
by transform
.
If selection
is given, only transform the atoms in selection
.
Source code in atomlib/atoms.py
round_near_zero
round_near_zero(tol: float = 1e-14) -> Self
Round atom position values near zero to zero.
Source code in atomlib/atoms.py
crop
crop(
x_min: float = -inf,
x_max: float = inf,
y_min: float = -inf,
y_max: float = inf,
z_min: float = -inf,
z_max: float = inf,
) -> Self
Crop, removing all atoms outside of the specified region, inclusive.
Source code in atomlib/atoms.py
deduplicate
deduplicate(
tol: float = 0.001,
subset: Iterable[str] = ("x", "y", "z", "symbol"),
keep: UniqueKeepStrategy = "first",
maintain_order: bool = True,
) -> Self
De-duplicate atoms in self
. Atoms of the same symbol
that are closer than tolerance
to each other (by Euclidian distance) will be removed, leaving only the atom specified by
keep
(defaults to the first atom).
If subset
is specified, only those columns will be included while assessing duplicates.
Floating point columns other than 'x', 'y', and 'z' will not by toleranced.
Source code in atomlib/atoms.py
with_bounds
with_bounds(
cell_size: Optional[VecLike] = None,
cell_origin: Optional[VecLike] = None,
) -> "AtomCell"
Return a periodic cell with the given orthogonal cell dimensions.
If cell_size is not specified, it will be assumed (and may be incorrect).
Source code in atomlib/atoms.py
coords
coords(
selection: Optional[AtomSelection] = None,
*,
frame: Literal["local"] = "local"
) -> NDArray[float64]
Return a (N, 3)
ndarray of atom coordinates (dtype numpy.float64
).
Source code in atomlib/atoms.py
x
y
z
velocities
velocities(
selection: Optional[AtomSelection] = None,
) -> Optional[NDArray[float64]]
Return a (N, 3)
ndarray of atom velocities (dtype numpy.float64
).
Source code in atomlib/atoms.py
types
types() -> Optional[Series]
Returns a Series
of atom types (dtype polars.Int32
).
Source code in atomlib/atoms.py
masses
masses() -> Optional[Series]
Returns a Series
of atom masses (dtype polars.Float32
).
Source code in atomlib/atoms.py
add_atom
add_atom(
elem: Union[int, str],
/,
x: Union[ArrayLike, float],
y: Optional[float] = None,
z: Optional[float] = None,
**kwargs: Any,
) -> Self
Return a copy of self
with an extra atom.
By default, all extra columns present in self
must be specified as **kwargs
.
Try to avoid calling this in a loop (Use HasAtoms.concat
instead).
Source code in atomlib/atoms.py
pos
pos(
x: Union[Sequence[Optional[float]], float, None] = None,
y: Optional[float] = None,
z: Optional[float] = None,
*,
tol: float = 1e-06,
**kwargs: Any
) -> Expr
Select all atoms at a given position.
Formally, returns all atoms within a cube of radius tol
centered at (x,y,z)
, exclusive of the cube's surface.
Additional parameters given as kwargs
will be checked
as additional parameters (with strict equality).
Source code in atomlib/atoms.py
with_index
with_index(index: Optional[AtomValues] = None) -> Self
Returns self
with a row index added in column 'i' (dtype polars.Int64
).
If index
is not specified, defaults to an existing index or a new index.
Source code in atomlib/atoms.py
with_wobble
with_wobble(wobble: Optional[AtomValues] = None) -> Self
Return self
with the given displacements in column 'wobble' (dtype polars.Float64
).
If wobble
is not specified, defaults to the already-existing wobbles or 0.
Source code in atomlib/atoms.py
with_occupancy
with_occupancy(
frac_occupancy: Optional[AtomValues] = None,
) -> Self
Return self with the given fractional occupancies (dtype polars.Float64
).
If frac_occupancy
is not specified, defaults to the already-existing occupancies or 1.
Source code in atomlib/atoms.py
apply_wobble
Displace the atoms in self
by the amount in the wobble
column.
wobble
is interpretated as a mean-squared displacement, which is distributed
equally over each axis.
Source code in atomlib/atoms.py
apply_occupancy
For each atom in self
, use its frac_occupancy
to randomly decide whether to remove it.
Source code in atomlib/atoms.py
with_type
with_type(types: Optional[AtomValues] = None) -> Self
Return self
with the given atom types in column 'type'.
If types
is not specified, use the already existing types or auto-assign them.
When auto-assigning, each symbol is given a unique value, case-sensitive.
Values are assigned from lowest atomic number to highest.
For instance: ["Ag+", "Na", "H", "Ag"]
=> [3, 11, 1, 2]
Source code in atomlib/atoms.py
with_mass
Return self
with the given atom masses in column 'mass'
.
If mass
is not specified, use the already existing masses or auto-assign them.
Source code in atomlib/atoms.py
with_symbol
with_symbol(
symbols: ArrayLike,
selection: Optional[AtomSelection] = None,
) -> Self
Return self
with the given atomic symbols.
Source code in atomlib/atoms.py
with_coords
with_coords(
pts: ArrayLike,
selection: Optional[AtomSelection] = None,
*,
frame: Literal["local"] = "local"
) -> Self
Return self
replaced with the given atomic positions.
Source code in atomlib/atoms.py
with_velocity
with_velocity(
pts: Optional[ArrayLike] = None,
selection: Optional[AtomSelection] = None,
) -> Self
Return self
replaced with the given atomic velocities.
If pts
is not specified, use the already existing velocities or zero.
Source code in atomlib/atoms.py
Cell
dataclass
Bases: HasCell
Internal class for representing the coordinate systems of a crystal.
The overall transformation from crystal coordinates to real-space coordinates is
is split into four transformations, applied from bottom to top. First is n_cells
,
which scales from fractions of a unit cell to fractions of a supercell. Next is
cell_size
, which scales to real-space units. ortho
is an orthogonalization
matrix, a det = 1 upper-triangular matrix which transforms crystal axes to
an orthogonal coordinate system. Finally, affine
contains any remaining
transformations to the local coordinate system, which atoms are stored in.
Source code in atomlib/cell.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
|
affine
property
affine: AffineTransform3D
Affine transformation. Holds transformation from 'ortho' to 'local' coordinates, including rotation away from the standard crystal orientation.
ortho
property
ortho: LinearTransform3D
Orthogonalization transformation. Skews but does not scale the crystal axes to cartesian axes.
metric
property
metric: LinearTransform3D
Cell metric tensor
Returns the dot product between every combination of basis vectors.
:math:\mathbf{a} \cdot \mathbf{b} = a_i M_ij b_j
pbc
property
Flags indicating the presence of periodic boundary conditions along each axis.
ortho_size
property
Return size of orthogonal unit cell.
Equivalent to the diagonal of the orthogonalization matrix.
box_size
property
Return size of the cell box.
Equivalent to self.n_cells * self.cell_size
.
get_transform
get_transform(
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> AffineTransform3D
In the two-argument form, get the transform to frame_to
from frame_from
.
In the one-argument form, get the transform from local coordinates to 'frame'.
Source code in atomlib/cell.py
corners
corners(frame: CoordinateFrame = 'local') -> ndarray
bbox_cell
bbox_cell(frame: CoordinateFrame = 'local') -> BBox3D
Return the bounding box of the cell box in the given coordinate system.
is_orthogonal
is_orthogonal_in_local
Returns whether this cell is orthogonal and aligned with the local coordinate system.
Source code in atomlib/cell.py
to_ortho
to_ortho() -> AffineTransform3D
transform_cell
transform_cell(
transform: AffineTransform3D,
frame: CoordinateFrame = "local",
) -> HasCellT
Apply the given transform to the unit cell, and return a new Cell
.
The transform is applied in coordinate frame 'frame'.
Orthogonal and affine transformations are applied to the affine matrix component,
while skew and scaling is applied to the orthogonalization matrix/cell_size.
Source code in atomlib/cell.py
strain_orthogonal
strain_orthogonal() -> HasCellT
Orthogonalize using strain.
Strain is applied such that the x-axis remains fixed, and the y-axis remains in the xy plane. For small displacements, no hydrostatic strain is applied (volume is conserved).
Source code in atomlib/cell.py
repeat
Tile the cell by n
in each dimension.
Source code in atomlib/cell.py
explode
explode() -> HasCellT
Materialize repeated cells as one supercell.
Source code in atomlib/cell.py
explode_z
explode_z() -> HasCellT
Materialize repeated cells as one supercell in z.
Source code in atomlib/cell.py
crop
crop(
x_min: float = -inf,
x_max: float = inf,
y_min: float = -inf,
y_max: float = inf,
z_min: float = -inf,
z_max: float = inf,
*,
frame: CoordinateFrame = "local"
) -> HasCellT
Crop self
to the given extents. For a non-orthogonal
cell, this must be specified in cell coordinates. This
function implicity explode
s the cell as well.
Source code in atomlib/cell.py
change_transform
change_transform(
transform: AffineTransform3D,
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> AffineTransform3D
change_transform(
transform: Transform3D,
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> Transform3D
change_transform(
transform: Transform3D,
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> Transform3D
Coordinate-change a transformation from frame_from
into frame_to
.
Source code in atomlib/cell.py
assert_equal
assert_equal(other: Any)
Source code in atomlib/cell.py
get_cell
get_cell() -> Cell
with_cell
from_unit_cell
staticmethod
from_unit_cell(
cell_size: VecLike,
cell_angle: Optional[VecLike] = None,
n_cells: Optional[VecLike] = None,
pbc: Optional[VecLike] = None,
)
Source code in atomlib/cell.py
from_ortho
staticmethod
from_ortho(
ortho: AffineTransform3D,
n_cells: Optional[VecLike] = None,
pbc: Optional[VecLike] = None,
)
Source code in atomlib/cell.py
HasCell
Source code in atomlib/cell.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
affine
property
affine: AffineTransform3D
Affine transformation. Holds transformation from 'ortho' to 'local' coordinates, including rotation away from the standard crystal orientation.
ortho
property
ortho: LinearTransform3D
Orthogonalization transformation. Skews but does not scale the crystal axes to cartesian axes.
metric
property
metric: LinearTransform3D
Cell metric tensor
Returns the dot product between every combination of basis vectors.
:math:\mathbf{a} \cdot \mathbf{b} = a_i M_ij b_j
pbc
property
Flags indicating the presence of periodic boundary conditions along each axis.
ortho_size
property
Return size of orthogonal unit cell.
Equivalent to the diagonal of the orthogonalization matrix.
box_size
property
Return size of the cell box.
Equivalent to self.n_cells * self.cell_size
.
get_cell
abstractmethod
get_cell() -> Cell
with_cell
abstractmethod
get_transform
get_transform(
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> AffineTransform3D
In the two-argument form, get the transform to frame_to
from frame_from
.
In the one-argument form, get the transform from local coordinates to 'frame'.
Source code in atomlib/cell.py
corners
corners(frame: CoordinateFrame = 'local') -> ndarray
bbox_cell
bbox_cell(frame: CoordinateFrame = 'local') -> BBox3D
Return the bounding box of the cell box in the given coordinate system.
is_orthogonal
is_orthogonal_in_local
Returns whether this cell is orthogonal and aligned with the local coordinate system.
Source code in atomlib/cell.py
to_ortho
to_ortho() -> AffineTransform3D
transform_cell
transform_cell(
transform: AffineTransform3D,
frame: CoordinateFrame = "local",
) -> HasCellT
Apply the given transform to the unit cell, and return a new Cell
.
The transform is applied in coordinate frame 'frame'.
Orthogonal and affine transformations are applied to the affine matrix component,
while skew and scaling is applied to the orthogonalization matrix/cell_size.
Source code in atomlib/cell.py
strain_orthogonal
strain_orthogonal() -> HasCellT
Orthogonalize using strain.
Strain is applied such that the x-axis remains fixed, and the y-axis remains in the xy plane. For small displacements, no hydrostatic strain is applied (volume is conserved).
Source code in atomlib/cell.py
repeat
Tile the cell by n
in each dimension.
Source code in atomlib/cell.py
explode
explode() -> HasCellT
Materialize repeated cells as one supercell.
Source code in atomlib/cell.py
explode_z
explode_z() -> HasCellT
Materialize repeated cells as one supercell in z.
Source code in atomlib/cell.py
crop
crop(
x_min: float = -inf,
x_max: float = inf,
y_min: float = -inf,
y_max: float = inf,
z_min: float = -inf,
z_max: float = inf,
*,
frame: CoordinateFrame = "local"
) -> HasCellT
Crop self
to the given extents. For a non-orthogonal
cell, this must be specified in cell coordinates. This
function implicity explode
s the cell as well.
Source code in atomlib/cell.py
change_transform
change_transform(
transform: AffineTransform3D,
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> AffineTransform3D
change_transform(
transform: Transform3D,
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> Transform3D
change_transform(
transform: Transform3D,
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> Transform3D
Coordinate-change a transformation from frame_from
into frame_to
.
Source code in atomlib/cell.py
assert_equal
assert_equal(other: Any)
Source code in atomlib/cell.py
AtomCell
dataclass
Bases: AtomCellIOMixin
, HasAtomCell
Cell of atoms with known size and periodic boundary conditions.
Source code in atomlib/atomcell.py
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 |
|
affine
property
affine: AffineTransform3D
Affine transformation. Holds transformation from 'ortho' to 'local' coordinates, including rotation away from the standard crystal orientation.
ortho
property
ortho: LinearTransform3D
Orthogonalization transformation. Skews but does not scale the crystal axes to cartesian axes.
metric
property
metric: LinearTransform3D
Cell metric tensor
Returns the dot product between every combination of basis vectors.
:math:\mathbf{a} \cdot \mathbf{b} = a_i M_ij b_j
pbc
property
Flags indicating the presence of periodic boundary conditions along each axis.
ortho_size
property
Return size of orthogonal unit cell.
Equivalent to the diagonal of the orthogonalization matrix.
box_size
property
Return size of the cell box.
Equivalent to self.n_cells * self.cell_size
.
columns
property
dtypes
property
dtypes: List[DataType]
schema
property
Return the schema of self
.
RETURNS | DESCRIPTION |
---|---|
Schema
|
A dictionary of column names and |
atoms
instance-attribute
atoms: Atoms
Atoms in the cell. Stored in 'local' coordinates (i.e. relative to the enclosing group but not relative to box dimensions).
frame
class-attribute
instance-attribute
frame: CoordinateFrame = 'local'
Coordinate frame 'atoms' are stored in.
get_transform
get_transform(
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> AffineTransform3D
In the two-argument form, get the transform to frame_to
from frame_from
.
In the one-argument form, get the transform from local coordinates to 'frame'.
Source code in atomlib/cell.py
corners
corners(frame: CoordinateFrame = 'local') -> ndarray
bbox_cell
bbox_cell(frame: CoordinateFrame = 'local') -> BBox3D
Return the bounding box of the cell box in the given coordinate system.
bbox
bbox(frame: CoordinateFrame = 'local') -> BBox3D
Return the combined bounding box of the cell and atoms in the given coordinate system.
To get the cell or atoms bounding box only, use bbox_cell
or bbox_atoms
.
Source code in atomlib/atomcell.py
is_orthogonal
is_orthogonal_in_local
Returns whether this cell is orthogonal and aligned with the local coordinate system.
Source code in atomlib/cell.py
to_ortho
to_ortho() -> AffineTransform3D
transform_cell
transform_cell(
transform: AffineTransform3D,
frame: CoordinateFrame = "local",
) -> Self
Apply the given transform to the unit cell, without changing atom positions. The transform is applied in coordinate frame 'frame'.
Source code in atomlib/atomcell.py
strain_orthogonal
strain_orthogonal() -> HasCellT
Orthogonalize using strain.
Strain is applied such that the x-axis remains fixed, and the y-axis remains in the xy plane. For small displacements, no hydrostatic strain is applied (volume is conserved).
Source code in atomlib/cell.py
repeat
Tile the cell
Source code in atomlib/atomcell.py
explode
Materialize repeated cells as one supercell.
explode_z
explode_z() -> HasCellT
Materialize repeated cells as one supercell in z.
Source code in atomlib/cell.py
crop
crop(
x_min: float = -inf,
x_max: float = inf,
y_min: float = -inf,
y_max: float = inf,
z_min: float = -inf,
z_max: float = inf,
*,
frame: CoordinateFrame = "local"
) -> Self
Crop atoms and cell to the given extents. For a non-orthogonal
cell, this must be specified in cell coordinates. This
function implicity explode
s the cell as well.
To crop atoms only, use crop_atoms
instead.
Source code in atomlib/atomcell.py
change_transform
change_transform(
transform: AffineTransform3D,
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> AffineTransform3D
change_transform(
transform: Transform3D,
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> Transform3D
change_transform(
transform: Transform3D,
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> Transform3D
Coordinate-change a transformation from frame_from
into frame_to
.
Source code in atomlib/cell.py
describe
describe(
percentiles: Union[Sequence[float], float, None] = (
0.25,
0.5,
0.75,
),
*,
interpolation: RollingInterpolationMethod = "nearest",
frame: Optional[CoordinateFrame] = None
) -> DataFrame
Return summary statistics for self
. See DataFrame.describe
for more information.
PARAMETER | DESCRIPTION |
---|---|
percentiles
|
List of percentiles/quantiles to include. Defaults to 25% (first quartile), 50% (median), and 75% (third quartile).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
A dataframe containing summary statistics (mean, std. deviation, percentiles, etc.) for each column. |
Source code in atomlib/atomcell.py
with_columns
with_columns(
*exprs: Union[IntoExpr, Iterable[IntoExpr]],
frame: Optional[CoordinateFrame] = None,
**named_exprs: IntoExpr
) -> Self
Return a copy of self
with the given columns added.
insert_column
insert_column(index: int, column: Series) -> DataFrame
get_column
get_column(
name: str, *, frame: Optional[CoordinateFrame] = None
) -> Series
Get the specified column from self
, raising polars.ColumnNotFoundError
if it's not present.
Source code in atomlib/atomcell.py
get_columns
get_columns(
*, frame: Optional[CoordinateFrame] = None
) -> List[Series]
Return all columns from self
as a list of Series
.
Source code in atomlib/atomcell.py
get_column_index
Get the index of a column by name, raising polars.ColumnNotFoundError
if it's not present.
group_by
group_by(
*by: Union[IntoExpr, Iterable[IntoExpr]],
maintain_order: bool = False,
frame: Optional[CoordinateFrame] = None,
**named_by: IntoExpr
) -> GroupBy
Start a group by operation. See DataFrame.group_by
for more information.
Source code in atomlib/atomcell.py
pipe
pipe(
function: Callable[Concatenate[HasAtomCellT, P], T],
*args: args,
**kwargs: kwargs
) -> T
Apply function
to self
(in method-call syntax).
drop
filter
filter(
*predicates: Union[
None,
IntoExprColumn,
Iterable[IntoExprColumn],
bool,
List[bool],
ndarray,
],
frame: Optional[CoordinateFrame] = None,
**constraints: Any
) -> Self
Filter self
, removing rows which evaluate to False
.
Source code in atomlib/atomcell.py
sort
sort(
by: Union[IntoExpr, Iterable[IntoExpr]],
*more_by: IntoExpr,
descending: Union[bool, Sequence[bool]] = False,
nulls_last: bool = False
) -> Self
Sort the atoms in self
by the given columns/expressions.
Source code in atomlib/atomcell.py
slice
slice(
offset: int,
length: Optional[int] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
head
head(
n: int = 5, *, frame: Optional[CoordinateFrame] = None
) -> Self
tail
tail(
n: int = 5, *, frame: Optional[CoordinateFrame] = None
) -> Self
drop_nulls
drop_nulls(
subset: Union[str, Collection[str], None] = None
) -> DataFrame
Drop rows that contain nulls in any of columns subset
.
fill_null
fill_nan
fill_nan(
value: Union[Expr, int, float, None],
*,
frame: Optional[CoordinateFrame] = None
) -> Self
concat
classmethod
concat(
atoms: Union[
HasAtomsT,
IntoAtoms,
Iterable[Union[HasAtomsT, IntoAtoms]],
],
*,
rechunk: bool = True,
how: ConcatMethod = "vertical"
) -> HasAtomsT
Concatenate multiple Atoms
together, handling metadata appropriately.
Source code in atomlib/atoms.py
partition_by
partition_by(
by: Union[str, Sequence[str]],
*more_by: str,
maintain_order: bool = True,
include_key: bool = True,
as_dict: bool = False
) -> Union[List[Self], Dict[Any, Self]]
Group by the given columns and partition into separate dataframes.
Return the partitions as a dictionary by specifying as_dict=True
.
Source code in atomlib/atoms.py
select
select(
*exprs: Union[IntoExpr, Iterable[IntoExpr]],
frame: Optional[CoordinateFrame] = None,
**named_exprs: IntoExpr
) -> DataFrame
Select exprs
from self
, and return as a polars.DataFrame
.
Expressions may either be columns or expressions of columns.
Source code in atomlib/atomcell.py
select_schema
select_schema(schema: SchemaDict) -> DataFrame
Select columns from self
and cast to the given schema.
Raises TypeError
if a column is not found or if it can't be cast.
Source code in atomlib/atoms.py
select_props
select_props(
*exprs: Union[IntoExpr, Iterable[IntoExpr]],
frame: Optional[CoordinateFrame] = None,
**named_exprs: IntoExpr
) -> Self
Select exprs
from self
, while keeping required columns.
Doesn't affect the cell.
RETURNS | DESCRIPTION |
---|---|
Self
|
A |
Self
|
the specified properties (as well as required columns). |
Source code in atomlib/atomcell.py
try_select
try_select(
*exprs: Union[IntoExpr, Iterable[IntoExpr]],
frame: Optional[CoordinateFrame] = None,
**named_exprs: IntoExpr
) -> Optional[DataFrame]
Try to select exprs
from self
, and return as a polars.DataFrame
.
Expressions may either be columns or expressions of columns. Returns None
if any
columns are missing.
Source code in atomlib/atomcell.py
try_get_column
Try to get a column from self
, returning None
if it doesn't exist.
bbox_atoms
bbox_atoms(
frame: Optional[CoordinateFrame] = None,
) -> BBox3D
Return the bounding box of all the atoms in self
, in the given coordinate frame.
transform_atoms
transform_atoms(
transform: IntoTransform3D,
selection: Optional[AtomSelection] = None,
*,
frame: CoordinateFrame = "local",
transform_velocities: bool = False
) -> Self
Transform the atoms in self
by transform
.
If selection
is given, only transform the atoms in selection
.
Source code in atomlib/atomcell.py
transform
transform(
transform: AffineTransform3D,
frame: CoordinateFrame = "local",
) -> Self
Source code in atomlib/atomcell.py
round_near_zero
round_near_zero(
tol: float = 1e-14,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
crop_atoms
crop_atoms(
x_min: float = -inf,
x_max: float = inf,
y_min: float = -inf,
y_max: float = inf,
z_min: float = -inf,
z_max: float = inf,
*,
frame: CoordinateFrame = "local"
) -> Self
Source code in atomlib/atomcell.py
deduplicate
deduplicate(
tol: float = 0.001,
subset: Iterable[str] = ("x", "y", "z", "symbol"),
keep: UniqueKeepStrategy = "first",
maintain_order: bool = True,
) -> Self
De-duplicate atoms in self
. Atoms of the same symbol
that are closer than tolerance
to each other (by Euclidian distance) will be removed, leaving only the atom specified by
keep
(defaults to the first atom).
If subset
is specified, only those columns will be included while assessing duplicates.
Floating point columns other than 'x', 'y', and 'z' will not by toleranced.
Source code in atomlib/atoms.py
with_bounds
with_bounds(
cell_size: Optional[VecLike] = None,
cell_origin: Optional[VecLike] = None,
) -> "AtomCell"
Return a periodic cell with the given orthogonal cell dimensions.
If cell_size is not specified, it will be assumed (and may be incorrect).
Source code in atomlib/atoms.py
coords
coords(
selection: Optional[AtomSelection] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> NDArray[float64]
Return a (N, 3)
ndarray of atom positions (dtype numpy.float64
)
in the given coordinate frame.
Source code in atomlib/atomcell.py
x
y
z
velocities
velocities(
selection: Optional[AtomSelection] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Optional[NDArray[float64]]
Return a (N, 3)
ndarray of atom velocities (dtype numpy.float64
)
in the given coordinate frame.
Source code in atomlib/atomcell.py
types
types() -> Optional[Series]
Returns a Series
of atom types (dtype polars.Int32
).
Source code in atomlib/atoms.py
masses
masses() -> Optional[Series]
Returns a Series
of atom masses (dtype polars.Float32
).
Source code in atomlib/atoms.py
add_atom
add_atom(
elem: Union[int, str],
/,
x: Union[ArrayLike, float],
y: Optional[float] = None,
z: Optional[float] = None,
*,
frame: Optional[CoordinateFrame] = None,
**kwargs: Any,
) -> Self
Return a copy of self
with an extra atom.
By default, all extra columns present in self
must be specified as **kwargs
.
Try to avoid calling this in a loop (Use concat
instead).
Source code in atomlib/atomcell.py
pos
pos(
x: Union[Sequence[Optional[float]], float, None] = None,
y: Optional[float] = None,
z: Optional[float] = None,
*,
tol: float = 1e-06,
**kwargs: Any
) -> Expr
Select all atoms at a given position.
Formally, returns all atoms within a cube of radius tol
centered at (x,y,z)
, exclusive of the cube's surface.
Additional parameters given as kwargs
will be checked
as additional parameters (with strict equality).
Source code in atomlib/atoms.py
with_index
with_index(
index: Optional[AtomValues] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Returns self
with a row index added in column 'i' (dtype polars.Int64
).
If index
is not specified, defaults to an existing index or a new index.
Source code in atomlib/atomcell.py
with_wobble
with_wobble(
wobble: Optional[AtomValues] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self
with the given displacements in column 'wobble' (dtype polars.Float64
).
If wobble
is not specified, defaults to the already-existing wobbles or 0.
Source code in atomlib/atomcell.py
with_occupancy
with_occupancy(
frac_occupancy: Optional[AtomValues] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self with the given fractional occupancies (dtype polars.Float64
).
If frac_occupancy
is not specified, defaults to the already-existing occupancies or 1.
Source code in atomlib/atomcell.py
apply_wobble
apply_wobble(
rng: Union[Generator, int, None] = None,
frame: Optional[CoordinateFrame] = None,
) -> Self
Displace the atoms in self
by the amount in the wobble
column.
wobble
is interpretated as a mean-squared displacement, which is distributed
equally over each axis.
Source code in atomlib/atomcell.py
apply_occupancy
For each atom in self
, use its frac_occupancy
to randomly decide whether to remove it.
Source code in atomlib/atoms.py
with_type
with_type(
types: Optional[AtomValues] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self
with the given atom types in column 'type'.
If types
is not specified, use the already existing types or auto-assign them.
When auto-assigning, each symbol is given a unique value, case-sensitive.
Values are assigned from lowest atomic number to highest.
For instance: ["Ag+", "Na", "H", "Ag"]
=> [3, 11, 1, 2]
Source code in atomlib/atomcell.py
with_mass
with_mass(
mass: Optional[ArrayLike] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self
with the given atom masses in column 'mass'
.
If mass
is not specified, use the already existing masses or auto-assign them.
Source code in atomlib/atomcell.py
with_symbol
with_symbol(
symbols: ArrayLike,
selection: Optional[AtomSelection] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self
with the given atomic symbols.
with_coords
with_coords(
pts: ArrayLike,
selection: Optional[AtomSelection] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self
replaced with the given atomic positions.
with_velocity
with_velocity(
pts: Optional[ArrayLike] = None,
selection: Optional[AtomSelection] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self
replaced with the given atomic velocities.
If pts
is not specified, use the already existing velocities or zero.
Source code in atomlib/atomcell.py
get_atomcell
get_atomcell() -> AtomCell
to_frame
to_frame(frame: CoordinateFrame) -> Self
crop_to_box
crop_to_box(eps: float = 1e-05) -> Self
wrap
wrap(eps: float = 1e-05) -> Self
repeat_to
Repeat the cell so it is at least size
along the crystal's axes.
If crop
, then crop the cell to exactly size
. This may break periodicity.
crop
may be a vector, in which case you can specify cropping only along some axes.
Source code in atomlib/atomcell.py
repeat_x
repeat_x(n: int) -> Self
repeat_y
repeat_y(n: int) -> Self
repeat_z
repeat_z(n: int) -> Self
repeat_to_x
Repeat the cell so it is at least size size
along the x axis.
repeat_to_y
Repeat the cell so it is at least size size
along the y axis.
repeat_to_z
Repeat the cell so it is at least size size
along the z axis.
repeat_to_aspect
repeat_to_aspect(
plane: Literal["xy", "xz", "yz"] = "xy",
*,
aspect: float = 1.0,
min_size: Optional[VecLike] = None,
max_size: Optional[VecLike] = None
) -> Self
Repeat to optimize the aspect ratio in plane
,
while staying above min_size
and under max_size
.
Source code in atomlib/atomcell.py
periodic_duplicate
periodic_duplicate(eps: float = 1e-05) -> Self
Add duplicate copies of atoms near periodic boundaries.
For instance, an atom at a corner will be duplicated into 8 copies. This is mostly only useful for visualization.
Source code in atomlib/atomcell.py
read
classmethod
read(path: FileOrPath, ty: FileType) -> HasAtomsT
read(
path: FileOrPath, ty: Optional[FileType] = None
) -> HasAtomsT
Read a structure from a file.
Supported types can be found in the io module.
If no ty
is specified, it is inferred from the file's extension.
Source code in atomlib/mixins.py
read_cif
classmethod
read_cif(
f: Union[FileOrPath, CIF, CIFDataBlock],
block: Union[int, str, None] = None,
) -> HasAtomsT
Read a structure from a CIF file.
If block
is specified, read data from the given block of the CIF file (index or name).
Source code in atomlib/mixins.py
read_xyz
classmethod
read_xyz(f: Union[FileOrPath, XYZ]) -> HasAtomsT
read_xsf
classmethod
read_xsf(f: Union[FileOrPath, XSF]) -> HasAtomsT
read_cfg
classmethod
read_cfg(f: Union[FileOrPath, CFG]) -> HasAtomsT
read_lmp
classmethod
read_lmp(
f: Union[FileOrPath, LMP],
type_map: Optional[Dict[int, Union[str, int]]] = None,
) -> HasAtomsT
Read a structure from a LAAMPS data file.
Source code in atomlib/mixins.py
write_cif
write_cif(f: FileOrPath)
write_xyz
write_xyz(f: FileOrPath, fmt: XYZFormat = 'exyz')
write_xsf
write_xsf(f: FileOrPath)
write_cfg
write_cfg(f: FileOrPath)
write_lmp
write_lmp(f: FileOrPath)
write
write(path: FileOrPath, ty: FileType)
write(path: FileOrPath, ty: Optional[FileType] = None)
Write this structure to a file.
A file type may be specified using ty
.
If no ty
is specified, it is inferred from the path's extension.
Source code in atomlib/mixins.py
write_mslice
write_mslice(
f: BinaryFileOrPath,
template: Optional[MSliceFile] = None,
*,
slice_thickness: Optional[float] = None,
scan_points: Optional[ArrayLike] = None,
scan_extent: Optional[ArrayLike] = None,
noise_sigma: Optional[float] = None,
conv_angle: Optional[float] = None,
energy: Optional[float] = None,
defocus: Optional[float] = None,
tilt: Optional[Tuple[float, float]] = None,
tds: Optional[bool] = None,
n_cells: Optional[ArrayLike] = None
)
Write a structure to an mslice file.
template
may be a file, path, or ElementTree
containing an existing mslice file.
Its structure will be modified to make the final output. If not specified, a default
template will be used.
Additional options modify simulation properties. If an option is not specified, the template's properties are used.
Source code in atomlib/mixins.py
write_qe
write_qe(
f: FileOrPath,
pseudo: Optional[Mapping[str, str]] = None,
)
Write a structure to a Quantum Espresso pw.x file.
PARAMETER | DESCRIPTION |
---|---|
f
|
File or path to write to
TYPE:
|
pseudo
|
Mapping from atom symbol |
Source code in atomlib/mixins.py
get_cell
get_cell() -> Cell
with_cell
with_cell(cell: Cell) -> Self
get_atoms
get_atoms(frame: Optional[CoordinateFrame] = None) -> Atoms
Get atoms contained in self
, in the given coordinate frame.
Source code in atomlib/atomcell.py
with_atoms
with_atoms(
atoms: HasAtoms, frame: Optional[CoordinateFrame] = None
) -> Self
get_frame
get_frame() -> CoordinateFrame
from_ortho
classmethod
from_ortho(
atoms: IntoAtoms,
ortho: LinearTransform3D,
*,
n_cells: Optional[VecLike] = None,
frame: CoordinateFrame = "local",
keep_frame: bool = False
)
Make an atom cell given a list of atoms and an orthogonalization matrix.
Atoms are assumed to be in the coordinate system frame
.
Source code in atomlib/atomcell.py
from_unit_cell
classmethod
from_unit_cell(
atoms: IntoAtoms,
cell_size: VecLike,
cell_angle: Optional[VecLike] = None,
*,
n_cells: Optional[VecLike] = None,
frame: CoordinateFrame = "local",
keep_frame: bool = False
)
Make a cell given a list of atoms and unit cell parameters.
Atoms are assumed to be in the coordinate system frame
.
Source code in atomlib/atomcell.py
orthogonalize
orthogonalize() -> OrthoCell
clone
HasAtomCell
Source code in atomlib/atomcell.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
|
affine
property
affine: AffineTransform3D
Affine transformation. Holds transformation from 'ortho' to 'local' coordinates, including rotation away from the standard crystal orientation.
ortho
property
ortho: LinearTransform3D
Orthogonalization transformation. Skews but does not scale the crystal axes to cartesian axes.
metric
property
metric: LinearTransform3D
Cell metric tensor
Returns the dot product between every combination of basis vectors.
:math:\mathbf{a} \cdot \mathbf{b} = a_i M_ij b_j
pbc
property
Flags indicating the presence of periodic boundary conditions along each axis.
ortho_size
property
Return size of orthogonal unit cell.
Equivalent to the diagonal of the orthogonalization matrix.
box_size
property
Return size of the cell box.
Equivalent to self.n_cells * self.cell_size
.
columns
property
dtypes
property
dtypes: List[DataType]
schema
property
Return the schema of self
.
RETURNS | DESCRIPTION |
---|---|
Schema
|
A dictionary of column names and |
get_cell
abstractmethod
get_cell() -> Cell
get_transform
get_transform(
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> AffineTransform3D
In the two-argument form, get the transform to frame_to
from frame_from
.
In the one-argument form, get the transform from local coordinates to 'frame'.
Source code in atomlib/cell.py
corners
corners(frame: CoordinateFrame = 'local') -> ndarray
bbox_cell
bbox_cell(frame: CoordinateFrame = 'local') -> BBox3D
Return the bounding box of the cell box in the given coordinate system.
is_orthogonal
is_orthogonal_in_local
Returns whether this cell is orthogonal and aligned with the local coordinate system.
Source code in atomlib/cell.py
to_ortho
to_ortho() -> AffineTransform3D
strain_orthogonal
strain_orthogonal() -> HasCellT
Orthogonalize using strain.
Strain is applied such that the x-axis remains fixed, and the y-axis remains in the xy plane. For small displacements, no hydrostatic strain is applied (volume is conserved).
Source code in atomlib/cell.py
explode_z
explode_z() -> HasCellT
Materialize repeated cells as one supercell in z.
Source code in atomlib/cell.py
change_transform
change_transform(
transform: AffineTransform3D,
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> AffineTransform3D
change_transform(
transform: Transform3D,
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> Transform3D
change_transform(
transform: Transform3D,
frame_to: Optional[CoordinateFrame] = None,
frame_from: Optional[CoordinateFrame] = None,
) -> Transform3D
Coordinate-change a transformation from frame_from
into frame_to
.
Source code in atomlib/cell.py
insert_column
insert_column(index: int, column: Series) -> DataFrame
get_column_index
Get the index of a column by name, raising polars.ColumnNotFoundError
if it's not present.
clone
drop
drop_nulls
drop_nulls(
subset: Union[str, Collection[str], None] = None
) -> DataFrame
Drop rows that contain nulls in any of columns subset
.
concat
classmethod
concat(
atoms: Union[
HasAtomsT,
IntoAtoms,
Iterable[Union[HasAtomsT, IntoAtoms]],
],
*,
rechunk: bool = True,
how: ConcatMethod = "vertical"
) -> HasAtomsT
Concatenate multiple Atoms
together, handling metadata appropriately.
Source code in atomlib/atoms.py
partition_by
partition_by(
by: Union[str, Sequence[str]],
*more_by: str,
maintain_order: bool = True,
include_key: bool = True,
as_dict: bool = False
) -> Union[List[Self], Dict[Any, Self]]
Group by the given columns and partition into separate dataframes.
Return the partitions as a dictionary by specifying as_dict=True
.
Source code in atomlib/atoms.py
select_schema
select_schema(schema: SchemaDict) -> DataFrame
Select columns from self
and cast to the given schema.
Raises TypeError
if a column is not found or if it can't be cast.
Source code in atomlib/atoms.py
try_get_column
Try to get a column from self
, returning None
if it doesn't exist.
deduplicate
deduplicate(
tol: float = 0.001,
subset: Iterable[str] = ("x", "y", "z", "symbol"),
keep: UniqueKeepStrategy = "first",
maintain_order: bool = True,
) -> Self
De-duplicate atoms in self
. Atoms of the same symbol
that are closer than tolerance
to each other (by Euclidian distance) will be removed, leaving only the atom specified by
keep
(defaults to the first atom).
If subset
is specified, only those columns will be included while assessing duplicates.
Floating point columns other than 'x', 'y', and 'z' will not by toleranced.
Source code in atomlib/atoms.py
with_bounds
with_bounds(
cell_size: Optional[VecLike] = None,
cell_origin: Optional[VecLike] = None,
) -> "AtomCell"
Return a periodic cell with the given orthogonal cell dimensions.
If cell_size is not specified, it will be assumed (and may be incorrect).
Source code in atomlib/atoms.py
x
y
z
types
types() -> Optional[Series]
Returns a Series
of atom types (dtype polars.Int32
).
Source code in atomlib/atoms.py
masses
masses() -> Optional[Series]
Returns a Series
of atom masses (dtype polars.Float32
).
Source code in atomlib/atoms.py
pos
pos(
x: Union[Sequence[Optional[float]], float, None] = None,
y: Optional[float] = None,
z: Optional[float] = None,
*,
tol: float = 1e-06,
**kwargs: Any
) -> Expr
Select all atoms at a given position.
Formally, returns all atoms within a cube of radius tol
centered at (x,y,z)
, exclusive of the cube's surface.
Additional parameters given as kwargs
will be checked
as additional parameters (with strict equality).
Source code in atomlib/atoms.py
apply_occupancy
For each atom in self
, use its frac_occupancy
to randomly decide whether to remove it.
Source code in atomlib/atoms.py
get_frame
abstractmethod
get_frame() -> CoordinateFrame
with_atoms
abstractmethod
with_atoms(
atoms: HasAtoms, frame: Optional[CoordinateFrame] = None
) -> Self
Replace the atoms in self
. If no coordinate frame is specified, keep the coordinate frame unchanged.
with_cell
with_cell(cell: Cell) -> Self
get_atomcell
get_atomcell() -> AtomCell
get_atoms
abstractmethod
get_atoms(frame: Optional[CoordinateFrame] = None) -> Atoms
bbox_atoms
bbox_atoms(
frame: Optional[CoordinateFrame] = None,
) -> BBox3D
Return the bounding box of all the atoms in self
, in the given coordinate frame.
bbox
bbox(frame: CoordinateFrame = 'local') -> BBox3D
Return the combined bounding box of the cell and atoms in the given coordinate system.
To get the cell or atoms bounding box only, use bbox_cell
or bbox_atoms
.
Source code in atomlib/atomcell.py
to_frame
to_frame(frame: CoordinateFrame) -> Self
transform_atoms
transform_atoms(
transform: IntoTransform3D,
selection: Optional[AtomSelection] = None,
*,
frame: CoordinateFrame = "local",
transform_velocities: bool = False
) -> Self
Transform the atoms in self
by transform
.
If selection
is given, only transform the atoms in selection
.
Source code in atomlib/atomcell.py
transform_cell
transform_cell(
transform: AffineTransform3D,
frame: CoordinateFrame = "local",
) -> Self
Apply the given transform to the unit cell, without changing atom positions. The transform is applied in coordinate frame 'frame'.
Source code in atomlib/atomcell.py
transform
transform(
transform: AffineTransform3D,
frame: CoordinateFrame = "local",
) -> Self
Source code in atomlib/atomcell.py
crop
crop(
x_min: float = -inf,
x_max: float = inf,
y_min: float = -inf,
y_max: float = inf,
z_min: float = -inf,
z_max: float = inf,
*,
frame: CoordinateFrame = "local"
) -> Self
Crop atoms and cell to the given extents. For a non-orthogonal
cell, this must be specified in cell coordinates. This
function implicity explode
s the cell as well.
To crop atoms only, use crop_atoms
instead.
Source code in atomlib/atomcell.py
crop_atoms
crop_atoms(
x_min: float = -inf,
x_max: float = inf,
y_min: float = -inf,
y_max: float = inf,
z_min: float = -inf,
z_max: float = inf,
*,
frame: CoordinateFrame = "local"
) -> Self
Source code in atomlib/atomcell.py
crop_to_box
crop_to_box(eps: float = 1e-05) -> Self
wrap
wrap(eps: float = 1e-05) -> Self
repeat
Tile the cell
Source code in atomlib/atomcell.py
repeat_to
Repeat the cell so it is at least size
along the crystal's axes.
If crop
, then crop the cell to exactly size
. This may break periodicity.
crop
may be a vector, in which case you can specify cropping only along some axes.
Source code in atomlib/atomcell.py
repeat_x
repeat_x(n: int) -> Self
repeat_y
repeat_y(n: int) -> Self
repeat_z
repeat_z(n: int) -> Self
repeat_to_x
Repeat the cell so it is at least size size
along the x axis.
repeat_to_y
Repeat the cell so it is at least size size
along the y axis.
repeat_to_z
Repeat the cell so it is at least size size
along the z axis.
repeat_to_aspect
repeat_to_aspect(
plane: Literal["xy", "xz", "yz"] = "xy",
*,
aspect: float = 1.0,
min_size: Optional[VecLike] = None,
max_size: Optional[VecLike] = None
) -> Self
Repeat to optimize the aspect ratio in plane
,
while staying above min_size
and under max_size
.
Source code in atomlib/atomcell.py
explode
Materialize repeated cells as one supercell.
periodic_duplicate
periodic_duplicate(eps: float = 1e-05) -> Self
Add duplicate copies of atoms near periodic boundaries.
For instance, an atom at a corner will be duplicated into 8 copies. This is mostly only useful for visualization.
Source code in atomlib/atomcell.py
describe
describe(
percentiles: Union[Sequence[float], float, None] = (
0.25,
0.5,
0.75,
),
*,
interpolation: RollingInterpolationMethod = "nearest",
frame: Optional[CoordinateFrame] = None
) -> DataFrame
Return summary statistics for self
. See DataFrame.describe
for more information.
PARAMETER | DESCRIPTION |
---|---|
percentiles
|
List of percentiles/quantiles to include. Defaults to 25% (first quartile), 50% (median), and 75% (third quartile).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
A dataframe containing summary statistics (mean, std. deviation, percentiles, etc.) for each column. |
Source code in atomlib/atomcell.py
with_columns
with_columns(
*exprs: Union[IntoExpr, Iterable[IntoExpr]],
frame: Optional[CoordinateFrame] = None,
**named_exprs: IntoExpr
) -> Self
Return a copy of self
with the given columns added.
get_column
get_column(
name: str, *, frame: Optional[CoordinateFrame] = None
) -> Series
Get the specified column from self
, raising polars.ColumnNotFoundError
if it's not present.
Source code in atomlib/atomcell.py
get_columns
get_columns(
*, frame: Optional[CoordinateFrame] = None
) -> List[Series]
Return all columns from self
as a list of Series
.
Source code in atomlib/atomcell.py
group_by
group_by(
*by: Union[IntoExpr, Iterable[IntoExpr]],
maintain_order: bool = False,
frame: Optional[CoordinateFrame] = None,
**named_by: IntoExpr
) -> GroupBy
Start a group by operation. See DataFrame.group_by
for more information.
Source code in atomlib/atomcell.py
pipe
pipe(
function: Callable[Concatenate[HasAtomCellT, P], T],
*args: args,
**kwargs: kwargs
) -> T
Apply function
to self
(in method-call syntax).
filter
filter(
*predicates: Union[
None,
IntoExprColumn,
Iterable[IntoExprColumn],
bool,
List[bool],
ndarray,
],
frame: Optional[CoordinateFrame] = None,
**constraints: Any
) -> Self
Filter self
, removing rows which evaluate to False
.
Source code in atomlib/atomcell.py
sort
sort(
by: Union[IntoExpr, Iterable[IntoExpr]],
*more_by: IntoExpr,
descending: Union[bool, Sequence[bool]] = False,
nulls_last: bool = False
) -> Self
Sort the atoms in self
by the given columns/expressions.
Source code in atomlib/atomcell.py
slice
slice(
offset: int,
length: Optional[int] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
head
head(
n: int = 5, *, frame: Optional[CoordinateFrame] = None
) -> Self
tail
tail(
n: int = 5, *, frame: Optional[CoordinateFrame] = None
) -> Self
fill_null
fill_nan
fill_nan(
value: Union[Expr, int, float, None],
*,
frame: Optional[CoordinateFrame] = None
) -> Self
select
select(
*exprs: Union[IntoExpr, Iterable[IntoExpr]],
frame: Optional[CoordinateFrame] = None,
**named_exprs: IntoExpr
) -> DataFrame
Select exprs
from self
, and return as a polars.DataFrame
.
Expressions may either be columns or expressions of columns.
Source code in atomlib/atomcell.py
select_props
select_props(
*exprs: Union[IntoExpr, Iterable[IntoExpr]],
frame: Optional[CoordinateFrame] = None,
**named_exprs: IntoExpr
) -> Self
Select exprs
from self
, while keeping required columns.
Doesn't affect the cell.
RETURNS | DESCRIPTION |
---|---|
Self
|
A |
Self
|
the specified properties (as well as required columns). |
Source code in atomlib/atomcell.py
try_select
try_select(
*exprs: Union[IntoExpr, Iterable[IntoExpr]],
frame: Optional[CoordinateFrame] = None,
**named_exprs: IntoExpr
) -> Optional[DataFrame]
Try to select exprs
from self
, and return as a polars.DataFrame
.
Expressions may either be columns or expressions of columns. Returns None
if any
columns are missing.
Source code in atomlib/atomcell.py
round_near_zero
round_near_zero(
tol: float = 1e-14,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
coords
coords(
selection: Optional[AtomSelection] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> NDArray[float64]
Return a (N, 3)
ndarray of atom positions (dtype numpy.float64
)
in the given coordinate frame.
Source code in atomlib/atomcell.py
velocities
velocities(
selection: Optional[AtomSelection] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Optional[NDArray[float64]]
Return a (N, 3)
ndarray of atom velocities (dtype numpy.float64
)
in the given coordinate frame.
Source code in atomlib/atomcell.py
add_atom
add_atom(
elem: Union[int, str],
/,
x: Union[ArrayLike, float],
y: Optional[float] = None,
z: Optional[float] = None,
*,
frame: Optional[CoordinateFrame] = None,
**kwargs: Any,
) -> Self
Return a copy of self
with an extra atom.
By default, all extra columns present in self
must be specified as **kwargs
.
Try to avoid calling this in a loop (Use concat
instead).
Source code in atomlib/atomcell.py
with_index
with_index(
index: Optional[AtomValues] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Returns self
with a row index added in column 'i' (dtype polars.Int64
).
If index
is not specified, defaults to an existing index or a new index.
Source code in atomlib/atomcell.py
with_wobble
with_wobble(
wobble: Optional[AtomValues] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self
with the given displacements in column 'wobble' (dtype polars.Float64
).
If wobble
is not specified, defaults to the already-existing wobbles or 0.
Source code in atomlib/atomcell.py
with_occupancy
with_occupancy(
frac_occupancy: Optional[AtomValues] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self with the given fractional occupancies (dtype polars.Float64
).
If frac_occupancy
is not specified, defaults to the already-existing occupancies or 1.
Source code in atomlib/atomcell.py
apply_wobble
apply_wobble(
rng: Union[Generator, int, None] = None,
frame: Optional[CoordinateFrame] = None,
) -> Self
Displace the atoms in self
by the amount in the wobble
column.
wobble
is interpretated as a mean-squared displacement, which is distributed
equally over each axis.
Source code in atomlib/atomcell.py
with_type
with_type(
types: Optional[AtomValues] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self
with the given atom types in column 'type'.
If types
is not specified, use the already existing types or auto-assign them.
When auto-assigning, each symbol is given a unique value, case-sensitive.
Values are assigned from lowest atomic number to highest.
For instance: ["Ag+", "Na", "H", "Ag"]
=> [3, 11, 1, 2]
Source code in atomlib/atomcell.py
with_mass
with_mass(
mass: Optional[ArrayLike] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self
with the given atom masses in column 'mass'
.
If mass
is not specified, use the already existing masses or auto-assign them.
Source code in atomlib/atomcell.py
with_symbol
with_symbol(
symbols: ArrayLike,
selection: Optional[AtomSelection] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self
with the given atomic symbols.
with_coords
with_coords(
pts: ArrayLike,
selection: Optional[AtomSelection] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self
replaced with the given atomic positions.
with_velocity
with_velocity(
pts: Optional[ArrayLike] = None,
selection: Optional[AtomSelection] = None,
*,
frame: Optional[CoordinateFrame] = None
) -> Self
Return self
replaced with the given atomic velocities.
If pts
is not specified, use the already existing velocities or zero.