pool = Pool(6)
output = pool.map(peak_velocity, izip(*posns))

pool.close()
pool.join()

for out in output:
    peakvels[out[1], out[2]] = out[0]

peakvels[peakvels == 0.0 * u.m / u.s] = np.NaN * u.m / u.s

peak_intens_name = "M33_14B-088_HI.clean.image.pbcov_gt_{}.ellip_mask.peakvels.fits".formt(pb_lim)
peakvels = peakvels.astype(np.float32)
# peakvels = spectral_peakintensity(subcube).astype(np.float32)
peakvels.header["BITPIX"] = -32
peakvels.write(fourteenB_HI_data_path(peak_intens_name, no_check=True),
               overwrite=True)


# Trying Gauss-Hermite fits. The basic outline of the lmfit code is from:
# http://research.endlessfernweh.com/curve-fitting/

gauss_herm_center = Projection(np.zeros(subcube.shape[1:]),
                               wcs=cube.wcs.celestial,
                               unit=cube.spectral_axis.unit)


def gaussfunc_gh(paramsin, x):

    try:
        amp = paramsin['amp'].value
        center = paramsin['center'].value