<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def filterdata(data, plinds, d, threshold, ignorestr):
 """ Iteratively filter bad times and set indices for later plotting """


    logger.info('Ignoring times from ignorestr {0}'.format(ignorestr))
    ignoret = parseignoret(ignorestr)

    thresh0 = d['sigma_image1']
    thresh1 = d['sigma_plot']

    plinds['cir'] = calcinds(data, thresh0, ignoret=ignoret) # positive cands
    plinds['cro'] = calcinds(data, -1*thresh0, ignoret=ignoret) # negative cands
    plinds['edg'] = calcinds(data, thresh1, ignoret=ignoret) # cands with png plots
    sortinds = sorted(set(plinds['cir'] + plinds['cro'] + plinds['edg']))
    logger.info('Selected {} ({} linked) points.'.format(len(sortinds), len(plinds['edg'])))
    
    logger.info('Estimated total on target time: {} s\n'.format(calcontime(
        data, inds=plinds['cir']+plinds['cro']+plinds['edg'])))
    
    # these must get get rescaled when cands are ignored
    data['zs'] = normprob(d, data['snrs'], inds=sortinds)   

    # print high 1s bin counts
    logger.info('Finding high 1-second bins with threshold {0}'.format(threshold))
    hight, highcount = findhight(data, ignoret=ignoret, threshold=threshold)
    if len(hight):
        logger.info('High times \t High counts:')
        for i in range(len(hight)):
              logger.info('{0}\t{1}'.format(hight[i], highcount[i]))
    else:
        logger.info('No high 1s bin counts.\n')

    # print high cands and their times
    biginds = np.argsort(data['abssnr'][sortinds])[-5:]    
    logger.info('Top 5 abs(snr) candidates and times:')
    for ind in biginds[::-1]:
        logger.info('{0} {1}'.format(data['snrs'][sortinds][ind], data['time'][sortinds][ind]))
    logger.info('\n')