picometer 0.2.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {picometer-0.2.0 → picometer-0.3.1}/PKG-INFO +5 -2
- {picometer-0.2.0 → picometer-0.3.1}/README.md +3 -0
- {picometer-0.2.0 → picometer-0.3.1}/picometer/atom.py +35 -14
- {picometer-0.2.0 → picometer-0.3.1}/picometer/instructions.py +28 -0
- picometer-0.3.1/picometer/utility.py +13 -0
- {picometer-0.2.0 → picometer-0.3.1}/pyproject.toml +2 -2
- picometer-0.2.0/picometer/utility.py +0 -5
- {picometer-0.2.0 → picometer-0.3.1}/LICENSE +0 -0
- {picometer-0.2.0 → picometer-0.3.1}/picometer/__init__.py +0 -0
- {picometer-0.2.0 → picometer-0.3.1}/picometer/__main__.py +0 -0
- {picometer-0.2.0 → picometer-0.3.1}/picometer/logging.py +0 -0
- {picometer-0.2.0 → picometer-0.3.1}/picometer/models.py +0 -0
- {picometer-0.2.0 → picometer-0.3.1}/picometer/process.py +0 -0
- {picometer-0.2.0 → picometer-0.3.1}/picometer/settings.py +0 -0
- {picometer-0.2.0 → picometer-0.3.1}/picometer/settings.yaml +0 -0
- {picometer-0.2.0 → picometer-0.3.1}/picometer/shapes.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: picometer
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Precisely define and calculate measurements across multiple crystal structures
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Daniel Tchoń
|
|
@@ -140,6 +140,9 @@ The following instructions are currently supported by picometer:
|
|
|
140
140
|
- fit `line` to the current atom / centroid selection;
|
|
141
141
|
- fit `plane` to the currect atom / centroid selection;
|
|
142
142
|
- **Evaluation instructions**
|
|
143
|
+
- write out fractional `coordinates` of currently selected centroids or atoms.
|
|
144
|
+
- write out `displacement` parameters of currently selected centroids or atoms
|
|
145
|
+
(note: currently does not correctly handle symmetry transformations).
|
|
143
146
|
- measure `distance` between 2 selected objects; if the selection includes
|
|
144
147
|
groups of atoms, measure closes distance to the group of atoms.
|
|
145
148
|
- measure `angle` between 2–3 selected objects: planes, lines, or (ordered) atoms.
|
|
@@ -120,6 +120,9 @@ The following instructions are currently supported by picometer:
|
|
|
120
120
|
- fit `line` to the current atom / centroid selection;
|
|
121
121
|
- fit `plane` to the currect atom / centroid selection;
|
|
122
122
|
- **Evaluation instructions**
|
|
123
|
+
- write out fractional `coordinates` of currently selected centroids or atoms.
|
|
124
|
+
- write out `displacement` parameters of currently selected centroids or atoms
|
|
125
|
+
(note: currently does not correctly handle symmetry transformations).
|
|
123
126
|
- measure `distance` between 2 selected objects; if the selection includes
|
|
124
127
|
groups of atoms, measure closes distance to the group of atoms.
|
|
125
128
|
- measure `angle` between 2–3 selected objects: planes, lines, or (ordered) atoms.
|
|
@@ -2,15 +2,20 @@ from copy import deepcopy
|
|
|
2
2
|
import logging
|
|
3
3
|
from typing import Dict, NamedTuple, List, Sequence
|
|
4
4
|
|
|
5
|
-
import hikari.symmetry
|
|
6
5
|
from hikari.dataframes import BaseFrame, CifFrame
|
|
7
|
-
import numpy as np
|
|
8
6
|
from numpy.linalg import norm
|
|
7
|
+
import numpy as np
|
|
9
8
|
import pandas as pd
|
|
10
9
|
|
|
11
10
|
from picometer.shapes import (are_synparallel, degrees_between, Line,
|
|
12
11
|
Plane, Shape, Vector3)
|
|
13
|
-
from picometer.utility import ustr2float
|
|
12
|
+
from picometer.utility import ustr2float, ustr2floats
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
from hikari.symmetry import Operation
|
|
17
|
+
except ImportError: # hikari version < 0.3.0
|
|
18
|
+
from hikari.symmetry import SymmOp as Operation
|
|
14
19
|
|
|
15
20
|
|
|
16
21
|
logger = logging.getLogger(__name__)
|
|
@@ -78,16 +83,32 @@ class AtomSet(Shape):
|
|
|
78
83
|
al=ustr2float(cb['_cell_angle_alpha']),
|
|
79
84
|
be=ustr2float(cb['_cell_angle_beta']),
|
|
80
85
|
ga=ustr2float(cb['_cell_angle_gamma']))
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
atoms =
|
|
86
|
+
|
|
87
|
+
atoms = pd.DataFrame()
|
|
88
|
+
|
|
89
|
+
atom_labels = cb.get('_atom_site_label', [])
|
|
90
|
+
atom_xs = ustr2floats(cb.get('_atom_site_fract_x', []))
|
|
91
|
+
atom_ys = ustr2floats(cb.get('_atom_site_fract_y', []))
|
|
92
|
+
atom_zs = ustr2floats(cb.get('_atom_site_fract_z', []))
|
|
93
|
+
atom_u_isos = ustr2floats(cb.get('_atom_site_U_iso_or_equiv', []))
|
|
94
|
+
for label, x, y, z in zip(atom_labels, atom_xs, atom_ys, atom_zs):
|
|
95
|
+
atoms.loc[label, ['fract_x', 'fract_y', 'fract_z']] = [x, y, z]
|
|
96
|
+
for label, u_iso in zip(atom_labels, atom_u_isos):
|
|
97
|
+
atoms.loc[label, 'Uiso'] = u_iso
|
|
98
|
+
|
|
99
|
+
atom_labels = cb.get('_atom_site_aniso_label', [])
|
|
100
|
+
atom_u11s = ustr2floats(cb.get('_atom_site_aniso_U_11', []))
|
|
101
|
+
atom_u22s = ustr2floats(cb.get('_atom_site_aniso_U_22', []))
|
|
102
|
+
atom_u33s = ustr2floats(cb.get('_atom_site_aniso_U_33', []))
|
|
103
|
+
atom_u12s = ustr2floats(cb.get('_atom_site_aniso_U_12', []))
|
|
104
|
+
atom_u13s = ustr2floats(cb.get('_atom_site_aniso_U_13', []))
|
|
105
|
+
atom_u23s = ustr2floats(cb.get('_atom_site_aniso_U_23', []))
|
|
106
|
+
atom_us = zip(atom_u11s, atom_u22s, atom_u33s, atom_u12s, atom_u13s, atom_u23s)
|
|
107
|
+
for label, us in zip(atom_labels, atom_us):
|
|
108
|
+
atoms.loc[label, ['U11', 'U22', 'U33', 'U12', 'U13', 'U23']] = list(us)
|
|
109
|
+
|
|
110
|
+
for col in atoms.columns:
|
|
111
|
+
atoms[col] = pd.to_numeric(atoms[col], errors='coerce')
|
|
91
112
|
return AtomSet(bf, atoms)
|
|
92
113
|
|
|
93
114
|
@property
|
|
@@ -131,7 +152,7 @@ class AtomSet(Shape):
|
|
|
131
152
|
return self.__class__(self.base, deepcopy(self.table[mask]))
|
|
132
153
|
|
|
133
154
|
def transform(self, symm_op_code: str) -> 'AtomSet':
|
|
134
|
-
symm_op =
|
|
155
|
+
symm_op = Operation.from_code(symm_op_code)
|
|
135
156
|
fract_xyz = symm_op.transform(self.fract_xyz.T)
|
|
136
157
|
data = deepcopy(self.table)
|
|
137
158
|
data['fract_x'] = fract_xyz[:, 0]
|
|
@@ -307,6 +307,34 @@ class PlaneInstructionsHandler(SerialInstructionHandler):
|
|
|
307
307
|
logger.info(f'Defined plane {label}: {plane} for model state {ms_key}')
|
|
308
308
|
|
|
309
309
|
|
|
310
|
+
class CoordinatesInstructionHandler(SerialInstructionHandler):
|
|
311
|
+
name = 'coordinates'
|
|
312
|
+
kwargs = None
|
|
313
|
+
|
|
314
|
+
def handle_one(self, instruction: Instruction, ms_key: str, ms: ModelState) -> None:
|
|
315
|
+
focus = ms.nodes.locate(self.processor.selection)
|
|
316
|
+
for label, coords in focus.table.iterrows():
|
|
317
|
+
self.processor.evaluation_table.loc[ms_key, label + '_x'] = coords.fract_x
|
|
318
|
+
self.processor.evaluation_table.loc[ms_key, label + '_y'] = coords.fract_y
|
|
319
|
+
self.processor.evaluation_table.loc[ms_key, label + '_z'] = coords.fract_z
|
|
320
|
+
logger.info(f'Noted coordinates for current selection in model state {ms_key}')
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
class DisplacementInstructionHandler(SerialInstructionHandler):
|
|
324
|
+
name = 'displacement'
|
|
325
|
+
kwargs = None
|
|
326
|
+
|
|
327
|
+
def handle_one(self, instruction: Instruction, ms_key: str, ms: ModelState) -> None:
|
|
328
|
+
focus = ms.nodes.locate(self.processor.selection)
|
|
329
|
+
for label, displacements in focus.table.iterrows():
|
|
330
|
+
for suffix in 'Uiso U11 U22 U33 U23 U13 U12'.split():
|
|
331
|
+
label_ = label + '_' + suffix
|
|
332
|
+
value = getattr(displacements, suffix, None)
|
|
333
|
+
if value is not None:
|
|
334
|
+
self.processor.evaluation_table.loc[ms_key, label_] = value
|
|
335
|
+
logger.info(f'Noted displacement for current selection in model state {ms_key}')
|
|
336
|
+
|
|
337
|
+
|
|
310
338
|
class DistanceInstructionHandler(SerialInstructionHandler):
|
|
311
339
|
name = 'distance'
|
|
312
340
|
kwargs = dict(label=str)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from typing import Iterable, List
|
|
2
|
+
|
|
3
|
+
import uncertainties as uc
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def ustr2float(s: str) -> float:
|
|
7
|
+
"""Convert a string "1.23(4)" to float `1.23`, stripping uncertainty."""
|
|
8
|
+
return uc.ufloat_fromstr(s).nominal_value
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def ustr2floats(s: Iterable[str]) -> List[float]:
|
|
12
|
+
"""Convenience function to convert an iterable of u-strings to floats."""
|
|
13
|
+
return [ustr2float(s) for s in s]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "picometer"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.1"
|
|
4
4
|
description = "Precisely define and calculate measurements across multiple crystal structures"
|
|
5
5
|
authors = ["Daniel Tchoń"]
|
|
6
6
|
license = "MIT"
|
|
@@ -33,7 +33,7 @@ branch = "master" # branch to make releas
|
|
|
33
33
|
changelog_file = "CHANGELOG.md" # changelog file
|
|
34
34
|
build_command = "pip install poetry && poetry build" # build dists
|
|
35
35
|
commit_parser = "emoji" # default EmojiCommitParser
|
|
36
|
-
major_on_zero = true
|
|
36
|
+
major_on_zero = false # change to "true" only if you are sure you want version 1
|
|
37
37
|
commit_message = ":bookmark: v{version}\n\nAutomatically generated by python-semantic-release"
|
|
38
38
|
|
|
39
39
|
[tool.semantic_release.branches]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|