docs: def split(config,dirname='split',force=False):
      """ Take a pre-existing maglim map and divide it into
      chunks consistent with the catalog pixels. """
  
      config = Config(config)
      filenames = config.getFilenames()
      #healpix = filenames['pix'].compressed()
  
      # Check that things are ok
      basedir,basename = os.path.split(config['mask']['dirname'])
      #if basename == dirname:
      #    msg = "Input and output directory are the same."
      #    raise Exception(msg)
      outdir = mkdir(os.path.join(basedir,dirname))
      
      nside_catalog = config['coords']['nside_catalog']
      nside_pixel = config['coords']['nside_pixel']
  
      release = config['data']['release'].lower()
      band1 = config['catalog']['mag_1_band']
      band2 = config['catalog']['mag_2_band']
  
      # Read the magnitude limits
      maglimdir = config['maglim']['dirname']
  
      maglimfile_1 = join(maglimdir,config['maglim']['filename_1'])
      logger.info("Reading %s..."%maglimfile_1)
      maglim1 = read_map(maglimfile_1)
      
      maglimfile_2 = join(maglimdir,config['maglim']['filename_2'])
      logger.info("Reading %s..."%maglimfile_2)
      maglim2 = read_map(maglimfile_2)
  
      # Read the footprint
      footfile = config['data']['footprint']
      logger.info("Reading %s..."%footfile)
      footprint = read_map(footfile)
  
      # Output mask names
      mask1 = os.path.basename(config['mask']['basename_1'])
      mask2 = os.path.basename(config['mask']['basename_2'])
  
      for band,maglim,base in [(band1,maglim1,mask1),(band2,maglim2,mask2)]:
          nside_maglim = hp.npix2nside(len(maglim))
          if nside_maglim != nside_pixel:
              msg = "Mask nside different from pixel nside"
              logger.warning(msg)
              #raise Exception(msg)
  
          pixels = np.nonzero(maglim>0)[0]
          superpix = superpixel(pixels,nside_maglim,nside_catalog)
          healpix = np.unique(superpix)
          for hpx in healpix:
              outfile = join(outdir,base)%hpx
              if os.path.exists(outfile) and not force:
                  logger.warning("Found %s; skipping..."%outfile)
                  continue
  
              pix = pixels[superpix == hpx]
              print(hpx, len(pix))
  
              logger.info('Writing %s...'%outfile)
              data = odict()
              data['PIXEL']=pix
              data['MAGLIM']=maglim[pix].astype('f4')
              data['FRACDET']=footprint[pix].astype('f4')
              ugali.utils.healpix.write_partial_map(outfile,data,nside_pixel)