Mercurial > repos > muon-spectroscopy-computational-project > larch_artemis
changeset 3:2ceaa943a2ad draft
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
author | muon-spectroscopy-computational-project |
---|---|
date | Thu, 11 Apr 2024 09:01:48 +0000 |
parents | f802cd616862 |
children | 39ab361e6d59 |
files | common.py larch_artemis.xml test-data/fit_report.txt |
diffstat | 3 files changed, 72 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/common.py Mon Mar 04 11:43:09 2024 +0000 +++ b/common.py Thu Apr 11 09:01:48 2024 +0000 @@ -7,14 +7,14 @@ def get_group(athena_group: AthenaGroup, key: str = None) -> Group: - group_keys = list(athena_group._athena_groups.keys()) + group_keys = list(athena_group.keys()) if key is None: key = group_keys[0] else: key = key.replace("-", "_") try: - return extract_athenagroup(athena_group._athena_groups[key]) + return extract_athenagroup(athena_group.groups[key]) except KeyError as e: raise KeyError(f"{key} not in {group_keys}") from e @@ -28,7 +28,7 @@ do_fft=False, ) all_groups = {} - for key in athena_group._athena_groups.keys(): + for key in athena_group.keys(): print(f"\nExtracting group {key}") group = get_group(athena_group, key) pre_edge_with_defaults(group=group) @@ -52,13 +52,22 @@ return group -def pre_edge_with_defaults(group: Group, settings: dict = None): +def pre_edge_with_defaults( + group: Group, settings: dict = None, ref_channel: str = None +): merged_settings = {} - try: - bkg_parameters = group.athena_params.bkg - except AttributeError as e: - print(f"Cannot load group.athena_params.bkg from group:\n{e}") - bkg_parameters = None + if ref_channel is not None: + print(f"Performing pre-edge with reference channel {ref_channel}") + ref = getattr(group, ref_channel.lower()) + group.e0 = None + pre_edge(energy=group.energy, mu=ref, group=group) + bkg_parameters = group.pre_edge_details + else: + try: + bkg_parameters = group.athena_params.bkg + except AttributeError as e: + print(f"Cannot load group.athena_params.bkg from group:\n{e}") + bkg_parameters = None keys = ( ("e0", "e0", None), @@ -73,7 +82,11 @@ ) for key, parameters_key, default in keys: extract_attribute( - merged_settings, key, bkg_parameters, parameters_key, default + merged_settings=merged_settings, + key=key, + parameters_group=bkg_parameters, + parameters_key=parameters_key, + default=default, ) if settings: @@ -116,7 +129,11 @@ ) for key, parameters_key, default in keys: extract_attribute( - merged_settings, key, fft_parameters, parameters_key, default + merged_settings=merged_settings, + key=key, + parameters_group=fft_parameters, + parameters_key=parameters_key, + default=default, ) if settings:
--- a/larch_artemis.xml Mon Mar 04 11:43:09 2024 +0000 +++ b/larch_artemis.xml Thu Apr 11 09:01:48 2024 +0000 @@ -2,7 +2,7 @@ <description>generate Artemis projects from XAFS data</description> <macros> <!-- version of underlying tool (PEP 440) --> - <token name="@TOOL_VERSION@">0.9.74</token> + <token name="@TOOL_VERSION@">0.9.75</token> <!-- version of this tool wrapper (integer) --> <token name="@WRAPPER_VERSION@">0</token> <!-- citation should be updated with every underlying tool version -->
--- a/test-data/fit_report.txt Mon Mar 04 11:43:09 2024 +0000 +++ b/test-data/fit_report.txt Thu Apr 11 09:01:48 2024 +0000 @@ -1,50 +1,53 @@ =================== FEFFIT RESULTS ==================== \[\[Statistics\]\] - nvarys, npts = 6, 104 - n_independent = 12\.205 - chi_square = [\d\.]{9} - reduced chi_square = [\d\.]{9} - r-factor = [\d\.]{9} - Akaike info crit = [\d\.]{9} - Bayesian info crit = [\d\.]{9} - -\[\[Data\]\] - fit space = 'r' - r-range = 1\.400, 3\.000 - k-range = 3\.000, 14\.000 - k window, dk = 'hanning', 1\.000 - paths used in fit = \['feff/feff0001\.dat', 'feff/feff0002\.dat', 'feff/feff0003\.dat', 'feff/feff0004\.dat'\] - k-weight = 2 - epsilon_k = Array\(mean=5\.1913e-4, std=4\.5676e-4\) - epsilon_r = [\d\.]{9} - n_independent = 12\.205 + n_function_calls = 4\d\d + n_variables = 6 + n_data_points = 104 + n_independent = 12\.2045080 + chi_square = [\d\.]{10} + reduced chi_square = [\d\.]{10} + r-factor = [\d\.]{10} + Akaike info crit = [\d\.]{10} + Bayesian info crit = [\d\.]{10} \[\[Variables\]\] - alpha = [-\s][\d\.]{9} \+/- [\d\.]{9} \(init= 1\.0000e-7\) - amp = [-\s][\d\.]{9} \+/- [\d\.]{9} \(init= 1\.0000000\) - enot = [-\s][\d\.]{9} \+/- [\d\.]{9} \(init= 1\.0000e-7\) - ss = [-\s][\d\.]{9} \+/- [\d\.]{9} \(init= 0\.0030000\) - ss2 = [-\s][\d\.]{9} \+/- [\d\.]{9} \(init= 0\.0030000\) - ss3 = [-\s][\d\.]{9} \+/- [\d\.]{9} = 'ss2' - ssfe = [-\s][\d\.]{9} \+/- [\d\.]{9} \(init= 0\.0030000\) + alpha = [-\s][\d\.]{9} \+/- [\d\.]{9} \(init= 1\.0000e-7\) + amp = [-\s][\d\.]{9} \+/- [\d\.]{9} \(init= 1\.0000000\) + enot = [-\s][\d\.]{9} \+/- [\d\.]{9} \(init= 1\.0000e-7\) + ss = [-\s][\d\.]{9} \+/- [\d\.]{9} \(init= 0\.0030000\) + ss2 = [-\s][\d\.]{9} \+/- [\d\.]{9} \(init= 0\.0030000\) + ss3 = [-\s][\d\.]{9} \+/- [\d\.]{9} = 'ss2' + ssfe = [-\s][\d\.]{9} \+/- [\d\.]{9} \(init= 0\.0030000\) -\[\[Correlations\]\] \(unreported correlations are < 0\.100\) - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} - \w+, \w+\s+= [\s\-]0\.\d{3} +\[\[Correlations\]\] \(unreported correlations are < 0\.100\) + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} + \w+, \w+\s+= [\s\-]0\.\d{3} +\[\[Dataset\]\] + unique_id = 'dm7xe57x' + fit space = 'r' + r-range = 1\.400, 3\.000 + k-range = 3\.000, 14\.000 + k window, dk = 'hanning', 1\.000 + paths used in fit = \['feff/feff0001\.dat', 'feff/feff0002\.dat', 'feff/feff0003\.dat', 'feff/feff0004\.dat'\] + k-weight = 2 + epsilon_k = Array\(mean=5\.1913e-4, std=4\.5676e-4\) + epsilon_r = [\d\.]{9} + n_independent = 12\.205 + \[\[Paths\]\] = Path 'S1' = Rh K Edge feffdat file = feff/feff0001\.dat, from feff run 'feff'