% Sept. 22, 2003
%
% Load the main package and example subroutines.  In ISIS, the first
% line could, and probably should, be replaced by: require("sitar");
%
   () = evalfile("sitar.sl");
   () = evalfile("fold_the_asm_examp.sl");

   variable ev, rb, pf, ef,id;

%%%%%%%%

% Set up to echo the most essential commands being run (but not all 
% the details of the commands to set up the plots).  

%%%%%%%%

   ev = sitar_readasm("xa_herx1_d1",,,1.1);

   message(" ");
   message("ev = sitar_readasm(\"xa_herx1_d1\",,,1.1);");
   message("plot(ev.time,ev.rate);");
   message(" ");


   asm_plot_range(700.,3480.,-12.,16.);
   asm_xyplot("Time (Mission Days)","ASM Rate (cps)","herx-1","_ev",
              ev.time,ev.rate,0,0,1);

%%%%%%%%

   rb = sitar_rebin_rate(ev.time,ev.rate,,7.); 

   message(" ");
   message("rb = sitar_rebin_rate(ev.time,ev.rate,,7.);");
   message("hplot(rb.bin_lo,rb.bin_hi,rb.rate);");
   message(" ");

   asm_plot_range(700.,3480.,-1.1,7.7);
   asm_xyhplot("Time (Mission Days)","ASM Rate (cps)","herx-1","_rb",
               rb.bin_lo,rb.bin_hi,rb.rate,,0,0,0,1);

%%%%%%%%
  
   pf = sitar_pfold_rate(ev.time,ev.rate,35.);

   message(" ");
   message("pf = sitar_pfold_rate(ev.time,ev.rate,35.);");
   message("hplot(pf.bin_lo,pf.bin_hi,pf.mean);");
   message(" ");

   asm_plot_range(-0.01,1.01,0.0,3.4);
   asm_xyhplot("35 Day Period Phase","Mean ASM Rate (cps)","herx-1","_pf",
               pf.bin_lo,pf.bin_hi,pf.mean,pf.sdm,1,0,0,1);

%%%%%%%%

   message(" ");
   message("ef = sitar_epfold_rate(ev.time,ev.rate,1.,100.,20,-500.);");

   ef = sitar_epfold_rate(ev.time,ev.rate,1.,100.,20,-500.);

   message("plot(ef.prd,ef.lstat);");
   message(" ");

   asm_plot_range(0.9,105.,-2.,390.);
   asm_xyplot("Trial Period","L Statistic","herx-1","_ef",
               ef.prd,ef.lstat,1,0,1);

%%%%%%%%
 





