def merge_likelihood_headers(filenames, outfile):
    """
    Merge header information from likelihood files.

    Parameters:
    -----------
    filenames : input filenames
    oufile    : the merged file to write
    
    Returns:
    --------
    data      : the data being written
    """

    filenames = np.atleast_1d(filenames)

    ext='PIX_DATA'
    nside = fitsio.read_header(filenames[0],ext=ext)['LKDNSIDE']
    
    keys=['STELLAR','NINSIDE','NANNULUS']
    data_dict = odict(PIXEL=[])
    for k in keys:
        data_dict[k] = []

    for i,filename in enumerate(filenames):
        logger.debug('(%i/%i) %s'%(i+1, len(filenames), filename))
        header = fitsio.read_header(filename,ext=ext)
        data_dict['PIXEL'].append(header['LKDPIX'])
        for key in keys:
            data_dict[key].append(header[key])

        del header
        
    data_dict['PIXEL'] = np.array(data_dict['PIXEL'],dtype=int)
    for key in keys:
        data_dict[key] = np.array(data_dict[key],dtype='f4')

    #import pdb; pdb.set_trace()
    write_partial_map(outfile, data_dict, nside)
    return data_dict
Merge header information from likelihood files.

    Parameters:
    -----------
    filenames : input filenames
    oufile    : the merged file to write
    
    Returns:
    --------
    data      : the data being written