spectrochempy.load
- load(filename: str | pathlib.Path | BinaryIO, **kwargs: Any) -> Any: """ Open data from a '*.scp' (NDDataset) or '*.pscp' (Project) file. Parameters ---------- filename : `str`, `pathlib` or `file` objects The name of the file to read (or a file objects). **kwargs Optional keyword parameters (see Other Parameters). Other Parameters ---------------- content : str, optional The optional content of the file(s) to be loaded as a binary string. See Also -------- read : Import dataset from various orgines. save : Save the current dataset. Notes ----- Adapted from `numpy.load` . Examples -------- >>> nd1 = scp.read('irdata/nh4y-activation.spg') >>> f = nd1.save() >>> f.name 'nh4y-activation.scp' >>> nd2 = scp.load(f) Alternatively, this method can be called as a class method of NDDataset or Project object: >>> from spectrochempy import * >>> nd2 = NDDataset.load(f) """ content = kwargs.get("content") if content: fid = io.BytesIO(content) else: # be sure to convert filename to a pathlib object with the # default suffix filename = pathclean(filename) suffix = cls().suffix filename = filename.with_suffix(suffix) if kwargs.get("directory") is not None: filename = pathclean(kwargs.get("directory")) / filename if not filename.exists()[source]
Open data from a ‘.scp’ (NDDataset) or ‘.pscp’ (Project) file.
- Parameters:
- Other Parameters:
content (str, optional) – The optional content of the file(s) to be loaded as a binary string.
See also
read
Import dataset from various orgines.
save
Save the current dataset.
Notes
Adapted from
numpy.load
.Examples
>>> nd1 = scp.read('irdata/nh4y-activation.spg') >>> f = nd1.save() >>> f.name 'nh4y-activation.scp' >>> nd2 = scp.load(f)
Alternatively, this method can be called as a class method of NDDataset or Project object:
>>> from spectrochempy import * >>> nd2 = NDDataset.load(f)