next up previous
Next: Files in this Distribution Up: Spectral Calibration of the Previous: Channel Boundary Plots

Creating Simulated Datasets with XSPEC

We do not yet have a script to create simulations. The following recipe works:

  1.   Create a shell script to provide inputs to xspec. The following is an example used to create the 0.4 keV pha files for 61 Cyg:
    #! /bin/tcsh -f
    
    echo "mo ray" 
    echo "0.4 1.0000E-02  8.0000E-03  8.0000E-03 64.00       64.00"
    echo "1.0     -1.0000E-03      0.          0.       5.000       5.000"
    echo "0.     -1.0000E-03      0.          0.       2.000       2.000"
    echo "1e-3      1.0000E-02      0.          0.      1.0000E+24  1.0000E+24"
    
    
    set comlist = `cat $1`
    
    foreach file ($comlist)
    
    echo "fakeit none"
    echo "new_resp.fits"
    echo " hri_arf.fits" 
    echo "y" 
    echo "\n"
    echo $file 
    echo "6688,  1.0000 , 1.0000 , 0."
    
    end

    The script will output the model parameters, ie. the first 5 lines of the script. The script will then read in a list of file names and output a set of instructions to xspec to create multiple fake pha files. If the list of file names is as follows:

    pha1
    pha2
    the output of the script will be:

    mo ray
    0.4 1.0000E-02  8.0000E-03  8.0000E-03 64.00       64.00
    1.0     -1.0000E-03      0.          0.       5.000       5.000
    0.     -1.0000E-03      0.          0.       2.000       2.000
    1e-3      1.0000E-02      0.          0.      1.0000E+24  1.0000E+24
    fakeit none
    new_resp.fits
     hri_arf.fits
    y
    \n
    pha1
    6688,  1.0000 , 1.0000 , 0.
    fakeit none
    new_resp.fits
     hri_arf.fits
    y
    \n
    pha2
    6688,  1.0000 , 1.0000 , 0.
  2. Run xspec to generate fake pha files. If the output of the script in item 1 was piped to a file called xinput, run xspec with the command
    > xspec xinput
    The result will be 2 fake pha files, pha1.pha and pha2.pha. A larger number will be needed to obtain a statistically meaningful result!
  3. Obtain the hardness ratios of the fake data files. The following is an IRAF script to do this in an automated way.
    procedure ratio (scanfile,output)
    
    char *list
    char scanfile {prompt ="Enter simulation list"}  #image list
    char output {prompt="Output file"}
    
    begin
    
    #declare local variables
    
    char spect,outfile
    real h,r,e,s
    
    list=scanfile
    outfile=output
    
    #read file
    
    while (fscan (list,spect) !=EOF){
    
    fstatistic(infile=spect,colname="counts",rows="1-4")
    s=fstatistic.sum
    fstatistic(infile=spect,colname="counts",rows="5-15")
    r=s/h
    e=r*(s**(-1)+h**(-1))**(0.5)
    print(h,s,r,e, >> outfile)
    
    }
    end

    The parameters for this script are a file containing a list of fake pha files and the name of the output file. The output file is an ascii file with columns containing the number of ``hard'' counts (channels 5-15 in this case), the number of ``soft'' counts (channels 1-4), the ratio soft/hard and the ratio error.

  4. Read the file with counts and ratios into IDL or other plotting/analysis package and plot a histogram.


prestwich@cfa.harvard.edu
Mon May 11 15:21:25 EDT 1998