fpipy.io

Functions for reading data from various formats.

Functions

read_ENVI_cfa(filepath[, raw_unit])

Read ENVI format CFA data and metadata to an xarray Dataset.

read_calibration(calibfile[, wavelength_unit])

Read a CSV calibration file to a structured dataset.

read_hdt(hdtfile)

Load metadata from a .hdt header file (VTT format).

fpipy.io.read_ENVI_cfa(filepath, raw_unit='dn', **kwargs)[source]

Read ENVI format CFA data and metadata to an xarray Dataset.

For the VTT format raw ENVI files the ENVI metadata is superfluous and is discarded, with the actual metadata read from the separate VTT header file. Wavelength and fwhm data will be replaced with information from metadata and number of layers etc. are omitted as redundant. Gain and bayer pattern are assumed to be constant within each file.

Parameters
  • filepath (str) – Path to the datafile to be opened, either with or without extension. Expects data and metadata to have extensions .dat and .hdt.

  • raw_unit (str, optional) – Units for the raw data.

  • **kwargs – Keyword arguments to be passed on to xr.open_rasterio.

Returns

dataset – Dataset derived from the raw image data and accompanying metadata. If the ENVI data had an included dark layer, it is separated into its own data variable in the dataset.

Return type

xarray.Dataset

fpipy.io.read_calibration(calibfile, wavelength_unit='nm')[source]

Read a CSV calibration file to a structured dataset.

Parameters
  • calibfile (str) – Filepath to the CSV file containing the metadata. The CSV is assumed to have the following columns (case-sensitive, in no specific order): [‘Npeaks’, ‘SP1’, ‘SP2’, ‘SP3’, ‘PeakWL’, ‘FWHM’, ‘Sinv’]

  • wavelength_unit (str, optional) – Unit of the wavelength data in the calibration file.

Returns

Dataset containing the calibration data in a structured format.

Return type

xr.Dataset

fpipy.io.read_hdt(hdtfile)[source]

Load metadata from a .hdt header file (VTT format).