pro lum_r,kepmag,ext,teff,ra,dec,lumr
; this routine estimates the luminosity (in solar units) of the stars in
; its input vectors, based on a distance estimate derived from the extinction
; ext and on the galactic latitude computed from ra (in decimal hours) and
; dec (in decimal degrees).

; constants
k=.001             ; mag extinction per pc in the galactic plane
hh=250.            ; scale height for dust in pc
erat=0.7           ; ratio of extinction in kepler filter to V (???)
vsun=4.82          ; solar V abs mag.
radian=180./!pi
tt=[3170.,3840.,4830.,5310.,5790.,6250.,7000.,8180.,9790.,15200.,20900.]
bc=[-2.73,-1.38,-.42,-.4,-.2,-.16,-.11,-.15,-.30,-1.46,-2.35]
vmk=[2.6,1.74,.98,.75,.65,.62,.45,.19,.01,-.14,-.21]

; make interpolated values of the BC and V-kepler color for actual teffs
bco=interpol(bc,tt,teff)
vmko=interpol(vmk,tt,teff)

; make galactic latitude, max allowed extinction
glactc,ra,dec,2000.,gl,gb,1
sinb=sin(gb/radian) 
exmax=k*hh/sinb
extc=(ext > 0.) < exmax
; arbitrary increase in extinction for ext>1, to compensate for no ext > 2
ss=where(extc gt 1.,nss)
exte=extc
if(nss gt 0) then exte(ss)=1.+(ext(ss)-1.)*2.

; make distance estimate, with lower bound
dd=(-hh/sinb)*alog(1.-exte*sinb/(k*hh) > .0001) > 100.

; absolute kepler magnitude
kpp=kepmag-extc*erat
kpp=kpp-5.*alog10(dd)+5.

; estimated V absolute mag, luminosity
vv=kpp+vmko
lumr=10.^(0.4*(vsun-vv-bco))

end