Data Tree element which can be filtered by ids
The children branches of this data tree node are all tagged with one or several "Id"s.
The branches can then be accessed via the id
argument of the get_index() method.
Note: If one branch is tagged with a list of several "Id"s, any of these "Id"s in the last can be used to access the tagged branch.
Definition at line 18 of file IdMapNode.m.
Public Member Functions | |
IdMapNode (idmap, initvalues, mergefun) | |
constructor for an IdMapNode mapping the children nodes with "Id" tags. More... | |
function data = | get (index) |
Access to a child of the current node. More... | |
function index = | get_index (id, mu, nt) |
Obtains the leaf index vector that best fits the child description given by the three arguments. More... | |
function tree = | create_tree (creator, ids, mu_cube, tslice, basepath) |
Creates a new tree from a subtree specified by ids, parameter and time index regions. More... | |
function this = | set (i, value, mergefun) |
sets a new value at a specific child branch More... | |
function scalar = | scalar (mergefun) |
reduces the data tree values with help of the mergefun More... | |
function ids = | get_all_ids () |
returns all "Id" strings in this IdMapNode. More... | |
function st = | get_flat_struct () |
makes a struct from the data tree with field names equal to the "Id" names. More... | |
function str = | num2str () |
converts the data tree into a string More... | |
function this = | minus (scalar) |
substracts a scalar from each of the values in the data tree. More... | |
function | display () |
prints out a string representation of the data tree. | |
Public Member Functions inherited from DataTree.DefaultNode | |
function
children = | length () |
Returns the number of children of the node. More... | |
function this = | set (index, value) |
Sets a child at the given path in the tree hierarchy. More... | |
Public Member Functions inherited from DataTree.INode | |
virtual function DataTree.INode tree = | create_tree (DataTree.ICreator creator, ids, mu_cube, tslice, basepath) |
Creates a new tree from a subtree specified by ids, parameter and time index regions. More... | |
function | leaf_func (funcptr, ids, mu_cube, tslice) |
applies a function to all leafs of a DataTree More... | |
function tree = | create_scalar_tree (funcptr, ids, mu_cube, tslice) |
copies the current trees with different leafs. These leafs are computes by a function returning scalar values. More... | |
function
start_index = | traverse_start () |
Start iterator for a full traverse of the DataTree. More... | |
function
next_index = | traverse_next (this_index) |
iterator for a full traverse of the DataTree. More... | |
function
description = | get_active_leaf_description (IModel model, ids) |
returns an enumeration of all leaves' basepath index vectors with a description of their parents. More... | |
function
description = | get_leaf_description (ids, mu_cube, tslice) |
returns an enumeration of all leaves' basepath index vectors with a description of their parents. More... | |
function tstop = | index_valid_till (index) |
Returns the last valid time step index of a time slice. More... | |
function INode data = | get_by_description (id, mu, nt) |
A combination of get_index() and get() More... | |
function
active_leaf_index = | get_active_leaf_index (IModel model, id) |
retuns the leaf element index for the current IDetailedModel configuration. More... | |
function
DataTree.LeafNode active_leaf = | get_active_leaf (IModel model, id) |
retuns the leaf element for the current IDetailedModel configuration. More... | |
function | display (fn, basepath, name) |
overwrites the standard display method for DataTree objects More... | |
function lines = | disp_node (basepath, fn) |
returns a cell array of strings with information on the node. More... | |
Static Public Member Functions | |
static function flatca = | flatten_cell_array (ca) |
flattens a cell array, i.e. returns a cell without cell entries which are cell arrays by itself. More... | |
static function idname = | name_from_idmap (idmap) |
creates a string representation of an "Id"-map More... | |
Public Attributes | |
idmap | |
cell array of "Id" strings More... | |
Public Attributes inherited from DataTree.DefaultNode | |
values = "[]" | |
cell array of DataTree.INode elements, holding the childrens of this DataTree.INode. More... | |
Static Public Attributes | |
static const | data_node_type = "IdMap" |
Data node type identifier. More... | |
DataTree.IdMapNode.IdMapNode | ( | idmap, | |
initvalues, | |||
mergefun | |||
) |
constructor for an IdMapNode mapping the children nodes with "Id" tags.
The constructor runs in Flat-mode, if a mergefun
is given or if initvalues
is a cell array. Otherwise, it runs in Recursive-mode.
initvalues
are wrapped by a DataTree.DummyLeafNode if they are not derived from a DataTree.INode.idmap | a cell array of "Id" strings that are tagged to the children of this node. These "Id"s can also be nested, which either leads to a child tagged with more than one "Id"s or a recursively build tree of IdMapNode nodes. See the explanation of Flat-mode and Recursive-Mode for details. |
initvalues | This can be
|
mergefun | This is a function pointer to a function expecting a cell array of values as an argument and returning an arbitrary value. This function pointer is used, in case the constructor runs in Flat-mode and the initvalues are given as an IdMapNode or a struct. For children tagged with several "Id"s id1, ..., idn , mergefun can be used to compute a value for this child from the cell array {initvalues.id1,..., initvalues.idn} . If mergefun is set to [] , a default function @(x) x{1};
|
Definition at line 74 of file IdMapNode.m.
function tree = DataTree.IdMapNode.create_tree | ( | creator, | |
ids, | |||
mu_cube, | |||
tslice, | |||
basepath | |||
) |
Creates a new tree from a subtree specified by ids, parameter and time index regions.
The method creates a new DataTree for all nodes tagged by an id in ids, lying in the time slice given by tslice and inside the parameter space region given by mu_rect. At each of these nodes a method from a creator is called to build the tree.
creator | an object creating the new tree. |
ids | a cell array of ids which shall be filtered. An empty cell array means that all ids are accepted. (default = []) |
mu_cube | a 1x2 -cell array of vectors { lower_left, upper_right } specifying the lower left and the upper right corner of a cube in the parameter space for filtering parameter vectors. An empty array disables the filtering (default = []). |
tslice | a 2D vector specifying an interval of time step indices for time slicing. An empty vector disables the filtering (default = []) |
basepath | a vector specifying the relation of the current node to the parent node at which the merge began. |
tree | the newly created tree |
Calls DataTree.Creator.create_idmap_node() to build new elements.
Definition at line 243 of file IdMapNode.m.
|
static |
flattens a cell array, i.e. returns a cell without cell entries which are cell arrays by itself.
ca | a cell array |
flatca | the flattended cell array |
Definition at line 531 of file IdMapNode.m.
|
virtual |
Access to a child of the current node.
Access a children node by an index which is usually retrieved by a call to get_index()
index | vector describing the father-child relation |
data | the children node |
Reimplemented from DataTree.DefaultNode.
Definition at line 188 of file IdMapNode.m.
function ids = DataTree.IdMapNode.get_all_ids | ( | ) |
returns all "Id" strings in this IdMapNode.
ids | a cell array of strings with the "Id"s in this data tree. |
Definition at line 382 of file IdMapNode.m.
function st = DataTree.IdMapNode.get_flat_struct | ( | ) |
makes a struct from the data tree with field names equal to the "Id" names.
st | flat struct as described above |
Definition at line 397 of file IdMapNode.m.
|
virtual |
Obtains the leaf index vector that best fits the child description given by the three arguments.
id | id string filtered by this node or another IdMapNode instance. |
mu | a parameter vector filtered through a DataTree.PpartNode instance in the tree hierarchy. |
nt | an integer corresponding to a time step index filtered through a DataTree.TpartNode instance in the tree hierarchy. |
index | index vector for the element which is filter by the argument triple. If none such element exists, empty vector. |
Reimplemented from DataTree.DefaultNode.
Definition at line 210 of file IdMapNode.m.
function this = DataTree.IdMapNode.minus | ( | scalar | ) |
substracts a scalar from each of the values in the data tree.
This function assumes, that the IdMapNode has only leaf children.
scalar | The scalar to substract from the leaf values. |
this | handle to the changed IdMapNode. |
Definition at line 434 of file IdMapNode.m.
|
static |
creates a string representation of an "Id"-map
idmap | a cell array of strings |
idname | a string of all "Id"s concatenated with the _ character. |
Definition at line 598 of file IdMapNode.m.
function str = DataTree.IdMapNode.num2str | ( | ) |
converts the data tree into a string
str | a string representation of the data tree |
Definition at line 414 of file IdMapNode.m.
function scalar = DataTree.IdMapNode.scalar | ( | mergefun | ) |
reduces the data tree values with help of the mergefun
mergefun | This is a function pointer to a function expecting a cell array of values as an argument and returning an arbitrary value. For children tagged with several "Id"s id1, ..., idn , mergefun can be used to compute a single value for all thes children values. It gathers the values { values1, ..., valuesn } in a cell array and applies the mergefun on it. The result is returned. The algorithm is run recursively, such that the leaf-level is reduced first, and the upper level's values are reduced. If mergefun is set to [] , a default function @(x) x{1};
|
scalar | scalar |
Definition at line 350 of file IdMapNode.m.
function this = DataTree.IdMapNode.set | ( | i, | |
value, | |||
mergefun | |||
) |
sets a new value at a specific child branch
i | scalar index of the child to be set or vector of indices. In the latter case, set() is called recursively. |
value | a scalar, a struct or a tree of IdMapNode nodes as described in the constructor IdMapNode.IdMapNode(). |
mergefun | (optional) If given, the function runs in Flat-mode as described in the constructor description IdMapNode.IdMapNode(). Then value needs to be a struct or a tree of IdMapNode nodes. |
this | handle to the changed IdMapNode. |
Definition at line 302 of file IdMapNode.m.
|
static |
DataTree.IdMapNode.idmap |
cell array of "Id" strings
SetAccess = Private, GetAccess = Public
Definition at line 39 of file IdMapNode.m.