Esempio n. 1
0
def load_mib(filename, scan_size, sum_length=10):
    """Load a medipix hdr/mib file.

    Parameters
    ----------
    filename : string
        File path and name to .hdr file.
    scan_size : int
        Scan size in pixels, allows the function to reshape the array into
        the right shape.
    sum_length : int
        Number of lines to sum over to determine scan fly back location.

    """
    dpt = load_with_reader(filename=filename, reader=mib_reader)
    dpt = ElectronDiffraction(
        dpt.data.reshape((scan_size, scan_size, 256, 256)))
    trace = dpt.inav[:, 0:sum_length].sum((1, 2, 3))
    edge = np.where(trace == max(trace.data))[0][0]
    if edge == scan_size - 1:
        dp = ElectronDiffraction(dpt.inav[0:edge, 1:])
    else:
        dp = ElectronDiffraction(
            np.concatenate((dpt.inav[edge + 1:, 1:], dpt.inav[0:edge, 1:]),
                           axis=1))

    return dp
Esempio n. 2
0
def _load_fpd_sum_im(filename):
    s = load_with_reader(filename,
                         reader=emd,
                         dataset_name="/fpd_expt/fpd_sum_im")
    if len(s.axes_manager.shape) == 3:
        s = s.isig[0, :, :]
    return s
Esempio n. 3
0
def _load_fpd_emd_file(filename, lazy=False):
    s = load_with_reader(filename,
                         reader=emd,
                         lazy=lazy,
                         dataset_name="/fpd_expt/fpd_data")
    if len(s.axes_manager.shape) == 5:
        s = s.isig[:, :, 0, :, :]
    s = s.transpose(signal_axes=(0, 1))
    s._lazy = lazy
    s_new = signal_to_pixelated_stem(s)
    return s_new
Esempio n. 4
0
def load_single_file(filename, signal_type=None, **kwds):
    """
    Load any supported file into an HyperSpy structure
    Supported formats: netCDF, msa, Gatan dm3, Ripple (rpl+raw),
    Bruker bcf, FEI ser and emi, EDAX spc and spd, hspy (HDF5), and SEMPER unf.

    Parameters
    ----------

    filename : string
        File name (including the extension)

    """
    extension = os.path.splitext(filename)[1][1:]

    i = 0
    while extension.lower() not in io_plugins[i].file_extensions and \
            i < len(io_plugins) - 1:
        i += 1
    if i == len(io_plugins):
        # Try to load it with the python imaging library
        try:
            from hyperspy.io_plugins import image
            reader = image
            return load_with_reader(filename,
                                    reader,
                                    signal_type=signal_type,
                                    **kwds)
        except BaseException:
            raise IOError('If the file format is supported'
                          ' please report this error')
    else:
        reader = io_plugins[i]
        return load_with_reader(filename=filename,
                                reader=reader,
                                signal_type=signal_type,
                                **kwds)
Esempio n. 5
0
def load_mib(filename, scan_size):
    """
    Load medipix file.
    Paramters:
        filename : string
            File path and name
        scan_size : int
            Scan size in pixels, allows the function to reshape the array into
            the right shape.

    """
    dpt = load_with_reader(filename=filename, reader=mib_reader)
    dpt = ElectronDiffraction(dpt.data.reshape((scan_size, scan_size, 256, 256)))
    trace = dpt.inav[:,0:5].sum((1,2,3))
    edge = np.where(trace==max(trace.data))[0][0]
    if edge==scan_size - 1:
        dp = ElectronDiffraction(dpt.inav[0:edge, 1:])
    else:
        dp = ElectronDiffraction(np.concatenate((dpt.inav[edge + 1:, 1:], dpt.inav[0:edge, 1:]), axis=1))

    return dp