File I/O

IO

class LuxFlux.fluxEngineNET.IO

Static class that contains functions that interact with I/O of data (measurements, references).

Public Types

enum ReferenceImportFlag

Flags that influence importing of references

This enumeration contains flags that may be passed to the IO.ImportReference() function that will influence the behavior of that function.

Values:

None

No specific flags set (use default behavior)

IgnoreParameterMismatch

Ignore parameter mismatch

If the parameters stored with the reference don’t match the current instrument parameters, this flag may be provided to indicate that these issues should be ignored.

A reference measured for a different exposure time or a different ROI offset will be able to be loaded with this flag set, though the math with that reference loaded will likely not work out correctly.

Public Static Functions

MeasurementList LoadMeasurementList (Handle handle, string format, string fileName)

Load a measurement from disk

This function may be used to load a measurement from disk. At the moment the following formats are supported:

  • Hyperspectral cubes in ENVI format. (Specify "ENVI" as the format ; note that this is case-sensitive.)

Please refer to the main fluxEngine documentation for details on the supported file formats.

If the data could be loaded from disk successfully, a MeasurementList object will be returned. Many file formats (for example ENVI) only support storing a single measurement in a file, which means that the list of measurements will always contain exactly one entry for that type of format. Other formats may support storing multiple measurements in a file, in which case number of measurements in the resulting list may vary.

The user must ensure they have enough RAM to load the corresponding measurement. Especially HSI cubes may be quite large and take up quite a bit of RAM.

HSI cubes: when loading HSI cubes their storage order is normalized at load time. All cubes, regardless of their storage order on disk, will be available in BIP storage order. This means that the first dimension of the loaded data will correspond to the y dimension, the second to the x dimension and the third to the wavelength dimension.

Param handle:

The fluxEngine handle

Param format:

The format of the file to load. Note that the string is case-sensitive.

Param fileName:

The file name to load

Return:

The loaded measurement list

void SaveMeasurementList (Handle handle, MeasurementList measurementList, string format, string fileName, bool saveReferences)

Save a measurement (list) to disk

This function may be used to save a measurement (list) to disk. At the moment the following formats are supported:

  • Hyperspectral cubes in ENVI format. (Specify "ENVI" as the format ; note that this is case-sensitive.)

Please refer to the main fluxEngine documentation for details on the supported file formats.

The measurements in the supplied measurement list must be compatible with the save format, otherwise an error will occur. In particular, some formats, such as ENVI, only support saving a single measurement in a file.

HSI cubes: note that this routine always stores HSI cubes in the BIP storage order when the format allows for a choice in that.

Licensing: this function may be called even if the device a license has been tied to has since been disconnected, or the license dongle has since been removed, in order to allow the application gracefully save data before failing. However, if the license is tied to a device, the device must have been connected at least once with the current handle before this function can be called successfully.

Param handle:

The fluxEngine handle

Param measurementList:

The list of measurements to save

Param format:

The format of the file to load. Note that the string is case-sensitive.

Param fileName:

The file name to load

Param saveReferences:

Whether to also save reference measurements (if present), or only save the actual measurement itself.

void ExportReference (InstrumentDevice device, BufferContainer referenceData, string fileName)

Export measured reference data to a file

After a user has filled a buffer container with data from a reference measurement, that measurement may be exported to a file on disk, so it may be loaded again at a later point in time.

Measured references are typically stored in a file ending in .fluxref.

The buffer container’s structure is checked against the buffer structure of the device. If that doesn’t match, the export will fail.

The instrument device’s current settings that influence a reference measurement will be stored in the exported reference. These will be used to check if the reference is compatible when loading it again. (That check may be disabled, see ReferenceImportFlag.IgnoreParameterMismatch when importing it.)

Restrictions: it is currently not possible to export a ring buffer container. (This will be lifted in a future version.)

Param device:

The instrument device for which to export the reference data.

Param referenceData:

The buffer container containing the reference data to export.

Param fileName:

The file name of the reference to export. This file will be overwritten.

BufferContainer ImportReference (InstrumentDevice device, string fileName, ReferenceImportFlag flags)

Import a reference measurement from disk

Imports the raw data of a reference measurement from disk. This will load .fluxref files that may either be created via the fluxRecorder/fluxTrainer applications or have been exported via the ExportReference() from within fluxEngine.

These will create a buffer container object that may then be passed to instrument processing contexts.

The tensor data type and dimensions for the reference that is loaded must be compatible, or an error will occur.

The instrument device’s current settings that influence a reference measurement will be compared against the settings stored in the exported reference. If these don’t match, by default this function will return an error, but that behavior may be overridden by specifying the ReferenceImportFlag.IgnoreParameterMismatch flag, in which case the reference is loaded regardless.

Param device:

The instrument device for which to import the reference data.

Param fileName:

The file name of the reference to import.

Param flags:

A bitwise or’d list of flags described in the ReferenceImportFlag enumeration that will influence how this function behaves.

Return:

The newly loaded buffer container containing the reference