def load_data(path, fmt=None, bg_data=None, bg_fmt=None,<EOL>meta_data={}, holo_kw={}, as_type="<STR_LIT>"):
path = pathlib.Path(path).resolve()<EOL>for kk in meta_data:<EOL><INDENT>if kk not in qpimage.meta.DATA_KEYS:<EOL><INDENT>msg = "<STR_LIT>".format(kk)<EOL>raise ValueError(msg)<EOL><DEDENT><DEDENT>for kk in list(meta_data.keys()):<EOL><INDENT>if meta_data[kk] in [np.nan, None]:<EOL><INDENT>meta_data.pop(kk)<EOL><DEDENT><DEDENT>if fmt is None:<EOL><INDENT>fmt = guess_format(path)<EOL><DEDENT>else:<EOL><INDENT>if not formats_dict[fmt].verify(path):<EOL><INDENT>msg = "<STR_LIT>".format(fmt, path)<EOL>raise WrongFileFormatError(msg)<EOL><DEDENT><DEDENT>dataobj = formats_dict[fmt](path=path,<EOL>meta_data=meta_data,<EOL>holo_kw=holo_kw,<EOL>as_type=as_type)<EOL>if bg_data is not None:<EOL><INDENT>if isinstance(bg_data, qpimage.QPImage):<EOL><INDENT>dataobj.set_bg(bg_data)<EOL><DEDENT>else:<EOL><INDENT>bg_path = pathlib.Path(bg_data).resolve()<EOL>if bg_fmt is None:<EOL><INDENT>bg_fmt = guess_format(bg_path)<EOL>bgobj = formats_dict[bg_fmt](path=bg_path,<EOL>meta_data=meta_data,<EOL>holo_kw=holo_kw,<EOL>as_type=as_type)<EOL>dataobj.set_bg(bgobj)<EOL><DEDENT><DEDENT><DEDENT>return dataobj<EOL>
Load experimental data

    Parameters
    ----------
    path: str
        Path to experimental data file or folder
    fmt: str
        The file format to use (see `file_formats.formats`).
        If set to `None`, the file format is guessed.
    bg_data: str
        Path to background data file or `qpimage.QPImage`
    bg_fmt: str
        The file format to use (see `file_formats.formats`)
        for the background. If set to `None`, the file format
        is be guessed.
    meta_data: dict
        Meta data (see `qpimage.meta.DATA_KEYS`)
    as_type: str
        Defines the data type that the input data is casted to.
        The default is "float32" which saves memory. If high
        numerical accuracy is required (does not apply for a
        simple 2D phase analysis), set this to double precision
        ("float64").

    Returns
    -------
    dataobj: SeriesData or SingleData
        Object that gives lazy access to the experimental data.