File I/O for Raw References

ReferenceImportFlag

class fluxEngine.ReferenceImportFlag(value)

Flags that influence importing of references

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

IgnoreParameterMismatch = 1

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.

importReference

fluxEngine.importReference(device, fileName, 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.

Parameters:
  • device (InstrumentDevice) – The instrument device for which to import the reference data

  • fileName (str) – The file name of the reference to import

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

Returns:

The newly loaded buffer container containing the reference

Return type:

BufferContainer

exportReference

fluxEngine.exportReference(device, referenceData, 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.)

Parameters:
  • device (InstrumentDevice) – The instrument device for which to export the reference data

  • referenceData (BufferContainer) – The buffer container containing the reference data to export

  • fileName (str) – The file name of the reference to export. This file will be overwritten.