Work I did in:   /home/sco/tmp/samples/p3/S

Initial README 
-------------------------------------------------------------------------------
Here I grab some data from a table file, then setup plot and fit files:

  Make_XY                             # make initial data files
  clcf_line.sh X.dat Y.dat 40         # fit a line


Make a curve file (line)
  echo "line   b - 10 Fit" > xy_from_table.input
  xy_from_table clcf_line.fitcurve 1 2
  cat XY.plot > STYLE

View the plot:
pxy_SM_plot.py STYLE 0 360 -50 10 SHOW
-------------------------------------------------------------------------------

==================================================================
Then I made the script do it all:  
% cat Make_XY

#!/bin/bash 
colget.py ../hetAZindo_dec01.dat 2 X.dat N
printf "\nX data: "
calstats.py -v X.dat

colget.py ../hetAZindo_dec01.dat 6 Y.dat N
printf "\nY data: "
calstats.py -v Y.dat

printf "# data\n" > XY.table_data
paste X.dat Y.dat >>  XY.table_data

# make file for xyplotter
echo "Test daya" > list.axes
echo "0 360 X" >> list.axes
echo "-50 10 Y" >> list.axes
echo "XY.table_data 1 2    point  r o 10   Set1" >list.data

# run xyplotter 
xyplotter list.data list.axes  

# 
# printf "\nTo run fit:\n"
# printf "  clcf_line.sh X.dat Y.dat 40\n"
# printf "  echo \"line   b - 10 Fit\" > xy_from_table.input \n"
# printf "  xy_from_table  clcf_line.fitcurve 1 2 \n"
# printf "  echo \"XY.plot\" >> STYLE \n" 
# printf "  pxy_SM_plot.py STYLE 0 360 -50 10 SHOW \n"

clcf_line.sh X.dat Y.dat 40
echo "line   b - 10 Fit" > xy_from_table.input
xy_from_table  clcf_line.fitcurve 1 2
echo "XY.plot" >> STYLE 

printf "\nTo view fit:\n"
printf "  pxy_SM_plot.py STYLE 0 360 -50 10 SHOW \n"
==================================================================



Herer are more example where I start computing values from the 
fit results (in prep fro residuals). 
 

 Generate and fit a line 

To make line data: 
% cat c.line
0.0
1.00

% make_fit_data line c.line 8 1.0 10.0 0.3
% ls
c.line	make_fit_data.out

% mv make_fit_data.out line_1.table

----------------------------------------------------
I make the Axes.1 and List.1 files:
% cat Axes.1
Test data 
0 10 "X axis title"
-10 20 "Y-axis"  

% cat List.1
line_1.table  1  2    point   r o 30   Line_1 
----------------------------------------------------

To plot the data:
% xyplotter List.1 Axes.1
% pxy_SM_plot.py STYLE 0 10 -10 20 SHOW
**** Get a good plot of line data 

To fit the data:
% colget.py line_1.table 1 X.dat N
% colget.py line_1.table 2 Y.dat N
# Now we have our X,Y data files for fitting 

# we fit a line and generate a fitted curve of 40 points 
% clcf_line.sh X.dat Y.dat 40

% cat clcf_line.explain 
Line fit:     y = a0 + a1*x 
Coefficients and erros in clcf_line.out:
a0   err_a0 
a1   err_a1 
% cat clcf_line.out
     0.0282969       0.0500399
     1.2471875       0.0090982
# These are very close to our input values 

The fitted curve is in clcf_line.fitcurve. Since this is 
a table file, we can just add a line to "List.1" and get 
the fitted line into our plot. 
% cat List.1
line_1.table       1  2    point   r o 30   Line 1 
clcf_line.fitcurve  1 2    line    b - 30   Fit 1

% xyplotter List.1 Axes.1
% pxy_SM_plot.py STYLE 0 10 -10 20 SHOW
# Now I have data points and a fitted line. 

NEXT: I want to compute Y residuals (O-C) and statistics based 
      on these residuals. 

Remember:
  1) the fitted coefficients are in:   clcf_line.out
  2) The observed X values are in:     X.dat     (no header) 
 
**** I modified gen_curve so that it will generate the value from 
     a file of X values 

So I can do:
gen_curve.sh line clcf_line.out 30 file X.dat Y > AA     
**** This generates the values for my original X values in X.dat
     (what I would want for residuals) 

But I could generate values at any points:
 % cat X.any
2.0 
4.0 
6.0 
8.0 

% gen_curve.sh line clcf_line.out 30 file X.any Y > XY.any.3
% cat XY.any.3
# func = line        
# N terms =  2
       0.028296901
       1.247187495
# data
     2.00000      2.52267
     4.00000      5.01705
     6.00000      7.51142
     8.00000     10.00580

*** I just add a line in List.1 to use XY.any.3
% cat List.1
line_1.table       1  2    point      r o 30   Line 1 
clcf_line.fitcurve  1 2    line       b - 30   Fit 1
XY.any.3            1 2    pointopen   g h 70   AnyX

% xyplotter List.1 Axes.1
% pxy_SM_plot.py STYLE 0 10 -10 20 SHOW
**** This seems to work great!