pro set_bpow, bpow_par, xs, ys

;+
; Name: pro set_bpow
;
; Usage: set_bpow, bpow_par [, xs, ys]
;
; from 3 points selected graphically below the break
; above the break, and below the break,
; return the standard broken power-law parameterization
; used in f_bpow:
;	APAR = [ a0, a1, a2, a3 ]
;	a0 - normalization at Epivot, normally 50 keV
;	a1 - negative power-law index, a1>0, at energies less than the break
;	a2 - break energy
;	a3 - negative power-law index for energies greater than the break
;
; routines called
;	point
;
; Inputs - XS, YS each arrays of three points chosen graphically
;
;	If XS or YS is undefined, then point is called to select the
;	three points.
; Outputs - Function returns the standard parameters for a broken power-law
;	  - See F_BPOW
;-

@function_com

if n_elements(xs) ne 3 or n_elements(ys) ne 3 then begin
	print,'Select the starting values for a broken power-law graphically'
	print,'Pick a point at an energy less than the break energy.'
	point,npoints=1, x1,y1
	print, x1,y1
	print,'Pick the break energy.'
	point,npoints=1, x2,y2
	print, x2,y2
	print,'Pick a point at an energy greater than the break energy.'
	point,npoints=1, x3,y3
	print, x3,y3
	xs = [x1,x2,x3]
	ys = [y1,y2,y3]
endif

a2 = xs(1)
a1 = alog( ys(0)/ys(1) ) / alog( a2/xs(0) )
a0 = ys(1) / (Epivot/xs(1))^a1
a3 = alog( ys(2)/ys(1) ) / alog( a2/xs(2) )

bpow_par = [a0,a1,a2,a3]
print, 'Bpow parameters are: '
print, bpow_par

end
