Environment
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
GNU bash, version 4.3.8(1)-release (x86_64-pc-linux-gnu)
This article is related to ADDA (light scattering simulator based on the discrete dipole approximation).
About
To read dipole coordinate file produced using this code.
codev v0.1
UtilReadCoordinate.py
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import array
import sys
'''
v0.1 Apr. 09, 2017
- add read_coordinate_file()
- add wrap_fromfile()
'''
# codingrule:PEP8
# on Python 2.7.6
# np.set_printoptions(precision=6)
def wrap_fromfile(rfp, typecode, num):
res = array.array(typecode)
res.fromfile(rfp, num)
return res
def debug_group_print(local_nvoid_Ndip, coord):
print(local_nvoid_Ndip)
for idx in range(10):
print('%.5f,%.5f,%.5f' %
(coord[idx*3], coord[idx*3+1], coord[idx*3+2]))
def read_coordinate_file(crdFilename, debugPrint=False):
if debugPrint:
print(crdFilename)
with open(crdFilename, "rb") as crdfp:
local_nvoid_Ndip = wrap_fromfile(crdfp, 'i', num=1)
coord = wrap_fromfile(crdfp, 'd', num=local_nvoid_Ndip[0]*3)
if debugPrint:
print(local_nvoid_Ndip)
for idx in range(10):
print('%.5f,%.5f,%.5f' %
(coord[idx*3], coord[idx*3+1], coord[idx*3+2]))
return local_nvoid_Ndip[0], coord
if __name__ == '__main__':
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
print("ERROR: chpoint file is not specified\r\n")
print(" [cmd] [coordinate file] \r\n")
sys.exit()
res = read_coordinate_file(argvs[1], debugPrint=False)
local_nvoid_Ndip, coord = res
#
debug_group_print(local_nvoid_Ndip, coord)
run
$ python UtilReadCoordinate.py coord.0
9328
-0.20944,-1.46608,-5.23599
0.20944,-1.46608,-5.23599
-1.04720,-1.04720,-5.23599
-0.62832,-1.04720,-5.23599
-0.20944,-1.04720,-5.23599
0.20944,-1.04720,-5.23599
0.62832,-1.04720,-5.23599
1.04720,-1.04720,-5.23599
-1.04720,-0.62832,-5.23599
-0.62832,-0.62832,-5.23599