Mercurial > repos > muon-spectroscopy-computational-project > larch_athena
annotate larch_athena.py @ 4:a0d3b0fe0fa3 draft
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
author | muon-spectroscopy-computational-project |
---|---|
date | Thu, 11 Apr 2024 09:01:59 +0000 |
parents | 82e9dd980916 |
children | 27015eaf9a78 |
rev | line source |
---|---|
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
1 import gc |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
2 import json |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
3 import os |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
4 import re |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
5 import sys |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
6 |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
7 from common import ( |
3
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
8 pre_edge_with_defaults, |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
9 read_all_groups, |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
10 read_group, |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
11 xftf_with_defaults, |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
12 ) |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
13 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
14 from larch.io import ( |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
15 create_athena, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
16 h5group, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
17 merge_groups, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
18 read_ascii, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
19 set_array_labels, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
20 ) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
21 from larch.symboltable import Group |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
22 from larch.xafs import rebin_xafs |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
23 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
24 import matplotlib |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
25 import matplotlib.pyplot as plt |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
26 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
27 import numpy as np |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
28 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
29 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
30 class Reader: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
31 def __init__( |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
32 self, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
33 energy_column: str, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
34 mu_column: str, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
35 data_format: str, |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
36 extract_group: "dict[str, str]" = None, |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
37 ): |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
38 self.energy_column = energy_column |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
39 self.mu_column = mu_column |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
40 self.data_format = data_format |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
41 self.extract_group = extract_group |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
42 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
43 def load_data( |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
44 self, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
45 dat_file: str, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
46 merge_inputs: bool, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
47 is_zipped: bool, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
48 ) -> "dict[str, Group]": |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
49 if merge_inputs: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
50 out_group = self.merge_files( |
3
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
51 dat_files=dat_file, |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
52 is_zipped=is_zipped, |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
53 ) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
54 return {"out": out_group} |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
55 else: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
56 return self.load_single_file( |
3
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
57 filepath=dat_file, |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
58 is_zipped=is_zipped, |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
59 ) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
60 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
61 def merge_files( |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
62 self, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
63 dat_files: str, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
64 is_zipped: bool, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
65 ) -> Group: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
66 if is_zipped: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
67 all_groups = list(self.load_zipped_files().values()) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
68 else: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
69 all_groups = [] |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
70 for filepath in dat_files.split(","): |
2
a1e26990131c
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 0f66842e802430e887d1c6cb7be1cc5436408fd2
muon-spectroscopy-computational-project
parents:
1
diff
changeset
|
71 for group in self.load_single_file(filepath).values(): |
a1e26990131c
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 0f66842e802430e887d1c6cb7be1cc5436408fd2
muon-spectroscopy-computational-project
parents:
1
diff
changeset
|
72 all_groups.append(group) |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
73 |
2
a1e26990131c
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 0f66842e802430e887d1c6cb7be1cc5436408fd2
muon-spectroscopy-computational-project
parents:
1
diff
changeset
|
74 merged_group = merge_groups(all_groups, xarray="energy", yarray="mu") |
a1e26990131c
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 0f66842e802430e887d1c6cb7be1cc5436408fd2
muon-spectroscopy-computational-project
parents:
1
diff
changeset
|
75 pre_edge_with_defaults(merged_group) |
a1e26990131c
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 0f66842e802430e887d1c6cb7be1cc5436408fd2
muon-spectroscopy-computational-project
parents:
1
diff
changeset
|
76 return merged_group |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
77 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
78 def load_single_file( |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
79 self, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
80 filepath: str, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
81 is_zipped: bool = False, |
2
a1e26990131c
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 0f66842e802430e887d1c6cb7be1cc5436408fd2
muon-spectroscopy-computational-project
parents:
1
diff
changeset
|
82 ) -> dict: |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
83 if is_zipped: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
84 return self.load_zipped_files() |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
85 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
86 print(f"Attempting to read from {filepath}") |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
87 if self.data_format == "athena": |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
88 if self.extract_group["extract_group"] == "single": |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
89 group = read_group(filepath, self.extract_group["group_name"]) |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
90 return {"out": group} |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
91 elif self.extract_group["extract_group"] == "multiple": |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
92 groups = {} |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
93 for repeat in self.extract_group["multiple"]: |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
94 name = repeat["group_name"] |
2
a1e26990131c
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 0f66842e802430e887d1c6cb7be1cc5436408fd2
muon-spectroscopy-computational-project
parents:
1
diff
changeset
|
95 print(f"\nExtracting group {name}") |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
96 groups[name] = read_group(filepath, name) |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
97 return groups |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
98 else: |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
99 return read_all_groups(filepath) |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
100 |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
101 else: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
102 # Try ascii anyway |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
103 try: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
104 group = self.load_ascii(filepath) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
105 if not group.array_labels: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
106 # In later versions of larch, won't get a type error it |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
107 # will just fail to load any data |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
108 group = self.load_h5(filepath) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
109 except (UnicodeDecodeError, TypeError): |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
110 # Indicates this isn't plaintext, try h5 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
111 group = self.load_h5(filepath) |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
112 pre_edge_with_defaults(group) |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
113 xftf_with_defaults(group) |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
114 return {"out": group} |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
115 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
116 def load_ascii(self, dat_file): |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
117 with open(dat_file) as f: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
118 labels = None |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
119 last_line = None |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
120 line = f.readline() |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
121 while line: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
122 if not line.startswith("#"): |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
123 if last_line is not None and last_line.find("\t") > 0: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
124 labels = [] |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
125 for label in last_line.split("\t"): |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
126 labels.append(label.strip()) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
127 break |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
128 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
129 last_line = line |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
130 line = f.readline() |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
131 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
132 xas_data = read_ascii(filename=dat_file, labels=labels) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
133 xas_data = self.rename_cols(xas_data) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
134 return xas_data |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
135 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
136 def load_h5(self, dat_file): |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
137 h5_group = h5group(fname=dat_file, mode="r") |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
138 energy = h5_group.entry1.instrument.qexafs_energy.qexafs_energy |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
139 mu = h5_group.entry1.instrument.qexafs_counterTimer01.lnI0It |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
140 xafs_group = Group(data=np.array([energy[:], mu[:]])) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
141 set_array_labels(xafs_group, ["energy", "mu"]) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
142 return xafs_group |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
143 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
144 def load_zipped_files(self) -> "dict[str, Group]": |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
145 def sorting_key(filename: str) -> str: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
146 return re.findall(r"\d+", filename)[-1] |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
147 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
148 all_paths = list(os.walk("dat_files")) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
149 all_paths.sort(key=lambda x: x[0]) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
150 file_total = sum([len(f) for _, _, f in all_paths]) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
151 print(f"{file_total} files found") |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
152 keyed_data = {} |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
153 for dirpath, _, filenames in all_paths: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
154 try: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
155 filenames.sort(key=sorting_key) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
156 except IndexError as e: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
157 print( |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
158 "WARNING: Unable to sort files numerically, " |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
159 f"defaulting to sorting alphabetically:\n{e}" |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
160 ) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
161 filenames.sort() |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
162 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
163 for filename in filenames: |
2
a1e26990131c
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 0f66842e802430e887d1c6cb7be1cc5436408fd2
muon-spectroscopy-computational-project
parents:
1
diff
changeset
|
164 if len(all_paths) > 1: |
a1e26990131c
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 0f66842e802430e887d1c6cb7be1cc5436408fd2
muon-spectroscopy-computational-project
parents:
1
diff
changeset
|
165 key = f"{dirpath}_{filename}" |
a1e26990131c
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 0f66842e802430e887d1c6cb7be1cc5436408fd2
muon-spectroscopy-computational-project
parents:
1
diff
changeset
|
166 else: |
a1e26990131c
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 0f66842e802430e887d1c6cb7be1cc5436408fd2
muon-spectroscopy-computational-project
parents:
1
diff
changeset
|
167 key = filename |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
168 filepath = os.path.join(dirpath, filename) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
169 xas_data = self.load_single_file(filepath) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
170 keyed_data[key] = xas_data["out"] |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
171 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
172 return keyed_data |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
173 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
174 def rename_cols(self, xafs_group: Group) -> Group: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
175 labels = [label.lower() for label in xafs_group.array_labels] |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
176 print(f"Read columns: {labels}") |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
177 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
178 if "energy" in labels: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
179 print("'energy' present in column headers") |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
180 elif self.energy_column: |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
181 if self.energy_column.lower() in labels: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
182 labels[labels.index(self.energy_column.lower())] = "energy" |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
183 else: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
184 raise ValueError(f"{self.energy_column} not found in {labels}") |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
185 else: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
186 for i, label in enumerate(labels): |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
187 if label in ("col1", "ef") or label.endswith("energy"): |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
188 labels[i] = "energy" |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
189 break |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
190 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
191 if "mu" in labels: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
192 print("'mu' present in column headers") |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
193 elif self.mu_column: |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
194 if self.mu_column.lower() in labels: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
195 labels[labels.index(self.mu_column.lower())] = "mu" |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
196 else: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
197 raise ValueError(f"{self.mu_column} not found in {labels}") |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
198 else: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
199 for i, label in enumerate(labels): |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
200 if label in ["col2", "xmu", "lni0it", "ffi0", "ff/i1"]: |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
201 labels[i] = "mu" |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
202 break |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
203 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
204 if labels != xafs_group.array_labels: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
205 print(f"Renaming columns to: {labels}") |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
206 return set_array_labels(xafs_group, labels) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
207 else: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
208 return xafs_group |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
209 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
210 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
211 def calibrate_energy( |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
212 xafs_group: Group, |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
213 calibration_e0: float = None, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
214 energy_min: float = None, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
215 energy_max: float = None, |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
216 ): |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
217 if calibration_e0 is not None: |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
218 print(f"Recalibrating edge from {xafs_group.e0} to {calibration_e0}") |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
219 xafs_group.energy = xafs_group.energy + calibration_e0 - xafs_group.e0 |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
220 xafs_group.e0 = calibration_e0 |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
221 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
222 if not (energy_min or energy_max): |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
223 return xafs_group |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
224 |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
225 if energy_min is not None: |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
226 index_min = np.searchsorted(xafs_group.energy, energy_min) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
227 else: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
228 index_min = 0 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
229 |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
230 if energy_max is not None: |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
231 index_max = np.searchsorted(xafs_group.energy, energy_max) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
232 else: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
233 index_max = len(xafs_group.energy) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
234 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
235 print( |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
236 f"Cropping energy range from {energy_min} to {energy_max}, " |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
237 f"index {index_min} to {index_max}" |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
238 ) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
239 try: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
240 xafs_group.dmude = xafs_group.dmude[index_min:index_max] |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
241 xafs_group.pre_edge = xafs_group.pre_edge[index_min:index_max] |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
242 xafs_group.post_edge = xafs_group.post_edge[index_min:index_max] |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
243 xafs_group.flat = xafs_group.flat[index_min:index_max] |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
244 except AttributeError: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
245 pass |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
246 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
247 xafs_group.energy = xafs_group.energy[index_min:index_max] |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
248 xafs_group.mu = xafs_group.mu[index_min:index_max] |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
249 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
250 # Sanity check |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
251 if len(xafs_group.energy) == 0: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
252 raise ValueError("Energy cropping led to an empty array") |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
253 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
254 return xafs_group |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
255 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
256 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
257 def main( |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
258 xas_data: Group, |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
259 do_calibrate: bool, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
260 calibrate_settings: dict, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
261 do_rebin: bool, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
262 do_pre_edge: bool, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
263 pre_edge_settings: dict, |
4
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
264 ref_channel: str, |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
265 do_xftf: bool, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
266 xftf_settings: dict, |
3
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
267 plot_graph: list, |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
268 annotation: str, |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
269 path_key: str = "out", |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
270 ): |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
271 if do_calibrate: |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
272 print(f"Calibrating energy with {calibrate_settings}") |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
273 xas_data = calibrate_energy(xas_data, **calibrate_settings) |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
274 # After re-calibrating, will need to redo pre-edge with new range |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
275 do_pre_edge = True |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
276 |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
277 if do_rebin: |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
278 print("Re-binning data") |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
279 rebin_xafs( |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
280 energy=xas_data.energy, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
281 mu=xas_data.mu, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
282 group=xas_data, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
283 **pre_edge_settings, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
284 ) |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
285 xas_data = xas_data.rebinned |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
286 # After re-bin, will need to redo pre-edge |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
287 do_pre_edge = True |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
288 |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
289 if do_pre_edge: |
4
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
290 pre_edge_with_defaults(xas_data, pre_edge_settings, ref_channel) |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
291 |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
292 if do_xftf: |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
293 xftf_with_defaults(xas_data, xftf_settings) |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
294 |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
295 if plot_graph: |
3
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
296 plot_graphs( |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
297 plot_path=f"plot/{path_key}.png", |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
298 xas_data=xas_data, |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
299 plot_keys=plot_graph, |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
300 ) |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
301 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
302 xas_project = create_athena(f"prj/{path_key}.prj") |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
303 xas_project.add_group(xas_data) |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
304 if annotation: |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
305 group = next(iter(xas_project.groups.values())) |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
306 group.args["annotation"] = annotation |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
307 xas_project.save() |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
308 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
309 # Ensure that we do not run out of memory when running on large zips |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
310 gc.collect() |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
311 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
312 |
3
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
313 def plot_graphs( |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
314 plot_path: str, |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
315 xas_data: Group, |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
316 plot_keys: list, |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
317 ) -> None: |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
318 nrows = len(plot_keys) |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
319 index = 1 |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
320 plt.figure(figsize=(6.4, nrows * 4.8)) |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
321 if "edge" in plot_keys: |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
322 plt.subplot(nrows, 1, index) |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
323 plt.plot(xas_data.energy, xas_data.pre_edge, "g", label="pre-edge") |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
324 plt.plot(xas_data.energy, xas_data.post_edge, "r", label="post-edge") |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
325 plt.plot(xas_data.energy, xas_data.mu, "b", label="fit data") |
4
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
326 if hasattr(xas_data, "mu_std"): |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
327 plt.fill_between( |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
328 x=xas_data.energy, |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
329 y1=xas_data.mu - xas_data.mu_std, |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
330 y2=xas_data.mu + xas_data.mu_std, |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
331 alpha=0.2, |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
332 label="standard deviation", |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
333 ) |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
334 e0 = xas_data.e0 |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
335 plt.axvline(e0, color="m", label=f"edge energy = {e0}") |
3
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
336 plt.grid(color="r", linestyle=":", linewidth=1) |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
337 plt.xlabel("Energy (eV)") |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
338 plt.ylabel("x$\mu$(E)") # noqa: W605 |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
339 plt.title("Pre-edge and post_edge fitting to $\mu$") # noqa: W605 |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
340 plt.legend() |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
341 index += 1 |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
342 |
3
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
343 if "flat" in plot_keys: |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
344 plt.subplot(nrows, 1, index) |
4
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
345 plt.plot(xas_data.energy, xas_data.flat, label="flattened signal") |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
346 if hasattr(xas_data, "mu_std"): |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
347 mu_std_normalised = xas_data.mu_std / xas_data.edge_step |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
348 plt.fill_between( |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
349 x=xas_data.energy, |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
350 y1=xas_data.flat - mu_std_normalised, |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
351 y2=xas_data.flat + mu_std_normalised, |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
352 alpha=0.2, |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
353 label="standard deviation", |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
354 ) |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
355 plt.legend() |
3
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
356 plt.grid(color="r", linestyle=":", linewidth=1) |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
357 plt.xlabel("Energy (eV)") |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
358 plt.ylabel("Flattened x$\mu$(E)") # noqa: W605 |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
359 index += 1 |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
360 |
3
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
361 if "dmude" in plot_keys: |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
362 plt.subplot(nrows, 1, index) |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
363 plt.plot(xas_data.energy, xas_data.dmude) |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
364 plt.grid(color="r", linestyle=":", linewidth=1) |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
365 plt.xlabel("Energy (eV)") |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
366 plt.ylabel("Derivative normalised to x$\mu$(E)") # noqa: W605 |
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
367 index += 1 |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
368 |
3
82e9dd980916
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit d4c7e090dc5c94395d7e1574845ac2c76f2e4f5f
muon-spectroscopy-computational-project
parents:
2
diff
changeset
|
369 plt.tight_layout(rect=(0, 0, 0.88, 1)) |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
370 plt.savefig(plot_path, format="png") |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
371 plt.close("all") |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
372 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
373 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
374 if __name__ == "__main__": |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
375 # larch imports set this to an interactive backend, so need to change it |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
376 matplotlib.use("Agg") |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
377 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
378 dat_file = sys.argv[1] |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
379 input_values = json.load(open(sys.argv[2], "r", encoding="utf-8")) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
380 merge_inputs = input_values["merge_inputs"]["merge_inputs"] |
4
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
381 format_inputs = input_values["merge_inputs"]["format"] |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
382 if "is_zipped" in format_inputs: |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
383 is_zipped = bool(format_inputs["is_zipped"]["is_zipped"]) |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
384 else: |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
385 is_zipped = False |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
386 |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
387 extract_group = None |
4
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
388 if "extract_group" in format_inputs: |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
389 extract_group = format_inputs["extract_group"] |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
390 |
4
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
391 if "energy_column" not in format_inputs: |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
392 energy_column = None |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
393 else: |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
394 energy_column = format_inputs["energy_column"]["energy_column"] |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
395 if energy_column == "auto": |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
396 energy_column = None |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
397 elif energy_column == "other": |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
398 energy_column_input = format_inputs["energy_column"] |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
399 energy_column = energy_column_input["energy_column_text"] |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
400 |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
401 if "mu_column" not in format_inputs: |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
402 mu_column = None |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
403 else: |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
404 mu_column = format_inputs["mu_column"]["mu_column"] |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
405 if mu_column == "auto": |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
406 mu_column = None |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
407 elif mu_column == "other": |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
408 mu_column = format_inputs["mu_column"]["mu_column_text"] |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
409 |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
410 reader = Reader( |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
411 energy_column=energy_column, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
412 mu_column=mu_column, |
4
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
413 data_format=format_inputs["format"], |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
414 extract_group=extract_group, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
415 ) |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
416 keyed_data = reader.load_data( |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
417 dat_file=dat_file, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
418 merge_inputs=merge_inputs, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
419 is_zipped=is_zipped, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
420 ) |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
421 |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
422 calibrate_items = input_values["processing"]["calibrate"].items() |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
423 calibrate_settings = {k: v for k, v in calibrate_items if v is not None} |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
424 do_calibrate = calibrate_settings.pop("calibrate") == "true" |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
425 |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
426 do_rebin = input_values["processing"].pop("rebin") |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
427 |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
428 pre_edge_items = input_values["processing"]["pre_edge"].items() |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
429 pre_edge_settings = {k: v for k, v in pre_edge_items if v is not None} |
4
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
430 do_pre_edge = bool(pre_edge_settings.pop("pre_edge")) |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
431 |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
432 ref_channel = None |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
433 if "ref_channel" in pre_edge_settings: |
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
434 ref_channel = pre_edge_settings.pop("ref_channel") |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
435 |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
436 xftf_items = input_values["processing"]["xftf"].items() |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
437 xftf_settings = {k: v for k, v in xftf_items if v is not None} |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
438 do_xftf = xftf_settings.pop("xftf") == "true" |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
439 |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
440 plot_graph = input_values["plot_graph"] |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
441 annotation = input_values["annotation"] |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
442 |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
443 for key, group in keyed_data.items(): |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
444 main( |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
445 group, |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
446 do_calibrate=do_calibrate, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
447 calibrate_settings=calibrate_settings, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
448 do_rebin=do_rebin, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
449 do_pre_edge=do_pre_edge, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
450 pre_edge_settings=pre_edge_settings, |
4
a0d3b0fe0fa3
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 3fe6078868efd0fcea0fb5eea8dcd4b152d9c0a8
muon-spectroscopy-computational-project
parents:
3
diff
changeset
|
451 ref_channel=ref_channel, |
1
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
452 do_xftf=do_xftf, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
453 xftf_settings=xftf_settings, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
454 plot_graph=plot_graph, |
2b3115342fef
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 1cf6d7160497ba58fe16a51f00d088a20934eba6
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
455 annotation=annotation, |
0
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
456 path_key=key, |
ae2f265ecf8e
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
457 ) |