pyTEMlib 0.2023.8.0__py2.py3-none-any.whl → 0.2024.2.0__py2.py3-none-any.whl

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.

Potentially problematic release.


This version of pyTEMlib might be problematic. Click here for more details.

pyTEMlib/config_dir.py CHANGED
@@ -7,7 +7,6 @@
7
7
  config_dir: setup of directory ~/.pyTEMlib for custom sources and database
8
8
  """
9
9
  import os
10
- import numpy as np
11
10
 
12
11
  # import wget
13
12
  if os.name == 'posix':
pyTEMlib/crystal_tools.py CHANGED
@@ -27,6 +27,7 @@ import ase.data.colors
27
27
 
28
28
  import matplotlib.pylab as plt # basic plotting
29
29
  from scipy.spatial import cKDTree
30
+ import scipy
30
31
  _spglib_present = True
31
32
  try:
32
33
  import spglib
@@ -137,26 +138,26 @@ def get_projection(crystal, layers=1):
137
138
  for pro in projected:
138
139
  atomic_numbers.append(projected_crystal.get_atomic_numbers()[pro].sum())
139
140
 
140
- projected_crystal.rotate(np.degrees(angle)%360, 'z', rotate_cell=True)
141
+ projected_crystal.rotate(np.degrees(angle) % 360, 'z', rotate_cell=True)
141
142
 
142
- near_base = np.array([projected_crystal.cell[0,:2], -projected_crystal.cell[0,:2],
143
- projected_crystal.cell[1,:2], -projected_crystal.cell[1,:2],
144
- projected_crystal.cell[0,:2] + projected_crystal.cell[1,:2],
145
- -(projected_crystal.cell[0,:2] + projected_crystal.cell[1,:2])])
146
- lines = np.array( [[[0, near_base[0,0]],[0, near_base[0,1]]],
147
- [[0, near_base[2,0]],[0, near_base[2,1]]],
148
- [[near_base[0,0], near_base[4,0]],[near_base[0,1], near_base[4,1]]],
149
- [[near_base[2,0], near_base[4,0]],[near_base[2,1], near_base[4,1]]]])
143
+ near_base = np.array([projected_crystal.cell[0, :2], -projected_crystal.cell[0, :2],
144
+ projected_crystal.cell[1, :2], -projected_crystal.cell[1, :2],
145
+ projected_crystal.cell[0, :2] + projected_crystal.cell[1, :2],
146
+ -(projected_crystal.cell[0, :2] + projected_crystal.cell[1, :2])])
147
+ lines = np.array([[[0, near_base[0, 0]], [0, near_base[0, 1]]],
148
+ [[0, near_base[2, 0]], [0, near_base[2, 1]]],
149
+ [[near_base[0, 0], near_base[4, 0]], [near_base[0, 1], near_base[4, 1]]],
150
+ [[near_base[2, 0], near_base[4, 0]], [near_base[2, 1], near_base[4, 1]]]])
150
151
  projected_atoms = []
151
152
  for index in projected:
152
- projected_atoms.append(index[0])
153
+ projected_atoms.append(index[0])
153
154
 
154
- projected_crystal.info['projection']={'indices': projected,
155
- 'projected': projected_atoms,
156
- 'projected_Z': atomic_numbers,
157
- 'angle': np.degrees(angle)+180%360,
158
- 'near_base': near_base,
159
- 'lines': lines}
155
+ projected_crystal.info['projection'] = {'indices': projected,
156
+ 'projected': projected_atoms,
157
+ 'projected_Z': atomic_numbers,
158
+ 'angle': np.degrees(angle)+180 % 360,
159
+ 'near_base': near_base,
160
+ 'lines': lines}
160
161
  return projected_crystal
161
162
 
162
163
 
@@ -283,13 +284,8 @@ def ball_and_stick(atoms, extend=1, max_bond_length=0.):
283
284
  neighbor_list.update(super_cell)
284
285
  bond_matrix = neighbor_list.get_connectivity_matrix()
285
286
 
286
- del_double = []
287
- for (k, s) in bond_matrix.keys():
288
- if k > s:
289
- del_double.append((k, s))
290
- for key in del_double:
291
- bond_matrix.pop(key)
292
-
287
+ bond_matrix = np.triu(bond_matrix.toarray())
288
+ bond_matrix = scipy.sparse.dok_array(bond_matrix)
293
289
  if super_cell.info is None:
294
290
  super_cell.info = {}
295
291
  super_cell.info['plot_cell'] = {'bond_matrix': bond_matrix, 'corner_vectors': corner_vectors,
@@ -298,7 +294,7 @@ def ball_and_stick(atoms, extend=1, max_bond_length=0.):
298
294
  return super_cell
299
295
 
300
296
 
301
- def plot_unit_cell(atoms, extend=1, max_bond_length=1.0, ax = None):
297
+ def plot_unit_cell(atoms, extend=1, max_bond_length=1.0, ax=None):
302
298
  """
303
299
  Simple plot of unit cell
304
300
  """
@@ -309,8 +305,8 @@ def plot_unit_cell(atoms, extend=1, max_bond_length=1.0, ax = None):
309
305
  positions = super_cell.positions - super_cell.cell.lengths()/2
310
306
 
311
307
  if ax is None:
312
- fig = plt.figure()
313
- ax = fig.add_subplot(111, projection='3d')
308
+ fig = plt.figure()
309
+ ax = fig.add_subplot(111, projection='3d')
314
310
  # draw unit_cell
315
311
 
316
312
  for line in super_cell.info['plot_cell']['corner_matrix'].keys():