%; Time-stamp: <2002-02-27 11:48:41 dph> 
%; MIT Directory: ~dph/libisis
%; File: splot_data.sl
%; Author: D. Huenemoerder
%; Original version: 2001.10.26
%;====================================================================
% version: 0.1
%
% purpose: smooth histogram via convolution w/ gaussian before plotting.
%
%

require("gsmooth");
provide("splot_data_counts");
provide("osplot_data_counts");
provide("splot_data_flux");
provide("osplot_data_flux");

provide("splot_model_counts");
provide("osplot_model_counts");
provide("splot_model_flux");
provide("osplot_model_flux");

provide("shplot");
provide("oshplot");



define splot_data_counts( )
{
  variable color = 1 ;

  if ( (_NARGS < 2) or (_NARGS > 3) )
    usage("USAGE: splot_data_counts( hist, sigma[, color]);");

  if (_NARGS == 3)
    color = ();

  variable sigma = ();
  variable hist  = ();  

  variable v = get_data_counts(hist);
  variable sv = gsmooth(v.bin_lo, v.bin_hi, v.value, sigma);

  hplot(v.bin_lo, v.bin_hi, sv, color);
}

define osplot_data_counts( )
{
  variable color = 1 ;

  if ( (_NARGS < 2) or (_NARGS > 3) )
    usage("USAGE: osplot_data_counts( hist, sigma[, color]);");

  if (_NARGS == 3)
    color = ();

  variable sigma = ();
  variable hist  = ();  

  variable v = get_data_counts(hist);
  variable sv = gsmooth(v.bin_lo, v.bin_hi, v.value, sigma);

  ohplot(v.bin_lo, v.bin_hi, sv, color);
}

define splot_data_flux( )
{
  variable color = 1 ;

  if ( (_NARGS < 2) or (_NARGS > 3) )
    usage("USAGE: splot_data_flux( hist, sigma[, color]);");

  if (_NARGS == 3)
    color = ();

  variable sigma = ();
  variable hist  = ();  

  variable v = get_data_flux(hist);
  variable sv = gsmooth(v.bin_lo, v.bin_hi, v.value, sigma);

  hplot(v.bin_lo, v.bin_hi, sv, color);
}

define osplot_data_flux( )
{
  variable color = 1 ;

  if ( (_NARGS < 2) or (_NARGS > 3) )
    usage("USAGE: osplot_data_flux( hist, sigma[, color]);");

  if (_NARGS == 3)
    color = ();

  variable sigma = ();
  variable hist  = ();  

  variable v = get_data_flux(hist);
  variable sv = gsmooth(v.bin_lo, v.bin_hi, v.value, sigma);

  ohplot(v.bin_lo, v.bin_hi, sv, color);
}


define splot_model_counts( )
{
  variable color = 1 ;

  if ( (_NARGS < 2) or (_NARGS > 3) )
    usage("USAGE: splot_model_counts( hist, sigma[, color]);");

  if (_NARGS == 3)
    color = ();

  variable sigma = ();
  variable hist  = ();  

  variable v = get_model_counts(hist);
  variable sv = gsmooth(v.bin_lo, v.bin_hi, v.value, sigma);

  hplot(v.bin_lo, v.bin_hi, sv, color);
}

define osplot_model_counts( )
{
  variable color = 1 ;

  if ( (_NARGS < 2) or (_NARGS > 3) )
    usage("USAGE: osplot_model_counts( hist, sigma[, color]);");

  if (_NARGS == 3)
    color = ();

  variable sigma = ();
  variable hist  = ();  

  variable v = get_model_counts(hist);
  variable sv = gsmooth(v.bin_lo, v.bin_hi, v.value, sigma);

  ohplot(v.bin_lo, v.bin_hi, sv, color);
}

define splot_model_flux( )
{
  variable color = 1 ;

  if ( (_NARGS < 2) or (_NARGS > 3) )
    usage("USAGE: splot_model_flux( hist, sigma[, color]);");

  if (_NARGS == 3)
    color = ();

  variable sigma = ();
  variable hist  = ();  

  variable v = get_model_flux(hist);
  variable sv = gsmooth(v.bin_lo, v.bin_hi, v.value, sigma);

  hplot(v.bin_lo, v.bin_hi, sv, color);
}

define osplot_model_flux( )
{
  variable color = 1 ;

  if ( (_NARGS < 2) or (_NARGS > 3) )
    usage("USAGE: osplot_model_flux( hist, sigma[, color]);");

  if (_NARGS == 3)
    color = ();

  variable sigma = ();
  variable hist  = ();  

  variable v = get_model_flux(hist);
  variable sv = gsmooth(v.bin_lo, v.bin_hi, v.value, sigma);

  ohplot(v.bin_lo, v.bin_hi, sv, color);
}
  
    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
define shplot( )  
{
  variable color = 1;

  if ( (_NARGS < 4) or (_NARGS > 6) )
    usage("USAGE: shplot( xlo, xhi, y, sigma[, color]);");

  if (_NARGS == 5)    color = ();

  variable sigma = ();
  variable v = ();
  variable xhi  = ();  
  variable xlo  = ();  

  hplot( xlo, xhi, gsmooth(xlo, xhi, v, sigma), color);
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
define oshplot( )  
{
  variable color = 1;

  if ( (_NARGS < 4) or (_NARGS > 6) )
    usage("USAGE: oshplot( xlo, xhi, y, sigma[, color]);");

  if (_NARGS == 5)    color = ();

  variable sigma = ();
  variable v = ();
  variable xhi  = ();  
  variable xlo  = ();  

  ohplot( xlo, xhi, gsmooth(xlo, xhi, v, sigma), color);
}
%%%%%%%%%%%%%%%%%%%%
