Viewing contents of file '../idllib/ghrs/pro/bbdraw.pro'
;************************************************************************
;+
;*NAME:
;   	BBDRAW     6-JAN-83
;  
;*PURPOSE:
;   	Draw blackbody curves over data through a given point.
;  
;*CALLING SEQUENCE:
;   	BBDRAW,WAVE,FLUX,WPICK,TEMP,DILUTION,WBB,FBB
;  
;*PARAMETERS:
;
;   	WAVE		(REQ) (I) (1) (I L F D)
;			Wavelength scale.
;
;   	FLUX		(REQ) (I) (1) (I L F D)
;			Flux to be fit.
;
;   	WPICK		(REQ) (O) (0) (F)
;			Wavelength of the point through which the blackbody curve
;               	is forced to pass.
;
;   	TEMP		(REQ) (O) (0) (F)
;			Blackbody temperature last chosen by user.
;
;   	DILUTION	(REQ) (O) (0) (F)
;			Dilution factor at point chosen by user for blackbody 
;			with temperature temp.
;	
;     	WBB		(REQ) (O) (1) (F)
;			Array of final blackbody wavelengths.
;
;    	FBB		(REQ) (O) (1) (F)
;			Array of final blackbody fluxes.
;  
;*INTERACTIVE INPUT:
;
;       User selects a point through which the blackbody curve must pass, 
;  	then user inputs guesses for temperature until he gets tired.
;  
;*SUBROUTINES CALLED:
;    	PLANCK
;  
;*RESTRICTIONS:  modified for sun idl version 1.1
;  
;*NOTES:
;    	Uses planck.pro to calculate the bb curves.
;  
;*MODIFICATION HISTORY:
;
;     	26-JAN-83 BY RJP= correction of a program by I. Ahmad based on a
;             	program by S. Heap
;     	6-21-85 RWT add WBB and FBB output parameters, use new IUEPLOT
;             	and remove unnecesssary compiles
;    	10-22-85 RWT DIDL change: use # for @
;      	5-6-87 RWT VAX mods: add PARCHECK, plot titles, and use 
;             	CURSOR for TEKDATA
;     	9-24-87 CAG corrected dilution factor to reflect IUE calibration
;             	wavelength scale units of per Angstrom instead of per cm
;             	(as given in Allen, Astrophysical Quantities). URP #275.
;    	10-12-87 RWT add procedure call listing
;       05-oct-89 jtb @gsfc modified for sun/unix idl
;       Mar 4 1991      JKF/ACC    - moved to GHRS DAF (IDL Version 2)
;-
;************************************************************************
pro bbdraw,wave,flux,wpick,temp,dilution,wbb,fbb
;
; initial setups
;
npar = n_params(0)
if npar eq 0 then begin
    print,' bbdraw,WAVE,FLUX,WPICK,TEMP,DILUTION,WBB,FBB
    retall & end
parcheck,npar,7,'bbdraw'
;
; make plot and give instructions for interative inputs
;
plot,wave,flux,xmargin=[30,4],ymargin=[4,4],ycharsize=.8,font=-1
;
hpos   = !d.x_ch_size
vspace = !d.y_ch_size * 1.1
vpos   = !d.y_vsize -vspace
xyouts,hpos,vpos,/device, $
       font=0,'Place cursor at point to fit and press any key.'
vpos   = vpos - vspace
xyouts,hpos,vpos,/device, $
       font=0,'Enter a temperature at the prompt (0 to quit).'
;
cursor,wpick,fpick,/data    ; accept input from cursor
flush = get_kbrd(0)                 ;flush type buffer
;
repeat begin ; guess temperature
  vpos = vpos - vspace
  xyreads,hpos,vpos,t,'bbtemp> ',/device
  t=float(t)
  if t gt 0 then begin  ; calculate and overplot the bb curve
    temp=t
    planck,temp,wpick,bbfpick ; bbfpick assumes per cm
    bbfpick=bbfpick*1e-8      ; convert to per angstrom to be compatible with
    dilution=fpick/bbfpick    ; iue
    planck,temp,wave,bbflux   ; now calculate for the input wavelength grid
    bbflux=bbflux*1e-8        ; make same conversion for output vector
    oplot,wave,dilution*bbflux
    end    ; calculate and overplot
  end until t le 0  ; guess temperature
wbb = wave
fbb = dilution * bbflux
; 
return                
end