CODで遊ぶ の履歴(No.1)


CODで遊ぶ (2016/04/16作成)(2017/05/25追加、訂正など)


CODとは

CODのダウンロード

鉱物名を取り出す

Vestaでオープン

さらに簡単にVestaでオープン(2016/04/26)

#!/usr/bin/python
import sys,subprocess
# curl version
list = ['' for i in range(500)]
min_name = sys.argv[1]
mineral_file = '/Users/masami/minerals_in_cod.txt' # mineral-list, change here
try: # text file open
	 fin = open(mineral_file,'r')
except IOError, (errno, msg): # file not found
	print 'minerals_in_cod.txt is missing.'
	exit()
contents = fin.readlines() # read all lines in cif file to contents
fin.close() # close file
find = 0
for line in contents:
	if min_name in line: # mineral name in a line?
		find = find + 1
		list[find] = line.strip() # strip \n
		print str(find) + ": " + list[find] 
if find == 0:
	print "No such mineral in the list."
	exit()
elif find == 1: # just one, no selection
	input_no = 1
else: # select by number
	print "Select by number? (0 to stop)."
	input_no = input('>>> ')
if (input_no <= 0) or (input_no > find):
	exit()
s = list[input_no].index(",")
t = len(list[input_no])
fname = list[input_no][s+1:t] # get file name
cmd = "curl -s -o" + " " + fname + " " + "https://www.crystallography.net/cod/" + fname
subprocess.call(cmd.split(" ")) # Get specified cif file from the COD site by curl   
cmd = "open -a VESTA" + " " + fname
subprocess.call(cmd.split(" ")) # open VESTA using a downloaded cif file  
#cmd = "open -a Jedit\ X" + " " + fname
#subprocess.call(cmd,shell=True) # open cif file by JeditX			 
exit()
# end of the code, mkanzaki@me.com

使い方は、terminal上では次のような感じ。moganiteを検索すると、3つ存在したので、2番目を選んでいる。9005115.cifがCODサイトからダウンロードされ、Vestaに表示される。なお、そのcifファイルはカレントディレクトリに保存されているので、後で再利用できる。

> ./vesta_curl.py moganite
1: moganite,9002648.cif
2: moganite,9002649.cif
3: moganite,9005115.cif
Select by number? (0 to stop).
>>> 2

化学組成なども取り出したリストで検索(2016/05/06)

cifファイルから粉末回折パターンを計算する(2016/05/06)

実測と計算回折パターンの比較

他のCOD関連wikiページ