Group class¶
- class araucaria.main.group.Group(name=None, **kwargs)[source]¶
Group storage class.
This class stores a single XAFS dataset.
- Parameters
Notes
The following methods are currently implemented:
Method
Description
Adds content to the group.
Returns a copy of the group.
Returns the scan mode of the group.
Tests if the group has a reference scan.
Renames the group.
Example
>>> from araucaria import Group >>> group = Group() >>> type(group) <class 'araucaria.main.group.Group'>
- add_content(content)[source]¶
Adds content to the group.
- Parameters
content (
dict
) – Dictionary with content for the group.- Return type
- Returns
- Raises
TypeError – If
content
is not a dictionary.
Example
>>> from araucaria import Group >>> from araucaria.utils import check_objattrs >>> content = {'var': 'xas'} >>> group = Group() >>> group.add_content(content) >>> check_objattrs(group, Group, attrlist=['name', 'var']) [True, True]
- copy()[source]¶
Returns a deep copy of the group.
- Parameters
None –
- Return type
- Returns
Copy of the group.
Example
>>> from numpy import allclose >>> from araucaria import Group >>> content = {'energy': [1,2,3,4,5,6]} >>> group1 = Group() >>> group1.add_content(content) >>> group2 = group1.copy() >>> allclose(group1.energy, group2.energy) True
- get_mode()[source]¶
Returns scan mode of mu(E) for the group.
- Parameters
None –
- Return type
- Returns
Scan mode of mu(E). Either ‘fluo’, ‘mu’, or ‘mu_ref’.
- Raises
ValueError – If the scan mode is unavailable or not recognized.
Important
The scan mode of mu(E) is assigned during reading of a file, and should adhere to the following convention:
mu
corresponds to a transmision mode scan.fluo
corresponds to a fluorescence mode scan.mu_ref
corresponds to a reference scan.
Examples
>>> from araucaria.testdata import get_testpath >>> from araucaria.io import read_xmu >>> fpath = get_testpath('xmu_testfile.xmu') >>> # extracting mu and mu_ref scans >>> group_mu = read_xmu(fpath, scan='mu') >>> group_mu.get_mode() 'mu'
>>> # extracting only fluo scan >>> group_fluo = read_xmu(fpath, scan='fluo', ref=False) >>> group_fluo.get_mode() 'fluo'
>>> # extracting only mu_ref scan >>> group_ref = read_xmu(fpath, scan=None, ref=True) >>> group_ref.get_mode() 'mu_ref'
- has_ref()[source]¶
Tests if the group contains a reference scan for mu(E).
- Parameters
None –
- Return type
- Returns
True if attribute
mu_ref
exists in the group. False otherwise.
Examples
>>> from araucaria.testdata import get_testpath >>> from araucaria.io import read_xmu >>> fpath = get_testpath('xmu_testfile.xmu') >>> # extracting mu and mu_ref scans >>> group_mu = read_xmu(fpath, scan='mu') >>> group_mu.has_ref() True
>>> # extracting only fluo scan >>> group_fluo = read_xmu(fpath, scan='fluo', ref=False) >>> group_fluo.has_ref() False
>>> # extracting only mu_ref scan >>> group_ref = read_xmu(fpath, scan=None, ref=True) >>> group_ref.has_ref() True
- rename(newname)[source]¶
Renames the group.
- Parameters
newname (
str
) – New name for the group.- Return type
- Returns
- Raises
TypeError – If
newname
is not a string.
Example
>>> from araucaria import Group >>> content = {'name': 'group1'} >>> group = Group(name = 'group1') >>> print(group.name) group1 >>> group.rename('group2') >>> print(group.name) group2