Fast Bayesian Semiparametric Curve-Fitting and Clustering in Massive Data With Application to Cosmology