imas.ids_path.IDSPath

class imas.ids_path.IDSPath(path: str)

Bases: object

Represent a path in an IDS.

An IDS Path indicates the relative position of an element in an IDS and is similar to a directory structure.

Paths consist of elements with an optional index, separated by slashes. For example:

  • ids_properties/version_put/data_dictionary, no indices

  • profiles_1d(itime)/zeff, using a dummy itime index

  • distribution(1)/process(:)/nbi_unit, using a Fortran-style explicit index (1) and Fortran-style range selector (:)

  • distribution[0]/process[:]/nbi_unit, using a Python-style explicit index [0] and Python-style range selector [:]

  • coordinate_system(process(i1)/coordinate_index)/coordinate(1) using another IDSPath as index.

__init__(path: str)

Methods

__init__(path)

goto(from_element, *[, from_root])

Go to this path, taking from_element as reference.

goto_metadata(from_metadata)

Go to the metadata of this path, taking from_metadata as reference.

is_ancestor_of(other_path)

Test if this path is an ancestor of the other path.

items()

(part, index) iterator

goto(from_element: IDSBase, *, from_root: bool = True) IDSBase

Go to this path, taking from_element as reference.

This returns the IDS node at the specified path, or raises an error when that path cannot be found.

Parameters:
from_element: IDSBase

IDS element to start the goto from

from_root: bool = True

True iff we should start at the root, otherwise we start from the provided IDS element (see example)

Example

cp = imas.IDSFactory().core_profiles()
cp.profiles_1d.resize(1)
element = cp.profiles_1d[0]
path1 = IDSPath("ids_properties/homogeneous_time")
assert path1.goto(element, True) is cp.ids_properties.homogeneous_time
path2 = IDSPath("electrons/temperature")
assert path2.goto(element, False) is element.electrons.temperature
goto_metadata(from_metadata: IDSMetadata) IDSMetadata

Go to the metadata of this path, taking from_metadata as reference.

This returns the metadata of the metadata IDS node at the specified path, or raises an error when that path cannot be found. It is useful when you want to retrieve the metadata of an IDS node without having to traverse the IDS nodes.

Parameters:
from_metadata: IDSMetadata

IDS metadata node to start the goto from

Example

es = imas.IDSFactory().edge_sources()
path = IDSPath("source/ggd/ion/energy")
energy_metadata = path.goto_metadata(es.metadata)
is_ancestor_of(other_path: IDSPath) bool

Test if this path is an ancestor of the other path.

items() Iterator[tuple[str, None | str | int | IDSPath | slice]]

(part, index) iterator


Last update: 2026-01-28