erlab.io.utilities

Functions

fix_attr_format(da)

Discards attributes that are incompatible with the netCDF4 file format.

get_files(directory[, extensions, contains, ...])

Return a list of files in a directory with the given extensions.

load_hdf5(filename, **kwargs)

Load data from an HDF5 file saved with save_as_hdf5.

open_hdf5(filename, **kwargs)

Open data from an HDF5 file saved with save_as_hdf5.

save_as_hdf5(data, filename[, igor_compat])

Save data in HDF5 format.

save_as_netcdf(data, filename, **kwargs)

Save data in netCDF4 format.

showfitsinfo(path)

Print raw metadata from a .fits file.

erlab.io.utilities.get_files(directory, extensions=None, contains=None, notcontains=None)[source]

Return a list of files in a directory with the given extensions.

Parameters:
  • directory – Target directory.

  • extensions (Sequence[str] | None) – List of extensions to filter for. If not provided, all files are returned.

  • contains (str | None) – String to filter for in the file names.

  • notcontains (str | None) – String to filter out of the file names.

Returns:

files – List of files in the directory.

Return type:

list of str

erlab.io.utilities.load_hdf5(filename, **kwargs)[source]

Load data from an HDF5 file saved with save_as_hdf5.

This is a thin wrapper around xarray.load_dataarray and xarray.load_dataset.

Parameters:
Returns:

The loaded data.

Return type:

xarray.DataArray or xarray.Dataset

erlab.io.utilities.open_hdf5(filename, **kwargs)[source]

Open data from an HDF5 file saved with save_as_hdf5.

This is a thin wrapper around xarray.open_dataarray and xarray.open_dataset.

Parameters:
Returns:

The opened data.

Return type:

xarray.DataArray or xarray.Dataset

erlab.io.utilities.save_as_hdf5(data, filename, igor_compat=True, **kwargs)[source]

Save data in HDF5 format.

Parameters:
erlab.io.utilities.save_as_netcdf(data, filename, **kwargs)[source]

Save data in netCDF4 format.

Discards invalid netCDF4 attributes and produces a warning.

Parameters:
erlab.io.utilities.showfitsinfo(path)[source]

Print raw metadata from a .fits file.

Parameters:

path (str | PathLike) – Local path to .fits file.