pro prob_z,logzn,lprobz
; This routine accepts a vector logzn(npt) containing values of log(Z)
; (relative to solar abundance), and returns lprobz(npt), containing the
; ln of the unnormalized probability that a star has this logz, per unit logz.
; Method is evaluation of a polynomial with linear extension to extreme
; values of logz.  The polynomial was derived from a simple fit to a histogram
; of abundance values from Nordstrom et al. 2001, obtained through Vizier
; and read with the routine rd_nord.pro.

; constants
cc=[6.79395,-3.50625,-14.5389,-4.41683,6.50095,4.97298,0.886019,-0.125414,$
    -0.0377715]
zmin=-3.
slmin=3.
zmax=0.9
slmax=-20.
lp0=-3.8

; get sizes
npt=n_elements(logzn)
lprobz=fltarr(npt)

s=where(logzn ge zmin and logzn le zmax,ns)
if(ns gt 0) then lprobz(s)=poly(logzn(s),cc)

s=where(logzn lt zmin,ns)
if(ns gt 0) then lprobz(s)=lp0+(logzn(s)-zmin)*slmin

s=where(logzn gt zmax,ns)
if(ns gt 0) then lprobz(s)=lp0+(logzn(s)-zmax)*slmax

end