@@ -543,6 +543,22 @@ def to_xarray(ids: IDSToplevel, *paths: str) -> Any:
543
543
Returns:
544
544
An ``xarray.Dataset`` object.
545
545
546
+ Notes:
547
+ - Lazy loaded IDSs are not supported for full IDS conversion
548
+ (``imas.util.to_xarray(ids)`` will raise an exception for lazy loaded IDSs).
549
+ This function can work with lazy loaded IDSs when paths are explicitly
550
+ provided: this might take a while because it will load all data for the
551
+ provided paths and their coordinates.
552
+ - This function does not accept wildcards for the paths. However, it is possible
553
+ to combine this method with :py:func:`imas.util.find_paths`, see the Examples
554
+ below.
555
+ - This function may return an empty dataset in the following cases:
556
+
557
+ - The provided IDS does not contain any data.
558
+ - The IDS does not contain any data for the provided paths.
559
+ - The provided paths do not point to data nodes, but to (arrays of)
560
+ structures.
561
+
546
562
Examples:
547
563
.. code-block:: python
548
564
@@ -563,6 +579,12 @@ def to_xarray(ids: IDSToplevel, *paths: str) -> Any:
563
579
"profiles_1d.electrons.temperature",
564
580
)
565
581
582
+ # Combine with imas.util.find_paths to include all paths containing
583
+ # "profiles_1d" in the xarray conversion:
584
+ profiles_1d_paths = imas.util.find_paths(ids, "profiles_1d")
585
+ assert len(profiles_1d_paths) > 0
586
+ ds = imas.util.to_xarray(ids, *profiles_1d_paths)
587
+
566
588
See Also:
567
589
https://docs.xarray.dev/en/stable/generated/xarray.Dataset.html
568
590
"""
0 commit comments