import glob


def summfile(ifldpth,idx):
    """ Find _x1dsum file ending with idx + '_x1dsum.fits'

    Parameters
    ----------
    ifldpth : str
       path to the files
    idx : str
      the file ends with idx + '_x1dsum.fits'
      e.g. idx = '10'

    Returns
    -------
      fname : str
        sum file name

    """

    fname = glob.glob(ifldpth+'*'+idx+'_x1dsum.fits')
    if len(fname) != 1:
        print('multiple or zero '+idx+'_x1dsum files: ', len(fname))
        print(ifldpth)
    else:
        fname = fname[0]
    return fname