changeset 3:6bb927e155fc draft

planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_lcf commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
author muon-spectroscopy-computational-project
date Thu, 11 Apr 2024 09:02:19 +0000
parents 85284c3e1354
children c2d5bfef5b63
files common.py larch_lcf.xml
diffstat 2 files changed, 29 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/common.py	Mon Mar 04 11:43:39 2024 +0000
+++ b/common.py	Thu Apr 11 09:02:19 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_lcf.xml	Mon Mar 04 11:43:39 2024 +0000
+++ b/larch_lcf.xml	Thu Apr 11 09:02:19 2024 +0000
@@ -2,7 +2,7 @@
     <description>perform linear combination fit on XAS 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 -->