Skip to content

Commit ff0f628

Browse files
committed
Add example in doc to list available IDS+occ in a data-entry (#35)
1 parent 09104ac commit ff0f628

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

docs/source/courses/basic/analyze.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,20 @@ Exercise 5
246246
A plot of :math:`T_e` vs :math:`t`.
247247

248248
.. seealso:: :ref:`Lazy loading`
249+
250+
251+
Explore the DBEntry
252+
'''''''''''''''''''
253+
254+
You may not know apriori which types of IDSs are available within an IMAS database entry.
255+
It can also happen that several IDSs objects of the same type are stored within
256+
this entry, in that case each IDS is stored as a separate `occurrence`
257+
(occurrences are identified with an integer value, 0 being the default).
258+
259+
In IMAS-Python, the function :meth:`~imas.db_entry.DBEntry.list_all_occurrences()` will
260+
help you finding which occurrences are available in a given database entry and for a given
261+
IDS type.
262+
263+
The following snippet shows how to list the available IDSs in a given database entry:
264+
265+
.. literalinclude:: imas_snippets/explore_data_entry.py

docs/source/courses/basic/explore.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ In this part of the training, we will learn how to use Python to explore data
77
saved in IDSs.
88

99

10-
Explore which IDSs are available
11-
--------------------------------
10+
Explore which IDS structures are available
11+
------------------------------------------
1212

1313
Most codes will touch multiple IDSs inside a single IMAS data entry. For example
1414
a heating code using a magnetic equilibrium from the ``equilibrium`` IDS with a
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import imas
2+
3+
# Open input data entry
4+
entry = imas.DBEntry("imas:hdf5?path=<...>","r")
5+
6+
# Print the list of available IDSs with their occurrence
7+
print([(idsname,occ) for idsname in imas.IDSFactory().ids_names() for occ in entry.list_all_occurrences(idsname)])
8+
9+
entry.close()

0 commit comments

Comments
 (0)