Break catalog into chunks by healpix pixel.
    
    Parameters:
    -----------
    infiles : List of input files
    config  : Configuration file
    force   : Overwrite existing files (depricated)
    
    Returns:
    --------
    None

def pixelizeCatalog(infiles, config, force=False):
    """
    Break catalog into chunks by healpix pixel.
    
    Parameters:
    -----------
    infiles : List of input files
    config  : Configuration file
    force   : Overwrite existing files (depricated)
    
    Returns:
    --------
    None
    """
    nside_catalog = config['coords']['nside_catalog']
    nside_pixel = config['coords']['nside_pixel']
    coordsys = config['coords']['coordsys'].upper()
    outdir = mkdir(config['catalog']['dirname'])
    filenames = config.getFilenames()
    lon_field = config['catalog']['lon_field'].upper()
    lat_field = config['catalog']['lat_field'].upper()

    # ADW: It would probably be better (and more efficient) to do the
    # pixelizing and the new column insertion separately.
    for i,filename in enumerate(infiles):
        logger.info('(%i/%i) %s'%(i+1, len(infiles), filename))
        data = fitsio.read(filename)
        logger.info("%i objects found"%len(data))
        if not len(data): continue

        columns = map(str.upper,data.dtype.names)
        names,arrs = [],[]

        if (lon_field in columns) and (lat_field in columns):
            lon,lat = data[lon_field],data[lat_field]
        elif coordsys == 'GAL':
            msg = "Columns '%s' and '%s' not found."%(lon_field,lat_field)
            msg += "\nConverting from RA,DEC"
            logger.warning(msg)
            lon,lat = cel2gal(data['RA'],data['DEC'])
            names += [lon_field,lat_field]
            arrs  += [lon,lat]
        elif coordsys == 'CEL':
            msg = "Columns '%s' and '%s' not found."%(lon_field,lat_field)
            msg += "\nConverting from GLON,GLAT"
            lon,lat = gal2cel(data['GLON'],data['GLAT'])
            names  += [lon_field,lat_field]
            arrs   += [lon,lat]

        cat_pix = ang2pix(nside_catalog,lon,lat)
        pix_pix = ang2pix(nside_pixel,lon,lat)
        cat_pix_name = 'PIX%i'%nside_catalog
        pix_pix_name = 'PIX%i'%nside_pixel

        try:
            names += [cat_pix_name,pix_pix_name]
            arrs  += [cat_pix,pix_pix]
            data=mlab.rec_append_fields(data,names=names,arrs=arrs)
        except ValueError as e:
            logger.warn(str(e)+'; not adding column.')
            #data[cat_pix_name] = cat_pix
            #data[pix_pix_name] = pix_pix
                               
        for pix in np.unique(cat_pix):
            logger.debug("Processing pixel %s"%pix)

            arr = data[cat_pix == pix]
            outfile = filenames.data['catalog'][pix]

            if not os.path.exists(outfile):
                logger.debug("Creating %s"%outfile)
                out=fitsio.FITS(outfile,mode='rw')
                out.write(arr)

                hdr=healpix.header_odict(nside=nside_catalog,
                                                     coord=coordsys[0])
                for key in ['PIXTYPE','ORDERING','NSIDE','COORDSYS']:
                    out[1].write_key(*list(hdr[key].values()))
                out[1].write_key('PIX',pix,comment='HEALPIX pixel for this file')
            else:
                out=fitsio.FITS(outfile,mode='rw')
                out[1].append(arr)

            logger.debug("Writing %s"%outfile)
            out.close()