______________________________________________________________________

			      PD


	     PDCAL is a module which constructs the H&D curve for a
	photographic plate scanned with the PDS. NOTE-- AT PRESENT THE
	ROUTINE ASSUMES THAT THE MAX PDS OUTPUT VALUE IS 4096 AND THE
	output is in integers. The curve may be fit using splines, 1-7 
	order curves, or (when the routine is found) a deVauc fit.
	The calibration array ( *.CAL ) is a set of 4096 values
	where  J (a PDS integer number) --> val(J) (the logInt or Int
	value from the H and D curve).

	The type of file used to read in the spot relative intensities
	(instead of typing them in) is at the end of this description.

_______________________________________________________________________

 TYPE OPTIE                              28-JUN-1981 22:42:14.78
 >>>PD 
 OPTION PD
 IS THE INPUT IN REL INTEN vs.TRANS ? (NO = DEN,LOG I)
 TRANS=N		-------------	Can fit inten vs. trans
				this works better for lite plates.

 ARE SPOT AVERAGES ON DISK ? (IN REDSPOT FORM)
 DISK=N
			-------------    You can save the averaged
			-------------	spots on disk for another
			-------------	go round later.

 GIVE A NAME TO THE OUTPUT SPOT ARRAY (20CH)   --- (save the avgs)
 NAME=BAVG
 OPEN INPUT (PDS SPOTS) FILE
 TYPE FILENAME (<CR> FOR DEFAULT)
 FILI=BSPOT			-----------	Assumes it is *.SAD
 There are   8 maps in the file       
 Reading from the file
   40 rows of   40 pixels in R4 format
 TYPE NUMB SPOTS TO BE CALIBRATED (DEF = 12)
 NSPT=8
 TYPE SPOT MAP NO. IN ORDER OF INCR. INTEN
 MAPS=1:8
			-------------------	Can put in 2,1,5,4,8 etc
			-------------------	if they were measured 
			-------------------	that way

 TYPE CLEAR  MAP NOS IN SAME ORDER AS ABOVE (0=DEF)
 MAPC=0
			------------------	Either put in a "clear"
			------------------	map for each spot, ONE
			------------------	clear map for the whole
			------------------	batch, or NONE.
 TYPE NUMB OF FIRST SPOT (DEF=1)
 ISPST=1

			__________________	This is to match up
			------------------	the avg PDS values
			------------------	with the log Int
			------------------	values.

			-----------------	eg. If the first spot
			-----------------	MEASURED corresponds
			-----------------	to spot 2 in your inten
			-----------------	list - type "2".

 TYPE IN THE	DISK NAME WITH REL INTEN VALUES (DEF=TYPE IN DIRECT
 FILI=SPOTVAL
			------------------	See format of 
			-----------------	SPOTVAL.DAT below.
			-----------------	Values can be typed
			-----------------	in directly also -
			-----------------	Just hit RETURN here.

 DO YOU WANT TO SORT BY DENSITY  ?
			------	At this point, spotavg(i) has been 
			------	matched with spotint(i) but the order
			------	is the one given on the list of rel. int
			------	if this is NOT monatonically increasing
			------	in density - sort it. When sorted the
			------	PAIRING is preserved.
 SORT=Y
   DENSITY  LOG INTEN    STDEV 
      0.000     1.000     0.000	--------This is a "dummy" spot for
				-------- relitave intensity (1)

   1223.692     1.151   149.373

   1223.692     1.301   149.373

   1485.191     1.452   194.786

   1885.284     1.602   112.466

   2168.573     1.753   291.957

   3026.934     2.054   194.805

   3203.948     1.903   211.258

   3283.948     2.330   211.270





  WRITE SPOT AVERAGES TO DISK (UNIT 22) 
			------------	Named BAVG input above.

			_______	At this point the program rescales the
			------- relative intensities to a range that
			------- is easy to plot ( ITS all relative!)
			------- The PDS averages are converted to
			-------  "densities" ( div by 800).
	----------	NOTE THE "DUMMY" SPOT IS GONE 	------------

 LOOK AT THE VALUES ?
 LOOK=Y
 SPOT NO   REL INTENSITY     PDS VALUE          SIGMA          CLEAR
     1         1.32100         1.52962        0.186717        0.000000E+00
     2         1.47100         1.52962        0.186717        0.000000E+00
     3         1.62200         1.85649        0.243483        0.000000E+00
     4         1.77200         2.35661        0.140582        0.000000E+00
     5         1.92300         2.71072        0.364946        0.000000E+00
     6         2.22400         3.78367        0.243506        0.000000E+00
     7         2.07300         4.00493        0.264073        0.000000E+00
     8         2.50000         4.10493        0.264087        0.000000E+00
 TYPE PLOT DEVICE : 0=NONE   1=TEKT  2=FILE  3=RAMTEK
 NDEV=0				---------	Plotting is slow !
 SELECT OPTION
 	D	delete points
 	F	fit curve
 	Z	extrapolate lower end of curve
 	T	extrapolate top end of curve
 	P	plot the calibration
 	S	save the calibration curve
 	L       look at the points and fit
 	V	fit deVaucouleurs curve
   E	exit
  
 OPT=D
 TYPE NUMBERS OF POINTS TO BE DELETED
 DEL=1,7		--------	Points 1 and 7 were not nice.
 SELECT OPTION
 	D	delete points
 	F	fit curve
 	Z	extrapolate lower end of curve
 	T	extrapolate top end of curve
 	P	plot the calibration
 	S	save the calibration curve
 	L       look at the points and fit
 	V	fit deVaucouleurs curve
   E	exit
  
 OPT=F
 SELECT TYPE OF FIT
 	0	spline
  1 - 7    1st - 7th order
  
 FIT=3				-----------	Fit a cubic
 COEFFS 
    -0.76431          2.5144        -0.85522         0.10609    
 SIGMA    2.80141E-02
 SPOT NO.  PDS VAL  INT VAL  CAL VAL  DIF
     1       1.53     1.47     1.46    -0.01
     2       1.86     1.62     1.63     0.01
     3       2.36     1.77     1.80     0.03
     4       2.71     1.92     1.88    -0.04
     5       3.78     2.22     2.25     0.03
     6       4.10     2.50     2.48    -0.02
 SELECT OPTION
 	D	delete points
 	F	fit curve
 	Z	extrapolate lower end of curve
 	T	extrapolate top end of curve
 	P	plot the calibration
 	S	save the calibration curve
 	L       look at the points and fit
 	V	fit deVaucouleurs curve
   E	exit
  
 OPT=Z
		----------	To produce a nice curve you can
		----------	extrapolate at both the low den
		----------	or hi den end.
 ADD A ZERO (0,0) POINT? (INTEN vs. TRANS ONLY)
 ZERO=N
 DO YOU WANT TO EXTRAPOLATE AT THE LOW DENSITY END  ?
 LOW=Y
 SELECT KIND OF EXTRAPOLATION
 	1	linear
 	2	quadratic
  
 DEN=1
 HOW MANY POINTS TO FIT THE EXTRAPOLATION  ?
 NPTS=3
 GIVE THESE SPOT NUMBERS IN INCREASING ORDER
 SPOTS=1,2,3		-----------	Use these points to extrap.
 TYPE LOWEST DENSITY DESIRED (be reasonable!)
 MIN=1.0
		--------      There is now an extrapolated point at 1.0
 SELECT OPTION
 	D	delete points
 	F	fit curve
 	Z	extrapolate lower end of curve
 	T	extrapolate top end of curve
 	P	plot the calibration
 	S	save the calibration curve
 	L       look at the points and fit
 	V	fit deVaucouleurs curve
   E	exit
  
 OPT=L
 LOOK AT THE VALUES ?
 LOOK=Y
 SPOT NO   REL INTENSITY     PDS VALUE          SIGMA          CLEAR
     1         1.07290         1.00000        0.000000E+00    0.000000E+00
		^^--------	the extrapolated point
     2         1.47100         1.52962        0.186717        0.000000E+00
     3         1.62200         1.85649        0.243483        0.000000E+00
     4         1.77200         2.35661        0.140582        0.000000E+00
     5         1.92300         2.71072        0.364947        0.000000E+00
     6         2.22400         3.78367        0.243506        0.000000E+00
     7         2.50000         4.10494        0.264087        0.000000E+00
 AVCLEAR =     0.0000E+00
 TYPE PLOT DEVICE : 0=NONE   1=TEKT  2=FILE  3=RAMTEK
 NDEV=0
 SELECT OPTION
 	D	delete points
 	F	fit curve
 	Z	extrapolate lower end of curve
 	T	extrapolate top end of curve
 	P	plot the calibration
 	S	save the calibration curve
 	L       look at the points and fit
 	V	fit deVaucouleurs curve
   E	exit
  
 OPT=F
 SELECT TYPE OF FIT
 	0	spline
  1 - 7    1st - 7th order
  
 FIT=3
 COEFFS 
    -0.43253          2.1211        -0.70862         8.88377E-02
 SIGMA    2.64916E-02
 SPOT NO.  PDS VAL  INT VAL  CAL VAL  DIF
     1       1.00     1.07     1.07     0.00
     2       1.53     1.47     1.47     0.00
     3       1.86     1.62     1.63     0.01
     4       2.36     1.77     1.79     0.02
     5       2.71     1.92     1.88    -0.04
     6       3.78     2.22     2.26     0.04
     7       4.10     2.50     2.48    -0.02
 SELECT OPTION
 	D	delete points
 	F	fit curve
 	Z	extrapolate lower end of curve
 	T	extrapolate top end of curve
 	P	plot the calibration
 	S	save the calibration curve
 	L       look at the points and fit
 	V	fit deVaucouleurs curve
   E	exit
  
 OPT=D
 TYPE NUMBERS OF POINTS TO BE DELETED
 DEL=6
 COEFFS 
    -0.23796          1.8142        -0.56911         7.05744E-02
 SIGMA    1.65797E-02
 SPOT NO.  PDS VAL  INT VAL  CAL VAL  DIF
     1       1.00     1.07     1.08     0.00
     2       1.53     1.47     1.46    -0.01
     3       1.86     1.62     1.62     0.00
     4       2.36     1.77     1.80     0.03
     5       2.71     1.92     1.90    -0.02
     6       4.10     2.50     2.50     0.00
 SELECT OPTION
 	D	delete points
 	F	fit curve
 	Z	extrapolate lower end of curve
 	T	extrapolate top end of curve
 	P	plot the calibration
 	S	save the calibration curve
 	L       look at the points and fit
 	V	fit deVaucouleurs curve
   E	exit
  
 OPT=S
 			WARNING
 The calibration array may be unreliable above max PDS value
 IS THIS OK  ?
			-------	This comes up because the DEN do
			-------	not extend to 5.12
			-------	Extrapolate at the high den end
			-------	for a better fit.
 OK=Y
 SAVE THE CALIBRATION CURVE  ?
 SAVE=Y
 TYPE NAME OF OUTPUT CALIBRATION FILE (name is ...CAL)
 FILC=SPOT
 DO YOU WANT A HARD COPY PLOT  ?
 HARD=N

---------------------------------------------------------------

      *****	DATA FILE FOR RELATIVE INTENSITIES 	******
8		---------  First line = number of int values in file
		---------  Second line = blank
1 1.0		---------  Remaining lines = spot no.  rel int value
1 1.0		---------  (Either log or intensity units)
2 1.151
3 1.301
4 1.452
5 1.602
6 1.753
7 1.903
8 2.054