IO module¶
This module provides the input/output tools to read/save maps and datasets.
It is made of 3 main modules:
edxia.io.loader
: Load set of mapsedxia.io.raw_io
: Load and save individual mapsedxia.io.hdf5
: Load and save HDF5 datasets
Loaders¶
The edxia.io.loader
module offers loader classes to be able to easily
load component maps, composite or map stacks.
Three main loaders are defined:
edxia.io.loader.DefaultLoader
: A simple loader, applies the filters every timeedxia.io.loader.PickleLoader
: A loader with a cache, apply the filters only onceedxia.io.loader.StackLoader
: A loader not working from the filesystem, but using aedxia.core.map.MapsStack
as an input data.
The main functions are:
edxia.io.loader.base_loader.AbstractLoader.load_edsmap()
: load a BSE/EDS map,edxia.core.map.Map
.edxia.io.loader.base_loader.AbstractLoader.load_stack()
: load a set of maps,edxia.core.map.MapsStack
edxia.io.loader.base_loader.AbstractLoader.load_composite()
: load a composite map,edxia.composite.CompositeMap
-
class
edxia.io.loader.
DefaultLoader
(exp_manager, filters=None, no_BSE_filter=True)[source]¶ Bases:
edxia.io.loader.base_loader.AbstractLoader
Default loader without loading.
-
class
edxia.io.loader.
PickleLoader
(exp_manager, filters=None, no_BSE_filter=True, remove_previous=True)[source]¶ Bases:
edxia.io.loader.base_loader.AbstractLoader
This loader cache filtered map so long filtering can be done only once.
-
class
edxia.io.loader.
StackLoader
(stack)[source]¶ Bases:
edxia.io.loader.base_loader.AbstractLoader
Loader using a set of maps already read (and optionally filtered) using a different loader.
-
class
edxia.io.loader.base_loader.
AbstractLoader
(exp_manager, filters=None)[source]¶ Abstract base class for a map loader. This class is not intended for use, instead the user should use one of the class in
edxia.io.loader
.-
exp_manager
¶ Return the experience manager
-
filters
¶ Return the list of filters to apply at loading.
-
load_composite
(channels, is_rgb=True)[source]¶ Load a composite map
Parameters: - channels – the different channels to consider
- is_rgb – if true, the map is reduced to an RGB image
-
load_edsmap
(component)[source]¶ Load the map of ‘component’. It can be either a simple component (e.g. ‘BSE’, ‘Ca’), or a combination of components (e.g. “Si+Al/Ca”).
-
Raw IO¶
This module provides raw loading and saving helper functions. It defines how the maps are read before any transformation from the algorithm.
Example: Read txt format from bruker Esprit software:
bse_map_asarray = load_txt_map("map234_BSE.txt", esprit_ascii_map_format)
-
class
edxia.io.raw_io.
TextMapFormat
(delimiter, min_value, max_value, saveformat='%.4f')[source]¶ Bases:
object
A struct-like class to contain formatting information about raw EDS maps.
-
delimiter
¶ Return the column delimiter
-
escaped_delimiter
¶ Return an escaped version of the delimiter
-
max_value
¶ Return the maximum value allowed in the map
-
min_value
¶ Return the minimum value allowed in the map
-
saveformat
¶ Set the save format
-
-
edxia.io.raw_io.
esprit_ascii_map_format
= TextMapFormat(';',0,100)¶ Default EDS map format for the Bruker Esprit software
-
edxia.io.raw_io.
esprit_ascii_bse_format
= TextMapFormat(';',0,-1)¶ Default BSE map format for the Bruker Esprit software
-
edxia.io.raw_io.
aztec_ascii_map_format
= TextMapFormat(',',0,100)¶ Default EDS map format for the Oxford Aztec software
-
edxia.io.raw_io.
aztec_ascii_bse_format
= TextMapFormat(',',0,-1)¶ Default BSE map format for the Oxford Aztec software
-
edxia.io.raw_io.
imagej_ascii_bse_format
= TextMapFormat('\t',0,-1)¶ Format for a text image produced by ImageJ
-
edxia.io.raw_io.
load_txt_map
(filename, txtformat, resize=1)[source]¶ Load a 2D map
Parameters: - filename – filepath to the text map
- txtformat – the format of the text map
- resize – Stretch the map in each axis)
Returns: a 2D numpy array normalized between [0,1]
Raises: whatever numpy.loadtxt can raise
-
edxia.io.raw_io.
save_txt_map
(filename, amap, txtformat)[source]¶ Save a 2D map
Perform a copy first to normalize the data according the format.
Parameters: - filename – filepath to the file
- amap – a 2D map
Format txtformat: the format of the ascii saved map