2.6.1.1. embeam.stem.probe.ModelParams
- class ModelParams(lens_model_params=None, gun_model_params=None, convergence_semiangle=15, defocal_offset_supersampling=9, skip_validation_and_conversion=False)[source]
- Bases: - PreSerializableAndUpdatable- The model parameters of a probe. - Note that - embeamcurrently does not support the modelling of finite source effects that lead to spatially incoherent probes.- As discussed in greater detail in e.g. Ref. [Kirkland1], the \(k\)-space wavefunction of a coherent probe is well-described by the following model: (2.6.1.1.1)\[\Phi_{\text{probe}}\left(k_{x},k_{y};\delta_{f}\right)= \frac{1}{\sqrt{\pi k_{xy,\max}^{2}}} \Theta\left(k_{xy,\max}-k_{xy}\right) e^{-i\chi\left(k_{x},k_{y};\delta_{f}\right)},\]- where \(k_{x}\) and \(k_{y}\) are the Fourier coordinates; (2.6.1.1.2)\[k_{xy}=\sqrt{k_{x}^{2}+k_{y}^{2}},\](2.6.1.1.3)\[k_{xy,\max}=\frac{\alpha_{\max}}{\lambda},\]- with \(\alpha_{\max}\) being the convergence semiangle, and \(\lambda\) being the electron beam wavelength [given by Eq. (2.1.1)]; \(\delta_f\) is the defocal offset; \(\Theta\left(u\right)\) is the Heaviside step function; and \(\chi\left(k_{x},k_{y};\delta_f\right)\) is given by Eq. (2.2.1.1). The corresponding real-space wavefunction of the coherent probe can be expressed as (2.6.1.1.4)\[\psi_{\text{probe}}\left(x,y;\delta_{f}\right)= \int_{-\infty}^{\infty}dk_{x}\,\int_{-\infty}^{\infty}dk_{y}\, \Phi_{\text{probe}}\left(k_{x},k_{y};\delta_{f}\right) e^{2\pi ik_{x}x+2\pi ik_{y}y},\]- where \(x\) and \(y\) are the real-space coordinates. The \(k\)-space fractional intensity of the coherent probe is simply: (2.6.1.1.5)\[\begin{split}p_{\text{probe}}\left(\left.K_{x}=k_{x}\right|K_{y}=k_{y}; \delta_{f}\right)&=\left|\Phi_{\text{probe}}\left(k_{x},k_{y}; \delta_{f}\right)\right|^{2}\\&=\frac{1}{\pi k_{xy,\max}^{2}} \Theta\left(k_{xy,\max}-k_{xy}\right)\\ &=p_{\text{probe}}\left(\left.K_{x}=k_{x}\right|K_{y}=k_{y}; \delta_{f}=0\right),\end{split}\]- and the corresponding real-space fractional intensity of the coherent probe is: (2.6.1.1.6)\[p_{\text{probe}}\left(\left.X=x\right|Y=y;\delta_{f}\right)= \left|\psi_{\text{probe}}\left(x,y;\delta_{f}\right)\right|^{2}.\]- In scenarios where the probe forming lens is subject to chromatic aberrations, and there are small fluctuations in the electron beam energy over time, there will be correspondingly small fluctuations in the defocus of the electron beam over time. In such cases, the \(k\)-space fractional intensity of the incoherent probe is well-described by the following model: (2.6.1.1.7)\[\begin{split}p_{\text{probe}}\left(\left.K_{x}=k_{x}\right|K_{y}=k_{y}\right) &=\int_{-\infty}^{\infty}d\delta_{f}\, p_{\sigma_{f}}\left(\delta_{f}\right) p_{\text{probe}}\left(\left.K_{x}=k_{x}\right|K_{y}=k_{y}; \delta_{f}\right)\\ &=p_{\text{probe}}\left(\left.K_{x}=k_{x}\right|K_{y}=k_{y}; \delta_{f}=0\right)\int_{-\infty}^{\infty}d\delta_{f}\, p_{\sigma_{f}}\left(\delta_{f}\right)\\ &=p_{\text{probe}}\left(\left.K_{x}=k_{x}\right|K_{y}=k_{y}; \delta_{f}=0\right),\end{split}\]- where \(p_{\sigma_{f}}\left(\delta_{f}\right)\) is the distribution of \(\delta_{f}\): (2.6.1.1.8)\[p_{\sigma_{f}}\left(\delta_{f}\right)=\frac{1}{\sigma_{f}\sqrt{2\pi}} \exp\left(-\frac{1}{2}\frac{\delta_{f}^{2}}{\sigma_{f}^{2}}\right),\]- with \(\sigma_{f}\) being the defocal spread: (2.6.1.1.9)\[\sigma_{f}=C_{c}\sqrt{\left(\frac{\sigma_{E}/e}{V}\right)^{2} +\left(2\frac{\sigma_{I}}{I}\right)^{2} +\left(\frac{\sigma_{V}}{V}\right)^{2}},\]- \(C_c\) being the chromatic aberration coefficient, \(I\) being the mean current of the probe forming lens, \(\sigma_I\) being the standard deviation of the current of the probe forming lens, \(V\) being the mean accelerating voltage, \(e\) being the elementary charge, \(\sigma_V\) being the standard deviation of the accelerating voltage, and \(\sigma_E\) being the standard deviation of the electrons in the gun when operating a voltage supply that does not fluctuate [i.e. \(\sigma_E\) is the intrinsic energy spread of the gun]. The corresponding real-space fractional intensity of the incoherent probe is: (2.6.1.1.10)\[p_{\text{probe}}\left(\left.X=x\right|Y=y\right)= \int_{-\infty}^{\infty}d\delta_{f}\, p_{\sigma_{f}}\left(\delta_{f}\right) p_{\text{probe}}\left(\left.X=x\right|Y=y;\delta_{f}\right).\]- In - embeam, the integral in Eq. (2.6.1.1.10) is numerically evaluated using Gauss-Hermite quadrature:(2.6.1.1.11)\[p_{\text{probe}}\left(\left.X=x\right|Y=y\right)\approx \frac{1}{\sqrt{\pi}}\sum_{l=1}^{N_{f}}w_{f;l} p_{\text{probe}}\left(\left.X=x\right|Y=y; \delta_{f}=\sqrt{2}\sigma_{f}x_{f;l}\right),\]- where \(x_{f;l}\) is the \(l^{\text{th}}\) root of the Physicists’ version of the \(N_{f}^{\text{th}}\) Hermite polynomial \(H_{N_{f}}\left(x\right)\); and \(w_{f;l}\) is the \(l^{\text{th}}\) quadrature weight: (2.6.1.1.12)\[w_{f;l}=\sqrt{\pi} \frac{\tilde{w}_{f;l}}{\sum_{l=1}^{N_{f}}\tilde{w}_{f;l}},\]- with (2.6.1.1.13)\[\tilde{w}_{f;l}=\frac{2^{N_{f}-1}N_{f}!\sqrt{\pi}}{N_{f}^{2} \left\{ H_{N_{f}-1}\left(x_{l}\right)\right\} ^{2}}.\]- Note that the right-hand-side (RHS) of Eq. (2.6.1.1.11) equals the RHS Eq. (2.6.1.1.10) in the limit that \(N_{f}\to\infty\). - Parameters:
- lens_model_paramsembeam.lens.ModelParams| None, optional
- The model parameters of the probe forming lens. If - lens_model_paramsis set to- None[i.e. the default value], then no chromatic or coherent lens aberrations are assumed to be present.
- gun_model_paramsembeam.gun.ModelParams| None, optional
- The electron gun model parameters. If - gun_model_paramsis set to- None[i.e. the default value], then the parameter will be reassigned to the value- embeam.gun.ModelParams().
- convergence_semianglefloat, optional
- The convergence semiangle in mrads. Must be positive. 
- defocal_offset_supersamplingint, optional
- The number of points \(N_f\) to use in the Gauss-Hermite quadrature scheme of Eq. (2.6.1.1.12). Must be positive. 
- skip_validation_and_conversionbool, optional
- Let - validation_and_conversion_funcsand- core_attrsdenote the attributes- validation_and_conversion_funcsand- core_attrsrespectively, both of which being dict objects.- Let - params_to_be_mapped_to_core_attrsdenote the dict representation of the constructor parameters excluding the parameter- skip_validation_and_conversion, where each dict key- keyis a different constructor parameter name, excluding the name- "skip_validation_and_conversion", and- params_to_be_mapped_to_core_attrs[key]would yield the value of the constructor parameter with the name given by- key.- If - skip_validation_and_conversionis set to- False, then for each key- keyin- params_to_be_mapped_to_core_attrs,- core_attrs[key]is set to- validation_and_conversion_funcs[key] (params_to_be_mapped_to_core_attrs).- Otherwise, if - skip_validation_and_conversionis set to- True, then- core_attrsis set to- params_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 of- params_to_be_mapped_to_core_attrs, as it is guaranteed that no copies or conversions are made in this case.
 
