% Date: Aug. 19, 2011

%
% Save this and associated files as: 'glvary_examp.sl', 'sitar.sl'
%
% To run:   isis> .load glvary_examp  % and then you're finished!

% Load the main package:

require("sitar");

variable file="ps.evt.gz";   % Event file to read
variable t = fits_read_col(file,"TIME");

%  Chandra times are very big (e.g., 3.e8).  We start running into
%  roundoff issues if we try to keep the full times in there.  So,
%  subtract off the zero point for the calculations, then run the
%  Gregory & Loredo code.

variable gl = sitar_glvary (t-t[0]);

variable id = open_plot("glvary_examp.ps/vcps");
   resize(21,0.8); set_line_width(3); set_frame_line_width(3); charsize(1.1);
   xlabel("Time (sec)"); 
   ylabel("Rate");
   yrange(-0.001,0.0599);
   linestyle(4);
   plot(gl.tlc-gl.tlc[0],gl.rate-gl.erate);
   oplot(gl.tlc-gl.tlc[0],gl.rate+gl.erate,1);
   linestyle(1);
   oplot(gl.tlc-gl.tlc[0],gl.rate,1);
close_plot(id);
