initial commit: code ported from astroML