- lens_model_params
- Attributes:
- core_attrs
- dict: The “core attributes”. 
- de_pre_serialization_funcs
- dict: The de-pre-serialization functions. 
- is_azimuthally_symmetric
- bool: A boolean variable indicating whether the probe model is 
- is_coherent
- bool: A boolean variable indicating whether the probe model is 
- pre_serialization_funcs
- dict: The pre-serialization functions. 
- validation_and_conversion_funcs
- dict: 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. - execute_post_core_attrs_update_actions - Methods - Construct an instance from a serializable representation. - Serialize instance and save the result in a JSON file. - Serialize instance. - execute_post_core_attrs_update_actions- 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. - bool: A boolean variable indicating whether the probe model is azimuthally symmetric. - bool: A boolean variable indicating whether the probe model is coherent. - 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 attribute- validation_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 attribute- validation_and_conversion_funcs, which is also a dict object.- Let - validation_and_conversion_funcsand- pre_serialization_funcsdenote the attributes- validation_and_conversion_funcs- pre_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 as- validation_and_conversion_funcs, where for each dict key- keyin- core_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 as- core_attrs_candidate_1, where for each dict key- keyin- core_attrs_candidate_1,- serializable_rep[key]is set to- pre_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 to- de_pre_serialization_funcs[key](serializable_rep[key])not raising an exception for each dict key- keyin- serializable_rep.- Let - core_attrs_candidate_2be a dict object that has the same keys as- serializable_rep, where for each dict key- keyin- validation_and_conversion_funcs,- core_attrs_candidate_2[key]is set to- de_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 to- validation_and_conversion_funcs[key](core_attrs_candidate_2)not raising an exception for each dict key- keyin- core_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_funcsand- de_pre_serialization_funcsdenote the attributes- validation_and_conversion_funcs- de_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 to- de_pre_serialization_funcs[key](serializable_rep[key])not raising an exception for each dict key- keyin- serializable_rep.- Let - core_attrs_candidatebe a dict object that has the same keys as- serializable_rep, where for each dict key- keyin- serializable_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 to- validation_and_conversion_funcs[key](core_attrs_candidate)not raising an exception for each dict key- keyin- serializable_rep.
- skip_validation_and_conversionbool, optional
- Let - core_attrsdenote the attribute- core_attrs, which is a dict object.- If - skip_validation_and_conversionis set to- False, then for each key- keyin- serializable_rep,- core_attrs[key]is set to- validation_and_conversion_funcs[key] (core_attrs_candidate), with- validation_and_conversion_funcsand- core_attrs_candidate_1being introduced in the above description of- serializable_rep.- Otherwise, if - skip_validation_and_conversionis set to- True, then- core_attrsis set to- core_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 of- core_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 to- Falseand a file exists at the path- filename, 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 attribute- core_attrs, which is a dict object.- If - deep_copyis set to- True, then a deep copy of- core_attrsis returned. Otherwise, a shallow copy of- core_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.
 
 
 - property is_azimuthally_symmetric
- bool: A boolean variable indicating whether the probe model is azimuthally symmetric. - See the summary documentation of the classes - embeam.coherent.PhaseDeviationand- embeam.coherent.Aberrationfor additional context.- A probe model is azimuthally symmetric if the coherent aberrations of the probe-forming lens are azimuthally symmetric, i.e. if if \(\sum_{m=0}^{\infty}\sum_{n=0}^{\infty} n \left(C_{m,n}^{\text{mag}} C_{m,n}^{\text{ang}}\right)^2=0\). - Note that - is_azimuthally_symmetricshould be considered read-only.
 - property is_coherent
- bool: A boolean variable indicating whether the probe model is coherent. - See the summary documentation of the class - embeam.stem.probe.ModelParamsfor additional context.- If - is_coherentis set to- True, then the probe model is coherent. Otherwise, the probe model is not coherent.- Note that - is_coherentshould be considered read-only.
 - 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 that- json.load(open(filename, "r"))does not raise an exception.- Let - serializable_rep=json.load(open(filename, "r")).- Let - validation_and_conversion_funcsand- de_pre_serialization_funcsdenote the attributes- validation_and_conversion_funcs- de_pre_serialization_funcsrespectively, both of which being dict objects as well.- filenameis also expected to be such that- de_pre_serialization_funcs[key](serializable_rep[key])does not raise an exception for each dict key- keyin- de_pre_serialization_funcs.- Let - core_attrs_candidatebe a dict object that has the same keys as- de_pre_serialization_funcs, where for each dict key- keyin- serializable_rep,- core_attrs_candidate[key]is set to de_pre_serialization_funcs[key](serializable_rep[key])``.- filenameis also expected to be such that- validation_and_conversion_funcs[key](core_attrs_candidate)does not raise an exception for each dict key- keyin- serializable_rep.
- skip_validation_and_conversionbool, optional
- Let - core_attrsdenote the attribute- core_attrs, which is a dict object.- Let - core_attrs_candidatebe as defined in the above description of- filename.- If - skip_validation_and_conversionis set to- False, then for each key- keyin- core_attrs_candidate,- core_attrs[key]is set to- validation_and_conversion_funcs[key] (core_attrs_candidate), , with- validation_and_conversion_funcsand- core_attrs_candidatebeing introduced in the above description of- filename.- Otherwise, if - skip_validation_and_conversionis set to- True, then- core_attrsis set to- core_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 of- core_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 that- json.loads(serialized_rep)does not raise an exception.- Let - serializable_rep=json.loads(serialized_rep).- Let - validation_and_conversion_funcsand- de_pre_serialization_funcsdenote the attributes- validation_and_conversion_funcs- de_pre_serialization_funcsrespectively, both of which being dict objects as well.- serialized_repis also expected to be such that- de_pre_serialization_funcs[key](serializable_rep[key])does not raise an exception for each dict key- keyin- de_pre_serialization_funcs.- Let - core_attrs_candidatebe a dict object that has the same keys as- serializable_rep, where for each dict key- keyin- de_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 that- validation_and_conversion_funcs[key](core_attrs_candidate)does not raise an exception for each dict key- keyin- serializable_rep.
- skip_validation_and_conversionbool, optional
- Let - core_attrsdenote the attribute- core_attrs, which is a dict object.- If - skip_validation_and_conversionis set to- False, then for each key- keyin- core_attrs_candidate,- core_attrs[key]is set to- validation_and_conversion_funcs[key] (core_attrs_candidate), with- validation_and_conversion_funcsand- core_attrs_candidate_1being introduced in the above description of- serialized_rep.- Otherwise, if - skip_validation_and_conversionis set to- True, then- core_attrsis set to- core_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 of- core_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 attribute- validation_and_conversion_funcs, which is also a dict object.- Let - validation_and_conversion_funcsand- core_attrsdenote the attributes- validation_and_conversion_funcsand- core_attrsrespectively, the last of which being a dict object as well.- For each dict key - keyin- core_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 function- json.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)[source]
- 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_funcsand- core_attrsdenote the attributes- validation_and_conversion_funcsand- core_attrsrespectively, both of which being dict objects.- If - skip_validation_and_conversionis set to- False, then for each key- keyin- core_attrsthat is also in- new_core_attr_subset_candidate,- core_attrs[key]is set to- validation_and_conversion_funcs[key] (new_core_attr_subset_candidate).- Otherwise, if - skip_validation_and_conversionis set to- True, then for each key- keyin- core_attrsthat is also in- new_core_attr_subset_candidate,- core_attrs[key]is set to- new_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 of- new_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, excluding- skip_validation_and_conversionif it exists as a construction parameter.- Let - core_attrsdenote the attribute- core_attrs, which is also a dict object.- For each dict key - keyin- core_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.