Mercurial > repos > muon-spectroscopy-computational-project > larch_plot
annotate common.py @ 6:0339eb694129 draft default tip
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
author | muon-spectroscopy-computational-project |
---|---|
date | Tue, 03 Sep 2024 11:51:45 +0000 |
parents | 3584db5902b5 |
children |
rev | line source |
---|---|
5
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
1 import re |
0
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
2 from typing import Iterable |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
3 |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
4 from larch.io import extract_athenagroup, read_athena |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
5 from larch.io.athena_project import AthenaGroup |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
6 from larch.symboltable import Group |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
7 from larch.xafs import autobk, pre_edge, xftf |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
8 |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
9 |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
10 def get_group(athena_group: AthenaGroup, key: str = None) -> Group: |
4
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
11 group_keys = list(athena_group.keys()) |
0
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
12 if key is None: |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
13 key = group_keys[0] |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
14 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
15 try: |
4
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
16 return extract_athenagroup(athena_group.groups[key]) |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
17 except KeyError as e: |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
18 raise KeyError(f"{key} not in {group_keys}") from e |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
19 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
20 |
5
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
21 def read_all_groups(dat_file: str) -> "dict[str, Group]": |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
22 # Cannot rely on do_ABC as _larch is None |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
23 athena_group = read_athena( |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
24 dat_file, |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
25 do_preedge=False, |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
26 do_bkg=False, |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
27 do_fft=False, |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
28 ) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
29 all_groups = {} |
4
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
30 for key in athena_group.keys(): |
2
59d0d15a40ef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 0f66842e802430e887d1c6cb7be1cc5436408fd2
muon-spectroscopy-computational-project
parents:
1
diff
changeset
|
31 print(f"\nExtracting group {key}") |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
32 group = get_group(athena_group, key) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
33 pre_edge_with_defaults(group=group) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
34 xftf_with_defaults(group=group) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
35 all_groups[key] = group |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
36 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
37 return all_groups |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
38 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
39 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
40 def read_group(dat_file: str, key: str = None): |
5
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
41 if key: |
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
42 match_ = key.replace(" ", "_").replace("-", "_").replace(".", "_") |
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
43 else: |
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
44 match_ = None |
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
45 |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
46 # Cannot rely on do_ABC as _larch is None |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
47 athena_group = read_athena( |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
48 dat_file, |
5
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
49 match=match_, |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
50 do_preedge=False, |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
51 do_bkg=False, |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
52 do_fft=False, |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
53 ) |
5
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
54 group = get_group(athena_group, match_) |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
55 pre_edge_with_defaults(group=group) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
56 xftf_with_defaults(group=group) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
57 return group |
0
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
58 |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
59 |
4
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
60 def pre_edge_with_defaults( |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
61 group: Group, settings: dict = None, ref_channel: str = None |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
62 ): |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
63 merged_settings = {} |
4
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
64 if ref_channel is not None: |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
65 print(f"Performing pre-edge with reference channel {ref_channel}") |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
66 ref = getattr(group, ref_channel.lower()) |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
67 group.e0 = None |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
68 pre_edge(energy=group.energy, mu=ref, group=group) |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
69 bkg_parameters = group.pre_edge_details |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
70 else: |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
71 try: |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
72 bkg_parameters = group.athena_params.bkg |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
73 except AttributeError as e: |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
74 print(f"Cannot load group.athena_params.bkg from group:\n{e}") |
35d24102cefd
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
75 bkg_parameters = None |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
76 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
77 keys = ( |
6
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
78 ("e0", ("e0"), None), |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
79 ("pre1", ("pre1"), None), |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
80 ("pre2", ("pre2"), None), |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
81 ("norm1", ("nor1"), None), |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
82 ("norm2", ("nor2"), None), |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
83 ("nnorm", ("nnorm"), None), |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
84 ("make_flat", ("flatten"), None), |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
85 ("step", ("step"), None), |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
86 ("nvict", ("nvict"), None), |
0
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
87 ) |
6
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
88 for key, parameter_keys, default in keys: |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
89 extract_attribute( |
3
5b993aff09e3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
90 merged_settings=merged_settings, |
5b993aff09e3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
91 key=key, |
5b993aff09e3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
92 parameters_group=bkg_parameters, |
6
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
93 parameter_keys=parameter_keys, |
3
5b993aff09e3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
94 default=default, |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
95 ) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
96 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
97 if settings: |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
98 for k, v in settings.items(): |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
99 if k == "nvict": |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
100 print( |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
101 "WARNING: `nvict` can be used for pre-edge but is not " |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
102 "saved to file, so value used will not be accessible in " |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
103 "future operations using this Athena .prj" |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
104 ) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
105 merged_settings[k] = v |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
106 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
107 print(f"Pre-edge normalization with {merged_settings}") |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
108 try: |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
109 pre_edge(group, **merged_settings) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
110 except Warning as e: |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
111 raise Warning( |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
112 "Unable to perform pre-edge fitting with:\n\n" |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
113 f"energy:\n{group.energy}\n\nmu:{group.mu}\n\n" |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
114 "Consider checking the correct columns have been extracted" |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
115 ) from e |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
116 autobk(group, pre_edge_kws=merged_settings) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
117 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
118 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
119 def xftf_with_defaults(group: Group, settings: dict = None): |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
120 merged_settings = {} |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
121 try: |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
122 fft_parameters = group.athena_params.fft |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
123 except AttributeError as e: |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
124 print(f"Cannot load group.athena_params.fft from group:\n{e}") |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
125 fft_parameters = None |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
126 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
127 keys = ( |
6
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
128 ("kmin", ("kmin",), 0), |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
129 ("kmax", ("kmax",), 20), |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
130 ("dk", ("dk",), 1), |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
131 ("kweight", ("kw", "kweight"), 2), |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
132 ("window", ("kwindow",), "kaiser"), |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
133 ) |
6
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
134 for key, parameter_keys, default in keys: |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
135 extract_attribute( |
3
5b993aff09e3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
136 merged_settings=merged_settings, |
5b993aff09e3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
137 key=key, |
5b993aff09e3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
138 parameters_group=fft_parameters, |
6
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
139 parameter_keys=parameter_keys, |
3
5b993aff09e3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
140 default=default, |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
141 ) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
142 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
143 if settings: |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
144 for k, v in settings.items(): |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
145 merged_settings[k] = v |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
146 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
147 print(f"XFTF with {merged_settings}") |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
148 xftf(group, **merged_settings) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
149 xftf_details = Group() |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
150 setattr(xftf_details, "call_args", merged_settings) |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
151 group.xftf_details = xftf_details |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
152 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
153 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
154 def extract_attribute( |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
155 merged_settings: dict, |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
156 key: str, |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
157 parameters_group: Group, |
6
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
158 parameter_keys: "tuple[str]", |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
159 default: "str|int" = None, |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
160 ): |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
161 if parameters_group is not None: |
6
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
162 values = [] |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
163 for parameter_key in parameter_keys: |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
164 try: |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
165 values.append(getattr(parameters_group, parameter_key)) |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
166 except AttributeError: |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
167 pass |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
168 |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
169 if len(values) > 1: |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
170 print( |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
171 f"WARNING: values {values} for for keys {parameter_keys}, " |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
172 "using first entry" |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
173 ) |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
174 |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
175 if len(values) > 0: |
0339eb694129
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
muon-spectroscopy-computational-project
parents:
5
diff
changeset
|
176 merged_settings[key] = values[0] |
1
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
177 return |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
178 |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
179 if default is not None: |
002c18a3e642
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
180 merged_settings[key] = default |
0
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
181 |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
182 |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
183 def read_groups(dat_files: "list[str]", key: str = None) -> Iterable[Group]: |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
184 for dat_file in dat_files: |
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
185 yield read_group(dat_file=dat_file, key=key) |
5
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
186 |
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
187 |
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
188 def sorting_key(filename: str) -> str: |
3584db5902b5
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 4814f53888643f1d3667789050914675fffb7d59
muon-spectroscopy-computational-project
parents:
4
diff
changeset
|
189 return re.findall(r"\d+", filename)[-1] |