% Aug. 18, 2011
%
% Load the main package.

   require("sitar");

   variable ev, rb, pf, ef,id;

%  Read the ASM lightcurve

   ev = sitar_readasm("xa_herx1_d1.lc";maxchi2=1.1);

   xrange(700.,3480.); xlabel("Time (Mission Days)");
   yrange(-12.,16.);   ylabel("ASM Rate (cps)"); 
   title ("HERX-1");
   plot(ev.time,ev.rate);

% Rebin the ASM lightcurve
 
   rb = sitar_rebin_rate(ev.time,7.,ev.rate); 
   yrange();
   hplot(rb.bin_lo,rb.bin_hi,rb.rate);

% Fold the Her X-1 data on a 35 day period
  
   pf = sitar_pfold_rate(ev.time,ev.rate,35.);
   xrange(-0.01,1.01); xlabel("35 Day Period Phase");
   yrange(0,3.4);      ylabel("Mean ASM Rate (cps)");
   linestyle(4);
   hplot(pf.bin_lo,pf.bin_hi,pf.mean-pf.sdm,1);
   ohplot(pf.bin_lo,pf.bin_hi,pf.mean+pf.sdm,1);
   linestyle(1);
   ohplot(pf.bin_lo,pf.bin_hi,pf.mean,1);

% Epoch fold the Her X-1 data

   ef = sitar_epfold_rate(ev.time,ev.rate,1.,100.; nphs=20,nsrch=500,loggrid);

   xrange(0.9,105); xlabel("Trial Period");
   yrange(-2,390);  ylabel("L Statistic");
   plot(ef.prds,ef.lstat);

%%%%%%%%
 





