Re: plotting model components

From: <dph_at_email.domain.hidden>
Date: Fri, 07 Dec 2012 14:36:26 -0500
Hi Juan,

    juan> I would like to plot the individual contribution of each model
    juan> component, from a multi-component model, separately. Something
    juan> similar to what can be done with setplot add command in
    juan> XSPEC. Is there a similar function in ISIS?


While it sounds like it should be simple, it sometimes isn't.  Do you
want plots in model or data space? Do you have a multiplicative
component to include/exclude?  Do you have a continuum component to
include/exclude? 

What I have done is to set all relevant model amplitudes (or norms) to
0.0, except the one of interest, then evaluate the function or the
convolved model counts.

While some can be automated in specific cases, without knowing what kind
of models you have (and what globbing strings might be present), I'll
leave that as an "exercise for the reader" and just assume that the
parameter indices are somehow known and put into an array, idx, and that
you are working with one spectrum index, h.

   save_par( "final.par" ); % to preserve a copy.

   () = eval_counts;
   plot_data_counts( h );

   v = get_par( idx );

   for( i=0; i<length(idx); i++)
   {
     set_par( idx, 0, 1, 0, 0 );   % set all norms to 0
     set_par( idx[i], v[i] );      % set one to it's best fit value
     () = eval_counts;             % eval the model counts
     oplot_model_counts( h );      % overplot the model.
   }  


If you wanted the spectrum in model space, then you would use something
like:

   (w1,w2) = linear_grid( 1.0, 40.0, 8192 ); % make a wavelength grid

   load_par( "final.par" );
   y = eval_fun( w1, w2 );
   hplot( w1, w2, y );

   v = get_par( idx );

   for( i=0; i<length(idx); i++)
   {
     set_par( idx, 0, 1, 0, 0 );   % set all norms to 0
     set_par( idx[i], v[i] );      % set one to it's best fit value
     ohplot( w1, w2, eval_fun( w1, w2 ) ) ; 
   }  


There are variations on the theme, of couse. 
You might want to get the model counts or model flux into arrays:

   model_counts = Array_Type[ length( idx ) ] ; 
   model_flux   = Array_Type[ length( idx ) ] ; 


   ...
   model_counts[i] = get_model_counts( h );
   model_flux[i]   = eval_fun( w1, w2 );
   ...
  
and then plot them later.


You can use "globbing" of paramters:

p = get_par( "*.norm" );

Or get_fun_components() to get all the model compoenent names (and then
use eval_fun2().


But the above should get you started.  Like Mike said, there is no
convenient built-in ISIS thing to do this because of the flexibility in
models, but for your own, you should be able to do something fairly
straightforward (it's the general case for *any* model which is hard).

(and I don't understand the rest of what Mike sent you...)

If you need more specific help, send an example par file, and details on
what is to be plotted.


-- Dave

David Huenemoerder  617-253-4283 (o); -253-8084 (f); http://space.mit.edu/home/dph
MIT Kavli Institute for Astrophysics and Space Research
One Hampshire Street, Room NE80-6065
Cambridge, MA  02139
[Admin. Asst.: Elaine Tirrell, 617-253-7480, egt_at_email.domain.hidden
----
You received this message because you are
subscribed to the isis-users list.
To unsubscribe, send a message to
isis-users-request_at_email.domain.hiddenwith the first line of the message as:
unsubscribe
Received on Fri Dec 07 2012 - 14:36:49 EST

This archive was generated by hypermail 2.2.0 : Wed Dec 26 2012 - 12:56:21 EST