Re: plotting model over data gaps

From: Michael Nowak <mnowak_at_email.domain.hidden>
Date: Sat, 19 Mar 2011 23:04:53 -0400
On Mar 15, 2011, at 11:45 AM, Rhaana Starling wrote:

> I would like to be able to overplot my model fit on the data and interpolate/extrapolate it during data gaps. I'm just using the standard plot routines from .isisrc_plots you provide on the website and simple models such as smc*phabs*bknpl (from xspec, and smc is one I wrote into s-lang myself).
> Is it possible to do this, and does the routine/command already exist?
> 
> Also, can the model be overplotted as a smooth continuous line, ie using the values of the centres of bins only and doing a kind of dot-to-dot, rather than the default whole-bin span which in my case looks like steps?

Hi Rhaana-

First off, if the plots you are talking about are flux corrected spectral plots, 
e.g. using my plot_unfold routine, go with Dan Dewey's advice of the other 
day:

%%%%%%%%%%%%%%%%%%%%%%%%%


 It is possible to evaluate the model spectrum on a user grid (independent
of arfs or rfms) and then plot it as you wish, see
isis> help eval_fun
 Because the model spectrum is in units of photons/s/cm^2/bin
it is easiest to overplot the model on data that have been
flux corrected.  Assuming you have data and model in index 1
and are using plot_unit("keV") here's an example:

Flux correct your data and plot it:

isis> flux_corr(1);
isis> plot_bin_density;
isis> plot_data_flux(1);  % Photons/s/cm^2/keV

Evaluate the model and plot it.  The grid is in Ang's
and since I'm assuming you are plotting in keV I have made liberal
use of the constant Const_hc :

isis> (lo, hi) = linear_grid (1,30,2000);
isis> y = eval_fun (lo, hi);
isis> oplot(Const_hc/((lo+hi)/2.0), y/(Const_hc/lo - Const_hc/hi), 3);

re-plot the data on top for clarity

isis> oplot_data_flux(1,1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Similar concepts apply if you are using the plot_unfold function.  The one 
issue here is that you *won't* see the model smeared by the detector 
response if you do it like the above.

If on the other hand, you were talking about detector space data plots, e.g., 
plot_counts or plot_data, I have updated my routines, and placed them on the 
ISIS vs. XSPEC website:

	http://space.mit.edu/home/mnowak/isis_vs_xspec/isisrc.tar.gz

I have added a plot option, gap, that changes the way models get plotted.

	plot_{data,counts,unfold}(1;gap={1});  

and you get the usual behavior - models don't plot through the data gaps, 
and are histograms.  If instead you do:

	plot_{data,counts,unfold}(1;gap={0});  

and then the model plots by bin centers, and happily (linearly) plots through 
gaps. It's not a perfect solution, but I actually had kind of wanted something 
like this for plotting models through radio data (where we just have widely 
separated bin centers usually).

There are a bunch of other tweaks in there, too, to the routines.  A few bug 
fixes.  And I've changed the way the no_reset behavior works.  As a 
graduation present to Manfred, it now works as a qualifier, not a global 
variable.  (This breaks some backwards compatibility, but such is life.)  If this 
part makes no sense to you, don't worry about it and ignore it.  Everything 
else works the same as before.

Also, thanks to some tweaks of Manfred to the write_plot routine, the plotting
routines no longer need to be invoked in their own namespace.  

If anyone finds any bugs, let me know.

-Mike



----
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 Sat Mar 19 2011 - 23:05:15 EDT

This archive was generated by hypermail 2.2.0 : Mon Mar 21 2011 - 08:49:47 EDT