rayoptics.elem.parttree module

Manage connectivity between sequence and element models using a tree.

class PartTree(opt_model, **kwargs)[source]

Bases: object

sync_to_restore(opt_model)[source]
update_model(**kwargs)[source]
is_empty()[source]
init_from_sequence(seq_model)[source]

Initialize part tree using a seq_model.

sort_tree_using_sequence(seq_model)[source]

Resequence part tree using a seq_model.

add_element_model_to_tree(ele_model)[source]
add_element_to_tree(e, **kwargs)[source]
node(obj)[source]

Return the node paired with obj.

obj_by_name(name)[source]

Return the node paired with obj.

trim_node(obj)[source]

Remove the branch where obj is the sole leaf.

parent_node(obj, tag='#element#airgap#dummyifc')[source]

Return the parent node for obj, filtered by tag.

parent_object(obj, tag='#element#airgap#dummyifc')[source]

Return the parent object (and node) for obj, filtered by tag.

get_child_filter(tag='#element#assembly', not_tag='')[source]

Returns a fct that filters a list of nodes to satisfy the tags

list_tree(*args, **kwargs)[source]

Print a graphical console representation of the tree.

The optional arguments are passed through to the by_attr filter. Useful examples or arguments include:

  • pt.list_tree(lambda node: f”{node.name}: {node.tag}”)
  • pt.list_tree(attrname=’tag’)
list_tree_full()[source]

Print a graphical console representation of the tree with tags.

nodes_with_tag(tag='#element', not_tag='', root=None, node_list=None)[source]

Return a list of nodes that contain the requested tag.

list_model(tag='#element#assembly#dummyifc')[source]
sync_part_tree_on_restore(opt_model, ele_model, seq_model, root_node)[source]
sync_part_tree_on_restore_idkey(opt_model, ele_model, seq_model, root_node)[source]
sync_part_tree_on_update(ele_model, seq_model, root_node)[source]

Update node names to track element labels.

elements_from_sequence(ele_model, seq_model, part_tree)[source]

generate an element list from a sequential model

process_airgap(ele_model, seq_model, part_tree, i, g, z_dir, s, g_tfrm, add_ele=True)[source]
part_list_from_seq(opt_model, idx1, idx2)[source]

Using the part_tree, return the parts for the input sequence range.

list_tree_all_from_node(node, **kwargs)[source]

List the tree from node with full node output.

list_tree_from_node(node, *args, **kwargs)[source]

List the tree from node with attribute filtering.

The optional arguments are passed through to the by_attr filter. Useful examples or arguments include:

  • pt.list_tree(lambda node: f”{node.name}: {node.tag}”)
  • pt.list_tree(attrname=’tag’)