OSPEX Users Guide

From RHESSI Wiki

(Difference between revisions)
Jump to: navigation, search
Line 2: Line 2:
===Introduction===
===Introduction===
-
This document goes through the steps necessary to fit a time interval during a flare using OSPEX. It is based on [http://hesperia.gsfc.nasa.gov/~dennis/OSPEX/The_Basics/index.htm OSPEX - The Basics, Part Two]. The guide below assumes that the user has already created a spectrum file as described in Part One of OSPEX - The Basics. It goes through the steps for fitting a single time interval. This page links to [[using the HESSI GUI to create spectrum files]], [http://hesperia.gsfc.nasa.gov/ssw/packages/spex/doc/ospex_explanation.htm#Fit%20Intervals,%20Options,%20and%20Fitting fitting multiple intervals by looping], and how to use various [[fit function components]]. Please feel free to add any links, or edit any of the documentation.
+
This document goes through the steps necessary to fit a time interval during a flare using OSPEX. It is based on [http://hesperia.gsfc.nasa.gov/~dennis/OSPEX/The_Basics/index.htm#Step_2_-_OSPEX_-_Analyze_Count-rate_Spectra OSPEX - The Basics, Part Two]. The guide below assumes that the user has already created a spectrum file as described in Part One of OSPEX - The Basics. It goes through the steps for fitting a single time interval. This page links to [[using the HESSI GUI to create spectrum files]], [http://hesperia.gsfc.nasa.gov/ssw/packages/spex/doc/ospex_explanation.htm#Fit%20Intervals,%20Options,%20and%20Fitting fitting multiple intervals by looping], and how to use various [[fit function components]]. Please feel free to add any links, or edit any of the documentation.

Revision as of 17:53, 23 June 2009

Contents

Using OSPEX to Analyze a RHESSI Spectrum

Introduction

This document goes through the steps necessary to fit a time interval during a flare using OSPEX. It is based on OSPEX - The Basics, Part Two. The guide below assumes that the user has already created a spectrum file as described in Part One of OSPEX - The Basics. It goes through the steps for fitting a single time interval. This page links to using the HESSI GUI to create spectrum files, fitting multiple intervals by looping, and how to use various fit function components. Please feel free to add any links, or edit any of the documentation.


Starting the OSPEX GUI and Loading a Spectrum File

To start the OSPEX GUI at the sswidl command line type:

  o = ospex() 

This command sets up an OSPEX object named o, and starts the OSPEX GUI. The following screen appears when the GUI starts:

The OSPEX GUI Start Screen

Select the file button in the upper left corner, and choose the Select Input button in the drop down menu that appears. From here we can select the spectrum file for the flare we would like to analyze. The path to file can either be entered manually or the file can be selected using the Browse button. Once the spectrum file is selected the accompanying SRM file will be found automatically as long as files are saved in the same directory with the original names. For the 21Apr2002 flare the Select Input GUI looks like the following once the spectrum file for detector four is selected:

The Spectrum File Selection GUI

Note that the GUI allows you to display the spectrum file in various ways. To compare it to the spectrum created in the HESSI GUI we can plot the time profile. For the spectrum file for the 21Apr2002 event using only the front segment of detector 4 (4F), we see:

The RHESSI lightcurve for the 21Apr2002 flare

This should be same as the time profile we created with the HESSI GUI. The countflux data is displayed in the default energy bands. The Select Input GUI also allows you to display an energy profile of data, as well as a spectrogram of the data should these be preferable ways of viewing the spectrum file. For a more in depth discussion of ways to display the data go here.

Selecting Background

Before we can fit any time intervals during the flare we need to select background. Below the simplest method of selecting background will be described. For a more in depth discussion of background selection go here.

Lets look at a simple method for choosing background. First choose the Select Background button under File in the main OSPEX GUI. The Select Background GUI should appear. For our simple case we will leave it at the default settings, because of this we will be using the same background for all energy bands and times.

First we want to display the time profile for the spectrum. The easiest way to do this is to select the plot v. time option in the GUI. Now select change. Using the default settings this takes us to the GUI for defining a background interval graphically. We can simply use the mouse to define a interval. RHESSI begins taking data for approximately five minutes in nighttime before it’s orbit starts and for five minutes after its orbit. This data is non-solar and we can use it to define the non-solar background levels. Simply right click at the beginning of a nighttime interval and left click at the end. Choose the Adjust to data boundaries button then accept and close. You’ve now chosen your background. Select the Plot Spectrum button in the main Select Background GUI and you will see an energy profile of your selected background. The top panel below shows what you should expect to see after picking your background interval, the lower panel, the spectrum of the background chosen.


The Background Interval (upper panel) and Spectrum (lower panel)

Fit Options - Selecting Time Intervals and Doing Fits

We can now start to fit time intervals during the flare. To start choose the Select Fit Options and Do Fit… choice from the File Drop down menu. This brings up the Fit Options GUI. Once again we’ll go through a simple set of options for setting up and fitting time intervals during the flare. A more advanced discussion of these settings can be found here. For our simple case we start by defining our time intervals. To do this select the Change Fit Intervals button on the upper right of the GUI. This brings up the GUI that allows us to select time intervals graphically.


The pop up GUI for selecting time intervals graphically

All we need to do is left click on the main OSPEX window at the point at were we would like to define the start of our time period and left click at the end. Usually you will want to select a large time interval at this step. Once this is done double click in the highlighted interval. A popup menu will appear with various options for breaking up this large interval into smaller intervals. It should appear as below.

The selected time interval(red) along with the menu used to break it into smaller intervals

Usually at this point the easiest option is to break up the interval into sub-intervals of equal length. The length of each interval in seconds is set in the Select Time Intervals for Analysis widget. In this case 20 seconds was selected. Once this is done we simply select the Adjust to Data Boundaries option then Accept and Close. We have defined our time intervals for analysis.

Spectral Fitting

Now we are ready to begin fitting. The first step is to select an interval. We do this by picking an interval from the list that appears in the top right hand panel of the ‘Fit Options’ GUI (see below). After selecting an interval from the list we have created, select the plot spectrum button in the lower panel of the GUI. A plot of the count flux v. energy will appear in the main OSPEX GUI.


Selecting a Time Interval to Fit


Plot of the Spectrum(white) of the interval to be fit along with the selected background(purple)

Now we are ready to fit this interval. To start we select the ‘Do Fit’ button at the bottom of the ‘Fit Options’ GUI. The ‘Choose Fit Function Components and Set Parameters’ GUI appears. This is where we will set up our fit function and do our fit. The first thing we need to do is select our fit function components. By default the component for a single temperature thermal fit (vth) appears in the GUI. Clicking on the arrow next to the drop down list of components labeled ‘Choose’ at the top of GUI shows the complete list of available fit components, to select a component choose it in the list and click the ‘Add’ button to the right of the drop down list. In this case we’ve selected the single broken power law component (bpow) and a component which modifies the detector response matrix (drm_mod) in addition to vth.


The Fit Function Setup with components chosen and starting parameters adjusted

Before we do the fit we must start adjusting parameters to set it up. The first pair of decisions we need to make are the energy range we would like to fit and which parameters we want to allow to vary (free parameters) during the fit. To select the energy range select the ‘Change’ button next to ‘Energy range(s) to Fit’ near the bottom of the GUI. A text window will appear labeled ‘XTEXTEDIT’, simply enter the energy range you would like to fit. In this case we choose ‘6.0 to 40.0’. We can decide on this energy range by noting that are we in the A1 attenuator state. That means that many counts below ~6keV are due to K-escape and are not the result of the incident photon spectrum, hence we set the low end of our energy range at 6keV. We set the high end of our energy range by determining where our data returns to the background level. In this case that occurs around 40keV. Now we have to decide which parameters we will allow to vary during the fit (free parameters) and which will be fixed. We do this by setting the value of each parameter to 1 (free) or 0 (fixed) in the last column of each line of the fit components. For vth we can set all parameters as free. In general when modeling the thermal contribution to the spectrum the Emission Measure and Temperature are allowed to vary, in cases where the Fe line is visible above the continuum and the energy range we are fitting includes it we can also allow to Fe abundance to vary. When using bpow we generally fix the power law index below the break (A1) to 1.5. This is a convention that was adopted to prevent the energy from non-thermal electrons from becoming infinite in the thermal part of the spectrum. The other parameters are all allowed to vary. These consist of the normalization (A0), the break energy (A2), and the power law index above the break (A3). Finally in this simple model we use drm_mod to account for the changes in detector resolution (A0) and gain (A1) over time. Now we need to select reasonable starting parameters. Generally we can adjust any parameters until we have a reasonable approximation of the data. An important idea to keep in mind is that the values of the parameters should be physically meaningful. Using the fit function components we have selected there are some basic guidelines we can follow. The thermal component (vth in this case) will usually model the spectrum to approximately 20keV – 25keV. We can adjust the Emission Measure (A0), and the Temperature (A1), to model the spectrum to these energies. The broken power law (bpow) can then be adjusted to model the spectrum in energies above the thermal region. It is generally sufficient to start drm_mod at the default parameters for all values and then allow the values to vary during the fit. Once this is done we are ready to attempt the fit. To do this select the ‘Fit’ button at the bottom of the ‘Choose Fit Function Components and Set Parameters’ GUI.


The spectrum with the fit components after doing fit(upper panel) along with the residuals for the fit(lower panel)

The image above shows the result of doing a RHESSI fit with our simple model. Notice that the free parameters have changed values from their original starting points. The final values produced the lowest reduced Chi-squared value that this particular model could converge to given our selection of starting parameters. The residuals show us a representation of how far the model was from the data in any energy bin. This representation is in standard deviations from the data. The residuals can give key information about systematic problems with the fit. Any patterns in the residuals can reveal short comings of the model or a poor choice of choice of starting parameters. If we are satisfied with our fit we can select the 'Accept' button on the lower right of the GUI and choose 'and continue'. Our fit will be stored in this session. We have completed all steps necessary to fit a single interval with a function starting with a RHESSI spectrum and SRM file.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox