defdap.file_readers module

class defdap.file_readers.EBSDDataLoader[source]

Bases: object

Class containing methods for loading and checking EBSD data

static getLoader(dataType)[source]
Return type

Type[EBSDDataLoader]

checkMetadata()[source]

Checks that the number of phases from metadata matches the amount of phases loaded.

Return type

None

checkData()[source]
Return type

None

class defdap.file_readers.OxfordTextLoader[source]

Bases: defdap.file_readers.EBSDDataLoader

load(fileName, fileDir='')[source]

Read an Oxford Instruments .ctf file, which is a HKL single orientation file.

Parameters
  • fileName (str) – File name.

  • fileDir (str) – Path to file.

Returns

EBSD metadata and EBSD data.

Return type

dict, dict

class defdap.file_readers.OxfordBinaryLoader[source]

Bases: defdap.file_readers.EBSDDataLoader

load(fileName, fileDir='')[source]

Read Oxford Instruments .cpr/.crc file pair.

Parameters
  • fileName (str) – File name.

  • fileDir (str) – Path to file.

Returns

EBSD metadata and EBSD data.

Return type

dict, dict

loadOxfordCPR(fileName, fileDir='')[source]

Read an Oxford Instruments .cpr file, which is a metadata file describing EBSD data.

Parameters
  • fileName (str) – File name.

  • fileDir (str) – Path to file.

Return type

None

loadOxfordCRC(fileName, fileDir='')[source]

Read binary EBSD data from an Oxford Instruments .crc file

Parameters
  • fileName (str) – File name.

  • fileDir (str) – Path to file.

Return type

None

class defdap.file_readers.PythonDictLoader[source]

Bases: defdap.file_readers.EBSDDataLoader

load(dataDict)[source]

Construct EBSD data from a python dictionary.

Parameters

dataDict (Dict[str, Any]) –

Dictionary with keys:

’stepSize’ ‘phases’ ‘phase’ ‘eulerAngle’ ‘bandContrast’

Return type

None

class defdap.file_readers.DICDataLoader[source]

Bases: object

Class containing methods for loading and checking HRDIC data

checkMetadata()[source]
Return type

None

checkData()[source]

Calculate size of map from loaded data and check it matches values from metadata.

Return type

None

loadDavisMetadata(fileName, fileDir='')[source]

Load DaVis metadata from Davis .txt file.

Parameters
  • fileName (str) – File name.

  • fileDir (str) – Path to file.

Returns

Davis metadata.

Return type

dict

loadDavisData(fileName, fileDir='')[source]

Load displacement data from Davis .txt file containing x and y coordinates and x and y displacements for each coordinate.

Parameters
  • fileName (str) – File name.

  • fileDir (str) – Path to file.

Returns

Coordinates and displacements.

Return type

dict

static loadDavisImageData(fileName, fileDir='')[source]

A .txt file from DaVis containing a 2D image

Parameters
  • fileName (str) – File name.

  • fileDir (str) – Path to file.

Returns

Array of data.

Return type

np.ndarray

defdap.file_readers.readUntilString(file, termString, commentChar='*', lineProcess=None)[source]

Read lines in a file until a line starting with the termString is encounted. The file position is returned before the line starting with the termString when found. Comment and empty lines are ignored.

Parameters
  • file (TextIO) – An open python text file object.

  • termString (str) – String to terminate reading.

  • commentChar (str) – Character at start of a comment line to ignore.

  • lineProcess (Optional[Callable[[str], Any]]) – Function to apply to each line when loaded.

Returns

List of processed lines loaded from file.

Return type

list