ラベル xspec の投稿を表示しています。 すべての投稿を表示
ラベル xspec の投稿を表示しています。 すべての投稿を表示

2015年9月1日火曜日

tips in spec: write chi2 in plot

https://heasarc.gsfc.nasa.gov/xanadu/xspec/manual/XStclout.html

tclout stat
scan $xspec_tclout "%f" chistat
echo $chistat

tclout dof 1
scan $xspec_tclout "%d" dofd

setp com wi 2
setp com la f "chi2=$chistat dof=$dofd"


2015年2月12日木曜日

bash script to run XSPEC and find parameter error

(2015-02-12 for ASTRO-H simulation)

#!/bin/bash
# xspec find parameter range
# only 1 parameter fit

this=fitC1

# input
model_xcm=$1
data=$2

# fit range
free_p=$3
p_0=$4
p_width=$5
p_min=$6
p_max=$7

#default
# fit energy range
e_min=6.5
e_max=6.8
delta_chi=$DELTA_CHI

resp=${SXS_RMF}
arf=${SXS_ARF}

# output
if [ ! -e ${OUTDIR} ]; then
    echo "mkdir ${OUTDIR}"
    mkdir -p ${OUTDIR}
fi

log=${OUTDIR}/${this}_para${free_p}.log
com=${OUTDIR}/${this}_para${free_p}.xcm
ps=${OUTDIR}/${this}_para${free_p}.ps

# xspec will run ${model}

cat >| $com <que no
data ${data}

resp 1 $resp
arf 1 $arf

setp ene
cpd /xs

ig 0.0-${e_min} ${e_max}-**
@${model_xcm}

log $log
show all
fre 1-6
thaw ${free_p}
newp ${free_p}          ${p_0} ${p_width} ${p_min} ${p_min} ${p_max} ${p_max}
show free

plot d ratio

fit
fit
err ${delta_chi} ${free_p}
fit ${free_p}
err ${delta_chi} ${free_p}

log none

cpd $ps/vps
plot d ratio
cpd /xs
quit
y

EOF

xspec - $com

echo "check ${OUTDIR}"

















bach script to run fake in XSPEC

(2015-02-12 for ASTRO-H/SXS simulation)

#!/bin/bash
# run xspec
# fake spectra

#
this=fake1

# input
model_xcm=$1
t_exp=$2
outdir=$3

# responses
resp=${SXS_RMF}
arf=${SXS_ARF}

# grppha 2bin = 2eV
bin=2

# output
log=${outdir}/xspec.log
out=${outdir}/${this}.fak
out_bin=${out}.${bin}eVgrp
ps=${outdir}/${this}.ps

if [ -e ${out} ]; then
    rm -rf${out} ${out_bin}
fi

if [ ! -e ${outdir} ]; then
    mkdir -p ${outdir}
fi

# xspec will run here

xspec <
@${model_xcm}

fakeit none
${resp}
${arf}
y
fake
${out}
${t_exp}

## grouping ##
grppha ${out} ${out_bin}
group 0 16383 $bin
exit

## check flux

log ${log}
show all
flux 0.5 10
flux 6.61 6.71
ig 0.0-6.61 6.71-**
show data
log none
no 1-**

cpd /xs
setp com log x off
setp com r x 6.48 6.82
setp com la f ${outdir}/${out_bin}
setp com la t "exp=${t_exp} secs"
setp com fo ro
setp com cs 1.3

setp ene
plot d
cpd ${ps}/vps
plot d
cpd /xs
quit
y

EOF

ls ${outdir}














2014年8月15日金曜日

libc++abi.dylib: error from xspec

I could not solve this problem.

I install new heasoft 6.16 and OK.

type xspec
xspec is .../heasoft/heasoft-6.15.1/i386-apple-darwin12.5.0/bin/xspec
$xspec

                XSPEC version: 12.8.1g
                Build Date/Time: Thu Apr  3 12:33:54 2014

XSPEC12>xset APECROOT  apecNoLine/apec_v2.0.2_noline/apec_v2.0.2_noline
XSPEC12>model apec

Input parameter value, delta, min, bot, top, and max values for ...
              1       0.01(      0.01)      0.008      0.008         64         64
1:apec:kT>
              1     -0.001(      0.01)          0          0          5          5
2:apec:Abundanc>
              0      -0.01(      0.01)     -0.999     -0.999         10         10
3:apec:Redshift>
              1       0.01(      0.01)          0          0      1e+20      1e+24
4:apec:norm>
Reading APEC data from
apecNoLine/apec_v2.0.2_noline/apec_v2.0.2_noline
libc++abi.dylib: terminate called throwing an exception

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]