Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ nosetests.xml
setup.cfg
/DistancePrinter/version.cfg
/DistancePrinter/gitarchive.cfg

# test output
actual.res
32 changes: 21 additions & 11 deletions DistancePrinter/distanceprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
#
##############################################################################

import os
import sys
import itertools
import numpy as np

from diffpy.pdffit2 import PdfFit
from diffpy.Structure import PDFFitStructure
from diffpy.structure import PDFFitStructure

def calDistance(strufile, atomi, atomj, lb, ub, complete):

Expand All @@ -38,14 +36,14 @@ def calDistance(strufile, atomi, atomj, lb, ub, complete):
distlist = np.zeros(len(dij), dtype=dtypec)

if not complete:
for i, dist, dd, ij in itertools.izip(range(len(dij)), dij, ddij, ij0):
for i, dist, dd, ij in zip(range(len(dij)), dij, ddij, ij0):
if ij[0] > ij[1]:
distlist[i] = (dist, dd, ele[ij[1]], ele[ij[0]])
else:
distlist[i] = (dist, dd, ele[ij[0]], ele[ij[1]])
distlist = np.unique(distlist)
else:
for i, dist, dd, ij in itertools.izip(range(len(dij)), dij, ddij, ij0):
for i, dist, dd, ij in zip(range(len(dij)), dij, ddij, ij0):
distlist[i] = (dist, dd, '%s.%i' % (ele[ij[0]], ij[0]), '%s.%i' % (ele[ij[1]], ij[1]))

distlist.sort(order='distance')
Expand Down Expand Up @@ -78,18 +76,30 @@ def formatResults(stru, distlist, complete, all0ddij, **kw):

if complete:
for dist in distlist:
lines.append('%s-%s:\t%2.6f' % (dist[2], dist[3], dist[0]))
try:
lines.append('%s-%s:\t%2.6f' % (dist[2].decode('utf-8'), dist[3].decode('utf-8'), dist[0]))
except AttributeError:
lines.append('%s-%s:\t%2.6f' % (dist[2], dist[3], dist[0]))
else:
for dist in distlist:
lines.append('%s-%s:\t%2.6f (%1.1e)' % (dist[2], dist[3], dist[0], dist[1]))
try:
lines.append('%s-%s:\t%2.6f (%1.1e)' % (dist[2].decode('utf-8'), dist[3].decode('utf-8'), dist[0], dist[1]))
except AttributeError:
lines.append('%s-%s:\t%2.6f (%1.1e)' % (dist[2], dist[3], dist[0], dist[1]))
rv = '\n'.join(lines)
return rv

def writeToFile(filename, rv):
f = file(filename, 'w')
f.write(rv)
f.close()
return
f = open(filename, 'w', encoding="utf-8")
try:
rv = rv.decode('utf-8')
f.write(rv)
f.close()
except AttributeError:
# No need to decode in python 3
f.write(rv)
f.close()
pass

def main():
sysargv = sys.argv[1:]
Expand Down
13 changes: 4 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"""

import os
import glob
from setuptools import setup, find_packages


import os
import glob
from setuptools import setup, find_packages

# Use this version when git data are not available, like in git zip archive.
Expand All @@ -32,13 +28,13 @@ def gitinfo():
glog = proc.stdout.read()
rv = dict(version=FALLBACK_VERSION)
if desc != '':
rv['version'] = '-'.join(desc.strip().split('-')[:2]).lstrip('v')
rv['version'] = b'-'.join(desc.strip().split(b'-')[:2]).lstrip(b'v')
rv['commit'], rv['timestamp'], rv['date'] = glog.strip().split(None, 2)
return rv


def getversioncfg():
from ConfigParser import RawConfigParser
from configparser import RawConfigParser
vd0 = dict(version=FALLBACK_VERSION, commit='', date='', timestamp=0)
# first fetch data from gitarchivecfgfile, ignore if it is unexpanded
g = vd0.copy()
Expand Down Expand Up @@ -102,8 +98,7 @@ def getversioncfg():
'Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.13',
'Topic :: Scientific/Engineering :: Physics',
],
)
Expand Down
250 changes: 250 additions & 0 deletions tests/data/Ni-9008476.cif
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
#------------------------------------------------------------------------------
#$Date: 2017-10-15 03:23:08 +0300 (Sun, 15 Oct 2017) $
#$Revision: 202022 $
#$URL: file:///home/coder/svn-repositories/cod/cif/9/00/84/9008476.cif $
#------------------------------------------------------------------------------
#
# This file is available in the Crystallography Open Database (COD),
# http://www.crystallography.net/. The original data for this entry
# were provided the American Mineralogist Crystal Structure Database,
# http://rruff.geo.arizona.edu/AMS/amcsd.php
#
# The file may be used within the scientific community so long as
# proper attribution is given to the journal article from which the
# data were obtained.
#
data_9008476
loop_
_publ_author_name
'Wyckoff, R. W. G.'
_publ_section_title
;
Second edition. Interscience Publishers, New York, New York
Cubic closest packed, ccp, structure
;
_journal_name_full 'Crystal Structures'
_journal_page_first 7
_journal_page_last 83
_journal_volume 1
_journal_year 1963
_chemical_formula_sum Ni
_chemical_name_mineral Nickel
_space_group_IT_number 225
_symmetry_space_group_name_Hall '-F 4 2 3'
_symmetry_space_group_name_H-M 'F m -3 m'
_cell_angle_alpha 90
_cell_angle_beta 90
_cell_angle_gamma 90
_cell_length_a 3.52387
_cell_length_b 3.52387
_cell_length_c 3.52387
_cell_volume 43.758
_exptl_crystal_density_diffrn 8.909
_cod_original_sg_symbol_H-M 'F m 3 m'
_cod_database_code 9008476
loop_
_symmetry_equiv_pos_as_xyz
x,y,z
x,1/2+y,1/2+z
1/2+x,y,1/2+z
1/2+x,1/2+y,z
z,-x,y
z,1/2-x,1/2+y
1/2+z,-x,1/2+y
1/2+z,1/2-x,y
-y,z,-x
-y,1/2+z,1/2-x
1/2-y,z,1/2-x
1/2-y,1/2+z,-x
x,-y,z
x,1/2-y,1/2+z
1/2+x,-y,1/2+z
1/2+x,1/2-y,z
-z,x,-y
-z,1/2+x,1/2-y
1/2-z,x,1/2-y
1/2-z,1/2+x,-y
y,-z,x
y,1/2-z,1/2+x
1/2+y,-z,1/2+x
1/2+y,1/2-z,x
-x,y,-z
-x,1/2+y,1/2-z
1/2-x,y,1/2-z
1/2-x,1/2+y,-z
x,-z,-y
x,1/2-z,1/2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