Mercurial > repos > muon-spectroscopy-computational-project > larch_plot
changeset 5:3584db5902b5 draft
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
author | muon-spectroscopy-computational-project |
---|---|
date | Fri, 23 Aug 2024 14:10:50 +0000 |
parents | 35d24102cefd |
children | 0339eb694129 |
files | common.py larch_plot.xml |
diffstat | 2 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/common.py Thu Apr 11 09:02:24 2024 +0000 +++ b/common.py Fri Aug 23 14:10:50 2024 +0000 @@ -1,3 +1,4 @@ +import re from typing import Iterable from larch.io import extract_athenagroup, read_athena @@ -10,8 +11,6 @@ group_keys = list(athena_group.keys()) if key is None: key = group_keys[0] - else: - key = key.replace("-", "_") try: return extract_athenagroup(athena_group.groups[key]) @@ -19,7 +18,7 @@ raise KeyError(f"{key} not in {group_keys}") from e -def read_all_groups(dat_file: str, key: str = None) -> "dict[str, Group]": +def read_all_groups(dat_file: str) -> "dict[str, Group]": # Cannot rely on do_ABC as _larch is None athena_group = read_athena( dat_file, @@ -39,14 +38,20 @@ def read_group(dat_file: str, key: str = None): + if key: + match_ = key.replace(" ", "_").replace("-", "_").replace(".", "_") + else: + match_ = None + # Cannot rely on do_ABC as _larch is None athena_group = read_athena( dat_file, + match=match_, do_preedge=False, do_bkg=False, do_fft=False, ) - group = get_group(athena_group, key) + group = get_group(athena_group, match_) pre_edge_with_defaults(group=group) xftf_with_defaults(group=group) return group @@ -168,3 +173,7 @@ def read_groups(dat_files: "list[str]", key: str = None) -> Iterable[Group]: for dat_file in dat_files: yield read_group(dat_file=dat_file, key=key) + + +def sorting_key(filename: str) -> str: + return re.findall(r"\d+", filename)[-1]
--- a/larch_plot.xml Thu Apr 11 09:02:24 2024 +0000 +++ b/larch_plot.xml Fri Aug 23 14:10:50 2024 +0000 @@ -2,7 +2,7 @@ <description>plot Athena projects</description> <macros> <!-- version of underlying tool (PEP 440) --> - <token name="@TOOL_VERSION@">0.9.75</token> + <token name="@TOOL_VERSION@">0.9.80</token> <!-- version of this tool wrapper (integer) --> <token name="@WRAPPER_VERSION@">0</token> <!-- citation should be updated with every underlying tool version -->