spectrochempy.read_soc#

read_soc(*paths, **kwargs)[source]#

Read a Surface Optics Corp. file or a list of files with extension .ddr, .hdr or .sdr.

This is the explicit SOC reader in the public import API. Use spectrochempy.read for generic format autodetection and scp.soc.read(...) or spectrochempy.read_soc when the SOC format is already known.

SOC files use the same SPA-compatible binary layout as OMNIC .spa files, so this reader delegates parsing to the shared private SPA parser and records SOC provenance on the returned dataset(s).

Non-merged multi-file reads may return a list-like ScpObjectList exposing helper methods for dataset selection. See spectrochempy.read for the complete description of the generic import convention and multi-object return behavior.

Parameters:
  • *paths (str, Path object or valid urls, 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., ( filename1, filename2, …, kwargs )

    If the list of filenames are enclosed into brackets:

    • e.g., ( [filename1, filename2, …], kwargs )

    By default, SOC datasets are kept separate even when the filenames are passed as a list or tuple. Set merge=True to request merging of compatible datasets.

  • **kwargs (keyword parameters, optional) – See Other Parameters.

Returns:

NDDataset or ScpObjectList of NDDataset – The returned dataset(s). When several datasets are returned, the result is a list-like ScpObjectList with helper attributes such as .names, .select_largest(), .select_by_name(), .filter_by_ndim(), and .filter_by_shape().

Other Parameters:
  • 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 web application to handle drag and drop of files into a Browser.

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

  • directory (Path object or valid urls, optional) – From where to read the files.

  • download_only (bool, optional, default: False) – Used only when url are specified. If True, only downloading and saving of the files is performed, with no attempt to read their content.

  • merge (bool, optional, default: False) – If False (default), individual datasets are preserved and returned as a list. If True and several filenames have been provided with compatible dimensions, they are merged into a single NDDataset (stacked along the first dimension). When datasets have incompatible dimensions or origins, they may be grouped into multiple merged datasets.

  • origin (str, optional) – If provided it may be used to define the type of experiment: e.g., ‘ir’, ‘raman’,.. or the origin of the data, e.g., ‘omnic’, ‘opus’, … It is often provided by the reader automatically, but can be set manually.

    It is used when reading with the CSV protocol. In order to properly interpret CSV file it can be necessary to set the origin of the spectra. Up to now only 'omnic' and 'tga' have been implemented.

  • pattern (str, optional) – A pattern to filter the files to read.

    Added in version 0.7.2.

  • read_only (bool, optional, default: True) – Used only when url are specified. If True, saving of the files is performed in the current directory, or in the directory specified by the directory parameter.

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

  • replace_existing (bool, optional, default: False) – Used only when url are specified. By default, existing files are not replaced so not downloaded.

  • return_ifg (str or None, optional) – Default value is None. When set to ‘sample’ returns the sample interferogram of the spa file if present or None if absent. When set to ‘background’ returns the background interferogram of the spa file if present or None if absent.

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

See also

read

Generic read function.

Examples

Using the explicit namespace API

>>> scp.soc.read('irdata/soc/sample.hdr')

Using the top-level API

>>> scp.read_soc('irdata/soc/sample.hdr')