Event-2D: Home Examples Install Documenation News & Pubs

Example: ACIS imaging observation, SNR E0102

The following gives a quick overview of the Event-2D software capabilities and use. See the comments in the example .sl files linked here (as .sl.txt) for more details. The Documenation page gives tips on getting help with the various routines and common variables.


Loading and viewing the data




(click for
fullsize)
The X,Y (and Energy) event data can be loaded at the command line with a simple custom script.
1D projections can be plotted for each image axis and for the energy.
[linux] hydra
. . .
hydra> .source e0102_acis_data
. . . [ click on the "Done" button on the pane below the image ]
hydra>
hydra> e2d_plot_1d(1,1); % project onto the 1st(X) axis
hydra> e2d_plot_1d(1,2); % project onto the 2nd(Y) axis
hydra> e2d_plot_1d(1,3); % project onto the 3rd(Energy) axis
hydra>

Files used: e0102_acis_data.sl, obs_3545_evt1.fits, obs_3545_extract.warf



Defining and viewing a model





The model components and their geometry and spectra are defined with a custom script which sets-up and makes-use-of the Source-3D infrastructure. Once defined, the model parameters (the norms and the values in the parameter structure, s3d_ps) can be changed and the model updated and viewed again.
. . .
hydra> .source e0102_model
. . .
hydra> s3d_proj_comps;
hydra> s3d_view_comps(1); % 3D sliced model view
. . . [ Adjust the Y slider; click "Done" button ]
hydra>
hydra> s3d_list_model;
hydra> s3d_ps.Ri=4.0;
hydra> s3d_ps.Ro=10;
hydra> s3d_update;
hydra> s3d_proj_comps;

Additional files: e0102_model.sl



Comparing data and model











The Event-2D command e2d_pars2fom carries out the whole process to go from the current model parameter values to the final Figure of Merit (FOM) between model and data; this is shown schematically in the Big Picture. (The model components are updated, model simulated events are generated, model and data events are binned, and the FOM is calculated.) Relevant statistics are shown on the screen and the data/model/residual images can be see using e2d_view_resid. Model parameters can be manually changed as above and then doing e2d_pars2fom will show the effect on the FOM.
[linux] hydra
hydra> .source e0102_acis_data
hydra> .source e0102_model
. . .
hydra> e2d_pars2fom;
Event2D: parameters to FOM
- update parameters [e2d_update_pars]
- updating the model ... [s3d_update]
- Dataset 1: generating photons from the model... [s3d_xray_photons]
- calculate and show the figure of merit... [e2d_list_fom]
. o Data-Model 1, chi^2 = 15605.1 from 2698 cells; chi^2/cell = 5.78394;
. o Total FOM = 15605.1 , from 2698 cells. FOM/sqrt(2Nfom) = 212.437
- - -
hydra> e2d_view_resid;
hydra>
hydra> s3d_ps.yc=-2.0;
hydra> e2d_pars2fom;
. . .
. o Data-Model 1, chi^2 = 45727.3 from 2962 cells; chi^2/cell = 15.438;
. o Total FOM = 45727.3 , from 2962 cells. FOM/sqrt(2Nfom) = 594.111
- - -
hydra> e2d_view_resid; % Oops, that's worse (more red, blue in residual.)
hydra>

Additional files: none.



Scaning a parameter value









