mlreflect.data_generation package
Submodules
mlreflect.data_generation.data_generator module
- class mlreflect.data_generation.data_generator.ReflectivityGenerator(q_values: numpy.ndarray, sample: mlreflect.data_generation.multilayer.MultilayerStructure, random_seed: Optional[int] = None)[source]
Bases:
object
Generation of simulated reflectivity data and labels for neural network training.
- Parameters
q_values – An array-like object (list, tuple, ndarray, etc.) that contains the q-values in units of 1/Å at which the reflected intensity will be simulated.
sample –
MultilayerStructure
object where the sample layers and their names and parameter ranges are defined.random_seed – Random seed for numpy.random.seed which affects the generation of the random labels (default
None
means random seed).
- generate_random_labels(number_of_samples: int, distribution_type: str = 'bolstered', bolster_fraction: float = 0.15, bolster_width: float = 0.1) pandas.core.frame.DataFrame [source]
Generates random labels in the parameter ranges defined by the sample and returns them as pandas DataFrame.
- Parameters
number_of_samples – Number of label sets that will be generated.
distribution_type – Can be
'bolstered'
(default) or'uniform'
.bolster_fraction – Fraction of simulated samples that will be redistributed to the sides of the distribution.
bolster_width – Width of the Gaussian distribution of the redistributed samples.
- Returns
Pandas DataFrame with the randomly generated labels.
- Return type
labels
- make_sld_profile(thickness: numpy.ndarray, sld: numpy.ndarray, roughness: numpy.ndarray, sld_substrate: float, sld_ambient: float) Tuple[numpy.ndarray, numpy.ndarray] [source]
Generate scattering length density profile in units 1/Å^-2 * 10^-6 with height in units Å.
- Parameters
thickness – ndarray of layer thicknesses in units Å from bottom to top. For no layers (only substrate) provide empty tuple
(,)
.sld – ndarray of layer scattering length densities in units 1/Å^-2 * 10^-6 from bottom to top. For no layers (only substrate) provide empty tuple
(,)
.roughness – ndarray of RMS interface roughnesses in units Å from bottom to top. At least one has to be given.
sld_substrate – Scattering length density of the used substrate in units 1/Å^-2 * 10^-6.
sld_ambient – Scattering length density of the ambient medium in units 1/Å^-2 * 10^-6.
- Returns
Tuple of ndarrays of sample height in units Å and the scattering length density profile in units 1/Å^-2 * 10^-6.
- Return type
height, sld_profile
- static separate_labels_by_category(labels: pandas.core.frame.DataFrame) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] [source]
- simulate_reflectivity(labels: pandas.core.frame.DataFrame, q_noise_spread: float = 0, engine: str = 'refl1d', progress_bar=True) numpy.ndarray [source]
Simulates reflectivity curves for the given labels and returns them as ndarray.
- Parameters
labels – Must a pandas DataFrame with each column representing one label. The label order from left to right must be “thickness”, “roughness” and “scattering length density” with layers from bottom to top. Example for 2 layers:
['thickness_layer1', 'thickness_layer2', 'roughness_layer1', 'roughness_layer2', 'sld_layer1', 'sld_layer2']
q_noise_spread – Standard deviation of the normal distribution of scaling factors (centered at 1) that are applied to each q-value during reflectivity simulation.
engine –
'refl1d'
(default): Uses C++-based simulation from the refl1d package.'builtin'
: Uses the built-in python-based simulation (slower).progress_bar – If True, a tqdm progress bar will be displayed.
labels – Must a pandas DataFrame with each column representing one label.
- Returns
Simulated reflectivity curves.
- Return type
reflectivity_curves
- simulate_sld_profiles(labels: pandas.core.frame.DataFrame, progress_bar=True) List[numpy.ndarray] [source]
Simulates real scattering length density profiles for the given labels and returns them as ndarray.
- Parameters
labels – Must be pandas DataFrame with each column representing one label. The label order from left to right must be “thickness”, “roughness” and “scattering length density” with layers from bottom to top. Example for 2 layers:
['thickness_layer1', 'thickness_layer2', 'roughness_layer1', 'roughness_layer2', 'sld_layer1', 'sld_layer2']
progress_bar – If True, a tqdm progress bar will be displayed.
- Returns
List of ndarray of simulated scattering length density profiles (real part).
- Return type
sld_profiles
mlreflect.data_generation.distributions module
- mlreflect.data_generation.distributions.bolstered_uniform_distribution(min_value: float, max_value: float, n_samples: int, bolster_fraction: float, bolster_width: float) Union[float, numpy.ndarray] [source]
Sample from a modified uniform distribution that has a higher sampling density at the limits
- Parameters
min_value – lower limit of the distribution
max_value – upper limit of the distribution
n_samples – number of samples drawn from the distribution
bolster_fraction – fraction of samples that are drawn around the limits (instead of uniformly)
bolster_width – width of the normal distribution that is sampled from around both limits
- Returns
ndarray
- Return type
samples
- mlreflect.data_generation.distributions.random_logarithmic_distribution(min_value: float, max_value: float, n_values: float) Union[float, numpy.ndarray] [source]
Sample uniformly from a logarithmic distribution.
- mlreflect.data_generation.distributions.sample_distribution(number_of_values: int, **kwargs) Union[float, numpy.ndarray] [source]
Sample from the specified distribution
- Parameters
number_of_values – number of samples values
**kwargs – distribution_type: ‘uniform’, ‘logarithmic’ or ‘bolstered’ min_value, max_value: float limits of the distribution bolster_fraction: float fraction of samples that are redistributed to the limits bolster_width: width of the normal distribution of the redistributed samples
- Returns
ndarray
- Return type
samples
mlreflect.data_generation.layers module
- class mlreflect.data_generation.layers.AmbientLayer(name: str, sld: Union[float, complex, mlreflect.data_generation.parameters.ConstantParameter])[source]
Bases:
mlreflect.data_generation.layers.ConstantLayer
- property ranges
- class mlreflect.data_generation.layers.ConstantLayer(name: str, thickness: Union[float, mlreflect.data_generation.parameters.ConstantParameter], roughness: Union[float, mlreflect.data_generation.parameters.ConstantParameter], sld: Union[float, complex, mlreflect.data_generation.parameters.ConstantParameter])[source]
Bases:
mlreflect.data_generation.layers.Layer
Defines the name and constant parameter values of a single sample layer.
- Parameters
name – User defined name of this layer.
thickness – Thickness of this layer in units of Å. Must be a float or int.
roughness – Roughness of this layer in units of Å. Must be a float or int.
sld – Scattering length density (SLD) of this layer in units of 1e-6 1/Å^2. Must be a float or int.
- Returns
Layer object
- property ranges
- class mlreflect.data_generation.layers.Layer(name: str, thickness: Union[float, Iterable, mlreflect.data_generation.parameters.Parameter], roughness: Union[float, Iterable, mlreflect.data_generation.parameters.Parameter], sld: Union[float, complex, Iterable, mlreflect.data_generation.parameters.Parameter])[source]
Bases:
object
Defines the name and parameter ranges of a single sample layer.
- Parameters
name – User defined name of this layer.
thickness – Thickness of this layer in units of Å. Can be a float for a constant vale or a tuple for a range.
roughness – Roughness of this layer in units of Å. Can be a float for a constant vale or a tuple for a range.
sld – Scattering length density (SLD) of this layer in units of 1e-6 1/Å^2. Can be a float for a constant vale or a tuple for a range.
- Returns
Layer object
- property ranges
- class mlreflect.data_generation.layers.Substrate(name: str, roughness: Union[float, mlreflect.data_generation.parameters.ConstantParameter], sld: Union[float, complex, mlreflect.data_generation.parameters.ConstantParameter])[source]
Bases:
mlreflect.data_generation.layers.ConstantLayer
- property ranges
mlreflect.data_generation.model_mixer module
- class mlreflect.data_generation.model_mixer.ModelMixer(q_values)[source]
Bases:
object
Simulate reflectivity curves from given labels with different models with given probabilities.
- Parameters
q_values – An array-like object (list, tuple, ndarray, etc.) that contains the q-values in units of 1/Å at which the reflected intensity will be simulated.
- property model_weights
- property q
- property sample_models
mlreflect.data_generation.multilayer module
- class mlreflect.data_generation.multilayer.LayerOnSubstrate[source]
Bases:
mlreflect.data_generation.multilayer.MultilayerStructure
Defines the structure of a multilayer sample through one or multiple
Layer
objects and an ambient SLD.Can only contain one non-constant layer of class Layer, all others must be of class ConstantLayer.
Initializes with a default ambient and substrate layer.
- Returns
MultilayerStructure
- add_layer(layer: Union[mlreflect.data_generation.layers.Layer, mlreflect.data_generation.layers.ConstantLayer], index: Union[str, int] = 'next')[source]
Add layer at given index position. If
index='next'
(default) layer is appended (added on top).
- property has_variable_layer
- class mlreflect.data_generation.multilayer.MultilayerStructure[source]
Bases:
object
Defines the structure of a multilayer sample through one or multiple
Layer
objects and an ambient SLD.Initializes with a default ambient and substrate layer.
- Returns
MultilayerStructure
- add_layer(layer: mlreflect.data_generation.layers.Layer, index: Union[str, int] = 'next')[source]
Add layer at given index position. If
index='next'
(default) layer is appended (added on top).
- property ambient_layer
- from_dict(sample_dict: dict)[source]
Set the layers in the MultilayerStructure according to the dictionary representation.
- property label_names: List[str]
Get list of all layer names in order.
- move_layer(from_index: int, to_index: int)[source]
Moves layer with given index to new index, shifting all layers with equal or higher index up.
- property roughnesses: list
- set_ambient_layer(ambient_layer: mlreflect.data_generation.layers.AmbientLayer)[source]
Set the ambient layer.
- set_substrate(substrate: mlreflect.data_generation.layers.Substrate)[source]
Set the substrate layer.
- property slds: list
- property substrate
- swap_layers(from_index: int, to_index: int)[source]
Swaps the position of the two layers given by
from_index
andto_index
.
- property thicknesses: list
mlreflect.data_generation.noise module
- mlreflect.data_generation.noise.apply_poisson_noise(reflectivity_curves: numpy.ndarray, rate_spread: Union[float, Tuple[float, float]]) Tuple[numpy.ndarray, numpy.ndarray] [source]
Returns reflectivity curves with applied shot noise based on shot_noise_spread.
- Parameters
reflectivity_curves – Array of normalized reflectivity curves
rate_spread – Scaling factor c for the standard deviation sqrt(I*c) of the shot noise around the intensity of simulated reflectivity curves. Since the intensity is normalized, this is equivalent to setting the direct beam intensity I_0 = 1/c. If a tuple with two values is given, a random value between the two is chosen for each curve.
- Returns
noisy_reflectivity, spreads
- mlreflect.data_generation.noise.apply_shot_noise(reflectivity_curves: numpy.ndarray, shot_noise_spread: Union[float, Tuple[float, float]]) Tuple[numpy.ndarray, numpy.ndarray] [source]
Returns reflectivity curves with applied shot noise based on shot_noise_spread.
- Parameters
reflectivity_curves – Array of normalized reflectivity curves
shot_noise_spread – Scaling factor c for the standard deviation sqrt(I*c) of the shot noise around the intensity of simulated reflectivity curves. Since the intensity is normalized, this is equivalent to setting the direct beam intensity I_0 = 1/c. If a tuple with two values is given, a random value between the two is chosen for each curve.
- Returns
noisy_reflectivity, spreads
- mlreflect.data_generation.noise.generate_background(number_of_curves: int, number_of_q_values: int, background_base_level: Union[float, Tuple[float, float]], relative_background_spread: float) Tuple[numpy.ndarray, numpy.ndarray] [source]
Returns a background with a normal distribution that can be added to a reflectivity curve.
- Parameters
number_of_curves – Number of curves for which a background is generated
number_of_q_values – Length of the generated array (should be same length as reflectivity curve)
background_base_level – Range from which the mean of the normal distribution is chosen
relative_background_spread – Relative standard deviation of the normal distribution (e.g. a value of
0.1
means the standard deviation is 10% of the mean)
- Returns
background has dimensions
(number_of_curves, number_of_q_values)
- Return type
background, means
mlreflect.data_generation.parameters module
- class mlreflect.data_generation.parameters.ConstantParameter(value, name: Optional[str] = None)[source]
Bases:
mlreflect.data_generation.parameters.Parameter
Defines a constant parameter that can be sampled to generate random training data.
- Parameters
value – value of the parameter
name – optional name for the parameter (usually ‘thickness’, ‘roughness’ or ‘sld’)
- property max
- property min
- sample(number_of_values: int, **distribution_params)[source]
Returns ndarray with number_of_values repetitions of the parameter value.
- property value
- class mlreflect.data_generation.parameters.Parameter(min_value, max_value, name: Optional[str] = None)[source]
Bases:
object
Defines a parameter range that can be sampled to generate random training data.
- Parameters
min_value – minimum value of the parameter range
max_value – maximum value of the parameter range
name – optional name for the parameter (usually ‘thickness’, ‘roughness’ or ‘sld’)
- sample(number_of_values: int, distribution_type: str = 'uniform', **distribution_params)[source]
Samples random values in the given parameter range with the specified distribution.
- Parameters
number_of_values – number of sampled values
distribution_type – distribution type ‘uniform’ is numpy.random.uniform(). ‘logarithmic’ is a uniformly sampled on a logarithmic scale. ‘bolstered’ is a uniform distribution where the sampling density is shifted towards both ends of the range.
**distribution_params – catch-all for all parameters concerning the specified distribution min_value, max_value: float limits of the distribution bolster_fraction: float fraction of samples that are redistributed to the limits bolster_width: width of the normal distribution of the redistributed samples
- Returns
ndarray
- Return type
samples
- property value
mlreflect.data_generation.reflectivity module
- mlreflect.data_generation.reflectivity.multilayer_reflectivity(q_values: Iterable, thickness: Iterable, roughness: Iterable, scattering_length_density: Iterable, ambient_sld: float = 0.0)[source]
Returns a normalized reflectivity curve for a set of stacked layers with the given parameters.
- Parameters
q_values – An array-like object (list, tuple, ndarray, etc.) that contains the q-values in SI base units (i.e. 1/m) at which the reflected intensity will be simulated.
thickness – An array-like object (list, tuple, ndarray, etc.) that contains the thicknesses of the sample layers in SI base units (i.e. m) in order from bottom to top excluding the bottom most layer (substrate).
roughness – An array-like object (list, tuple, ndarray, etc.) that contains the roughnesses of the sample interfaces in SI base units (i.e. m) in order from bottom to top.
scattering_length_density – An array-like object (list, tuple, ndarray, etc.) that contains the scattering length densities of the sample layers in SI base units (i.e. 1/m^2) in order from bottom to top (excluding the ambient SLD).
ambient_sld – Scattering length density of the ambient environment (above the top most layer).
- Returns
ndrray of simulated intensity values with same length as
q_values
.
Example
The following code can be used to simulate the reflectivity of a model with two layers with 100 and 250 Å thickness on a substrate.
``` q = np.linspace(0.01, 0.20, 1001) * 1e10 ambient_sld = 0 thickness = np.array([100, 250]) * 1e-10 roughness = np.array([3, 11, 5]) * 1e-10 sld = np.array([12 + 0.012j, 2.36 + 0j, 4.2 + 0.016j]) * 1e14
- simulated_curve = multilayer_reflectivity(q_values=q, thickness=thickness, roughness=roughness,
scattering_length_density=sld, ambient_sld=ambient_sld)
Module contents
- class mlreflect.data_generation.AmbientLayer(name: str, sld: Union[float, complex, mlreflect.data_generation.parameters.ConstantParameter])[source]
Bases:
mlreflect.data_generation.layers.ConstantLayer
- property ranges
- class mlreflect.data_generation.ConstantLayer(name: str, thickness: Union[float, mlreflect.data_generation.parameters.ConstantParameter], roughness: Union[float, mlreflect.data_generation.parameters.ConstantParameter], sld: Union[float, complex, mlreflect.data_generation.parameters.ConstantParameter])[source]
Bases:
mlreflect.data_generation.layers.Layer
Defines the name and constant parameter values of a single sample layer.
- Parameters
name – User defined name of this layer.
thickness – Thickness of this layer in units of Å. Must be a float or int.
roughness – Roughness of this layer in units of Å. Must be a float or int.
sld – Scattering length density (SLD) of this layer in units of 1e-6 1/Å^2. Must be a float or int.
- Returns
Layer object
- property ranges
- class mlreflect.data_generation.ConstantParameter(value, name: Optional[str] = None)[source]
Bases:
mlreflect.data_generation.parameters.Parameter
Defines a constant parameter that can be sampled to generate random training data.
- Parameters
value – value of the parameter
name – optional name for the parameter (usually ‘thickness’, ‘roughness’ or ‘sld’)
- property max
- property min
- sample(number_of_values: int, **distribution_params)[source]
Returns ndarray with number_of_values repetitions of the parameter value.
- property value
- class mlreflect.data_generation.Layer(name: str, thickness: Union[float, Iterable, mlreflect.data_generation.parameters.Parameter], roughness: Union[float, Iterable, mlreflect.data_generation.parameters.Parameter], sld: Union[float, complex, Iterable, mlreflect.data_generation.parameters.Parameter])[source]
Bases:
object
Defines the name and parameter ranges of a single sample layer.
- Parameters
name – User defined name of this layer.
thickness – Thickness of this layer in units of Å. Can be a float for a constant vale or a tuple for a range.
roughness – Roughness of this layer in units of Å. Can be a float for a constant vale or a tuple for a range.
sld – Scattering length density (SLD) of this layer in units of 1e-6 1/Å^2. Can be a float for a constant vale or a tuple for a range.
- Returns
Layer object
- property ranges
- class mlreflect.data_generation.LayerOnSubstrate[source]
Bases:
mlreflect.data_generation.multilayer.MultilayerStructure
Defines the structure of a multilayer sample through one or multiple
Layer
objects and an ambient SLD.Can only contain one non-constant layer of class Layer, all others must be of class ConstantLayer.
Initializes with a default ambient and substrate layer.
- Returns
MultilayerStructure
- add_layer(layer: Union[mlreflect.data_generation.layers.Layer, mlreflect.data_generation.layers.ConstantLayer], index: Union[str, int] = 'next')[source]
Add layer at given index position. If
index='next'
(default) layer is appended (added on top).
- property has_variable_layer
- class mlreflect.data_generation.MultilayerStructure[source]
Bases:
object
Defines the structure of a multilayer sample through one or multiple
Layer
objects and an ambient SLD.Initializes with a default ambient and substrate layer.
- Returns
MultilayerStructure
- add_layer(layer: mlreflect.data_generation.layers.Layer, index: Union[str, int] = 'next')[source]
Add layer at given index position. If
index='next'
(default) layer is appended (added on top).
- property ambient_layer
- from_dict(sample_dict: dict)[source]
Set the layers in the MultilayerStructure according to the dictionary representation.
- property label_names: List[str]
Get list of all layer names in order.
- move_layer(from_index: int, to_index: int)[source]
Moves layer with given index to new index, shifting all layers with equal or higher index up.
- property roughnesses: list
- set_ambient_layer(ambient_layer: mlreflect.data_generation.layers.AmbientLayer)[source]
Set the ambient layer.
- set_substrate(substrate: mlreflect.data_generation.layers.Substrate)[source]
Set the substrate layer.
- property slds: list
- property substrate
- swap_layers(from_index: int, to_index: int)[source]
Swaps the position of the two layers given by
from_index
andto_index
.
- property thicknesses: list
- class mlreflect.data_generation.Parameter(min_value, max_value, name: Optional[str] = None)[source]
Bases:
object
Defines a parameter range that can be sampled to generate random training data.
- Parameters
min_value – minimum value of the parameter range
max_value – maximum value of the parameter range
name – optional name for the parameter (usually ‘thickness’, ‘roughness’ or ‘sld’)
- sample(number_of_values: int, distribution_type: str = 'uniform', **distribution_params)[source]
Samples random values in the given parameter range with the specified distribution.
- Parameters
number_of_values – number of sampled values
distribution_type – distribution type ‘uniform’ is numpy.random.uniform(). ‘logarithmic’ is a uniformly sampled on a logarithmic scale. ‘bolstered’ is a uniform distribution where the sampling density is shifted towards both ends of the range.
**distribution_params – catch-all for all parameters concerning the specified distribution min_value, max_value: float limits of the distribution bolster_fraction: float fraction of samples that are redistributed to the limits bolster_width: width of the normal distribution of the redistributed samples
- Returns
ndarray
- Return type
samples
- property value
- class mlreflect.data_generation.ReflectivityGenerator(q_values: numpy.ndarray, sample: mlreflect.data_generation.multilayer.MultilayerStructure, random_seed: Optional[int] = None)[source]
Bases:
object
Generation of simulated reflectivity data and labels for neural network training.
- Parameters
q_values – An array-like object (list, tuple, ndarray, etc.) that contains the q-values in units of 1/Å at which the reflected intensity will be simulated.
sample –
MultilayerStructure
object where the sample layers and their names and parameter ranges are defined.random_seed – Random seed for numpy.random.seed which affects the generation of the random labels (default
None
means random seed).
- generate_random_labels(number_of_samples: int, distribution_type: str = 'bolstered', bolster_fraction: float = 0.15, bolster_width: float = 0.1) pandas.core.frame.DataFrame [source]
Generates random labels in the parameter ranges defined by the sample and returns them as pandas DataFrame.
- Parameters
number_of_samples – Number of label sets that will be generated.
distribution_type – Can be
'bolstered'
(default) or'uniform'
.bolster_fraction – Fraction of simulated samples that will be redistributed to the sides of the distribution.
bolster_width – Width of the Gaussian distribution of the redistributed samples.
- Returns
Pandas DataFrame with the randomly generated labels.
- Return type
labels
- make_sld_profile(thickness: numpy.ndarray, sld: numpy.ndarray, roughness: numpy.ndarray, sld_substrate: float, sld_ambient: float) Tuple[numpy.ndarray, numpy.ndarray] [source]
Generate scattering length density profile in units 1/Å^-2 * 10^-6 with height in units Å.
- Parameters
thickness – ndarray of layer thicknesses in units Å from bottom to top. For no layers (only substrate) provide empty tuple
(,)
.sld – ndarray of layer scattering length densities in units 1/Å^-2 * 10^-6 from bottom to top. For no layers (only substrate) provide empty tuple
(,)
.roughness – ndarray of RMS interface roughnesses in units Å from bottom to top. At least one has to be given.
sld_substrate – Scattering length density of the used substrate in units 1/Å^-2 * 10^-6.
sld_ambient – Scattering length density of the ambient medium in units 1/Å^-2 * 10^-6.
- Returns
Tuple of ndarrays of sample height in units Å and the scattering length density profile in units 1/Å^-2 * 10^-6.
- Return type
height, sld_profile
- static separate_labels_by_category(labels: pandas.core.frame.DataFrame) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] [source]
- simulate_reflectivity(labels: pandas.core.frame.DataFrame, q_noise_spread: float = 0, engine: str = 'refl1d', progress_bar=True) numpy.ndarray [source]
Simulates reflectivity curves for the given labels and returns them as ndarray.
- Parameters
labels – Must a pandas DataFrame with each column representing one label. The label order from left to right must be “thickness”, “roughness” and “scattering length density” with layers from bottom to top. Example for 2 layers:
['thickness_layer1', 'thickness_layer2', 'roughness_layer1', 'roughness_layer2', 'sld_layer1', 'sld_layer2']
q_noise_spread – Standard deviation of the normal distribution of scaling factors (centered at 1) that are applied to each q-value during reflectivity simulation.
engine –
'refl1d'
(default): Uses C++-based simulation from the refl1d package.'builtin'
: Uses the built-in python-based simulation (slower).progress_bar – If True, a tqdm progress bar will be displayed.
labels – Must a pandas DataFrame with each column representing one label.
- Returns
Simulated reflectivity curves.
- Return type
reflectivity_curves
- simulate_sld_profiles(labels: pandas.core.frame.DataFrame, progress_bar=True) List[numpy.ndarray] [source]
Simulates real scattering length density profiles for the given labels and returns them as ndarray.
- Parameters
labels – Must be pandas DataFrame with each column representing one label. The label order from left to right must be “thickness”, “roughness” and “scattering length density” with layers from bottom to top. Example for 2 layers:
['thickness_layer1', 'thickness_layer2', 'roughness_layer1', 'roughness_layer2', 'sld_layer1', 'sld_layer2']
progress_bar – If True, a tqdm progress bar will be displayed.
- Returns
List of ndarray of simulated scattering length density profiles (real part).
- Return type
sld_profiles
- class mlreflect.data_generation.Substrate(name: str, roughness: Union[float, mlreflect.data_generation.parameters.ConstantParameter], sld: Union[float, complex, mlreflect.data_generation.parameters.ConstantParameter])[source]
Bases:
mlreflect.data_generation.layers.ConstantLayer
- property ranges
- mlreflect.data_generation.interp_reflectivity(q_interp, q, reflectivity)[source]
Interpolate data on a base10 logarithmic scale.
- mlreflect.data_generation.multilayer_reflectivity(q_values: Iterable, thickness: Iterable, roughness: Iterable, scattering_length_density: Iterable, ambient_sld: float = 0.0)[source]
Returns a normalized reflectivity curve for a set of stacked layers with the given parameters.
- Parameters
q_values – An array-like object (list, tuple, ndarray, etc.) that contains the q-values in SI base units (i.e. 1/m) at which the reflected intensity will be simulated.
thickness – An array-like object (list, tuple, ndarray, etc.) that contains the thicknesses of the sample layers in SI base units (i.e. m) in order from bottom to top excluding the bottom most layer (substrate).
roughness – An array-like object (list, tuple, ndarray, etc.) that contains the roughnesses of the sample interfaces in SI base units (i.e. m) in order from bottom to top.
scattering_length_density – An array-like object (list, tuple, ndarray, etc.) that contains the scattering length densities of the sample layers in SI base units (i.e. 1/m^2) in order from bottom to top (excluding the ambient SLD).
ambient_sld – Scattering length density of the ambient environment (above the top most layer).
- Returns
ndrray of simulated intensity values with same length as
q_values
.
Example
The following code can be used to simulate the reflectivity of a model with two layers with 100 and 250 Å thickness on a substrate.
``` q = np.linspace(0.01, 0.20, 1001) * 1e10 ambient_sld = 0 thickness = np.array([100, 250]) * 1e-10 roughness = np.array([3, 11, 5]) * 1e-10 sld = np.array([12 + 0.012j, 2.36 + 0j, 4.2 + 0.016j]) * 1e14
- simulated_curve = multilayer_reflectivity(q_values=q, thickness=thickness, roughness=roughness,
scattering_length_density=sld, ambient_sld=ambient_sld)