2012年5月29日火曜日

ch7-read1.sh

input="/etc/hosts"

readfile () {
    while read f[0] f[1] f[2]; do
        # remove line from #                                                                                 
        if [ -z "$(echo ${f[0]} | grep ^#)" ]; then
            echo ${f[0]} ${f[1]}
        fi
        done
}

echo "readfile $input..."
readfile < $input

echo "## pattern 2"

{
    while read f[0] f[1] f[2]; do
        # remove line from #                                                                                 
        if [ -z "$(echo ${f[0]} | grep ^#)" ]; then
            echo ${f[0]} ${f[1]}
        fi
        done
} < $input

2012年5月25日金曜日

read xspec log in python

(readLog-test1.py)
#!/usr/bin/env python

"""
2012-05-25
cp ‾/2012FY/clusters/A2319/20120410/region-0416/readLog-fit1.pl .
"""

import sys

debug = "### debug"

x_xis0=[0,0]
for line in sys.stdin:
#    print debug, line,

    lines = line.split()
#    print debug, lines[0]

    if "4    2   apec       Redshift" in line:
        x_xis0[0] = lines[5]
        print debug, line, x_xis0[0]
    if "9    2   apec       Redshift" in line:
        x_xis0[1] = lines[5]
        print debug, line, x_xis0[1]

print "x_xis0 is", x_xis0[0],x_xis0[1]







   



xselect from python

see also uchiyama's blog

#!/usr/bin/env python

"""
2012-05-25
test
http://aidememoirehu.blogspot.jp/search/label/Python
"""

MY_NAME = "run_xselect2"

import sys
import os
import subprocess

out_name = 'test' + MY_NAME
out_com = out_name+'.com'

# if out_com is already present

# overwrite
com = open (out_com, 'w')

ev_file = "test_evlist.txt"

print >> com, """
clear all proceed=yes
set mission suzaku
set datadir /Volumes/Macintosh_HD_2/Nobackup/aepipeline//801040010/
"""
print >> com, "read events @"+ev_file+'¥n'
print >> com, """
ext image
save image test1.xy
"""
print out_com, "is created¥n"

com.close

# open file into string
com = open(out_com, 'r')
# com_list = com.readlines()
# TypeError: must be string or buffer, not list
# to list

com_str = com.read()
xsp = subprocess.Popen( 'xselect', stdin = subprocess.PIPE )
xsp.stdin.write( '¥n¥n' )
xsp.stdin.write( com_str )
xsp.stdin.write( 'quit ¥n ¥n' )
xsp.wait()









2012年5月16日水曜日

素粒子


素粒子の世界

自分の体,
身の回りのいろいろな物,
地球,そして宇宙は何からできているのだろう?
この謎を,多くの人々が探求してきた。
これに答えるには,物理の法則と素粒子の成り立ちを理解する必要がある。
四つの力は統一できるのだろうか?
クオークやレプトンはそれ以上,分解できないだろうか?
究極の理論はどんな数学で記述できろだろうか?

この広大な宇宙も実はいくつかの素粒子で作られている。



2012年5月11日金曜日

Learn Python

* Book,
初めてのPython 第3版

* web sites
http://docs.python.org/tutorial/index.html