Use sdmpy to get all scans and info needed for rtpipe as dict

def read_scans(sdmfile, bdfdir=''):
    """ Use sdmpy to get all scans and info needed for rtpipe as dict """

    sdm = getsdm(sdmfile, bdfdir=bdfdir)
    scandict = {}
    skippedscans = []

    for scan in sdm.scans():
        scannum = int(scan.idx)
        scandict[scannum] = {}

        intentstr = ' '.join(scan.intents)
        src = scan.source

        scandict[scannum]['source'] = src
        scandict[scannum]['intent'] = intentstr

        # bdf specific properties
        try:
            startmjd = scan.bdf.startTime
            nints = scan.bdf.numIntegration
            interval = scan.bdf.get_integration(0).interval
            endmjd = startmjd + (nints*interval)/(24*3600)
            bdfstr = scan.bdf.fname
        except AttributeError, IOError:
            skippedscans.append(scannum)
        else:
            scandict[scannum]['startmjd'] = startmjd
            scandict[scannum]['endmjd'] = endmjd
            scandict[scannum]['duration'] = endmjd-startmjd
            scandict[scannum]['nints'] = nints
            scandict[scannum]['bdfstr'] = bdfstr

            # clear reference to nonexistent BDFs (either bad or not in standard locations)
            if (not os.path.exists(scandict[scannum]['bdfstr'])) or ('X1' in bdfstr):
                scandict[scannum]['bdfstr'] = None
                logger.debug('Invalid bdf for %d of %s' % (scannum, sdmfile) )

    if skippedscans:
        logger.warn('No BDF found for scans {0}'.format(skippedscans))

    return scandict