catm-python-lib
Loading...
Searching...
No Matches
xcfgreader.py File Reference

reading utillities for configuration file of GET electronics More...

Go to the source code of this file.

Functions

 catmlib.util.xcfgreader.classify_indices (values)
 Classify indices by values in a list.
 catmlib.util.xcfgreader.get_tree (input_path)
 Parse an XML configuration file and return its root element.
 catmlib.util.xcfgreader.get_node (root, node_id_name='CoBo')
 Retrieve a specific <Node> element by its ID from the XML tree.
 catmlib.util.xcfgreader.get_instance (node, instance_id_name=' *')
 Retrieve a specific <Instance> element by its ID within a given <Node>.
 catmlib.util.xcfgreader.get_block (instance, label_name='AsAd', block_name='0')
 Retrieve a specific block element (e.g., AsAd or Aget) by tag and ID within an Instance.
 catmlib.util.xcfgreader.print_tree (element, indent=0, indent_label=1)
 Recursively print elements at a specified depth level in an XML tree.
 catmlib.util.xcfgreader.write_text (input_path, output_path)
 catmlib.util.xcfgreader.read_text (intput_path=None)
 Reads a tab-separated text file into a pandas DataFrame.
 catmlib.util.xcfgreader.get_matching_indices (data, cobo_value, asad_value, aget_value, channel_value)
 Get indices of rows in a DataFrame that match specified values.

Detailed Description

reading utillities for configuration file of GET electronics

Version
1
Author
Fumitaka ENDO
Date
2025-06-28T04:42:00+09:00

Definition in file xcfgreader.py.

Function Documentation

◆ classify_indices()

catmlib.util.xcfgreader.classify_indices ( values)

Classify indices by values in a list.

This function groups the indices of elements in the input list by their values.

Parameters
valuesA list of values to be classified.
Returns
A dictionary where each key is a unique value and the value is a list of indices where it occurs.

Definition at line 15 of file xcfgreader.py.

◆ get_block()

catmlib.util.xcfgreader.get_block ( instance,
label_name = 'AsAd',
block_name = '0' )

Retrieve a specific block element (e.g., AsAd or Aget) by tag and ID within an Instance.

Parameters
instanceThe parent Instance element.
label_nameThe tag name of the block to find (e.g., 'AsAd', 'Aget').
block_nameID attribute of the block element to retrieve (default is '0').
Returns
The block element if found; otherwise, None.

Definition at line 63 of file xcfgreader.py.

◆ get_instance()

catmlib.util.xcfgreader.get_instance ( node,
instance_id_name = '*' )

Retrieve a specific <Instance> element by its ID within a given <Node>.

Parameters
nodeThe parent Node element.
instance_id_nameID attribute value of the desired Instance element (default is '*').
Returns
The Instance element if found; otherwise, None.

Definition at line 52 of file xcfgreader.py.

◆ get_matching_indices()

catmlib.util.xcfgreader.get_matching_indices ( data,
cobo_value,
asad_value,
aget_value,
channel_value )

Get indices of rows in a DataFrame that match specified values.

Each parameter can be set to a specific value (non-negative) to filter, or a negative value to ignore the filter.

Parameters
dataA pandas DataFrame that contains columns: cobos, asads, agets, channels.
cobo_valueInteger. Cobo value to match (set < 0 to ignore).
asad_valueInteger. Asad value to match (set < 0 to ignore).
aget_valueInteger. Aget value to match (set < 0 to ignore).
channel_valueInteger. Channel value to match (set < 0 to ignore).
Returns
A list of indices in the DataFrame where all specified values match.

Definition at line 151 of file xcfgreader.py.

◆ get_node()

catmlib.util.xcfgreader.get_node ( root,
node_id_name = 'CoBo' )

Retrieve a specific <Node> element by its ID from the XML tree.

Parameters
rootRoot element of the XML tree.
node_id_nameID attribute value of the desired Node element (default is 'CoBo').
Returns
The Node element if found; otherwise, None.

Definition at line 40 of file xcfgreader.py.

◆ get_tree()

catmlib.util.xcfgreader.get_tree ( input_path)

Parse an XML configuration file and return its root element.

Parameters
input_pathPath to the XML configuration file.
Returns
Root element of the parsed XML tree.

Definition at line 29 of file xcfgreader.py.

◆ print_tree()

catmlib.util.xcfgreader.print_tree ( element,
indent = 0,
indent_label = 1 )

Recursively print elements at a specified depth level in an XML tree.

Parameters
elementThe current element to print.
indentCurrent recursion depth (used internally).
indent_labelTarget depth level at which to print elements.

Definition at line 75 of file xcfgreader.py.

◆ read_text()

catmlib.util.xcfgreader.read_text ( intput_path = None)

Reads a tab-separated text file into a pandas DataFrame.

Parameters
intput_pathThe path to the text file. If None, the function returns None.
Returns
A pandas DataFrame containing the loaded data, or None if no path is given.

Definition at line 140 of file xcfgreader.py.

◆ write_text()

catmlib.util.xcfgreader.write_text ( input_path,
output_path )

Definition at line 89 of file xcfgreader.py.