# HG changeset patch # User muon-spectroscopy-computational-project # Date 1712826139 0 # Node ID 6bb927e155fcad14f6b083c97a1cdf51b8a29fa2 # Parent 85284c3e13540f4f4e507a0ce4492ebcbb276bf5 planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_lcf commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8 diff -r 85284c3e1354 -r 6bb927e155fc common.py --- 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: diff -r 85284c3e1354 -r 6bb927e155fc larch_lcf.xml --- 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 @@ perform linear combination fit on XAS data - 0.9.74 + 0.9.75 0