Uses sdmpy to read a given range of integrations from sdm of given scan.

    readints=0 will read all of bdf (skipping nskip).

def read_bdf(sdmfile, scannum, nskip=0, readints=0, bdfdir=''):
    """ Uses sdmpy to read a given range of integrations from sdm of given scan.

    readints=0 will read all of bdf (skipping nskip).
    """

    assert os.path.exists(sdmfile), 'sdmfile %s does not exist' % sdmfile

    sdm = getsdm(sdmfile, bdfdir=bdfdir)
    scan = sdm.scan(scannum)
    assert scan.bdf.fname, 'bdfstr not defined for scan %d' % scannum

    if readints == 0:
        readints = scan.bdf.numIntegration - nskip

    logger.info('Reading %d ints starting at int %d' % (readints, nskip))
    npols = len(sdmpy.scan.sdmarray(sdm['Polarization'][0].corrType))
    data = np.empty( (readints, scan.bdf.numBaseline, sum(scan.numchans), npols), dtype='complex64', order='C')
    data[:] = scan.bdf.get_data(trange=[nskip, nskip+readints]).reshape(data.shape)

    return data