Difference between revisions of "Isis tutorial gratings"

From Remeis-Wiki
Jump to navigation Jump to search
(Created page with "**Copied by Shu** ====== Further Data Fitting ====== The walk through isis has given you a first overview of a simple X-ray spectral analysis. In this part of the tutorial w...")
 
Line 1: Line 1:
**Copied by Shu**
+
== Further Data Fitting ==
 
 
====== Further Data Fitting ======
 
  
 
The walk through isis has given you a first overview of a simple X-ray spectral analysis. In this part of the tutorial we build upon this experience by performing a more complicated analysis of Chandra gratings spectra. You will learn about X-ray data archives and what to do when not all keywords are set in a X-ray spectral file. Furthermore we introduce an important X-ray diagnostics for tenuous plasmas.
 
The walk through isis has given you a first overview of a simple X-ray spectral analysis. In this part of the tutorial we build upon this experience by performing a more complicated analysis of Chandra gratings spectra. You will learn about X-ray data archives and what to do when not all keywords are set in a X-ray spectral file. Furthermore we introduce an important X-ray diagnostics for tenuous plasmas.
  
===== Data Archives and the ADS =====
+
=== Data Archives and the ADS ===
  
 
==== ADS ====
 
==== ADS ====
  
In this tutorial we will demonstrate the analysis of Chandra gratings data of stellar spectra and try to reproduce the results obtained by [[http://adsabs.harvard.edu/abs/2002A%26A...394..911N|Jan-Uwe Ness et al., 2002, Coronal density diagnostics with Helium-like triplets: CHANDRA-LETGS observations of Algol, Capella, Procyon, epsilon Eri, alpha Cen A&B, UX Ari, AD Leo, YY Gem, and HR 1099, Astronomy and Astrophysics 394, 911]].  
+
In this tutorial we will demonstrate the analysis of Chandra gratings data of stellar spectra and try to reproduce the results obtained by [http://adsabs.harvard.edu/abs/2002A%26A...394..911N Jan-Uwe Ness et al., 2002, Coronal density diagnostics with Helium-like triplets: CHANDRA-LETGS observations of Algol, Capella, Procyon, epsilon Eri, alpha Cen A&B, UX Ari, AD Leo, YY Gem, and HR 1099, Astronomy and Astrophysics 394, 911].  
  
**//Exercise 1//**
+
'''''Exercise 1'''''
  * Go to the [[http://adsabs.harvard.edu/abstract_service.html|ADS Abstract Service]] and search for the above paper. The best way to do this is to enter ''^Ness'' for the Author and ''Capella'' for the Object. The ADS is the best data base to find astronomical literature. It goes back to the early 1800s and is almost complete for the past 50 years or so. It will be very worth your time to familiarize yourself with searching papers there - even if you do not want to do astronomy in the end but other areas of physics, which are indexed in the ADS as well. In order to make sure that you really did the search and did not just click the link above, what is the newest paper published by this author?
+
* Go to the [http://adsabs.harvard.edu/abstract_service.html ADS Abstract Service] and search for the above paper. The best way to do this is to enter <code>^Ness</code> for the Author and <code>Capella</code> for the Object. The ADS is the best data base to find astronomical literature. It goes back to the early 1800s and is almost complete for the past 50 years or so. It will be very worth your time to familiarize yourself with searching papers there - even if you do not want to do astronomy in the end but other areas of physics, which are indexed in the ADS as well. In order to make sure that you really did the search and did not just click the link above, what is the newest paper published by this author?
  
  * Download, print, and read this paper. Yes, really, print it - you will need to refer to this paper often and you might want to scribble comments on your paper copy and you will read the paper much more intensively if it is not on a computer screen. In order to get to the PDF-copy of the paper, click on "Full Refereed Journal Article (PDF/Postscript)" in the above link. You will see it is colored in green, meaning that the paper is not behind a paywall. This is not the case for new articles, unfortunately, in this case you can always go to the arXiv-Link and get a preprint from there. Virtually all important astronomical papers can be found this way.  
+
* Download, print, and read this paper. Yes, really, print it - you will need to refer to this paper often and you might want to scribble comments on your paper copy and you will read the paper much more intensively if it is not on a computer screen. In order to get to the PDF-copy of the paper, click on "Full Refereed Journal Article (PDF/Postscript)" in the above link. You will see it is colored in green, meaning that the paper is not behind a paywall. This is not the case for new articles, unfortunately, in this case you can always go to the arXiv-Link and get a preprint from there. Virtually all important astronomical papers can be found this way.  
  
 
==== Data Archives ====
 
==== Data Archives ====
  
Here, we will show you how to perform the analysis of Capella, in your homework you will work on one of the other sources. Like the analysis of data from all other X-ray satellites, the reduction of Chandra gratings data can become very involved. Since we "just" want to analyze the time averaged spectrum of the source, we are lucky that somebody else (well, the Chandra gratings team) has done the work for us and has put the reduced spectra on the WWW for us. Such archives of pre-reduced data exist for all satellites, and while I caution //not// to use the reduced data in these archives for publication-level work, they are useful to get a feel for what is available (the reason why you do not want to use these data for publication level work is that you will typically have to apply a newer version of the detector calibration, different background screening criteria, different time intervals, and so on). The following list contains the most important X-ray astronomical archives:
+
Here, we will show you how to perform the analysis of Capella, in your homework you will work on one of the other sources. Like the analysis of data from all other X-ray satellites, the reduction of Chandra gratings data can become very involved. Since we "just" want to analyze the time averaged spectrum of the source, we are lucky that somebody else (well, the Chandra gratings team) has done the work for us and has put the reduced spectra on the WWW for us. Such archives of pre-reduced data exist for all satellites, and while I caution ''not'' to use the reduced data in these archives for publication-level work, they are useful to get a feel for what is available (the reason why you do not want to use these data for publication level work is that you will typically have to apply a newer version of the detector calibration, different background screening criteria, different time intervals, and so on). The following list contains the most important X-ray astronomical archives:
  
  * **TO BE WRITTEN**
+
* '''TO BE WRITTEN'''
  * [[http://tgcat.mit.edu/|TGCat]] contains all public observations performed with the Chandra transmission gratings spectrometers. The user interface is self-explanatory and there is a nice help section available. If you know the name of the object you're interested in, enter it in the "Quick Query" box, then click on the object name and you will be getting a list of all available observations.
+
* [http://tgcat.mit.edu/ TGCat] contains all public observations performed with the Chandra transmission gratings spectrometers. The user interface is self-explanatory and there is a nice help section available. If you know the name of the object you're interested in, enter it in the "Quick Query" box, then click on the object name and you will be getting a list of all available observations.
  
**//Exercise 2//**
+
'''''Exercise 2'''''
  * Download the observation with the longest exposure time available for the object you are interested in, unless your instructions say otherwise. If possible, disregard the observations where the HRC was in the focal plane, i.e., look at the ACIS-observations only (the HRC is not energy dispersive, and therefore order sorting is not so easy with this detector).
+
* Download the observation with the longest exposure time available for the object you are interested in, unless your instructions say otherwise. If possible, disregard the observations where the HRC was in the focal plane, i.e., look at the ACIS-observations only (the HRC is not energy dispersive, and therefore order sorting is not so easy with this detector).
  
 
Select the data, ask TGCat to send you an email, and then download the file. For example
 
Select the data, ask TGCat to send you an email, and then download the file. For example
<code>
+
<ref>
 
wget http://tgcat.mit.edu/tmp/1337349938_174950000/tgcat.tar.gz
 
wget http://tgcat.mit.edu/tmp/1337349938_174950000/tgcat.tar.gz
</code>
+
</ref>
 
Unpack it with
 
Unpack it with
<code>
+
<ref>
 
tar xzvf tgcat.tar.gz
 
tar xzvf tgcat.tar.gz
</code>
+
</ref>
 
For Capella, we download the data from observation ID 8319. The data set looks as follows:
 
For Capella, we download the data from observation ID 8319. The data set looks as follows:
<code>
+
<ref>
 
hde226868:~/isistut> cd tgcat
 
hde226868:~/isistut> cd tgcat
 
hde226868:~/isistut/tgcat> ls -l
 
hde226868:~/isistut/tgcat> ls -l
Line 52: Line 50:
 
-r--r--r-- 1 wilms wilms 7032960 May 18 16:05 leg_1.rmf
 
-r--r--r-- 1 wilms wilms 7032960 May 18 16:05 leg_1.rmf
 
-rw-r--r-- 1 wilms wilms      71 May 18 16:05 vv_report.txt
 
-rw-r--r-- 1 wilms wilms      71 May 18 16:05 vv_report.txt
</code>
+
</ref>
The spectral file is called ''pha2.gz'', which is not a very meaningful name, so we unpack it and rename it:
+
The spectral file is called <code>pha2.gz</code>, which is not a very meaningful name, so we unpack it and rename it:
<code>
+
<ref>
 
hde226868:~/isistut/tgcat/obs_8319_tgid_3283> gunzip pha2.gz
 
hde226868:~/isistut/tgcat/obs_8319_tgid_3283> gunzip pha2.gz
 
hde226868:~/isistut/tgcat/obs_8319_tgid_3283> mv pha2 capella.pha2
 
hde226868:~/isistut/tgcat/obs_8319_tgid_3283> mv pha2 capella.pha2
</code>
+
</ref>
Note the name ''pha2''. In the walkthrough we encountered PHA-files, which contain one spectrum. ''pha2''-files contain multiple spectra. They are used, for example, in pulse phase resolved spectroscopy of neutron stars or in gratings spectra, where they contain multiple spectra.
+
Note the name <code>pha2</code>. In the walkthrough we encountered PHA-files, which contain one spectrum. <code>pha2</code>-files contain multiple spectra. They are used, for example, in pulse phase resolved spectroscopy of neutron stars or in gratings spectra, where they contain multiple spectra.
  
//** Exercise 3 **//
+
''''' Exercise 3 '''''
  
  * Take a look at the contents of your pha2-file using ''fv'' and ''fstruct''. Note that each "row" in the pha2-file now contains one spectrum.
+
* Take a look at the contents of your pha2-file using <code>fv</code> and <code>fstruct</code>. Note that each "row" in the pha2-file now contains one spectrum.
  
 
==== Preparing Gratings Data for Fitting ====
 
==== Preparing Gratings Data for Fitting ====
  
 
We now enter "isis", load the "isisscripts", and load our data set
 
We now enter "isis", load the "isisscripts", and load our data set
<code>
+
<ref>
 
hde226868:~/isistut/tgcat/obs_8319_tgid_3283> isis
 
hde226868:~/isistut/tgcat/obs_8319_tgid_3283> isis
 
:
 
:
Line 74: Line 72:
 
isis> capella=load_data("capella.pha2");
 
isis> capella=load_data("capella.pha2");
 
Reading: ......
 
Reading: ......
</code>
+
</ref>
 
As usual, we first take a look at what has been loaded, this time using a helpful function from the "isisscripts" that lists the data and the loaded "ARF"- and "RMF"-files.:
 
As usual, we first take a look at what has been loaded, this time using a helpful function from the "isisscripts" that lists the data and the loaded "ARF"- and "RMF"-files.:
<code>
+
<ref>
 
isis> list_all;               
 
isis> list_all;               
 
Current Spectrum List:
 
Current Spectrum List:
Line 93: Line 91:
 
file:  capella.pha2
 
file:  capella.pha2
 
isis>
 
isis>
</code>
+
</ref>
 
We note two things:
 
We note two things:
  - ''load_data'' loaded all contents of the ''pha2''-file,  total of **six** spectra. What these spectra are is identified in the ''part/m''-column: ''leg'' is the "low energy grating" of Chandra-HETGS (the other grating would be called ''meg'' for ''medium energy grating''), and -3, -2, -1, +1, +2, +3 identifies the order of the spectrum.
+
# <code>load_data</code> loaded all contents of the <code>pha2</code>-file,  total of '''six''' spectra. What these spectra are is identified in the <code>part/m</code>-column: <code>leg</code> is the "low energy grating" of Chandra-HETGS (the other grating would be called <code>meg</code> for <code>medium energy grating</code>), and -3, -2, -1, +1, +2, +3 identifies the order of the spectrum.
  - No ''ARF'' and ''RMF'' are listed. This means that while the spectra have been loaded we still need to tell ''isis'' what ''ARF'' and ''RMF'' to use for the spectra (you can also see this by noticing the dashes in the ''A'' and ''R'' columns).
+
# No <code>ARF</code> and <code>RMF</code> are listed. This means that while the spectra have been loaded we still need to tell <code>isis</code> what <code>ARF</code> and <code>RMF</code> to use for the spectra (you can also see this by noticing the dashes in the <code>A</code> and <code>R</code> columns).
  
 
We now remind ourselves what responses and ARF we were provided with, by using isis' "shell escape". This means that within isis we can precede a normal shell command by an exclamation mark to have it executed by the shell:
 
We now remind ourselves what responses and ARF we were provided with, by using isis' "shell escape". This means that within isis we can precede a normal shell command by an exclamation mark to have it executed by the shell:
<code>
+
<ref>
 
  isis> !ls -l
 
  isis> !ls -l
 
total 15648
 
total 15648
Line 109: Line 107:
 
-rw-r--r-- 1 wilms wilms      71 May 18 16:05 vv_report.txt
 
-rw-r--r-- 1 wilms wilms      71 May 18 16:05 vv_report.txt
 
isis>
 
isis>
</code>
+
</ref>
 
This means that we only have RMFs and ARFs available for the first order and we will have to ignore the higher orders. This is fine since most photons end up in the 1st order anyway. Let us now load the files:
 
This means that we only have RMFs and ARFs available for the first order and we will have to ignore the higher orders. This is fine since most photons end up in the 1st order anyway. Let us now load the files:
<code>
+
<ref>
 
isis> arfm1=load_arf("leg_-1.arf");  
 
isis> arfm1=load_arf("leg_-1.arf");  
 
isis> arfp1=load_arf("leg_1.arf");
 
isis> arfp1=load_arf("leg_1.arf");
 
isis> rmfm1=load_rmf("leg_-1.rmf");
 
isis> rmfm1=load_rmf("leg_-1.rmf");
 
isis> rmfp1=load_rmf("leg_1.rmf");  
 
isis> rmfp1=load_rmf("leg_1.rmf");  
</code>
+
</ref>
 
and check that everything went fine:
 
and check that everything went fine:
<code>
+
<ref>
 
isis> list_all;  
 
isis> list_all;  
 
Current Spectrum List:
 
Current Spectrum List:
Line 145: Line 143:
 
file:  leg_1.arf
 
file:  leg_1.arf
 
isis>
 
isis>
</code>
+
</ref>
 
We now need to assign each ARF and RMF to the spectrum taken with this detector:
 
We now need to assign each ARF and RMF to the spectrum taken with this detector:
<code>
+
<ref>
 
isis> assign_rmf(rmfm1,capella[2]);
 
isis> assign_rmf(rmfm1,capella[2]);
 
isis> assign_arf(arfm1,capella[2]);
 
isis> assign_arf(arfm1,capella[2]);
 
isis> assign_rmf(rmfp1,capella[3]);
 
isis> assign_rmf(rmfp1,capella[3]);
 
isis> assign_arf(arfp1,capella[3]);
 
isis> assign_arf(arfp1,capella[3]);
</code>
+
</ref>
Note that instead of using the ''id''-values directly (e.g., ''assign_rmf(1,3)'') we use the isis-variables that were returned in the different ''load''-commands (''capella'' is a variable, and in slang/isis arrays are zero-based). This approach is better than using the ids directly since it minimizes the likelihood of typos and we do not have to remember strange id numbers but rather variable names that (should) make sense. If you want to find out more about the slang programming language, you can have a look at the nice documentation at [[http://www.jedsoft.org/slang/doc/html/slang.html]]. In this case, especially Chapter 6 (Variables) and 11 (Arrays) might be interesting for you.
+
Note that instead of using the <code>id</code>-values directly (e.g., <code>assign_rmf(1,3)</code>) we use the isis-variables that were returned in the different <code>load</code>-commands (<code>capella</code> is a variable, and in slang/isis arrays are zero-based). This approach is better than using the ids directly since it minimizes the likelihood of typos and we do not have to remember strange id numbers but rather variable names that (should) make sense. If you want to find out more about the slang programming language, you can have a look at the nice documentation at [http://www.jedsoft.org/slang/doc/html/slang.html]. In this case, especially Chapter 6 (Variables) and 11 (Arrays) might be interesting for you.
  
 
Let's check whether the assignment was ok:
 
Let's check whether the assignment was ok:
<code>
+
<ref>
 
isis> list_data;                   
 
isis> list_data;                   
 
Current Spectrum List:
 
Current Spectrum List:
Line 172: Line 170:
 
   6    LETG-ACIS  leg+3  1    8192/ 8192  -  -  6.2380e+03    59.146  Capella
 
   6    LETG-ACIS  leg+3  1    8192/ 8192  -  -  6.2380e+03    59.146  Capella
 
file:  capella.pha2
 
file:  capella.pha2
</code>
+
</ref>
Notice that the ''A'' and ''R'' columns now contain the indices of the respective ARF and RMF.
+
Notice that the <code>A</code> and <code>R</code> columns now contain the indices of the respective ARF and RMF.
  
 
==== The First Fit ====
 
==== The First Fit ====
  
 
Since we do not have an ARF and RMF for the other orders, we need to tell isis not to work with these data sets:
 
Since we do not have an ARF and RMF for the other orders, we need to tell isis not to work with these data sets:
<code>
+
<ref>
isis> exclude([capella[0],capella[1],capella[4],capella[5]]);
+
isis> exclude([capella[0],capella[1],capella[4],capella[5]);
</code>
+
</ref>
The argument of the ''exclude'' function is an array containing the indices of all spectra that should be ignored when fitting. In slang/isis, arrays are defined by listing their contents in brackets, i.e.,
+
The argument of the <code>exclude</code> function is an array containing the indices of all spectra that should be ignored when fitting. In slang/isis, arrays are defined by listing their contents in brackets, i.e.,
<code>
+
<ref>
 
array=[1,2,5,6];
 
array=[1,2,5,6];
</code>
+
</ref>
 
It is also possible to use a shorthand notation to define larger arrays, e.g.,
 
It is also possible to use a shorthand notation to define larger arrays, e.g.,
<code>
+
<ref>
 
array=[1:10];
 
array=[1:10];
</code>
+
</ref>
 
creates an array containing the 10 numbers 1,2,...,10, while
 
creates an array containing the 10 numbers 1,2,...,10, while
<code>
+
<ref>
 
array=[1:10:2];
 
array=[1:10:2];
</code>
+
</ref>
 
creates an array containing the numbers 1,3,5,...,9. In principle, you can do something like this also with floating point numbers, but because of subtleties with floating point arithmetic, we do not recommend using this feature of the language.  
 
creates an array containing the numbers 1,3,5,...,9. In principle, you can do something like this also with floating point numbers, but because of subtleties with floating point arithmetic, we do not recommend using this feature of the language.  
  
In the ''exclude''-example before, note that we are again listing the indices of the spectra indirectly by specifying them through the ''capella'' variable. As before, this makes our code more portable. Finally, note that you could have also used the ''ignore''-function to ignore these data sets, but ''exclude'' is preferred since it does not affect the currently noticed energy ranges.
+
In the <code>exclude</code>-example before, note that we are again listing the indices of the spectra indirectly by specifying them through the <code>capella</code> variable. As before, this makes our code more portable. Finally, note that you could have also used the <code>ignore</code>-function to ignore these data sets, but <code>exclude</code> is preferred since it does not affect the currently noticed energy ranges.
  
Finally, since we now only have two spectra to work with,  let's remember their indices in shorter variables such that we do not have to type ''capella[x]'' all the time...
+
Finally, since we now only have two spectra to work with,  let's remember their indices in shorter variables such that we do not have to type <code>capella[x]</code> all the time...
<code>
+
<ref>
 
isis> m1=capella[2];                                         
 
isis> m1=capella[2];                                         
 
isis> p1=capella[3];
 
isis> p1=capella[3];
</code>
+
</ref>
 
We first plot the whole data set, switching the x-axis unit to Angstroms, because this is more appropriate for gratings data:
 
We first plot the whole data set, switching the x-axis unit to Angstroms, because this is more appropriate for gratings data:
<code>
+
<ref>
 
isis> fancy_plot_unit("A");  
 
isis> fancy_plot_unit("A");  
 
isis> plot_data(p1;dsym=1,dcol=2);
 
isis> plot_data(p1;dsym=1,dcol=2);
</code>
+
</ref>
Note that for the moment we are only plotting one data set in order not to confuse ourselves. With ''dsym=1'' we switch off the plot symbol, which is only distracting and does not help in understanding the figure (try the command without the ''dsym''-qualifier!).
+
Note that for the moment we are only plotting one data set in order not to confuse ourselves. With <code>dsym=1</code> we switch off the plot symbol, which is only distracting and does not help in understanding the figure (try the command without the <code>dsym</code>-qualifier!).
  
 
The resulting figure looks as follows:
 
The resulting figure looks as follows:
  
{{ :isis:tutorial:gratings01.png?direct |}}
+
[[File:Gratings01.png|center]]
  
 
Notice the very strong emission lines, which are typical for stellar coronae. Most of the things are happening between 5 and 25 Angstroms, so let's zoom in that region:
 
Notice the very strong emission lines, which are typical for stellar coronae. Most of the things are happening between 5 and 25 Angstroms, so let's zoom in that region:
  
{{ :isis:tutorial:gratings02.png?direct |}}
+
[[File:Gratings02.png|center]]
  
 
Isis has very powerful functions that help in the identification of these lines. Also note the "bump" at lower wavelengths, which is due to bremsstrahlung emission of the hot corona.  
 
Isis has very powerful functions that help in the identification of these lines. Also note the "bump" at lower wavelengths, which is due to bremsstrahlung emission of the hot corona.  
Line 221: Line 219:
 
Right now we are only interested in the He-like oxygen triplet at 21.6, 21.8, and 22.1 Angstroms. These are called the resonant, intercombination, and forbidden line, respectively, and their fluxes are typically called r, i, and f. Let's therefore take a look at the 20-23 A band only:
 
Right now we are only interested in the He-like oxygen triplet at 21.6, 21.8, and 22.1 Angstroms. These are called the resonant, intercombination, and forbidden line, respectively, and their fluxes are typically called r, i, and f. Let's therefore take a look at the 20-23 A band only:
  
{{ :isis:tutorial:gratings03.png?direct |}}
+
[[File:Gratings03.png|center]]
  
All three lines can be clearly seen in the data set. In order to get more quantitative information, a look at the spectral plot indicates that we should be able to model this spectral region well with a spectral model that consists of the three lines plus a constant flux component (model name ''constant'') that describes the continuum emission. We should probably also ignore the 20.5-21.5 A band because otherwise the fit would be contaminated by the emission lines there. Finally, experience tells us that in such line fits it is often not a good idea to let the wavelength/energy of the line to be completely free. The reason is that often initially the <latex>\chi^2</latex>-minimization routine will be trying to change the wavelength by a large factor and as a result it could be that the lines are switched. We therefore allow the lines only to vary by 0.1 A around their official values.
+
All three lines can be clearly seen in the data set. In order to get more quantitative information, a look at the spectral plot indicates that we should be able to model this spectral region well with a spectral model that consists of the three lines plus a constant flux component (model name <code>constant</code>) that describes the continuum emission. We should probably also ignore the 20.5-21.5 A band because otherwise the fit would be contaminated by the emission lines there. Finally, experience tells us that in such line fits it is often not a good idea to let the wavelength/energy of the line to be completely free. The reason is that often initially the <latex>\chi^2</latex>-minimization routine will be trying to change the wavelength by a large factor and as a result it could be that the lines are switched. We therefore allow the lines only to vary by 0.1 A around their official values.
  
With the commands discussed in the walkthrough, and with the information given by ''help set_par'' you should now be able to setup a fit function that looks like this (note: the ''gauss''-model in isis is a Gaussian line in Angstrom units, the ''gaussian''-model is the same, but in keV units):
+
With the commands discussed in the walkthrough, and with the information given by <code>help set_par</code> you should now be able to setup a fit function that looks like this (note: the <code>gauss</code>-model in isis is a Gaussian line in Angstrom units, the <code>gaussian</code>-model is the same, but in keV units):
<code>
+
<ref>
 
isis> list_par;                   
 
isis> list_par;                   
 
constant(1)+gauss(1)+gauss(2)+gauss(3)
 
constant(1)+gauss(1)+gauss(2)+gauss(3)
Line 240: Line 238:
 
   9  gauss(3).center      0    0            22.1          22        22.2  A
 
   9  gauss(3).center      0    0            22.1          22        22.2  A
 
  10  gauss(3).sigma      0    0            0.025      1e-06          1  A
 
  10  gauss(3).sigma      0    0            0.025      1e-06          1  A
</code>
+
</ref>
To get a good fit, plot the model (do not forget the ''eval_counts'' command!), and adjust the constant, line widths, and line fluxes (''area''-parameter) until you get a good "fit by eye". Playing a little bit with the parameters I find a starting model that looks as follows:
+
To get a good fit, plot the model (do not forget the <code>eval_counts</code> command!), and adjust the constant, line widths, and line fluxes (<code>area</code>-parameter) until you get a good "fit by eye". Playing a little bit with the parameters I find a starting model that looks as follows:
  
{{ :isis:tutorial:gratings04.png?direct |}}
+
[[File:Gratings04.png|center]]
  
 
We now ignore the 20.6-21.5 and 22.6-22.8 Angstrom bands in both data sets:
 
We now ignore the 20.6-21.5 and 22.6-22.8 Angstrom bands in both data sets:
<code>
+
<ref>
 
isis> ignore([p1,m1],20.6,21.5);
 
isis> ignore([p1,m1],20.6,21.5);
 
isis> ignore([p1,m1],22.6,22.8);
 
isis> ignore([p1,m1],22.6,22.8);
</code>
+
</ref>
 
Replot in order to confirm that these data are gone! Furthermore, we also ignore everything below 20A and above 23A:
 
Replot in order to confirm that these data are gone! Furthermore, we also ignore everything below 20A and above 23A:
<code>
+
<ref>
 
isis> ignore([p1,m1],NULL,20);                                                           
 
isis> ignore([p1,m1],NULL,20);                                                           
 
isis> ignore([p1,m1],23,NULL);
 
isis> ignore([p1,m1],23,NULL);
</code>
+
</ref>
 
perform the fit:
 
perform the fit:
<code>
+
<ref>
 
isis> Fit_Verbose=1;
 
isis> Fit_Verbose=1;
 
isis> fit_counts();                                                     
 
isis> fit_counts();                                                     
</code>
+
</ref>
 
The best fit parameters are as follows:
 
The best fit parameters are as follows:
<code>
+
<ref>
 
isis> list_par;                                                             
 
isis> list_par;                                                             
 
constant(1)+gauss(1)+gauss(2)+gauss(3)
 
constant(1)+gauss(1)+gauss(2)+gauss(3)
Line 275: Line 273:
 
   9  gauss(3).center      0    0        22.09971          22        22.2  A
 
   9  gauss(3).center      0    0        22.09971          22        22.2  A
 
  10  gauss(3).sigma      0    0      0.02135323      1e-06          1  A
 
  10  gauss(3).sigma      0    0      0.02135323      1e-06          1  A
</code>
+
</ref>
 
To check whether all went well with the fit, we plot our best fit. While for the manual adjustment of the fit parameters it was sufficient to just look at one of the spectra, we really should look at all of our data. This is done with
 
To check whether all went well with the fit, we plot our best fit. While for the manual adjustment of the fit parameters it was sufficient to just look at one of the spectra, we really should look at all of our data. This is done with
<code>
+
<ref>
 
isis> plot_data({m1,p1};dsym={1,1},decol={2,4},dcol={2,4},mcol={4,4},res=1);
 
isis> plot_data({m1,p1};dsym={1,1},decol={2,4},dcol={2,4},mcol={4,4},res=1);
</code>
+
</ref>
where the ''{1,2}'' etc. are so-called //lists//. These are somewhat more flexible forms of arrays. We will address the details of this data type later, for the moment, just remember that you need to put everything in curly parentheses instead of brackets. In the above, the color 4 is used for the m=+1 spectrum and 2 for the m=-1 spectrum.
+
where the <code>{1,2}</code> etc. are so-called ''lists''. These are somewhat more flexible forms of arrays. We will address the details of this data type later, for the moment, just remember that you need to put everything in curly parentheses instead of brackets. In the above, the color 4 is used for the m=+1 spectrum and 2 for the m=-1 spectrum.
  
 
The best fit looks as follows:
 
The best fit looks as follows:
  
{{ :isis:tutorial:gratings05.png?direct |}}
+
[[File:Gratings05.png|center]]
  
 
and the residuals are flat. This is not surprising, given that the reduced chi-square of the fit was only 0.5.
 
and the residuals are flat. This is not surprising, given that the reduced chi-square of the fit was only 0.5.
  
Looking at the paper by Ness et al., for the spectral diagnosis the ratio <latex>G=(f+i)/r</latex> as well as the ratio <latex>R=f/i</latex> is used. As discussed by Ness et al., the diagnostic information contained in these ratios is discussed in great detail by [[http://adsabs.harvard.edu/abs/2001A%26A...376.1113P|Porquet et al. (2001)]] (where the resonance line is called w, the intercombination x+y, and the forbidden line z; sorry, nobody claimed scientists are consistent...). Porquet et al. (2001) show that R is mainly dependent on the electron density and G is mainly dependent on the temperature.  
+
Looking at the paper by Ness et al., for the spectral diagnosis the ratio <latex>G=(f+i)/r</latex> as well as the ratio <latex>R=f/i</latex> is used. As discussed by Ness et al., the diagnostic information contained in these ratios is discussed in great detail by [http://adsabs.harvard.edu/abs/2001A%26A...376.1113P Porquet et al. (2001)] (where the resonance line is called w, the intercombination x+y, and the forbidden line z; sorry, nobody claimed scientists are consistent...). Porquet et al. (2001) show that R is mainly dependent on the electron density and G is mainly dependent on the temperature.  
  
The following analysis can now proceed either by using your pocket calculator or by using isis as a pocket calculator. Since we have not yet introduced programming in slang/isis, feel free to use either way, or [[isis:tutorial:slang|take a look at our Slang programming introduction]]. In the following, we show how one would get about calculating the above ratios with isis. To understand the code, you need to know that in slang structures contain several named values and that you can access the one of the variables ("tags") that make up the content of a structure with the usual ''variable.tag'' syntax that is also used, e.g., in C. Furthermore, read the help for the isis ''get_params'' function((if one is just interested in the best fit value of a parameter, you can also use the ''get_par'' function, however, this would not have allowed us to introduce slang structures...)).
+
The following analysis can now proceed either by using your pocket calculator or by using isis as a pocket calculator. Since we have not yet introduced programming in slang/isis, feel free to use either way, or [isis:tutorial:slang take a look at our Slang programming introduction]. In the following, we show how one would get about calculating the above ratios with isis. To understand the code, you need to know that in slang structures contain several named values and that you can access the one of the variables ("tags") that make up the content of a structure with the usual <code>variable.tag</code> syntax that is also used, e.g., in C. Furthermore, read the help for the isis <code>get_params</code> function<ref>if one is just interested in the best fit value of a parameter, you can also use the <code>get_par</code> function, however, this would not have allowed us to introduce slang structures...</ref>.
 
To calculate the ratios then do the following:
 
To calculate the ratios then do the following:
<code>
+
<ref>
 
isis> r=get_params("gauss(1).area");
 
isis> r=get_params("gauss(1).area");
 
isis> i=get_params("gauss(2).area");  
 
isis> i=get_params("gauss(2).area");  
 
isis> f=get_params("gauss(3).area");
 
isis> f=get_params("gauss(3).area");
</code>
+
</ref>
take a look at the contents of r (which per the documentation of ''get_params'' is an array):
+
take a look at the contents of r (which per the documentation of <code>get_params</code> is an array):
<code>
+
<ref>
 
isis> print(r);                     
 
isis> print(r);                     
 
{name="gauss(1).area", index=2, value=0.0011752452373316315, min=-1.7976931348623157e+308, max=1.7976931348623157e+308, hard_min=-inf, hard_max=inf, step=0.0, relstep=0.0001, freeze=0, tie=NULL, units="photons/s/cm^2", is_a_norm=1, fun=NULL}
 
{name="gauss(1).area", index=2, value=0.0011752452373316315, min=-1.7976931348623157e+308, max=1.7976931348623157e+308, hard_min=-inf, hard_max=inf, step=0.0, relstep=0.0001, freeze=0, tie=NULL, units="photons/s/cm^2", is_a_norm=1, fun=NULL}
</code>
+
</ref>
 
and therefore
 
and therefore
<code>
+
<ref>
 
isis> rat=f[0].value/i[0].value;
 
isis> rat=f[0].value/i[0].value;
 
isis> g=(f[0].value+i[0].value)/r[0].value;
 
isis> g=(f[0].value+i[0].value)/r[0].value;
Line 311: Line 309:
 
0.8959412576621245
 
0.8959412576621245
 
isis>
 
isis>
</code>
+
</ref>
 
Per the discussion in Porquet, the small value of G is an indication that the observed plasma is dominated by collisions, i.e., it is very thin and very hot and the ionization of the plasma is due to collisions and not due to a strong X-ray source in the vicinity that ionizes the plasma through photoionization. We are also happy that our ratio for R, 4.7, is close to that found by Ness et al., which is around 4 (right hand panel of their Figure 10).
 
Per the discussion in Porquet, the small value of G is an indication that the observed plasma is dominated by collisions, i.e., it is very thin and very hot and the ionization of the plasma is due to collisions and not due to a strong X-ray source in the vicinity that ionizes the plasma through photoionization. We are also happy that our ratio for R, 4.7, is close to that found by Ness et al., which is around 4 (right hand panel of their Figure 10).
  
While this is all very nice and the result that we obtain is in rough agreement with the literature, we do not know how uncertain our parameters are. The reason is that even though we have the best fit, we do not yet know the uncertainty of our fit parameters. To calculate the uncertainty of a parameter isis uses the usual <latex>\Delta\chi^2</latex> approach, first discussed for X-ray astronomical data by [[http://adsabs.harvard.edu/abs/1976ApJ...208..177L|Lampton, Margon, Bowyer, 1978, Apj 208, 177]]. We will call the parameter for which the uncertainty is to be calculated the "parameter of interest". Lampton et al. show that the confidence interval can be determined with the following recipe:
+
While this is all very nice and the result that we obtain is in rough agreement with the literature, we do not know how uncertain our parameters are. The reason is that even though we have the best fit, we do not yet know the uncertainty of our fit parameters. To calculate the uncertainty of a parameter isis uses the usual <latex>\Delta\chi^2</latex> approach, first discussed for X-ray astronomical data by [http://adsabs.harvard.edu/abs/1976ApJ...208..177L Lampton, Margon, Bowyer, 1978, Apj 208, 177]. We will call the parameter for which the uncertainty is to be calculated the "parameter of interest". Lampton et al. show that the confidence interval can be determined with the following recipe:
  - Calculate <latex>\Delta\chi^2</latex> from the chi-square-distribution with one degree of freedom. Common in X-ray astronomy are "<latex>1\sigma</latex>"-errors with <latex>\Delta\chi^2=1.00</latex>, 90% confidence ranges with <latex>\Delta\chi^2=2.71</latex>, and 99% confidence contours with <latex>\Delta\chi^2=6.63</latex>. The most common errors are the 90% ones.
+
# Calculate <latex>\Delta\chi^2</latex> from the chi-square-distribution with one degree of freedom. Common in X-ray astronomy are "<latex>1\sigma</latex>"-errors with <latex>\Delta\chi^2=1.00</latex>, 90% confidence ranges with <latex>\Delta\chi^2=2.71</latex>, and 99% confidence contours with <latex>\Delta\chi^2=6.63</latex>. The most common errors are the 90% ones.
  - Change the parameter of interest away from its best fit value to a slightly smaller value. Keep it frozen and refit. This will result in a slightly larger <latex>\chi^2</latex> for the best fit.
+
# Change the parameter of interest away from its best fit value to a slightly smaller value. Keep it frozen and refit. This will result in a slightly larger <latex>\chi^2</latex> for the best fit.
  - Repeat the previous step until you find the parameter value where the chi-squared is <latex>\chi^2 = \chi_\mathrm{min}^2+\Delta\chi^2</latex> where <latex>\chi_\mathrm{min}^2</latex> is the chi-squared of our original best fit. The value of our parameter is now the lower bound of the confidence interval.
+
# Repeat the previous step until you find the parameter value where the chi-squared is <latex>\chi^2 = \chi_\mathrm{min}^2+\Delta\chi^2</latex> where <latex>\chi_\mathrm{min}^2</latex> is the chi-squared of our original best fit. The value of our parameter is now the lower bound of the confidence interval.
  - Repeat for values larger than the best fit value until you find the upper bound of the confidence region.
+
# Repeat for values larger than the best fit value until you find the upper bound of the confidence region.
  - Designating the lower and upper end of the confidence region by <latex>p_\mathrm{min}</latex> and <latex>p_\mathrm{max}</latex> and the best fit value <latex>p</latex>, we then write the best fit parameter as follows: <latex>p^{+\Delta p_\mathrm{max}}_{-\Delta p_\mathrm{min}}</latex> where <latex>\Delta p_\mathrm{max} = p_\mathrm{max}-p</latex> and <latex>p_\mathrm{min}=p-p_\mathrm{min}</latex>.
+
# Designating the lower and upper end of the confidence region by <latex>p_\mathrm{min}</latex> and <latex>p_\mathrm{max}</latex> and the best fit value <latex>p</latex>, we then write the best fit parameter as follows: <latex>p^{+\Delta p_\mathrm{max}}_{-\Delta p_\mathrm{min}}</latex> where <latex>\Delta p_\mathrm{max} = p_\mathrm{max}-p</latex> and <latex>p_\mathrm{min}=p-p_\mathrm{min}</latex>.
  
 
Because of correlations between parameters, error bars are typically not symmetric and great care has to be taken when doing error propagation. We ignore all of those for the moment and use the rule of thumb that if the error bars are not too asymmetric, a rough estimate for a symmetric error bar which can be used for the standard Gaussian error propagation is the average of the lower and the upper error bars, i.e., use <latex>\Delta p =(\Delta p_\mathrm{min}+\Delta p_\mathrm{max})/2</latex> and write the best fit parameter as <latex>p\pm\Delta p</latex> (where we usually also use 90% error bars!).
 
Because of correlations between parameters, error bars are typically not symmetric and great care has to be taken when doing error propagation. We ignore all of those for the moment and use the rule of thumb that if the error bars are not too asymmetric, a rough estimate for a symmetric error bar which can be used for the standard Gaussian error propagation is the average of the lower and the upper error bars, i.e., use <latex>\Delta p =(\Delta p_\mathrm{min}+\Delta p_\mathrm{max})/2</latex> and write the best fit parameter as <latex>p\pm\Delta p</latex> (where we usually also use 90% error bars!).
 
   
 
   
The above procedure is implemented in isis through the ''conf'' and ''vconf'' functions. These are identical, ''vconf'' gives more information about the procedure (the "v" stands for "verbose"). Since the above procedure searches for the zero of a function, it is not guaranteed to converge numerically. For this reason isis calculates confidence intervals only when explicit limits are set. These limits are returned in case the error calculation failed. Typically, for good data sets the errors will be less than 20-30% of the value, but this depends a lot on the data set and one often has to play around a little bit.  
+
The above procedure is implemented in isis through the <code>conf</code> and <code>vconf</code> functions. These are identical, <code>vconf</code> gives more information about the procedure (the "v" stands for "verbose"). Since the above procedure searches for the zero of a function, it is not guaranteed to converge numerically. For this reason isis calculates confidence intervals only when explicit limits are set. These limits are returned in case the error calculation failed. Typically, for good data sets the errors will be less than 20-30% of the value, but this depends a lot on the data set and one often has to play around a little bit.  
  
 
The error bar for the flux of the forbidden line is then calculated as follows:
 
The error bar for the flux of the forbidden line is then calculated as follows:
<code>
+
<ref>
 
isis> set_par("gauss(3).area",f[0].value,0,0.75*f[0].value,1.25*f[0].value);
 
isis> set_par("gauss(3).area",f[0].value,0,0.75*f[0].value,1.25*f[0].value);
 
isis> list_par;                                                             
 
isis> list_par;                                                             
Line 359: Line 357:
 
isis> print(f[0].value);     
 
isis> print(f[0].value);     
 
0.0008692617403948057
 
0.0008692617403948057
</code>
+
</ref>
 
this means that the error bar is almost symmetric and therefore <latex>f=(8.7\pm1.0)\times10^{-5}\,\mathrm{ph}\,\mathrm{s}^{-1}\,\mathrm{cm}^{-2}</latex>
 
this means that the error bar is almost symmetric and therefore <latex>f=(8.7\pm1.0)\times10^{-5}\,\mathrm{ph}\,\mathrm{s}^{-1}\,\mathrm{cm}^{-2}</latex>
  
//**Exercise 4**//
+
'''''Exercise 4'''''
  - Perform the above analysis for "your" star. Do not forget to calculate error bars for R and G using error propagation!
+
# Perform the above analysis for "your" star. Do not forget to calculate error bars for R and G using error propagation!
  - Use the tables of Porquet et al. to estimate the density and temperature of the plasma. Looking at the discussion by Ness et al., what is the systematic error of this analysis?
+
# Use the tables of Porquet et al. to estimate the density and temperature of the plasma. Looking at the discussion by Ness et al., what is the systematic error of this analysis?
 
 
  
 +
==== References ====
  
 
[[Category:Isis / Slang]]
 
[[Category:Isis / Slang]]

Revision as of 16:13, 12 April 2018

Further Data Fitting

The walk through isis has given you a first overview of a simple X-ray spectral analysis. In this part of the tutorial we build upon this experience by performing a more complicated analysis of Chandra gratings spectra. You will learn about X-ray data archives and what to do when not all keywords are set in a X-ray spectral file. Furthermore we introduce an important X-ray diagnostics for tenuous plasmas.

Data Archives and the ADS

ADS

In this tutorial we will demonstrate the analysis of Chandra gratings data of stellar spectra and try to reproduce the results obtained by Jan-Uwe Ness et al., 2002, Coronal density diagnostics with Helium-like triplets: CHANDRA-LETGS observations of Algol, Capella, Procyon, epsilon Eri, alpha Cen A&B, UX Ari, AD Leo, YY Gem, and HR 1099, Astronomy and Astrophysics 394, 911.

Exercise 1

  • Go to the ADS Abstract Service and search for the above paper. The best way to do this is to enter ^Ness for the Author and Capella for the Object. The ADS is the best data base to find astronomical literature. It goes back to the early 1800s and is almost complete for the past 50 years or so. It will be very worth your time to familiarize yourself with searching papers there - even if you do not want to do astronomy in the end but other areas of physics, which are indexed in the ADS as well. In order to make sure that you really did the search and did not just click the link above, what is the newest paper published by this author?
  • Download, print, and read this paper. Yes, really, print it - you will need to refer to this paper often and you might want to scribble comments on your paper copy and you will read the paper much more intensively if it is not on a computer screen. In order to get to the PDF-copy of the paper, click on "Full Refereed Journal Article (PDF/Postscript)" in the above link. You will see it is colored in green, meaning that the paper is not behind a paywall. This is not the case for new articles, unfortunately, in this case you can always go to the arXiv-Link and get a preprint from there. Virtually all important astronomical papers can be found this way.

Data Archives

Here, we will show you how to perform the analysis of Capella, in your homework you will work on one of the other sources. Like the analysis of data from all other X-ray satellites, the reduction of Chandra gratings data can become very involved. Since we "just" want to analyze the time averaged spectrum of the source, we are lucky that somebody else (well, the Chandra gratings team) has done the work for us and has put the reduced spectra on the WWW for us. Such archives of pre-reduced data exist for all satellites, and while I caution not to use the reduced data in these archives for publication-level work, they are useful to get a feel for what is available (the reason why you do not want to use these data for publication level work is that you will typically have to apply a newer version of the detector calibration, different background screening criteria, different time intervals, and so on). The following list contains the most important X-ray astronomical archives:

  • TO BE WRITTEN
  • TGCat contains all public observations performed with the Chandra transmission gratings spectrometers. The user interface is self-explanatory and there is a nice help section available. If you know the name of the object you're interested in, enter it in the "Quick Query" box, then click on the object name and you will be getting a list of all available observations.

Exercise 2

  • Download the observation with the longest exposure time available for the object you are interested in, unless your instructions say otherwise. If possible, disregard the observations where the HRC was in the focal plane, i.e., look at the ACIS-observations only (the HRC is not energy dispersive, and therefore order sorting is not so easy with this detector).

Select the data, ask TGCat to send you an email, and then download the file. For example [1] Unpack it with [2] For Capella, we download the data from observation ID 8319. The data set looks as follows: [3] The spectral file is called pha2.gz, which is not a very meaningful name, so we unpack it and rename it: [4] Note the name pha2. In the walkthrough we encountered PHA-files, which contain one spectrum. pha2-files contain multiple spectra. They are used, for example, in pulse phase resolved spectroscopy of neutron stars or in gratings spectra, where they contain multiple spectra.

Exercise 3

  • Take a look at the contents of your pha2-file using fv and fstruct. Note that each "row" in the pha2-file now contains one spectrum.

Preparing Gratings Data for Fitting

We now enter "isis", load the "isisscripts", and load our data set [5] As usual, we first take a look at what has been loaded, this time using a helpful function from the "isisscripts" that lists the data and the loaded "ARF"- and "RMF"-files.: [6] We note two things:

  1. load_data loaded all contents of the pha2-file, total of six spectra. What these spectra are is identified in the part/m-column: leg is the "low energy grating" of Chandra-HETGS (the other grating would be called meg for medium energy grating), and -3, -2, -1, +1, +2, +3 identifies the order of the spectrum.
  2. No ARF and RMF are listed. This means that while the spectra have been loaded we still need to tell isis what ARF and RMF to use for the spectra (you can also see this by noticing the dashes in the A and R columns).

We now remind ourselves what responses and ARF we were provided with, by using isis' "shell escape". This means that within isis we can precede a normal shell command by an exclamation mark to have it executed by the shell: [7] This means that we only have RMFs and ARFs available for the first order and we will have to ignore the higher orders. This is fine since most photons end up in the 1st order anyway. Let us now load the files: [8] and check that everything went fine: [9] We now need to assign each ARF and RMF to the spectrum taken with this detector: [10] Note that instead of using the id-values directly (e.g., assign_rmf(1,3)) we use the isis-variables that were returned in the different load-commands (capella is a variable, and in slang/isis arrays are zero-based). This approach is better than using the ids directly since it minimizes the likelihood of typos and we do not have to remember strange id numbers but rather variable names that (should) make sense. If you want to find out more about the slang programming language, you can have a look at the nice documentation at [1]. In this case, especially Chapter 6 (Variables) and 11 (Arrays) might be interesting for you.

Let's check whether the assignment was ok: [11] Notice that the A and R columns now contain the indices of the respective ARF and RMF.

The First Fit

Since we do not have an ARF and RMF for the other orders, we need to tell isis not to work with these data sets: [12] The argument of the exclude function is an array containing the indices of all spectra that should be ignored when fitting. In slang/isis, arrays are defined by listing their contents in brackets, i.e., [13] It is also possible to use a shorthand notation to define larger arrays, e.g., [14] creates an array containing the 10 numbers 1,2,...,10, while [15] creates an array containing the numbers 1,3,5,...,9. In principle, you can do something like this also with floating point numbers, but because of subtleties with floating point arithmetic, we do not recommend using this feature of the language.

In the exclude-example before, note that we are again listing the indices of the spectra indirectly by specifying them through the capella variable. As before, this makes our code more portable. Finally, note that you could have also used the ignore-function to ignore these data sets, but exclude is preferred since it does not affect the currently noticed energy ranges.

Finally, since we now only have two spectra to work with, let's remember their indices in shorter variables such that we do not have to type capella[x] all the time... [16] We first plot the whole data set, switching the x-axis unit to Angstroms, because this is more appropriate for gratings data: [17] Note that for the moment we are only plotting one data set in order not to confuse ourselves. With dsym=1 we switch off the plot symbol, which is only distracting and does not help in understanding the figure (try the command without the dsym-qualifier!).

The resulting figure looks as follows:

Gratings01.png

Notice the very strong emission lines, which are typical for stellar coronae. Most of the things are happening between 5 and 25 Angstroms, so let's zoom in that region:

Gratings02.png

Isis has very powerful functions that help in the identification of these lines. Also note the "bump" at lower wavelengths, which is due to bremsstrahlung emission of the hot corona.

Right now we are only interested in the He-like oxygen triplet at 21.6, 21.8, and 22.1 Angstroms. These are called the resonant, intercombination, and forbidden line, respectively, and their fluxes are typically called r, i, and f. Let's therefore take a look at the 20-23 A band only:

Gratings03.png

All three lines can be clearly seen in the data set. In order to get more quantitative information, a look at the spectral plot indicates that we should be able to model this spectral region well with a spectral model that consists of the three lines plus a constant flux component (model name constant) that describes the continuum emission. We should probably also ignore the 20.5-21.5 A band because otherwise the fit would be contaminated by the emission lines there. Finally, experience tells us that in such line fits it is often not a good idea to let the wavelength/energy of the line to be completely free. The reason is that often initially the <latex>\chi^2</latex>-minimization routine will be trying to change the wavelength by a large factor and as a result it could be that the lines are switched. We therefore allow the lines only to vary by 0.1 A around their official values.

With the commands discussed in the walkthrough, and with the information given by help set_par you should now be able to setup a fit function that looks like this (note: the gauss-model in isis is a Gaussian line in Angstrom units, the gaussian-model is the same, but in keV units): [18] To get a good fit, plot the model (do not forget the eval_counts command!), and adjust the constant, line widths, and line fluxes (area-parameter) until you get a good "fit by eye". Playing a little bit with the parameters I find a starting model that looks as follows:

Gratings04.png

We now ignore the 20.6-21.5 and 22.6-22.8 Angstrom bands in both data sets: [19] Replot in order to confirm that these data are gone! Furthermore, we also ignore everything below 20A and above 23A: [20] perform the fit: [21] The best fit parameters are as follows: [22] To check whether all went well with the fit, we plot our best fit. While for the manual adjustment of the fit parameters it was sufficient to just look at one of the spectra, we really should look at all of our data. This is done with [23] where the {1,2} etc. are so-called lists. These are somewhat more flexible forms of arrays. We will address the details of this data type later, for the moment, just remember that you need to put everything in curly parentheses instead of brackets. In the above, the color 4 is used for the m=+1 spectrum and 2 for the m=-1 spectrum.

The best fit looks as follows:

Gratings05.png

and the residuals are flat. This is not surprising, given that the reduced chi-square of the fit was only 0.5.

Looking at the paper by Ness et al., for the spectral diagnosis the ratio <latex>G=(f+i)/r</latex> as well as the ratio <latex>R=f/i</latex> is used. As discussed by Ness et al., the diagnostic information contained in these ratios is discussed in great detail by Porquet et al. (2001) (where the resonance line is called w, the intercombination x+y, and the forbidden line z; sorry, nobody claimed scientists are consistent...). Porquet et al. (2001) show that R is mainly dependent on the electron density and G is mainly dependent on the temperature.

The following analysis can now proceed either by using your pocket calculator or by using isis as a pocket calculator. Since we have not yet introduced programming in slang/isis, feel free to use either way, or [isis:tutorial:slang take a look at our Slang programming introduction]. In the following, we show how one would get about calculating the above ratios with isis. To understand the code, you need to know that in slang structures contain several named values and that you can access the one of the variables ("tags") that make up the content of a structure with the usual variable.tag syntax that is also used, e.g., in C. Furthermore, read the help for the isis get_params function[24]. To calculate the ratios then do the following: [25] take a look at the contents of r (which per the documentation of get_params is an array): [26] and therefore [27] Per the discussion in Porquet, the small value of G is an indication that the observed plasma is dominated by collisions, i.e., it is very thin and very hot and the ionization of the plasma is due to collisions and not due to a strong X-ray source in the vicinity that ionizes the plasma through photoionization. We are also happy that our ratio for R, 4.7, is close to that found by Ness et al., which is around 4 (right hand panel of their Figure 10).

While this is all very nice and the result that we obtain is in rough agreement with the literature, we do not know how uncertain our parameters are. The reason is that even though we have the best fit, we do not yet know the uncertainty of our fit parameters. To calculate the uncertainty of a parameter isis uses the usual <latex>\Delta\chi^2</latex> approach, first discussed for X-ray astronomical data by Lampton, Margon, Bowyer, 1978, Apj 208, 177. We will call the parameter for which the uncertainty is to be calculated the "parameter of interest". Lampton et al. show that the confidence interval can be determined with the following recipe:

  1. Calculate <latex>\Delta\chi^2</latex> from the chi-square-distribution with one degree of freedom. Common in X-ray astronomy are "<latex>1\sigma</latex>"-errors with <latex>\Delta\chi^2=1.00</latex>, 90% confidence ranges with <latex>\Delta\chi^2=2.71</latex>, and 99% confidence contours with <latex>\Delta\chi^2=6.63</latex>. The most common errors are the 90% ones.
  2. Change the parameter of interest away from its best fit value to a slightly smaller value. Keep it frozen and refit. This will result in a slightly larger <latex>\chi^2</latex> for the best fit.
  3. Repeat the previous step until you find the parameter value where the chi-squared is <latex>\chi^2 = \chi_\mathrm{min}^2+\Delta\chi^2</latex> where <latex>\chi_\mathrm{min}^2</latex> is the chi-squared of our original best fit. The value of our parameter is now the lower bound of the confidence interval.
  4. Repeat for values larger than the best fit value until you find the upper bound of the confidence region.
  5. Designating the lower and upper end of the confidence region by <latex>p_\mathrm{min}</latex> and <latex>p_\mathrm{max}</latex> and the best fit value <latex>p</latex>, we then write the best fit parameter as follows: <latex>p^{+\Delta p_\mathrm{max}}_{-\Delta p_\mathrm{min}}</latex> where <latex>\Delta p_\mathrm{max} = p_\mathrm{max}-p</latex> and <latex>p_\mathrm{min}=p-p_\mathrm{min}</latex>.

Because of correlations between parameters, error bars are typically not symmetric and great care has to be taken when doing error propagation. We ignore all of those for the moment and use the rule of thumb that if the error bars are not too asymmetric, a rough estimate for a symmetric error bar which can be used for the standard Gaussian error propagation is the average of the lower and the upper error bars, i.e., use <latex>\Delta p =(\Delta p_\mathrm{min}+\Delta p_\mathrm{max})/2</latex> and write the best fit parameter as <latex>p\pm\Delta p</latex> (where we usually also use 90% error bars!).

The above procedure is implemented in isis through the conf and vconf functions. These are identical, vconf gives more information about the procedure (the "v" stands for "verbose"). Since the above procedure searches for the zero of a function, it is not guaranteed to converge numerically. For this reason isis calculates confidence intervals only when explicit limits are set. These limits are returned in case the error calculation failed. Typically, for good data sets the errors will be less than 20-30% of the value, but this depends a lot on the data set and one often has to play around a little bit.

The error bar for the flux of the forbidden line is then calculated as follows: [28] this means that the error bar is almost symmetric and therefore <latex>f=(8.7\pm1.0)\times10^{-5}\,\mathrm{ph}\,\mathrm{s}^{-1}\,\mathrm{cm}^{-2}</latex>

Exercise 4

  1. Perform the above analysis for "your" star. Do not forget to calculate error bars for R and G using error propagation!
  2. Use the tables of Porquet et al. to estimate the density and temperature of the plasma. Looking at the discussion by Ness et al., what is the systematic error of this analysis?

References

  1. wget http://tgcat.mit.edu/tmp/1337349938_174950000/tgcat.tar.gz
  2. tar xzvf tgcat.tar.gz
  3. hde226868:~/isistut> cd tgcat hde226868:~/isistut/tgcat> ls -l total 16 drwxr-xr-x 3 wilms wilms 4096 May 18 16:05 . drwxr-xr-x 3 wilms wilms 4096 May 20 14:05 .. -rw-r--r-- 1 wilms wilms 327 May 18 16:05 checksums.dat drwxr-xr-x 2 wilms wilms 4096 May 18 16:05 obs_8319_tgid_3283 hde226868:~/isistut/tgcat> cd obs_8319_tgid_3283 hde226868:~/isistut/tgcat/obs_8319_tgid_3283> ls -l total 15648 -r--r--r-- 1 wilms wilms 1419840 May 18 16:05 pha2.gz -r--r--r-- 1 wilms wilms 256320 May 18 16:05 leg_-1.arf -r--r--r-- 1 wilms wilms 7030080 May 18 16:05 leg_-1.rmf -r--r--r-- 1 wilms wilms 256320 May 18 16:05 leg_1.arf -r--r--r-- 1 wilms wilms 7032960 May 18 16:05 leg_1.rmf -rw-r--r-- 1 wilms wilms 71 May 18 16:05 vv_report.txt
  4. hde226868:~/isistut/tgcat/obs_8319_tgid_3283> gunzip pha2.gz hde226868:~/isistut/tgcat/obs_8319_tgid_3283> mv pha2 capella.pha2
  5. hde226868:~/isistut/tgcat/obs_8319_tgid_3283> isis
    isis> require("isisscripts");
    isis> capella=load_data("capella.pha2"); Reading: ......
  6. isis> list_all; Current Spectrum List: id instrument part/m src use/nbins A R totcts exp(ksec) target 1 LETG-ACIS leg-3 1 8192/ 8192 - - 1.0222e+04 59.146 Capella file: capella.pha2 2 LETG-ACIS leg-2 1 8192/ 8192 - - 4.4290e+03 59.146 Capella file: capella.pha2 3 LETG-ACIS leg-1 1 8192/ 8192 - - 7.0583e+04 59.146 Capella file: capella.pha2 4 LETG-ACIS leg+1 1 8192/ 8192 - - 1.1496e+05 59.146 Capella file: capella.pha2 5 LETG-ACIS leg+2 1 8192/ 8192 - - 4.7930e+03 59.146 Capella file: capella.pha2 6 LETG-ACIS leg+3 1 8192/ 8192 - - 6.2380e+03 59.146 Capella file: capella.pha2 isis>
  7. isis> !ls -l total 15648 -r--r--r-- 1 wilms wilms 1419840 May 18 16:05 capella.pha2 -r--r--r-- 1 wilms wilms 256320 May 18 16:05 leg_-1.arf -r--r--r-- 1 wilms wilms 7030080 May 18 16:05 leg_-1.rmf -r--r--r-- 1 wilms wilms 256320 May 18 16:05 leg_1.arf -r--r--r-- 1 wilms wilms 7032960 May 18 16:05 leg_1.rmf -rw-r--r-- 1 wilms wilms 71 May 18 16:05 vv_report.txt isis>
  8. isis> arfm1=load_arf("leg_-1.arf"); isis> arfp1=load_arf("leg_1.arf"); isis> rmfm1=load_rmf("leg_-1.rmf"); isis> rmfp1=load_rmf("leg_1.rmf");
  9. isis> list_all; Current Spectrum List: id instrument part/m src use/nbins A R totcts exp(ksec) target 1 LETG-ACIS leg-3 1 8192/ 8192 - - 1.0222e+04 59.146 Capella file: capella.pha2 2 LETG-ACIS leg-2 1 8192/ 8192 - - 4.4290e+03 59.146 Capella file: capella.pha2 3 LETG-ACIS leg-1 1 8192/ 8192 - - 7.0583e+04 59.146 Capella file: capella.pha2 4 LETG-ACIS leg+1 1 8192/ 8192 - - 1.1496e+05 59.146 Capella file: capella.pha2 5 LETG-ACIS leg+2 1 8192/ 8192 - - 4.7930e+03 59.146 Capella file: capella.pha2 6 LETG-ACIS leg+3 1 8192/ 8192 - - 6.2380e+03 59.146 Capella file: capella.pha2 Current RMF List: id grating detector m type file/function 1 LETG ACIS-7 -1 file: leg_-1.rmf 2 LETG ACIS-7 1 file: leg_1.rmf Current ARF List: id grating detector part/m src nbins exp(ksec) target 1 LETG ACIS leg-1 0 8192 59.15 Capella file: leg_-1.arf 2 LETG ACIS leg+1 0 8192 59.15 Capella file: leg_1.arf isis>
  10. isis> assign_rmf(rmfm1,capella[2]); isis> assign_arf(arfm1,capella[2]); isis> assign_rmf(rmfp1,capella[3]); isis> assign_arf(arfp1,capella[3]);
  11. isis> list_data; Current Spectrum List: id instrument part/m src use/nbins A R totcts exp(ksec) target 1 LETG-ACIS leg-3 1 8192/ 8192 - - 1.0222e+04 59.146 Capella file: capella.pha2 2 LETG-ACIS leg-2 1 8192/ 8192 - - 4.4290e+03 59.146 Capella file: capella.pha2 3 LETG-ACIS leg-1 1 8192/ 8192 1 1 7.0583e+04 59.146 Capella file: capella.pha2 4 LETG-ACIS leg+1 1 8192/ 8192 2 2 1.1496e+05 59.146 Capella file: capella.pha2 5 LETG-ACIS leg+2 1 8192/ 8192 - - 4.7930e+03 59.146 Capella file: capella.pha2 6 LETG-ACIS leg+3 1 8192/ 8192 - - 6.2380e+03 59.146 Capella file: capella.pha2
  12. isis> exclude([capella[0],capella[1],capella[4],capella[5]);
  13. array=[1,2,5,6];
  14. array=[1:10];
  15. array=[1:10:2];
  16. isis> m1=capella[2]; isis> p1=capella[3];
  17. isis> fancy_plot_unit("A"); isis> plot_data(p1;dsym=1,dcol=2);
  18. isis> list_par; constant(1)+gauss(1)+gauss(2)+gauss(3) idx param tie-to freeze value min max 1 constant(1).factor 0 0 1 0 1e+10 2 gauss(1).area 0 0 1 0 0 photons/s/cm^2 3 gauss(1).center 0 0 21.6 21.5 21.7 A 4 gauss(1).sigma 0 0 0.025 1e-06 1 A 5 gauss(2).area 0 0 1 0 0 photons/s/cm^2 6 gauss(2).center 0 0 21.8 21.7 21.9 A 7 gauss(2).sigma 0 0 0.025 1e-06 1 A 8 gauss(3).area 0 0 1 0 0 photons/s/cm^2 9 gauss(3).center 0 0 22.1 22 22.2 A 10 gauss(3).sigma 0 0 0.025 1e-06 1 A
  19. isis> ignore([p1,m1],20.6,21.5); isis> ignore([p1,m1],22.6,22.8);
  20. isis> ignore([p1,m1],NULL,20); isis> ignore([p1,m1],23,NULL);
  21. isis> Fit_Verbose=1; isis> fit_counts();
  22. isis> list_par; constant(1)+gauss(1)+gauss(2)+gauss(3) idx param tie-to freeze value min max 1 constant(1).factor 0 0 1.342954e-05 0 1e+10 2 gauss(1).area 0 0 0.001175245 0 0 photons/s/cm^2 3 gauss(1).center 0 0 21.60025 21.5 21.7 A 4 gauss(1).sigma 0 0 0.01614977 1e-06 1 A 5 gauss(2).area 0 0 0.000183689 0 0 photons/s/cm^2 6 gauss(2).center 0 0 21.79914 21.7 21.9 A 7 gauss(2).sigma 0 0 0.0108202 1e-06 1 A 8 gauss(3).area 0 0 0.0008692617 0 0 photons/s/cm^2 9 gauss(3).center 0 0 22.09971 22 22.2 A 10 gauss(3).sigma 0 0 0.02135323 1e-06 1 A
  23. isis> plot_data({m1,p1};dsym={1,1},decol={2,4},dcol={2,4},mcol={4,4},res=1);
  24. if one is just interested in the best fit value of a parameter, you can also use the get_par function, however, this would not have allowed us to introduce slang structures...
  25. isis> r=get_params("gauss(1).area"); isis> i=get_params("gauss(2).area"); isis> f=get_params("gauss(3).area");
  26. isis> print(r); {name="gauss(1).area", index=2, value=0.0011752452373316315, min=-1.7976931348623157e+308, max=1.7976931348623157e+308, hard_min=-inf, hard_max=inf, step=0.0, relstep=0.0001, freeze=0, tie=NULL, units="photons/s/cm^2", is_a_norm=1, fun=NULL}
  27. isis> rat=f[0].value/i[0].value; isis> g=(f[0].value+i[0].value)/r[0].value; isis> print(rat); 4.732248259283046 isis> print(g); 0.8959412576621245 isis>
  28. isis> set_par("gauss(3).area",f[0].value,0,0.75*f[0].value,1.25*f[0].value); isis> list_par; constant(1)+gauss(1)+gauss(2)+gauss(3) idx param tie-to freeze value min max 1 constant(1).factor 0 0 1.342954e-05 0 1e+10 2 gauss(1).area 0 0 0.001175245 0 0 photons/s/cm^2 3 gauss(1).center 0 0 21.60025 21.5 21.7 A 4 gauss(1).sigma 0 0 0.01614977 1e-06 1 A 5 gauss(2).area 0 0 0.000183689 0 0 photons/s/cm^2 6 gauss(2).center 0 0 21.79914 21.7 21.9 A 7 gauss(2).sigma 0 0 0.0108202 1e-06 1 A 8 gauss(3).area 0 0 0.0008692617 0.0006519463 0.001086577 photons/s/cm^2 9 gauss(3).center 0 0 22.09971 22 22.2 A 10 gauss(3).sigma 0 0 0.02135323 1e-06 1 A isis> (fmi,fma)=vconf("gauss(3).area");
    lots of output...
    gauss(3).sigma= 2.25766046e-02 chi-square value converged par[8]= 9.64711324e-04 stat= 1.5337e+02 dstat= 2.7100e+00 limit found: 9.64711324e-04 dstat= 2.7100e+00 isis> print(fmi); 0.0007743270669346407 isis> print(fma); 0.0009647113237380715 isis> print(f[0].value-fmi); 9.493467346016499e-05 isis> print(fma-f[0].value); 9.544958334326589e-05 isis> print(f[0].value); 0.0008692617403948057