def speccen_header(header, lon=None, lat=None):
    """
    Turn a cube header into a spectrum header, retaining RA/Dec vals where possible
    (speccen is like flatten; spec-ify would be better but, specify?  nah)

    Assumes 3rd axis is velocity
    """
    newheader = header.copy()
    newheader.set('CRVAL1', header.get('CRVAL3'))
    newheader.set('CRPIX1', header.get('CRPIX3'))
    if 'CD1_1' in header:
        newheader.rename_keyword('CD1_1', 'OLDCD1_1')
    elif 'CDELT1' in header:
        newheader.rename_keyword('CDELT1', 'OLDCDEL1')
    if 'CD3_3' in header:
        newheader.set('CDELT1', header.get('CD3_3'))
    elif 'CDELT3' in header:
        newheader.set('CDELT1', header.get('CDELT3'))
    newheader.set('CTYPE1', 'VRAD')
    if header.get('CUNIT3'):
        newheader.set('CUNIT1', header.get('CUNIT3'))
    else:
        print('Assuming CUNIT3 is km/s in speccen_header')
        newheader.set('CUNIT1', 'km/s')
    newheader.set('CRPIX2', 1)
    newheader.set('CTYPE2', 'RA---TAN')
    newheader.set('CRPIX3', 1)
    newheader.set('CTYPE3', 'DEC--TAN')
    if lon is not None:
        newheader.set('CRVAL2', lon)
    if lat is not None:
        newheader.set('CRVAL3', lat)
    if 'CD2_2' in header:
        newheader.rename_keyword('CD2_2', 'OLDCD2_2')
    if 'CD3_3' in header:
        newheader.rename_keyword('CD3_3', 'OLDCD3_3')
    return newheader
