spectrochempy.NDDataset.save_as
- NDDataset.save_as(filename: str = "", **kwargs: Any) -> pathlib.Path | None: """ Save the current NDDataset in SpectroChemPy format (.scp). Parameters ---------- filename : str The filename of the file where to save the current dataset. **kwargs Optional keyword parameters (see Other Parameters). Other Parameters ---------------- directory : str, optional If specified, the given `directory` and the `filename` will be appended. See Also -------- save : Save current dataset. write : Export current dataset to different format. Notes ----- Adapted from :class:`numpy.savez` . Examples -------- Read some data from an OMNIC file >>> nd = scp.read_omnic('wodger.spg') >>> assert nd.name == 'wodger' Write it in SpectroChemPy format (.scp) (return a `pathlib` object) >>> filename = nd.save_as('new_wodger') Check the existence of the scp file >>> assert filename.is_file() >>> assert filename.name == 'new_wodger.scp' Remove this file >>> filename.unlink() """ if filename: # we have a filename # by default it use the saved directory filename = pathclean(filename) if self.directory and self.directory != filename.parent: filename = self.directory / filename else: filename = self.directory # suffix must be specified which correspond to the type of the # object to save default_suffix = SCPY_SUFFIX[self._implements()] if filename is not None and not filename.is_dir()[source]
Save the current NDDataset in SpectroChemPy format (.scp).
- Parameters:
filename (str) – The filename of the file where to save the current dataset.
**kwargs – Optional keyword parameters (see Other Parameters).
- Other Parameters:
directory (str, optional) – If specified, the given
directory
and thefilename
will be appended.
Notes
Adapted from
numpy.savez
.Examples
Read some data from an OMNIC file
>>> nd = scp.read_omnic('wodger.spg') >>> assert nd.name == 'wodger'
Write it in SpectroChemPy format (.scp) (return a
pathlib
object)>>> filename = nd.save_as('new_wodger')
Check the existence of the scp file
>>> assert filename.is_file() >>> assert filename.name == 'new_wodger.scp'
Remove this file
>>> filename.unlink()