CXIExplorer#

class cdiutils.io.CXIExplorer(cxi_file)[source]#

Bases: object

Interactive explorer for CXI file inspection and visualisation.

Provides tools for navigating CXI file hierarchies, viewing metadata, and visualising array data. Requires Jupyter environment with ipywidgets for interactive features.

cxi#

CXIFile instance being explored.

paths#

List of all dataset/group paths in file.

Dictionary mapping soft link names to targets.

The CXIExplorer class provides an interactive widget for exploring CXI files. See the CXI explorer tutorial for usage examples.

max_number_of_values_printed = 100#
tree_max_string_length = 15#
tree_max_array_size = 5#
__init__(cxi_file)[source]#

Initialise the CXI explorer with either a path to a CXI file or a CXIFile object.

Parameters:
  • cxi_file (str | CXIFile) – Either a string path to a CXI file

  • object (or a CXIFile)

Raises:

ImportError – If ipywidgets is not installed (required for interactive features)

close()[source]#

Close the CXI file if it was opened by this explorer.

tree(max_depth=None, show_attributes=False)[source]#

Print a tree view of the CXI file structure similar to the Linux ‘tree’ command.

Parameters:
  • max_depth (int) – Maximum depth to traverse (None for unlimited). Defaults to None.

  • show_attributes (bool) – whether to show attributes. Defaults

  • False. (to)

explore()[source]#

Create an interactive widget to explore the CXI file.

tabbed_print(text, **kwargs)[source]#

Print text with optional tabbing.

Parameters:

text (str) – Text to print.

show(path, show_attributes=False, tab=0)[source]#

Visualise a specific dataset from the CXI file.

Notes: This function only prints the content of the subset without going any deeper into the tree, except for soft links, for which it will print the target content and its content. If the target content of a group or dataset is a soft link, it will not print the target content.

Parameters:
  • path (str) – Path to the dataset within the CXI file.

  • show_attributes (bool) – Whether to show attributes.

  • tab (int) – Initial tab level.

search(pattern, search_attrs=True)[source]#

Search for datasets, groups, or soft links that match the given pattern.

Parameters:
  • pattern (str) – pattern to search for in names

  • search_attrs (bool) – whether to also search in attribute values. Defaults to True.

summarise()[source]#

Provide a summary of the CXI file content.

Examples#

Exploring CXI file:

from cdiutils.io import CXIExplorer

# Create explorer (opens file automatically)
explorer = CXIExplorer("results.cxi")

# Show interactive widget in Jupyter notebook
# This displays file tree and interactive data viewer
explorer.show()

# Close when done
explorer.close()

# Or use context manager
with CXIExplorer("results.cxi") as explorer:
    explorer.show()

See Also#

CXIFile : Low-level CXI file access cdiutils.plot.plot_volume_slices() : 2D slice viewer for arrays