예제 #1
0
def read_aps_13bm(fname, format, proj=None, sino=None):
    """
    Read APS 13-BM standard data format. Searches directory for all necessary
    files, and then combines the separate flat fields.

    Parameters
    ----------
    fname : str
        Path to hdf5 file.

    format : str
        Data format. 'spe' or 'netcdf4'

    proj : {sequence, int}, optional
        Specify projections to read. (start, end, step)

    sino : {sequence, int}, optional
        Specify sinograms to read. (start, end, step)

    Returns
    -------
    ndarray
        3D tomographic data.
    """
    if format == 'spe':
        tomo = dxreader.read_spe(fname, slc=(None, sino))
    elif format == 'netcdf4':
        files = glob.glob(fname[0:-5] + '*[1-3].nc')
        tomo = dxreader.read_netcdf4(files[1], 'array_data', slc=(proj, sino))

        flat1 = dxreader.read_netcdf4(files[0], 'array_data', slc=(proj, sino))
        flat2 = dxreader.read_netcdf4(files[2], 'array_data', slc=(proj, sino))
        flat = np.concatenate((flat1, flat2), axis=0)
        del flat1, flat2

        setup = glob.glob(fname[0:-5] + '*.setup')
        setup = open(setup[0], 'r')
        setup_data = setup.readlines()
        result = {}
        for line in setup_data:
            words = line[:-1].split(':', 1)
            result[words[0].lower()] = words[1]

        dark = float(result['dark_current'])
        dark = flat * 0 + dark

        theta = np.linspace(0.0, np.pi, tomo.shape[0])

    return tomo, flat, dark, theta
예제 #2
0
def read_aps_13bm(fname, format, proj=None, sino=None):
    """
    Read APS 13-BM standard data format.

    Parameters
    ----------
    fname : str
        Path to hdf5 file.

    format : str
        Data format. 'spe' or 'netcdf4'

    proj : {sequence, int}, optional
        Specify projections to read. (start, end, step)

    sino : {sequence, int}, optional
        Specify sinograms to read. (start, end, step)

    Returns
    -------
    ndarray
        3D tomographic data.
    """
    if format == 'spe':
        tomo = dxreader.read_spe(fname, slc=(None, sino))
    elif format == 'netcdf4':
        tomo = dxreader.read_netcdf4(fname, 'array_data', slc=(proj, sino))
    return tomo