spectrochempy.read_spg

read_spg(*paths, **kwargs)[source]

Open a Thermo Nicolet file or a list of files with extension .spg.

Open Omnic file or a list of files with extension .spg and set data/metadata in the current dataset.

Parameters
  • *paths (str, pathlib.Path object, list of str, or list of pathlib.Path objects, optional) – The data source(s) can be specified by the name or a list of name for the file(s) to be loaded:

    e.g.,( file1, file2, …, **kwargs )

    If the list of filenames are enclosed into brackets:

    e.g., ( [ file1, file2, … ], **kwargs )

    The returned datasets are merged to form a single dataset, except if merge is set to False. If a source is not provided (i.e. no filename, nor content), a dialog box will be opened to select files.

  • **kwargs – Optional keyword parameters (see Other Parameters).

Returns

read_spg – The dataset or a list of dataset corresponding to a (set of) .spg file(s).

Other Parameters
  • directory (str, optional) – From where to read the specified filename. If not specified, read in the default datadir specified in SpectroChemPy Preferences.

  • merge (bool, optional) – Default value is False. If True, and several filenames have been provided as arguments, then a single dataset with merged (stacked along the first dimension) is returned (default=False).

  • sortbydate (bool, optional) – Sort multiple spectra by acquisition date (default=True).

  • description (str, optional) – A Custom description.

  • content (bytes object, optional) – Instead of passing a filename for further reading, a bytes content can be directly provided as bytes objects. The most convenient way is to use a dictionary. This feature is particularly useful for a GUI Dash application to handle drag and drop of files into a Browser. For examples on how to use this feature, one can look in the tests/tests_readers directory.

  • listdir (bool, optional) – If True and filename is None, all files present in the provided directory are returned (and merged if merge is True. It is assumed that all the files correspond to current reading protocol (default=True).

  • recursive (bool, optional) – Read also in subfolders. (default=False).

See also

read

Generic read method.

read_dir

Read a set of data from a directory.

read_omnnic

Read Omnic files.

read_spa

Read Omnic files *.spa.

read_srs

Read Omnic files *.srs.

read_opus

Read Bruker OPUS files.

read_topspin

Read TopSpin NMR files.

read_csv

Read *.csv.

read_matlab

Read MATLAB files *.mat.

read_zip

Read zipped group of files.

Notes

This method is an alias of read_omnic, except that the type of file is contrain to *.spg.

Examples

>>> scp.read_spg('irdata/nh4y-activation.spg')
NDDataset: [float64] a.u. (shape: (y:55, x:5549))