Skip to content

Datacube

load ¤

Create a 3D array (X and Y are the dimensions of the sample and Z dimension is the number of elements/emission lines taken into account for the classification).

Stack the information contained in the elemental files given ranked according to the spreasheet ranking.

If normalization is asked or if the elemental map is an image file, data in the array are between 0 and 100.

Three types of elemental files are accepted

  • Imges (.bmp of .tif), which are RGB files : each pixel contains 3 values between 0 and 255. The rgb is put into greyscale calculated by the norm 2.

  • Textfile (.txt), which is already the elemental array where the values are the number of counts.

  • Raw file (.rpl), wich is the datacube containing all the spectra for every pixel. The hyperspy library is used to extract the emission lines corresponding to the wanted elements.

Textfiles and raw files can be normalized or not, the spreadsheet must be written according to that.

The function also creates a dictionnary containing the Z position of the element in the 3D array created.

2 class files created in that function.

Parameters:

Name Type Description Default
prefix str

Common name between files.

required
suffix str

Extension name of the files.

required
normalization bool

If data are normalized between 0 and 100.

True
element_list List[str]

User can specify list elements to be taken, or let the program finds all data in corresponding to given prefix name.

None

Raises:

Type Description
TypeError

If given extension is not accepted by the program.

load_images ¤

Images Data loader.

Low-level function for data loading.

Parameters:

Name Type Description Default
file_list List[str]

List of images files to load.

required
prefix str

Common name between files.

required
suffix str

Extension name of the files.

required

Returns:

Type Description
MultiCube

Marcia MultiCube Objects.

MultiCube

MultiCube means data channels are discrete and not continuous.

load_textfile ¤

Text Data Loader.

Low-level function for data loading.

Parameters:

Name Type Description Default
file_list List[str]

List of images files to load.

required
prefix str

Common name between files.

required
suffix str

Extension name of the files.

required
normalization bool

If data are normalized between 0 and 100.

True

Returns:

Type Description
MultiCube

Marcia MultiCube Objects.

MultiCube

MultiCube means data channels are discrete and not continuous.

load_hypermap ¤

Raw HyperCube Data Loader.

Parameters:

Name Type Description Default
prefix str

Name of file.

required
suffix str

Extension name of the file.

required
name str

Physical measure of channel

'E'
units str

Unit of physical measure. Defaults to 'keV'.

'keV'
scale float

Scale realationship betwen channel and physical measure.

0.01
offset float

Scale offset between channel and physcial measure.

-0.97

Returns:

Type Description
HyperCube

Marcia HyperCube Object.

HyperCube

HyperCube means data channels are continuous.

save ¤

Save specified element as a .tif image file.

Parameters:

Name Type Description Default
datacube DataCube

Marcia DataCube Object.

required
element str

Name of the wanted element (eg: 'Fe')

required
raw bool

If saved image has information background or not.

False

save_cube_inside_mask ¤

Recreates raw datacube containing data only in the wanted element.

Parameters:

Name Type Description Default
data_cube DataCube

Marcia DataCube Object.

required
mineral str

Name of the wanted element (eg: 'Galene')

required

Raises:

Type Description
FileNotFoundError

If raw data cube is not in folder.

save_cube_outside_mask ¤

Recreates a raw datacube containing data that are not in the specified element.

Parameters:

Name Type Description Default
data_cube DataCube

Marcia DataCube Object.

required
mineral str

Name of the wanted element (eg: 'Galene')

required

Raises:

Type Description
FileNotFoundError

If raw data cube is not in folder.

save_mask_spectrum ¤

Save mean spectrum of a given mask as a .txt file.

  • First column is channel.
  • Second column is counts.

Parameters:

Name Type Description Default
data_cube DataCube

Marcia DataCube Object.

required
mask str

Name of the wanted mask (eg: 'Galene').

required

Raises:

Type Description
FileNotFoundError

If raw data cube is not in folder.