picometer 0.2.0__tar.gz → 0.3.0__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: picometer
3
- Version: 0.2.0
3
+ Version: 0.3.0
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,10 +2,9 @@ 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,
@@ -13,6 +12,12 @@ from picometer.shapes import (are_synparallel, degrees_between, Line,
13
12
  from picometer.utility import ustr2float
14
13
 
15
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
19
+
20
+
16
21
  logger = logging.getLogger(__name__)
17
22
 
18
23
 
@@ -85,6 +90,19 @@ class AtomSet(Shape):
85
90
  'fract_y': [ustr2float(v) for v in cb['_atom_site_fract_y']],
86
91
  'fract_z': [ustr2float(v) for v in cb['_atom_site_fract_z']],
87
92
  }
93
+ try:
94
+ atoms_dict['Uiso'] = [ustr2float(v) for v in cb['_atom_site_U_iso_or_equiv']]
95
+ except KeyError:
96
+ pass
97
+ try:
98
+ atoms_dict['U11'] = [ustr2float(v) for v in cb['_atom_site_aniso_U_11']]
99
+ atoms_dict['U22'] = [ustr2float(v) for v in cb['_atom_site_aniso_U_22']]
100
+ atoms_dict['U33'] = [ustr2float(v) for v in cb['_atom_site_aniso_U_33']]
101
+ atoms_dict['U23'] = [ustr2float(v) for v in cb['_atom_site_aniso_U_23']]
102
+ atoms_dict['U13'] = [ustr2float(v) for v in cb['_atom_site_aniso_U_13']]
103
+ atoms_dict['U12'] = [ustr2float(v) for v in cb['_atom_site_aniso_U_12']]
104
+ except KeyError:
105
+ pass
88
106
  atoms = pd.DataFrame.from_records(atoms_dict).set_index('label')
89
107
  except KeyError:
90
108
  atoms = pd.DataFrame()
@@ -131,7 +149,7 @@ class AtomSet(Shape):
131
149
  return self.__class__(self.base, deepcopy(self.table[mask]))
132
150
 
133
151
  def transform(self, symm_op_code: str) -> 'AtomSet':
134
- symm_op = hikari.symmetry.SymmOp.from_code(symm_op_code)
152
+ symm_op = Operation.from_code(symm_op_code)
135
153
  fract_xyz = symm_op.transform(self.fract_xyz.T)
136
154
  data = deepcopy(self.table)
137
155
  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)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "picometer"
3
- version = "0.2.0"
3
+ version = "0.3.0"
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