2.8.1.3. prismatique.stem.output.Params
- class Params(base_params=None, alg_specific_params=None, skip_validation_and_conversion=False)[source]
Bases:
PreSerializableAndUpdatableThe output parameters for STEM simulations.
See the documentation for the class
prismatique.cbed.Paramsfor a discussion on CBED patterns that is relevant to the discussion on this page. We refer to CBED patterns generated from a STEM simulation as 4D-STEM data.prismaticsimulates annular detectors shaped in concentric rings, where each ring has a fixed bin width that can be chosen by the user. This allows one to collect the integrated intensity over each ring in a given DP. Integrating over the rings this way for each CBED intensity pattern yields what we will refer to as the “3D_STEM intensity data/output”: there are still two spatial dimensions associated with each probe position, but now there is only one dimension associated with the diffraction data for each probe position, i.e. a radial dimension in momentum space.We can collect a further reduced set of data by integrating/summing over a consecutive set of rings for each CBED intensity pattern. For example, for each CBED intensity pattern we could integrate over the first so many rings that encompasses the direct beam, thus collecting bright field data. Therefore, for each CBED intensity pattern we extract a single number, which is the integrated intensity over a solid ring [e.g. in dark field imaging] or a disk [e.g. in bright field imaging]. We will call the resulting data the “2D_STEM intensity data/output”.
From the 4D-STEM intensity data, we can also calculate the “center-of-mass” (COM) momentum for each probe position:
(2.8.1.3.1)\[\left\langle \mathbf{k}_{\text{COM}}\right\rangle = \frac{\int d\mathbf{k}\, I_{\text{STEM}}\left(k_{x},k_{y}\right)\mathbf{k}}{\int d\mathbf{k}\, I_{\text{STEM}}\left(k_{x},k_{y}\right)},\]where \(I_{\text{STEM}}\left(k_{x},k_{y}\right)\) is the CBED intensity.
Upon the completion of a STEM simulation,
prismatiquecan optionally save a variety of different STEM data to a set of HDF5 files based on the specifications of the user. This is done by taking the original output file generated byprismatic, and then restructuring it into one or more output files. If the output parameters specify that intensity data be saved, then said data is extracted from the originalprismaticoutput files, postprocessed, and written to a new file with basename"stem_sim_intensity_output.h5"in a more readable layout. Assuming all intensity data is to be saved, this new output file has the following structure:metadata: <HDF5 group>
probe_positions: <HDF5 2D dataset>
dim 1: “probe idx”
dim 2: “vector component idx [0->x, 1->y]”
units: “Å”
pattern type: “rectangular grid” | “jittered rectangular grid” | “no underlying rectangular grid”
grid dimensions in units of probe shifts: <ordered pair> | “N/A”
output_layer_depths: <HDF5 1D dataset>
dim 1: “output layer idx”
units: “Å”
k_x: <HDF5 1D dataset>
dim 1: “k_x idx”
units: “1/Å”
k_y: <HDF5 1D dataset>
dim 1: “k_y idx”
units: “1/Å”
k_xy: <HDF5 1D dataset>
dim 1: “k_xy idx”
units: “1/Å”
data: <HDF5 group>
2D_STEM: <HDF5 group>
integrated_intensities: <HDF5 2D dataset>
dim 1: “output layer idx”
dim 2: “probe idx”
units: “dimensionless”
lower integration limit in mrads: <scalar>
upper integration limit in mrads: <scalar>
3D_STEM: <HDF5 group>
integrated_intensities: <HDF5 3D dataset>
dim 1: “output layer idx”
dim 2: “probe idx”
dim 3: “k_xy idx”
units: “dimensionless”
4D_STEM: <HDF5 group>
intensity_DPs: <HDF5 4D dataset>
dim 1: “output layer idx”
dim 2: “probe idx”
dim 3: “k_y idx”
dim 4: “k_x idx”
units: “dimensionless”
center_of_mass_momentum: <HDF5 3D dataset>
dim 1: “output layer idx”
dim 2: “vector component idx [0->x, 1->y]”
dim 3: “probe idx”
units: “1/Å”
Note that the sub-bullet points listed immediately below a given HDF5 dataset display the HDF5 attributes associated with said HDF5 dataset. Each HDF5 scalar and dataset has a
"units"attribute which, as the name suggests, indicates the units in which said data [i.e. the scalar or dataset] is expressed. Each HDF5 dataset will also have a set of attributes with names of the form"dim {}".format(i)withibeing an integer ranging from 1 to the rank of said HDF5 dataset. Attribute"dim {}".format(i)of a given HDF5 dataset labels the \(i^{\text{th}}\) dimension of the underlying array of the dataset. Most of these dimension labels should be self-explanatory but for clarification: “idx” is short for “index”; “k_x” and “k_y” refer to the \(x\)- and \(y\)-components of the electron scattering momentum; and the notion of an output layer is discussed in the documentation for the classprismatique.stem.output.multislice.Params.If the output parameters specify that complex-valued wavefunction data be saved, then said data is extracted from the original
prismaticoutput files, and written to a new set of files: one file per frozen phonon/atomic configuration subset. Note that, unlike the intensity data, the complex-valued wavefunction data is not postprocessed. See the documentation for the classprismatique.thermal.Paramsfor a discussion on frozen phonon configurations and their grouping into subsets. For theith frozen phonon configuration subset, the corresponding wavefunction data is saved to the file with basename"stem_sim_wavefunction_output_of_subset_"+str(i)+".h5". Each one of these new output files has the following structure:metadata: <HDF5 group>
probe_positions: <HDF5 2D dataset>
dim 1: “probe idx”
dim 2: “vector component idx [0->x, 1->y]”
units: “Å”
pattern type: “rectangular grid” | “jittered rectangular grid” | “no underlying rectangular grid”
grid dimensions in units of probe shifts: <ordered pair> | “N/A”
defocii: <HDF5 1D dataset>
dim 1: “defocus idx”
units: “Å”
output_layer_depths: <HDF5 1D dataset>
dim 1: “output layer idx”
units: “Å”
k_x: <HDF5 1D dataset>
dim 1: “k_x idx”
units: “1/Å”
k_y: <HDF5 1D dataset>
dim 1: “k_y idx”
units: “1/Å”
data: <HDF5 group>
4D_STEM: <HDF5 group>
complex_valued_DPs: <HDF5 6D dataset>
dim 1: “output layer idx”
dim 2: “atomic config idx”
dim 3: “defocus idx”
dim 4: “probe idx”
dim 5: “k_y idx”
dim 6: “k_x idx”
units: “dimensionless”
prismatiquecan also optionally save the “potential slice” [i.e. Eq. (2.3.1.7)] data for each subset of frozen phonon configurations into separate HDF5 output files by extracting said data from the originalprismaticoutput files. For theith subset, the corresponding potential slice data is saved to an HDF5 output file with basename"potential_slices_"+str(i)+".h5". Unlike the output data in the file"stem_simulation_output.h5", the layout of the potential slice data is kept the same as that found in the original file [i.e. the same HDF5 paths are used]. The same layout needs to be used in order forprismaticto be able to successfully import/load pre-calculated potential slice data for future simulations.Moreover if used/generated,
prismatiquecan also optionally save the \(S\)-matrix [i.e. Eq. (2.8.37)] data into a separate HDF5 output files by extracting said data from the originalprismaticoutput files. For theith subset, the corresponding \(S\)-matrix data is saved to an HDF5 output file with basename"S_matrix_"+str(i)+".h5". The layout of the \(S\)-matrix data is kept the same as that found in the original file for the same reason mentioned for the potential slice data. Note that \(S\)-matrix data is only generated/used when STEM simulations are performed using the PRISM algorithm [see the documentation for the subpackageprismatique.stemfor details on this algorithm].It is beyond the scope of the documentation to describe the structure of the potential slice and \(S\)-matrix output files. Users can analyze the data in these output files with the help of the tools found in the module
prismatique.load.The last file that is always generated after running a STEM simulation is a JSON file that contains, in a serialized format, the simulation parameters used. This file has the basename
"stem_sim_params.json".- Parameters:
- base_params
prismatique.stem.output.base.Params| None, optional The base output parameters for the STEM simulation. See the documentation for the class
prismatique.stem.output.base.Paramsfor a discussion on said parameters. Ifbase_paramsis set to None [i.e. the default value], then the aforementioned parameters are set to default values.- alg_specific_params
prismatique.stem.output.multislice.Params|prismatique.stem.output.prism.Params| None, optional The output parameters that are applicable only to the particular algorithm used perform the STEM simulation. If
alg_specific_paramsis set to an instance of the classprismatique.stem.output.multislice.Params, then the multislice algorithm is used to perform the STEM simulation. See the documentation for the classprismatique.stem.output.multislice.Paramsfor a discussion on the output parameters specific to the multislice algorithm. Ifalg_specific_paramsis set to an instance of the classprismatique.stem.output.prism.Params, then the PRISM algorithm is used to perform the STEM simulation. See the documentation for the classprismatique.stem.output.prism.Paramsfor a discussion on the output parameters specific to the PRISM algorithm. Ifalg_specific_paramsis set to None [i.e. the default value], then the multislice algorithm is used to perform the STEM simulation with the aforementioned output parameters set to default values.- skip_validation_and_conversionbool, optional
Let
validation_and_conversion_funcsandcore_attrsdenote the attributesvalidation_and_conversion_funcsandcore_attrsrespectively, both of which being dict objects.Let
params_to_be_mapped_to_core_attrsdenote the dict representation of the constructor parameters excluding the parameterskip_validation_and_conversion, where each dict keykeyis a different constructor parameter name, excluding the name"skip_validation_and_conversion", andparams_to_be_mapped_to_core_attrs[key]would yield the value of the constructor parameter with the name given bykey.If
skip_validation_and_conversionis set toFalse, then for each keykeyinparams_to_be_mapped_to_core_attrs,core_attrs[key]is set tovalidation_and_conversion_funcs[key] (params_to_be_mapped_to_core_attrs).Otherwise, if
skip_validation_and_conversionis set toTrue, thencore_attrsis set toparams_to_be_mapped_to_core_attrs.copy(). This option is desired primarily when the user wants to avoid potentially expensive deep copies and/or conversions of the dict values ofparams_to_be_mapped_to_core_attrs, as it is guaranteed that no copies or conversions are made in this case.
- base_params
- Attributes:
core_attrsdict: The “core attributes”.
de_pre_serialization_funcsdict: The de-pre-serialization functions.
pre_serialization_funcsdict: The pre-serialization functions.
validation_and_conversion_funcsdict: The validation and conversion functions.
Methods
de_pre_serialize([serializable_rep, ...])Construct an instance from a serializable representation.
dump([filename, overwrite])Serialize instance and save the result in a JSON file.
dumps()Serialize instance.
get_core_attrs([deep_copy])Return the core attributes.
Return the de-pre-serialization functions.
Return the pre-serialization functions.
Return the validation and conversion functions.
load([filename, skip_validation_and_conversion])Construct an instance from a serialized representation that is stored in a JSON file.
loads([serialized_rep, ...])Construct an instance from a serialized representation.
Pre-serialize instance.
update([new_core_attr_subset_candidate, ...])Update a subset of the core attributes.
Methods
Construct an instance from a serializable representation.
Serialize instance and save the result in a JSON file.
Serialize instance.
Return the core attributes.
Return the de-pre-serialization functions.
Return the pre-serialization functions.
Return the validation and conversion functions.
Construct an instance from a serialized representation that is stored in a JSON file.
Construct an instance from a serialized representation.
Pre-serialize instance.
Update a subset of the core attributes.
Attributes
dict: The "core attributes".
dict: The de-pre-serialization functions.
dict: The pre-serialization functions.
dict: The validation and conversion functions.
- property core_attrs
dict: The “core attributes”.
The keys of
core_attrsare the same as the attributevalidation_and_conversion_funcs, which is also a dict object.Note that
core_attrsshould be considered read-only.
- property de_pre_serialization_funcs
dict: The de-pre-serialization functions.
de_pre_serialization_funcshas the same keys as the attributevalidation_and_conversion_funcs, which is also a dict object.Let
validation_and_conversion_funcsandpre_serialization_funcsdenote the attributesvalidation_and_conversion_funcspre_serialization_funcsrespectively, the last of which being a dict object as well.Let
core_attrs_candidate_1be any dict object that has the same keys asvalidation_and_conversion_funcs, where for each dict keykeyincore_attrs_candidate_1,validation_and_conversion_funcs[key](core_attrs_candidate_1)does not raise an exception.Let
serializable_repbe a dict object that has the same keys ascore_attrs_candidate_1, where for each dict keykeyincore_attrs_candidate_1,serializable_rep[key]is set topre_serialization_funcs[key](core_attrs_candidate_1[key]).The items of
de_pre_serialization_funcsare expected to be set to callable objects that would lead tode_pre_serialization_funcs[key](serializable_rep[key])not raising an exception for each dict keykeyinserializable_rep.Let
core_attrs_candidate_2be a dict object that has the same keys asserializable_rep, where for each dict keykeyinvalidation_and_conversion_funcs,core_attrs_candidate_2[key]is set tode_pre_serialization_funcs[key](serializable_rep[key]).The items of
de_pre_serialization_funcsare also expected to be set to callable objects that would lead tovalidation_and_conversion_funcs[key](core_attrs_candidate_2)not raising an exception for each dict keykeyincore_attrs_candidate_2.Note that
de_pre_serialization_funcsshould be considered read-only.
- classmethod de_pre_serialize(serializable_rep={}, skip_validation_and_conversion=False)
Construct an instance from a serializable representation.
- Parameters:
- serializable_repdict, optional
A dict object that has the same keys as the attribute
validation_and_conversion_funcs, which is also a dict object.Let
validation_and_conversion_funcsandde_pre_serialization_funcsdenote the attributesvalidation_and_conversion_funcsde_pre_serialization_funcsrespectively, the last of which being a dict object as well.The items of
serializable_repare expected to be objects that would lead tode_pre_serialization_funcs[key](serializable_rep[key])not raising an exception for each dict keykeyinserializable_rep.Let
core_attrs_candidatebe a dict object that has the same keys asserializable_rep, where for each dict keykeyinserializable_rep,core_attrs_candidate[key]is set to de_pre_serialization_funcs[key](serializable_rep[key])``.The items of
serializable_repare also expected to be set to objects that would lead tovalidation_and_conversion_funcs[key](core_attrs_candidate)not raising an exception for each dict keykeyinserializable_rep.- skip_validation_and_conversionbool, optional
Let
core_attrsdenote the attributecore_attrs, which is a dict object.If
skip_validation_and_conversionis set toFalse, then for each keykeyinserializable_rep,core_attrs[key]is set tovalidation_and_conversion_funcs[key] (core_attrs_candidate), withvalidation_and_conversion_funcsandcore_attrs_candidate_1being introduced in the above description ofserializable_rep.Otherwise, if
skip_validation_and_conversionis set toTrue, thencore_attrsis set tocore_attrs_candidate.copy(). This option is desired primarily when the user wants to avoid potentially expensive deep copies and/or conversions of the dict values ofcore_attrs_candidate, as it is guaranteed that no copies or conversions are made in this case.
- Returns:
- instance_of_current_clsCurrent class
An instance constructed from the serializable representation
serializable_rep.
- dump(filename='serialized_rep_of_fancytype.json', overwrite=False)
Serialize instance and save the result in a JSON file.
- Parameters:
- filenamestr, optional
The relative or absolute path to the JSON file in which to store the serialized representation of an instance.
- overwritebool, optional
If
overwriteis set toFalseand a file exists at the pathfilename, then the serialized instance is not written to that file and an exception is raised. Otherwise, the serialized instance will be written to that file barring no other issues occur.
- Returns:
- dumps()
Serialize instance.
- Returns:
- serialized_repdict
A serialized representation of an instance.
- get_core_attrs(deep_copy=True)
Return the core attributes.
- Parameters:
- deep_copybool, optional
Let
core_attrsdenote the attributecore_attrs, which is a dict object.If
deep_copyis set toTrue, then a deep copy ofcore_attrsis returned. Otherwise, a shallow copy ofcore_attrsis returned.
- Returns:
- core_attrsdict
The attribute
core_attrs.
- classmethod get_de_pre_serialization_funcs()[source]
Return the de-pre-serialization functions.
- Returns:
- de_pre_serialization_funcsdict
The attribute
de_pre_serialization_funcs.
- classmethod get_pre_serialization_funcs()[source]
Return the pre-serialization functions.
- Returns:
- pre_serialization_funcsdict
The attribute
pre_serialization_funcs.
- classmethod get_validation_and_conversion_funcs()[source]
Return the validation and conversion functions.
- Returns:
- validation_and_conversion_funcsdict
The attribute
validation_and_conversion_funcs.
- classmethod load(filename='serialized_rep_of_fancytype.json', skip_validation_and_conversion=False)
Construct an instance from a serialized representation that is stored in a JSON file.
Users can save serialized representations to JSON files using the method
fancytypes.PreSerializable.dump().- Parameters:
- filenamestr, optional
The relative or absolute path to the JSON file that is storing the serialized representation of an instance.
filenameis expected to be such thatjson.load(open(filename, "r"))does not raise an exception.Let
serializable_rep=json.load(open(filename, "r")).Let
validation_and_conversion_funcsandde_pre_serialization_funcsdenote the attributesvalidation_and_conversion_funcsde_pre_serialization_funcsrespectively, both of which being dict objects as well.filenameis also expected to be such thatde_pre_serialization_funcs[key](serializable_rep[key])does not raise an exception for each dict keykeyinde_pre_serialization_funcs.Let
core_attrs_candidatebe a dict object that has the same keys asde_pre_serialization_funcs, where for each dict keykeyinserializable_rep,core_attrs_candidate[key]is set to de_pre_serialization_funcs[key](serializable_rep[key])``.filenameis also expected to be such thatvalidation_and_conversion_funcs[key](core_attrs_candidate)does not raise an exception for each dict keykeyinserializable_rep.- skip_validation_and_conversionbool, optional
Let
core_attrsdenote the attributecore_attrs, which is a dict object.Let
core_attrs_candidatebe as defined in the above description offilename.If
skip_validation_and_conversionis set toFalse, then for each keykeyincore_attrs_candidate,core_attrs[key]is set tovalidation_and_conversion_funcs[key] (core_attrs_candidate), , withvalidation_and_conversion_funcsandcore_attrs_candidatebeing introduced in the above description offilename.Otherwise, if
skip_validation_and_conversionis set toTrue, thencore_attrsis set tocore_attrs_candidate.copy(). This option is desired primarily when the user wants to avoid potentially expensive deep copies and/or conversions of the dict values ofcore_attrs_candidate, as it is guaranteed that no copies or conversions are made in this case.
- Returns:
- instance_of_current_clsCurrent class
An instance constructed from the serialized representation stored in the JSON file.
- classmethod loads(serialized_rep='{}', skip_validation_and_conversion=False)
Construct an instance from a serialized representation.
Users can generate serialized representations using the method
dumps().- Parameters:
- serialized_repstr | bytes | bytearray, optional
The serialized representation.
serialized_repis expected to be such thatjson.loads(serialized_rep)does not raise an exception.Let
serializable_rep=json.loads(serialized_rep).Let
validation_and_conversion_funcsandde_pre_serialization_funcsdenote the attributesvalidation_and_conversion_funcsde_pre_serialization_funcsrespectively, both of which being dict objects as well.serialized_repis also expected to be such thatde_pre_serialization_funcs[key](serializable_rep[key])does not raise an exception for each dict keykeyinde_pre_serialization_funcs.Let
core_attrs_candidatebe a dict object that has the same keys asserializable_rep, where for each dict keykeyinde_pre_serialization_funcs,core_attrs_candidate[key]is set to de_pre_serialization_funcs[key](serializable_rep[key])``.serialized_repis also expected to be such thatvalidation_and_conversion_funcs[key](core_attrs_candidate)does not raise an exception for each dict keykeyinserializable_rep.- skip_validation_and_conversionbool, optional
Let
core_attrsdenote the attributecore_attrs, which is a dict object.If
skip_validation_and_conversionis set toFalse, then for each keykeyincore_attrs_candidate,core_attrs[key]is set tovalidation_and_conversion_funcs[key] (core_attrs_candidate), withvalidation_and_conversion_funcsandcore_attrs_candidate_1being introduced in the above description ofserialized_rep.Otherwise, if
skip_validation_and_conversionis set toTrue, thencore_attrsis set tocore_attrs_candidate.copy(). This option is desired primarily when the user wants to avoid potentially expensive deep copies and/or conversions of the dict values ofcore_attrs_candidate, as it is guaranteed that no copies or conversions are made in this case.
- Returns:
- instance_of_current_clsCurrent class
An instance constructed from the serialized representation.
- property pre_serialization_funcs
dict: The pre-serialization functions.
pre_serialization_funcshas the same keys as the attributevalidation_and_conversion_funcs, which is also a dict object.Let
validation_and_conversion_funcsandcore_attrsdenote the attributesvalidation_and_conversion_funcsandcore_attrsrespectively, the last of which being a dict object as well.For each dict key
keyincore_attrs,pre_serialization_funcs[key](core_attrs[key])is expected to yield a serializable object, i.e. it should yield an object that can be passed into the functionjson.dumpswithout raising an exception.Note that
pre_serialization_funcsshould be considered read-only.
- pre_serialize()
Pre-serialize instance.
- Returns:
- serializable_repdict
A serializable representation of an instance.
- update(new_core_attr_subset_candidate={}, skip_validation_and_conversion=False)
Update a subset of the core attributes.
- Parameters:
- new_core_attr_subset_candidatedict, optional
A dict object.
- skip_validation_and_conversionbool, optional
Let
validation_and_conversion_funcsandcore_attrsdenote the attributesvalidation_and_conversion_funcsandcore_attrsrespectively, both of which being dict objects.If
skip_validation_and_conversionis set toFalse, then for each keykeyincore_attrsthat is also innew_core_attr_subset_candidate,core_attrs[key]is set tovalidation_and_conversion_funcs[key] (new_core_attr_subset_candidate).Otherwise, if
skip_validation_and_conversionis set toTrue, then for each keykeyincore_attrsthat is also innew_core_attr_subset_candidate,core_attrs[key]is set tonew_core_attr_subset_candidate[key]. This option is desired primarily when the user wants to avoid potentially expensive deep copies and/or conversions of the dict values ofnew_core_attr_subset_candidate, as it is guaranteed that no copies or conversions are made in this case.
- property validation_and_conversion_funcs
dict: The validation and conversion functions.
The keys of
validation_and_conversion_funcsare the names of the constructor parameters, excludingskip_validation_and_conversionif it exists as a construction parameter.Let
core_attrsdenote the attributecore_attrs, which is also a dict object.For each dict key
keyincore_attrs,validation_and_conversion_funcs[key](core_attrs)is expected to not raise an exception.Note that
validation_and_conversion_funcsshould be considered read-only.