erlab.io.utils¶
General-purpose I/O utilities.
Functions
|
Return file names in a directory with the given extension(s). |
|
Load data from an HDF5 file saved with |
|
Open data from an HDF5 file saved with |
|
Save data in |
|
Save data in |
|
Print raw metadata from a |
- erlab.io.utils.get_files(directory, extensions=None, contains=None, notcontains=None, exclude=None)[source]¶
Return file names in a directory with the given extension(s).
Directories are ignored.
- Parameters:
extensions (
Iterable[str] |str|None, default:None) – List of extensions to filter for. If not provided, all files are returned.contains (
str|None, default:None) – String to filter for in the file names.notcontains (
str|None, default:None) – String to filter out of the file names.exclude (
str|Iterable[str] |None, default:None) – Glob patterns to exclude from the search.
- Returns:
files (
setofpathlib.Path) – Set of file objects in the directory.- Return type:
- erlab.io.utils.load_hdf5(filename, **kwargs)[source]¶
Load data from an HDF5 file saved with
save_as_hdf5.This is a thin wrapper around
xarray.load_dataarrayandxarray.load_dataset.Deprecated since version 3.14.0: Use
xarray.load_dataarrayorxarray.load_datasetdirectly.- Parameters:
**kwargs – Extra arguments to
xarray.load_dataarrayorxarray.load_dataset.
- Returns:
xarray.DataArrayorxarray.Dataset– The loaded data.- Return type:
- erlab.io.utils.open_hdf5(filename, **kwargs)[source]¶
Open data from an HDF5 file saved with
save_as_hdf5.This is a thin wrapper around
xarray.open_dataarrayandxarray.open_dataset.Deprecated since version 3.14.0: Use
xarray.open_dataarrayorxarray.open_datasetdirectly.- Parameters:
**kwargs – Extra arguments to
xarray.open_dataarrayorxarray.open_dataset.
- Returns:
xarray.DataArrayorxarray.Dataset– The opened data.- Return type:
- erlab.io.utils.save_as_hdf5(data, filename, igor_compat=True, **kwargs)[source]¶
Save data in
HDF5format.Deprecated since version 3.14.0: Use
xarray.DataArray.to_netcdforxarray.Dataset.to_netcdfdirectly. To save data in a format compatible with Igor, useerlab.io.igor.save_wave().- Parameters:
data (
DataArray|Dataset) –xarray.DataArrayto save.igor_compat (
bool, default:True) – (Experimental) Make the resulting file compatible with Igor’sHDF5OpenFilefor DataArrays with up to 4 dimensions. A convenient Igor procedure is included in the repository. Default isTrue.**kwargs – Extra arguments to
xarray.DataArray.to_netcdf: refer to thexarraydocumentation for a list of all possible arguments.
- erlab.io.utils.save_as_netcdf(data, filename, **kwargs)[source]¶
Save data in
netCDF4format.Deprecated since version 3.14.0: Use
xarray.DataArray.to_netcdforxarray.Dataset.to_netcdfdirectly.Discards invalid
netCDF4attributes and produces a warning.- Parameters:
data (
DataArray) –xarray.DataArrayto save.**kwargs – Extra arguments to
xarray.DataArray.to_netcdf: refer to thexarraydocumentation for a list of all possible arguments.