Layers Class#

Layers give physical information for each layer in a slab model (such as thickness, SLD, roughness and hydration). Layers can be added as a group or individually. When added as a group, addLayerGroup method in projectClass iterates over the list of layers and adds them one by one using addLayer method which is used to add individual layers.

class API.projectClass.layersClass#

layersClass manages the layers for the project. It provides methods to add, update and remove layers. Each layer is stored as a row in a table and consists of a name, the thickness, the SLD, the roughness, the percent hydration, and whether the layer is hydrated with “bulk” in or “bulk out”. If the absorption is set to true, the SLD column is split into ‘SLD Imaginary’, and ‘SLD Real’.

Parameters:

SLDValues (cell string, default: 'SLD') – The name(s) of the SLD column(s).

varTable#

The table which contains the properties for each layer.

Type:

table

addLayer(paramNames, varargin)#

Adds a new layer to the layers table. This method can be called in 2 ways. The first for when absorption is false

addLayer(paramNames, name, thickness, realSLD, roughness, hydration, hydrateWith)

and the second includes an extra argument imaginarySLD for when absorption is true.

addLayer(paramNames, name, thickness, realSLD, imaginarySLD, roughness, hydration, hydrateWith)

Examples

To add a new layer with name only.

>>> parameterNames = project.getAllAllowedNames().paramNames;
>>> layers.addLayer(parameterNames, 'New layer');

To add a new layer when absorption is false.

>>> layers.addLayer(parameterNames, 'Water Layer', 'Water thickness', 'Water SLD', 'Bilayer heads roughness', 'Water hydration', 'Bulk out');

To add a new layer when absorption is true.

>>> layers.addLayer(parameterNames, 'Layer 1', 'Layer thickness', 'Layer Real SLD', 'Layer Imaginary SLD', 'Layers roughness, 'Layer hydration', 'Bulk in');
Parameters:
  • paramNames (cell) – A cell array which contains the names of available parameters.

  • name (string or char array, default: auto-generated name) – The name of this layer.

  • thickness (string or char array or whole number, default: '') – The name (or the row index) of the parameter describing the thickness of this layer.

  • realSLD (string or char array or whole number, default: '') – The name (or the row index) of the parameter describing the real (scattering) term for the scattering length density of this layer.

  • imaginarySLD (string or char array or whole number, default: '') – The name (or the row index) of the parameter describing the imaginary (absorption) term for the scattering length density of this layer.

  • roughness (string or char array or whole number, default: '') – The name (or the row index) of the parameter describing the roughness of this layer.

  • hydration (string or char array or whole number, default: '') – The name (or the row index) of the parameter describing the percent hydration for the layer

  • hydrateWith (hydrationTypes, default: hydrationTypes.BulkOut) – Whether the layer is hydrated with the “bulk in” or “bulk out”.

removeLayer(row)#

Removes a given layer from the table.

Examples

To remove the second layer in the table (layer in row 2).

>>> layers.removeLayer(2);

To remove layer with a specific name.

>>> layers.removeLayer('D2O');
Parameters:

row (string or char array or whole number) – If row is an integer, it is the row number of the layer to remove. If it is text, it is the name of the layer to remove.

setLayer(row, paramNames, options)#

Update properties of an existing layer. Any unset property will remain unchanged.

Examples

To update the thickness of the second layer in the table (layer in row 2).

>>> parameterNames = project.getAllAllowedNames().paramNames;
>>> layers.setLayer(2, paramNames, thickness='New thickness');

To change the properties of a layer called ‘Layer 1’.

>>> layers.setLayer('Layer 1', paramNames, name='new layer', thickness='New thickness', sld='Layer SLD');

To change the imaginary SLD when absorption is true.

>>> layers.setLayer('Layer 1', paramNames, name='new layer', thickness='New thickness', realSLD='Layer SLD', imaginarySLD='Layer Imaginary SLD');
Parameters:
  • row (string or char array or whole number) – If row is an integer, it is the row of the layer to update. If it is text, it is the name of the layer to update.

  • paramNames (cell) – A cell array which contains the names of available parameters.

  • options

    Keyword/value pair to properties to update for the specific parameter.
    • name (string or char array or whole number, default: ‘’) the new name of the layer.

    • thickness (string or char array or whole number, default: ‘’) The name (or the row index) of the parameter describing the thickness of this layer.

    • sld, realSLD (string or char array or whole number, default: ‘’) The name (or the row index) of the parameter describing the real (scattering) term of the SLD.

    • imaginarySLD (string or char array or whole number, default: ‘’) the new name (or the row index) of the parameter describing the imaginary (absorption) term of the SLD.

    • roughness (string or char array or whole number, default: ‘’) the new name (or the row index) of the parameter describing the roughness of this layer.

    • hydration (string or char array or whole number, default: ‘’) the new name (or the row index) of the parameter describing the percent hydration for the layer

    • hydrateWith (hydrationTypes, default: hydrationTypes.empty()) whether the layer is hydrated with the “bulk in” or “bulk out”.

toStruct(paramNames)#

Converts the layersClass content into a structure array.

Examples

>>> parameterNames = project.parameters.getNames();
>>> layerStruct = layers.toStruct(parameterNames);
Parameters:

paramNames (cell) – A cell array which contains the names of available parameters.

Returns:

layerStruct – A struct which contains the properties for all the layers.

Return type:

struct