(click for
fullsize)
The process of changing a parameter value and then seeiing how the FOM changes is supported through the e2d_scan_par routine and associated infrastructure. The following example shows the norm of the ring component being scanned.
[linux] hydra
hydra> .source scan_demo
. . .
hydra> public define e2d_update_pars ()
hydra> {
hydra> s3d_ps.norm2 = e2d_scan_vals[e2d_iscan];
hydra> };
hydra>
hydra> e2d_scan_par([0.27:0.67:#9],3);
Minimum FOM is at scan value = 0.42 giving a FOM of 1112.61 +/- 33.2813
. with a best norm adjust of 1.02058
. *** Parameter(s) set to this best-FOM value, BUT model not re-evaluated. ***
Fitting gives minimum at scan value = 0.446251 +/- 0.0296031, with a FOM of 1133.53
hydra> % OK, done with the scan, deactivate the scan definition:
hydra> e2d_update_pars_NULL;
hydra>
When the scan is complete a plot of the FOM vs the scan value is made. Because multiple evaluations are made at each scan value (the "3" argument) it is possible to estimate the variation of the FOM due to the Monte Carlo model/evaluation, i.e., the red and blue curves on the plot and the "+/- 33.2813" in the output.

Additional files: scan_demo.sl



Fitting model parameters


click for
fullsize



click for
fullsize


click for
fullsize


click for
fullsize


click for
fullsize


To determine the best-fit values for a set of parameters we use a simple conjugate-gradient scheme, see the Statistics & Fitting & MCMC section of the Event-2D overview. The scanning mechanism above serves as the basis of the fitting because the main step in the CG scheme is minimization along a 1D path (scan) in parameter space. The mapping between the fit parameters, pvals[], and the user's model parameters is defined and then starting values and smand ("should make a noticable difference") values are set and the fit is carried out.

The fitting process is monitored and the steps are recorded and visible through an HTML file which links to the various scans made during fitting. As an example, see:

cg_log_Mon_Oct_29_13_07_33_2012.html.

[linux] hydra
hydra> .source fit_demo
. . .
hydra> public define e2d_update_pars ()
hydra> {
% this line is the same for all cg fits:
variable pvals = cg_p0 + cg_smand*cg_dir*e2d_scan_vals[e2d_iscan];
% map the fitting parameter values to the desired model params:
s3d_ps.xc = pvals[0];
s3d_ps.yc = pvals[1];
s3d_ps.Ri = pvals[2];
s3d_ps.Ro = pvals[3]; s3d_ps.Si = pvals[3];
s3d_ps.Ra = pvals[4];
s3d_ps.norm1 = pvals[5];
% don't allow Ri to be too close to or greater than Ro:
if ((s3d_ps.Ri+0.6) > s3d_ps.Ro) s3d_ps.Ri = s3d_ps.Ro - 0.6;
hydra> };
hydra>
hydra> cg_p0 = [0.0, 3.0, 12.0, 17.0, 56.0, 0.62];
hydra> cg_smand = [1.0, 1.0, 1.0, 1.0, 5.0, 0.05];
hydra>
hydra> e2d_cg_fit(1); % *** Takes a looong time, 20--50 minutes ***
hydra>
hydra> e2d_update_pars_NULL;
hydra>
hydra> e2d_fomlog_plot("xc","yc",10.);
hydra> e2d_fomlog_plot("Ri","Ro",10.);
hydra> e2d_fomlog_plot("Ra","norm1",10.);

Additional files: fit_demo.sl



MCMC exploration of parameter space


click for
fullsize


click for
fullsize


click for
fullsize


click for
fullsize


click for
fullsize


The fitting above quickly found values for the model center, xc & yc, but other parameters like Ri & Ro, seem to have a more complex and shallower minimum-FOM region. For cases like this it is useful to use MCMC techniques to map out the low-FOM regions in parameter space.

The MCMC exploration routine directly uses the same setup and infrastructure as the fitting, allowing MCMC to directly follow fitting if desired. Likewise the "fomlog" plots are made the same way and provide a useful way to see how the MCMC is behaving, for example the FOM vs iteration plot. The useful "output" of the MCMC are plots in parameter space showing the locations of the accepted MCMC points (red) and the low-FOM values (circles), e.g., for Ri & Ro.

[linux] hydra
hydra> .source mcmc_demo
. . .
hydra> public define e2d_update_pars ()
hydra> {
% this line is the same for all cg fits:
variable pvals = cg_p0 + cg_smand*cg_dir*e2d_scan_vals[e2d_iscan];
% map the fitting parameter values to the desired model params:
s3d_ps.Ri = pvals[0];
s3d_ps.Ro = pvals[1]; s3d_ps.Si = pvals[1];
s3d_ps.Ra = pvals[2];
s3d_ps.norm1 = pvals[3];
% don't allow Ri to be too close to or greater than Ro:
if ((s3d_ps.Ri+0.6) > s3d_ps.Ro) s3d_ps.Ri = s3d_ps.Ro - 0.6;
hydra> };
hydra>
hydra> cg_p0 = [13.2, 16.60, 53.0, 0.62];
hydra> cg_smand = 1.01*[1.0, 1.0, 5.0, 0.05];
hydra>
hydra> e2d_mcmc_explore(200, 1.02);
. . .
hydra> e2d_fomlog_plot("Ri","Ro", 10.0);
hydra> e2d_fomlog_plot("Ra","norm1", 10.0);
hydra> e2d_fomlog_plot("Ra","Ro", 10.0);
hydra> e2d_fomlog_history(["Ri","Ro","Ra","norm1"]);
hydra>

Additional files: mcmc_demo.sl


Send comments to dd@space.mit.edu above last updated 10/30/2012