grpphaの実行形式は
$ grppha (infile) (outfile)である。以下の例では、 1ビンあたりの最小のカウント数
$grppha xis0.pha xis0_grp.pha
------------------------- MANDATORY KEYWORDS/VALUES ------------------------- -------------------------------------------------------------------- -------------------------------------------------------------------- EXTNAME - SPECTRUM Name of this BINTABLE TELESCOP - SUZAKU Mission/Satellite name INSTRUME - XIS0 Instrument/Detector FILTER - NONE Instrument filter in use EXPOSURE - 17225. Integration time (in secs) of PHA data AREASCAL - 1.0000 Area scaling factor BACKSCAL - 1.0000 Background scaling factor BACKFILE - none Associated background file CORRSCAL - 1.0000 Correlation scaling factor CORRFILE - none Associated correlation file RESPFILE - none Associated redistribution matrix file ANCRFILE - none Associated ancillary response file POISSERR - TRUE Whether Poissonian errors apply CHANTYPE - PI Whether channels have been corrected TLMIN1 - 0 First legal Detector channel DETCHANS - 4096 No. of legal detector channels NCHAN - 4096 No. of detector channels in dataset PHAVERSN - 1.2.0 OGIP FITS version number STAT_ERR - FALSE Statistical Error SYS_ERR - FALSE Fractional Systematic Error QUALITY - TRUE Quality Flag GROUPING - FALSE Grouping Flag -------------------------------------------------------------------- -------------------------------------------------------------------- GRPPHA[] group min 20 <--- (1)1bin あたり少なくとも20ctsはあるようにビンまとめ GRPPHA[exit] exit ... written the PHA data Extension ...... exiting, changes written to file : xis0_grp.pha ** grppha 3.0.0 completed successfully
xis0_grp.pha の中身をfdump してみると以下のように
GROUPINGというコラムができているのがわかる。
'1'から''をはさんで次の'1'がくるまでが一つのビンにまとめられている。
今 min 20 でビンまとめをしたので、0-96channelの足し合わせが28となり
ここまでが一つのビンにまとめられている。
------------- xis0_grp.pha の中身-------------- CHANNEL COUNTS QUALITY GROUPING count 1 0 0 0 1 2 1 0 0 -1 3 2 0 0 -1 4 3 0 0 -1 5 4 0 0 -1 ... skip ... 94 93 0 0 -1 95 94 0 0 -1 96 95 13 0 -1 97 96 15 0 -1 98 97 18 0 1 99 98 13 0 -1 -------------------------------------------------------------
GRPPHA[] group 0 511 1 512 1023 2 1024 2047 4 2048 4095 8 <--- (2)0-511 channel までは1binまとめ、512-1023 channel までは2binまとめ、、、
[最初のchannel] [最後のchannel] [ビンまとめ前のそのchannel のsystematic error]
である。したがって、上記のビンまとめでは
以下のように syserror_1.datというファイルを用意し、
ビンまとめ後に1%のsystematic error が定義する。
$ echo "0 511 1" | awk '{print $1,$2,$3/100}' > syserror_1.dat $ echo "512 1023 2 " | awk '{print $1,$2,$3**0.5/100}' >> syserror_1.dat $ echo "1024 2047 4 " | awk '{print $1,$2,$3**0.5/100}' >> syserror_1.dat $ echo "2048 4095 8' " | awk '{print $1,$2,$3**0.5/100}' >> syserror_1.dat --syserror_1.dat の中身-- 0 511 0.01 512 1023 0.0141421 1024 2047 0.02 2048 4095 0.0282843
GRPPHA[] group 0 511 1 512 1023 2 1024 2047 4 2048 4095 8 GRPPHA[] sys syserror_1.dat <---( systematic errorのファイルを読み込む)
統計が足りない場合、スペクトルを足したくなることもある。以下はxis0, xis2, xis3のphaファイルを足して、fi_ave.pha というファイルを作る場合を 示す。
$ mathpha ERRMETH=POISS-0 <-- POISS-0 ではエラーの計算はされない。 Expression to be evaluated[] xis0.pha+xis2.pha+xis3.pha <--- input file Units algebraic expression to be performed in (C,R,F or Help)[C] C <--- (C:Counts, R:Rate, F:File) O/p PHA filename[] fi_ave.pha <--- output file Exposure time flag/value ({value},{file},CALC,NULL or Help)[] CALC <---EXPOSURE を足し合わせる。 Areascal flag/value ({value},{file},NULL or Help)[%] NULL Number of comment strings to be added (up to 4)[1] Comment 1[] ......... processing file: xis0.pha ......... processing file: xis2.pha ......... processing file: xis3.pha ... Following keywrds set to null values in o/p file: ...... TELESCOP, INSTRUME, FILTER ... ... performing algebra in units of COUNTS ... written the PHA data Extension ** mathpha 4.5.7 completed successfully
★注意★上の実行例ではBACKSCALの値はリセットされるので、 後から書き直してやる必要がある。足し合わせたいファイルのBACKSCALの値が全て1%以内でそろっていれば、実行時にmathpha backscal='%' として書き込まれる。
$ setenv HEADAS /path/to/your/installed/headas/<PLATFORM> <-- HEADASをインストールした場所 $ source $HEADAS/headas-init.cshwhich xspec11 して確認する。
$ which xspec11 /path/to/your/installed/headas/<PLATFORM>/bin/xspec11
画面表示の設定もしておきます。ここでは/xwの場合ですが、重くて嫌な場合は /xtなども使える。
$ setenv XSPEC_TYPE cpd/xw $ setenv PGPLOT_TYPE /xw
$ xspec11 Xspec 11.3.2p 21:31:51 27-Jan-2006 For documentation, notes, and fixes see http://xspec.gsfc.nasa.gov/ Current plot device /xw Type "help" or "?" for further information Auto-save has been disabled. Abundances set to Anders & Ebihara XSPEC>exit Do you really want to exit? (y) XSPEC: quit Type <RETURN> for next page:
XSPEC>data 1:1 xis0_grp.pha XSPEC>back 1 xis0_bkg.pha XSPEC>resp 1 xis0.rmf <--- 検出器の適切なレスポンスを使用してください。 XSPEC>arf 1 xis0.arf <--- 検出器の適切なarfを使用してください。
とすればよい。正式のレスポンスはNASA/GSFCの以下のページから取得できる。
ここで、data, back, resp, arfの"1:1"や"1"は1番目のファイルであることを示す。 2番目のデータを同時に読み込みたければ、data 2:2 ***, back 2 ***, resp 2 ***, arf 2 *** と続ければよい。以下のようになればきちんと読み込まれている。
XSPEC>show files Information for file 1 belonging to plot group 5, data group 5 telescope = SUZAKU , instrument = XIS0 , channel type = PI Current data file : xis0_grp.pha with integration time 1.7225E+04 Background file : xis0_bkg.pha No current correction Response (RMF) file : xis0.rmf Auxiliary (ARF) file : xis0.arf Weighting method is standard
XSPEC>setplot ch <--- 横軸のスケールをchannel にする。(defaultはこっちなのでうたなくてもよい) XSPEC>plot ldata <--- 横軸channel で表示されるはず XSPEC>setplot energy <-- 横軸のスケールをenergyにする。 XSPEC>plot <--- 横軸energy [keV] で表示されるはず XSPEC>ignore **-1.0 10.0-** <--- 1keV以下、10keV以上は使わないという意味。(case by case) XSPEC>notice 0.3-10.0 <--- 0.3--10keVを使うという意味(case by case) XSPEC>plot <---0.3--10keVのスペクトルが表示されるはず。
xspecでは通常検定を用い、「モデルがデータをよく再現する」とき
reduced
の値
は1に近くなる。詳しくは、Bevingtonなど
の教科書を読んで勉強すること。試しに「吸収*ベキ関数」のモデルでフィット
する。吸収はwabs、ベキ関数はpowerlawというモデルを使う。
XSPEC>model wabs*power <--- (1)モデルを決める。 Model: wabs<1>( powerlaw<2> ) Input parameter value, delta, min, bot, top, and max values for ... 1 0.001 0 0 1E+05 1E+06 <-- defaultの値が表示される(最初の"1"がdefault値、次の0.001 がフィットする際のステップ幅、次の0と1E+5はベストフィットを探す最小/最大値) 1:wabs:nH>0.1 <--- (2a) wabsの初期値を入力ここでは0.1を入力してみる(何もいれなければdefault) 1 0.01 -3 -2 9 10 2:powerlaw:PhoIndex>2 <--- (2b) power-lawの光子指数の初期値を2にしてみる。 1 0.01 0 0 1E+24 1E+24 3:powerlaw:norm> <--- (2c) normalizationはdefault値を入れてみる。 --------------------------------------------------------------------------- --------------------------------------------------------------------------- Model: wabs<1>( powerlaw<2> ) Model Fit Model Component Parameter Unit Value par par comp 1 1 1 wabs nH 10^22 0.100000 +/- 0.00000 2 2 2 powerlaw PhoIndex 2.00000 +/- 0.00000 3 3 2 powerlaw norm 1.00000 +/- 0.00000 --------------------------------------------------------------------------- --------------------------------------------------------------------------- Chi-Squared = 3507078. using 118 PHA bins. <--- χ自乗値と自由度(まったく合っていない) Reduced chi-squared = 31313.20 for 112 degrees of freedom Null hypothesis probability = 0.00 <--- 信頼度 XSPEC>plot ldata delchi <--- スペクトル、モデルとのresidual を表示。 XSPEC>renorm <--- (3) モデルの形は変えずにnormalization だけ振ってみる。 あまりにもモデルとデータが離れすぎていると フィットに時間がかかるため。 Chi-Squared = 1422.628 using 118 PHA bins. Reduced chi-squared = 12.70203 for 112 degrees of freedom Null hypothesis probability = 0.00 XSPEC>show <--- パラメータがどうなっているか見てみる。 --------------------------------------------------------------------------- --------------------------------------------------------------------------- Model: wabs<1>( powerlaw<2> ) Model Fit Model Component Parameter Unit Value par par comp 1 1 1 wabs nH 10^22 0.100000 +/- 0.00000 2 2 2 powerlaw PhoIndex 2.00000 +/- 0.00000 3 3 2 powerlaw norm 0.314087 +/- 0.00000 <--- ここがかわった。 --------------------------------------------------------------------------- --------------------------------------------------------------------------- Chi-Squared = 1422.628 using 118 PHA bins. <--- 少し良くなったけど合っていない。 Reduced chi-squared = 12.70203 for 112 degrees of freedom Null hypothesis probability = 0.00 XSPEC>fit <--- (4)全てのパラメータをフィットしてみる。 Number of trials exceeded - last iteration delta = 0.1023 Continue fitting? (Y) と聞かれるので、フィットを続けたければyes、止めたければnoをうつ。いちいち聞かれるのが手間な場合は、fit の前に "query yes"もしくは"query no"と打っておけばよい。 fitが終わると次のようにでる。通常fitは数回繰り返すべき。 --------------------------------------------------------------------------- --------------------------------------------------------------------------- Model: wabs<1>( powerlaw<2> ) Model Fit Model Component Parameter Unit Value par par comp 1 1 1 wabs nH 10^22 0.304457 +/- 0.112850E-02 2 2 2 powerlaw PhoIndex 1.73741 +/- 0.195044E-02 3 3 2 powerlaw norm 0.415500 +/- 0.101485E-02 --------------------------------------------------------------------------- --------------------------------------------------------------------------- Chi-Squared = 115.9575 using 118 PHA bins. Reduced chi-squared = 1.035335 for 112 degrees of freedom <--- 良くなった。 Null hypothesis probability = 0.380
XSPEC>flux 0.5 10 と打つと、以下のように0.5-10keVのフラックスが求まる。 Model flux 0.4657 photons ( 2.0272E-09 ergs)cm**-2 s**-1 ( 0.500- 10.000)
XSPEC> dummy 0.1 100 1000 <-- 0.1keV から100keVまで1000binでダミーのレスポンスを作成 XSPEC> flux 0.1 100 Model flux 0.5590 photons ( 5.8868E-09 ergs)cm**-2 s**-1 ( 0.100-100.000)
たとえば、現在のモデル Model: wabs<1>( powerlaw<2> ) に対して、 XSPEC> add 2 diskbb とすると Model: wabs<1>( diskbb<2> + powerlaw<3> ) のように diskbb というモデルが2番目の成分として足される。
上記のモデルに対して XSPEC> del 2 とすれば、 Model: wabs<1>( powerlaw<2> ) のように diskbb が消されます。
もう少し複雑な場合、たとえば、 Model: wabs<1>( diskbb<2> + powerlaw<3> + gaussian<4>) にたいして、diskbb成分とpowerlaw成分にのみ吸収端(edge)をかけたいような場合、 editmodのコマンドが便利である。 XSPEC> editmod wabs((diskb + power) edge + gau) と打ってみると XSPEC>editmod wa((diskb+pow)*edge+gau) Model: wabs<1>( ( diskbb<2> + powerlaw<3> )edge<4> + gaussian<5> ) Input parameter value, delta, min, bot, top, and max values for ... 7 0.05 0 0 100 100 6:edge:edgeE> 1 0.01 0 0 5 10 7:edge:MaxTau> --------------------------------------------------------------------------- --------------------------------------------------------------------------- Model: wabs<1>( ( diskbb<2> + powerlaw<3> )edge<4> + gaussian<5> ) ... のように、新しい成分のパラメータのみを聞いてくれる。
XSPEC> plot ?と打てば、何が表示できるかわかる。以下のようなものが一般的。
XSPEC>pl ld delc :スペクトル、モデルとのresidual を表示。 XSPEC>setplot add :モデルが2成分以上ある場合に全ての成分を表示する(setplot noadで戻る)。 XSPEC>pl ld ra : スペクトル、モデルとの比を表示。 XSPEC>pl u : unfolded spectrumを表示 (縦軸はphoton flux) XSPEC>pl eeu : unfolded spectrumを表示(縦軸はνFν) XSPEC>pl mo : モデルを表示 XSPEC>pl eemo :モデルをνFνで表示
XSPEC>save all outfile.xcm :ファイル、レスポンス、モデルすべてをoutfile.xcmというファイルに保存 XSPEC>save model outfile.xcm :モデルのみをoutfile.xcmというファイルに保存 XSPEC>save files outfile.xcm :ファイルのみをoutfile.xcmというファイルに保存
次からは、xspecを立ち上げて、
XSPEC>@outfile.xcmとすれば良い。
XSPEC>iplot <--- QDPの環境に入る。 PLT> plot PLT> la ro <--- 縦軸の数字を回転。 PLT> fo ro <--- フォントをromanにする。 PLT> cs 1.5 <--- ラベルのサイズ PLT> hard spec.ps/cps <--- spec.psというpostscriptファイルに出力。(/cpsはカラーで表示の意味。/psとすればモノクロ) PLT> wd spec <--- spec.qdp ができる。 PLT> wh spec <--- spec.pco ができる。 PLT> q XSPEC>
XSPEC>model ? Possible additive models are : apec bapec bbody bbodyrad bexrav bexriv bknpower bkn2pow bmc bremss bvapec c6mekl c6pmekl c6pvmkl c6vmekl cemekl cevmkl cflow compbb compLS compPS compST compTT cutoffpl disk diskbb diskline diskm disko diskpn equil expdec ezdiskbb gaussian gnei grad grbm kerrbb kerrd laor lorentz meka mekal mkcflow nei npshock nsa nteea pegpwrlw pexrav pexriv plcabs powerlaw posm pshock raymond redge refsch sedov smaug srcut sresc step vapec vbremss vequil vgnei vmeka vmekal vmcflow vnei vnpshock vpshock vraymond vsedov zbbody zbremss zgauss zpowerlw eqpair eqpail eqpait compPS thCompml thCompm1 thCompm2 sxcomp thCompm0 smemm xsgacp dkbbth dkbbfth dkbbnth dkbbeq bplc photemis swindemm adisk2 atable Possible multiplicative models are : absori acisabs constant cabs cyclabs dust edge expabs expfac gabs highecut hrefl notch pcfabs phabs plabs pwab redden smedge spline SSS_ice TBabs TBgrain TBvarabs uvred varabs vphabs wabs wndabs xion zedge zhighect zpcfabs zphabs zredden zTBabs zvarabs zvfeabs zvphabs zwabs zwndabs smfix smfix2 smfix3 smfix4 smfixn smabs nick warmabs swindabs xisabs mpowerla mtable etable Possible mixing models are : ascac projct xmmpsf Possible convolution models are : gsmooth lsmooth reflect rgsxsrc reflxion reflxi2 reflxil reflbal reflbal2 reflbal3 ref2 conline nsline Possible pile-up models are : pileup Additional models are available at : legacy.gsfc.nasa.gov/docs/xanadu/xspec/newmodels.html
XSPEC>help models pow XSPEC_11.3_commands Models powerlaw Simple photon power law. ------------------------------------------------------------------------ A(E) = K (E/1 keV)**(-par1) ------------------------------------------------------------------------ where : par1 = photon index of power law (dimensionless) <--- パラメータ1は光子指数 K = photons/keV/cm**2/s at 1 keV. <--- normalization(パラメータ2)の定義 help> <--- リターンでもとにもどる。 XSPEC>
XSPEC>help commands XSPEC_11.3_commands Commands `abund` - Set the Solar abundance table. `addcomp` - Add a component to the model. <--- モデル成分を加える `arf` - Read an auxiliary response file. <--- arfを読み込む `autosave` - Periodically save XSPEC status. `backgrnd` - Reset the files to be used for background subtraction. <--- バックグラウンドを読み込む `bayes` - Set up for Bayesian inference. `chatter` - Control the verbosity of XSPEC. `corfile` - Reset the files to be used for background correction. `cornorm` - Reset the normalization to be used in correcting the background. `cosmo` - Set H0 and q0. `cpd` - Alias for `setplot device`. `data` - Input one or more pha data files. <--- dataを読み込む `delcomp` - Delete a component from the model. <--- モデル成分を取り除く `diagrsp` - Diagonalise the current response matrix for ideal response. `dummyrsp` - Create a 'dummy' response, covering a given energy range. <--- 仮のレスポンスを作る。bolometric fluxを求めたいときなどに使う。 `dump` - Write out history packages of the observed spectrum and model. `editmod` - Add, delete or change one component in the model. `eqwidth` - Calculate a model component's equivalent width.<--- lineなどの等価幅を求める。 `error` - Determine a single parameter confidence region. <--- パラメータのエラー。 `exec` - Execute a shell command from withing XSPEC. `exit` - Wind up any hardcopy plots and exit from XSPEC. <--- xspecから抜ける 'extend' - Extend the energy range over which models are calculated. <--- エネルギー領域を使用しているスペクトルの範囲以上にのばす。 convolution modelなどを使うときに重要。 `fakeit` - Produce simulated data files for sensitivity studies. <--- モデルとレスポンスに基づいてシミュレーション。 `fit` - Find the best fit model parameters. <--- フィットする `flux` - Calculate the current model's flux over an energy range. <-- fluxを求める。 `freeze` - Do not allow a fit parameter to vary during the fit. <--- パラメータを固定 'ftest' - Calculate the F statistic and probability. <--- F検定の値を計算 `gain` - Perform a simple modification of the response gain. `genetic` - Set parameters for the genetic algorithm. `goodness` - Monte Carlo calculation of goodness-of-fit `hardcopy` - Print the current plot to your default printer. `help` - Obtain help on XSPEC commands. `identify` - List possible lines in the specified energy range. `ignore` - Ignore a range of pha channels in future fit operations. <--- 無視するエネルギー範囲の設定 `improve` - Try to find a better minimum (requires MINUIT). `iplot` - As plot command but interactive using PLT. <--- QDPに入る `log` - Open the log file to save output. <--- ログファイルに落とす `lumin` - Calculate the current model's luminosity over a given rest frame energy range and redshift. `margin` - Calculate the multi-dimensional probability distribution `method` - Set the minimization method. `model` - Define the model to be used when fitting the data. `newpar` - Modify the model parameters. `notice` - Restore a range of pha channels for future operations. <--- エネルギー範囲の設定 `pause` - Exit via the FORTRAN PAUSE statement. `plot` - Plot various information on the current plot device. `query` - Switch on/off prompt to continue fitting. <--- fitの際の答えをyes/noに設定。 `quit` - An alias for `exit`. `readline` - Enable/disable the gnu readline command editing/history facility. `recornrm` - Adjust correction norms to minimize the fit statistic, holding the model fixed. `renorm` - Adjust the model norms, and/or allow automatic renorming. <--- モデルのnormalizationを変える `response` - Reset the files used to determine the detector responses. <--- レスポンスを読み込む `save` - Save aspects of the current state to a command file. <--- xcm file に保存。 `script` - Open the script file to save all commands input. `setplot` - Modify the plot device and other values used by the plot routines. `show` - Display current file and model information. `source` - Execute a script file. `statistic` - Change the fit statistic in use. `steppar` - Step through a range of parameter values; perform a fit <--- パラメータを at each step. ステップさせ、それぞれについてχ自乗値を計算。 `suggest` - Make a suggestion or report a bug to the XSPEC gnomes. `syscall` - Execute command in a shell. `systematic`- Set the model systematic error. `tclout` - Write xspec information to a Tcl variable. `thaw` - Allow a fit parameter to vary during the fit. <--- パラメータをfreeにする(<-->freez) `thleqw` - Calculates expected fluorescent line equivalent width. `time` - Display elapsed time and other statistical information. `uncertain` - Alias for `error`. `untie` - Untie linked parameters. `weight` - Change the weighting function used for chi-squared fits. `xhistory` - Open a history file, in order to save fit results. `xsect` - Changes the absorption cross-sections in use.