Mercurial > repos > muon-spectroscopy-computational-project > muspinsim_config
annotate build_file.py @ 3:331d0776abb4 draft
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
author | muon-spectroscopy-computational-project |
---|---|
date | Fri, 03 Feb 2023 15:39:07 +0000 |
parents | c70012022f0f |
children | e1e338f56656 |
rev | line source |
---|---|
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
1 import json |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
2 import re |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
3 import sys |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
4 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
5 from muspinsim import MuSpinInput |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
6 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
7 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
8 def write_file(file_name, content): |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
9 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
10 Write muspinsim file |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
11 :param file_name: name of file |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
12 :param content: list of strings containing blocks to write |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
13 """ |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
14 with open(file_name, "w", encoding="utf-8") as file: |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
15 file.write( |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
16 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
17 ####################################################### |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
18 # Muspinsim Input File |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
19 # Generated using Muon Galaxy Tool Muspinsim_Input |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
20 #######################################################\n\n""" |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
21 ) |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
22 file.write("".join(content)) |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
23 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
24 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
25 def build_block(title, vals): |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
26 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
27 Build keyword block |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
28 :param title: string - Keyword |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
29 :param vals: list of strings - lines containing values for keyword |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
30 :return: A string containing formatted keyword block |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
31 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
32 return "{0}\n {1}\n".format(title, "\n ".join(vals)) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
33 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
34 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
35 def format_entry(entry): |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
36 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
37 Helper function to remove whitespace between function parameters |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
38 and remove ',' or ';' inbetween parameters |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
39 :param entry: string - user entry |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
40 :return: string containing only valid parameters |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
41 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
42 stck = [] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
43 new_str = "" |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
44 for i, char in enumerate(entry): |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
45 if char == "(": |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
46 stck.append(i) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
47 elif char == ")": |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
48 if len(stck) == 0: |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
49 raise ValueError( |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
50 f"Could not parse entry {entry} brackets mismatch - " |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
51 f"unexpected ')' found on char {i}" |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
52 ) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
53 stck.pop() |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
54 elif char == " " and len(stck) > 0: |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
55 continue |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
56 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
57 # remove ',' between functions |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
58 elif char in [",", ";"] and len(stck) == 0: |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
59 new_str += " " |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
60 continue |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
61 new_str += char |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
62 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
63 if len(stck) != 0: |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
64 raise ValueError( |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
65 f"Could not parse entry {entry} brackets mismatch - unclosed '(' " |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
66 f"found on char(s): {stck}" |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
67 ) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
68 return new_str |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
69 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
70 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
71 def split_into_args(entry, nargs=1): |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
72 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
73 Helper function to split input into a list of args |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
74 :param entry: a string containing a user inputted line |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
75 :param nargs: number of expected arguments |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
76 :return: a list of arguments found |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
77 :exception: ValueError - if number of arguments |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
78 found does not match expected (nargs) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
79 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
80 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
81 # remove square brackets and extra whitespace/newline |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
82 content = " ".join(entry.replace("[", "").replace("]", "").split()) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
83 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
84 # remove whitespace in between expressions/functions |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
85 # remove commas/semicolons in between expressions/functions |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
86 # split on whitespace to separate args |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
87 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
88 content = re.split(r"\s", format_entry(content)) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
89 chars = [elem.strip() for elem in content if elem != ""] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
90 if len(chars) != nargs: |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
91 raise ValueError( |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
92 f"Could not parse entry {entry} incorrect number of args found " |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
93 f"{len(chars)}:\n({chars})\nBut expected {nargs}" |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
94 ) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
95 return chars |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
96 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
97 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
98 def parse_matrix(entry_string, size): |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
99 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
100 Helper function to parse and format matrix/vector |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
101 to be readable by MuSpinSim |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
102 :param entry_string: a user input string for a matrix/vector |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
103 :param size: (x, y) integer tuple: dimensions of matrix |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
104 :return: a list of strings of length y, each string |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
105 containing x elements (space separated) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
106 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
107 content = split_into_args(entry_string, nargs=size[0] * size[1]) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
108 return [ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
109 " ".join(content[x: x + size[0]]) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
110 for x in range(0, len(content), size[0]) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
111 ] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
112 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
113 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
114 def parse_interactions(interaction): |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
115 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
116 Helper function to build keyword blocks for all |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
117 interaction parameters entered |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
118 (hyperfine, zeeman, dipolar, quadrupolar and dissipation) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
119 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
120 :param interaction: a dictionary containing all interaction parameters |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
121 :return: a string containing several formatted blocks |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
122 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
123 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
124 options = interaction["interaction_options"] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
125 interaction_type = options["interaction"] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
126 try: |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
127 return { |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
128 "zeeman": lambda options: build_block( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
129 "zeeman {0}".format(options["zeeman_index"]), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
130 parse_matrix(options["zeeman_vector"], (3, 1)), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
131 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
132 "hyperfine": lambda options: build_block( |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
133 ( |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
134 f"hyperfine {options['hfine_index']} " |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
135 f"""{ |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
136 options['hfine_e_index'] |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
137 if options['hfine_e_index'] else '' |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
138 }""" |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
139 ).strip(), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
140 parse_matrix(options["hfine_matrix"], (3, 3)), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
141 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
142 "dipolar": lambda options: build_block( |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
143 f"dipolar {options['di_index']} {options['di_index_2']}", |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
144 parse_matrix(options["di_vector"], (3, 1)), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
145 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
146 "quadrupolar": lambda options: build_block( |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
147 f"quadrupolar {options['quad_index']}", |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
148 parse_matrix(options["quad_matrix"], (3, 3)), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
149 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
150 "dissipation": lambda options: build_block( |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
151 f"dissipation {options['dis_index']}", |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
152 [options["dis_val"]], |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
153 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
154 }.get(interaction_type)(options) |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
155 except ValueError as exc: |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
156 raise ValueError(f"Error occurred when parsing {exc}") from exc |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
157 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
158 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
159 def parse_orientation(orientation): |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
160 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
161 Helper function to parse orientation keyword arguments |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
162 :param orientation: a dictionary containing one set of |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
163 orientation arguments |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
164 :return: a formatted string |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
165 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
166 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
167 options = orientation["orientation_options"] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
168 preset = options["orientation_preset"] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
169 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
170 return { |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
171 "zcw": lambda options: "zcw({0})".format( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
172 " ".join(split_into_args(options["zcw_n"], 1)) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
173 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
174 "eulrange": lambda options: "eulrange({0})".format( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
175 " ".join(split_into_args(options["eul_n"], 1)) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
176 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
177 "2_polar": lambda options: "{0} {1}".format( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
178 " ".join(split_into_args(options["theta"], 1)), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
179 " ".join(split_into_args(options["phi"], 1)), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
180 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
181 "3_euler": lambda options: "{0} {1} {2}".format( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
182 " ".join(split_into_args(options["eul_1"], 1)), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
183 " ".join(split_into_args(options["eul_2"], 1)), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
184 " ".join(split_into_args(options["eul_3"], 1)), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
185 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
186 "4_euler": lambda options: "{0} {1} {2} {3}".format( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
187 " ".join(split_into_args(options["eul_1"], 1)), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
188 " ".join(split_into_args(options["eul_2"], 1)), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
189 " ".join(split_into_args(options["eul_3"], 1)), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
190 options["weight"], |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
191 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
192 }.get(preset)(options) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
193 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
194 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
195 def parse_polarization(polarization): |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
196 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
197 Helper function to parse polarization keyword arguments |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
198 :param polarization: a dictionary containing one set |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
199 of polarization arguments |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
200 :return: a formatted string |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
201 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
202 options = polarization["polarization_options"] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
203 preset = options["polarization_preset"] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
204 if preset != "custom": |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
205 return preset |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
206 else: |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
207 try: |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
208 return " ".join(split_into_args(options["polarization"], 1)) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
209 except ValueError: |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
210 return " ".join(split_into_args(options["polarization"], 3)) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
211 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
212 |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
213 def parse_field(field, field_type): |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
214 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
215 Helper function to parse field keyword arguments |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
216 :param field: a dictionary containing one set of field arguments |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
217 :param field_type: a string giving the type of field, either field or |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
218 intrinsic_field |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
219 :return: a formatted string |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
220 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
221 try: |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
222 return " ".join(split_into_args(field[field_type], 1)) |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
223 except ValueError: |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
224 return " ".join(split_into_args(field[field_type], 3)) |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
225 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
226 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
227 def parse_fitting_variables(fitting_variables): |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
228 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
229 Helper function to parse field keyword fitting_variables |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
230 :param fitting_variables: a dictionary containing one set of |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
231 arguments |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
232 :return: a formatted string |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
233 """ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
234 return "{0} {1} {2} {3}".format( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
235 fitting_variables["var_name"].strip().replace(" ", "_"), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
236 " ".join(split_into_args(fitting_variables["start_val"], 1)) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
237 if fitting_variables["start_val"].strip() != "" |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
238 else "", |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
239 " ".join(split_into_args(fitting_variables["min_bound"], 1)) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
240 if fitting_variables["min_bound"].strip() != "" |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
241 else "", |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
242 " ".join(split_into_args(fitting_variables["max_bound"], 1)) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
243 if fitting_variables["max_bound"].strip() != "" |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
244 else "", |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
245 ).strip() |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
246 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
247 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
248 def parse_spin(spin): |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
249 """ |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
250 Helper function for parsing a spin |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
251 :param spin: a dictionary containing a spin object from the config either |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
252 just a spin_preset or a custom value with a name and |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
253 atomic_mass |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
254 """ |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
255 if spin["spin_preset"] != "custom": |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
256 return spin["spin_preset"] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
257 else: |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
258 elem_name = spin["spin"].strip() |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
259 if elem_name not in ["e", "mu"]: |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
260 elem_name = elem_name.capitalize() |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
261 return ( |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
262 f"{int(spin['atomic_mass']) if spin['atomic_mass'] else ''}" |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
263 f"{elem_name}" |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
264 ).strip() |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
265 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
266 |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
267 def parse_celio(celio_params): |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
268 """ |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
269 Helper function for parsing Celio's method parameters |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
270 :param celio_params: a dictionary containing the parameters for Celio's |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
271 method |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
272 """ |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
273 options = celio_params["celio_options"] |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
274 if not options["celio_enabled"]: |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
275 return "" |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
276 else: |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
277 # Now have celio_k and potentially celio_averages |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
278 celio_k = options["celio_k"] |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
279 celio_averages = options["celio_averages"] |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
280 |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
281 # As celio_averages is optional so may be None |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
282 if celio_averages is None: |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
283 celio_averages = "" |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
284 |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
285 return build_block("celio", [f"{celio_k} {celio_averages}".strip()]) |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
286 |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
287 |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
288 parse_func_dict = { |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
289 "spins": lambda values: build_block( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
290 "spins", |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
291 [" ".join([parse_spin(entry["spin_options"]) for entry in values])], |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
292 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
293 # either 1x3 vector or scalar or function |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
294 "fields": lambda values: build_block( |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
295 "field", [parse_field(entry, "field") for entry in values] |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
296 ), |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
297 "intrinsic_fields": lambda values: build_block( |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
298 "intrinsic_field", |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
299 [parse_field(entry, "intrinsic_field") for entry in values], |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
300 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
301 # either scalar or single function |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
302 "times": lambda values: build_block( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
303 "time", |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
304 [" ".join(split_into_args(entry["time"], 1)) for entry in values], |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
305 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
306 # either scalar or single function |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
307 "temperatures": lambda values: build_block( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
308 "temperature", |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
309 [ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
310 " ".join(split_into_args(entry["temperature"], 1)) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
311 for entry in values |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
312 ], |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
313 ), |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
314 "axes_options": { |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
315 "x_axis_options": { |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
316 "x_axis": lambda value: build_block("x_axis", [value]), |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
317 "average_axes": lambda values: build_block( |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
318 "average_axes", values), |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
319 }, |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
320 "x_axis": lambda value: build_block("x_axis", [value]), |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
321 "y_axis": lambda value: build_block("y_axis", [value]), |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
322 "average_axes": lambda values: build_block( |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
323 "average_axes", values) |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
324 }, |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
325 "average_axes": lambda values: build_block("average_axes", values), |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
326 "experiment_preset": lambda value: build_block("experiment", [value]), |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
327 "orientations": lambda values: build_block( |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
328 f"orientation {EULER_CONVENTION}", |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
329 [parse_orientation(entry) for entry in values], |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
330 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
331 "interactions": lambda values: "".join( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
332 [parse_interactions(entry) for entry in values] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
333 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
334 "polarizations": lambda values: build_block( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
335 "polarization", |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
336 [parse_polarization(entry) for entry in values], |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
337 ), |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
338 "celio_params": parse_celio, |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
339 "fitting": lambda value: build_block( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
340 "fitting_data", ['load("fitting_data.dat")'] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
341 ), |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
342 "fitting_method": lambda value: build_block("fitting_method", [value]), |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
343 "fitting_variables": lambda values: build_block( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
344 "fitting_variables", |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
345 [parse_fitting_variables(entry) for entry in values], |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
346 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
347 "fitting_tolerance": lambda value: build_block( |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
348 "fitting_tolerance", |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
349 [str(value)], |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
350 ), |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
351 } |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
352 EULER_CONVENTION = "ZYZ" |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
353 |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
354 # Gives replacement values in the case a parameter is unassigned |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
355 parse_none_dict = { |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
356 # Allow average_axis to be None as by default is orientation in |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
357 # muspinsim but letting the UI present this here instead |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
358 "average_axes": ["none"], |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
359 } |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
360 |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
361 |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
362 def parse_dict(dictionary, params, file_contents) -> bool: |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
363 """ |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
364 Helper function for parsing nested dictionaries defined above |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
365 containing parse functions |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
366 :returns: Whether an error occurred |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
367 """ |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
368 |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
369 err_found = False |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
370 for keyword, val in params.items(): |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
371 |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
372 # Either don't allow the value to be None or replace |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
373 # with value in the parse_none_dict above |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
374 should_assign = val and val not in ["None"] |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
375 if not should_assign and keyword in parse_none_dict: |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
376 should_assign = keyword in parse_none_dict |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
377 val = parse_none_dict[keyword] |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
378 |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
379 if should_assign: |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
380 try: |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
381 keyword_func = dictionary.get(keyword) |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
382 # Check for nested dict, and add that contents as well if found |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
383 if isinstance(keyword_func, dict): |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
384 err_found = err_found or parse_dict( |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
385 keyword_func, val, file_contents) |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
386 else: |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
387 if keyword_func: |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
388 file_contents.append(keyword_func(val)) |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
389 |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
390 except ValueError as exc: |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
391 sys.stderr.write( |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
392 f"Error occurred when parsing {keyword}\n{str(exc)}" |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
393 ) |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
394 err_found = True |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
395 return err_found |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
396 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
397 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
398 def main(): |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
399 """ |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
400 Entry point |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
401 """ |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
402 input_json_path = sys.argv[1] |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
403 mu_params = json.load(open(input_json_path, "r", encoding="utf-8")) |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
404 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
405 out_file_name = mu_params["out_file_prefix"].strip().replace(" ", "_") |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
406 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
407 # combine all sections |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
408 mu_params = { |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
409 **mu_params["spins"], |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
410 **mu_params["interaction_params"], |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
411 **mu_params["experiment_params"], |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
412 **mu_params["fitting_params"]["fitting_options"], |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
413 } |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
414 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
415 # get experiment parameters |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
416 experiment = mu_params["experiment"] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
417 mu_params = {**mu_params, **experiment} |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
418 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
419 if experiment["experiment_preset"] == "custom": |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
420 del mu_params["experiment_preset"] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
421 del mu_params["experiment"] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
422 |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
423 global EULER_CONVENTION |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
424 EULER_CONVENTION = mu_params["euler_convention"] |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
425 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
426 file_contents = [ |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
427 build_block("name", [out_file_name.strip().replace(" ", "_")]) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
428 ] |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
429 |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
430 if parse_dict(parse_func_dict, mu_params, file_contents): |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
431 sys.exit(1) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
432 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
433 write_file("outfile.in", file_contents) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
434 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
435 try: |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
436 MuSpinInput(open("outfile.in", encoding="utf-8")) |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
437 except Exception as exc: # pylint: disable=broad-except |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
438 sys.stdout.write( |
3
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
439 "Warning, This created file may not work properly. Error(s) " |
331d0776abb4
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 4f06b404d8b7fb83995f3052faa7e2ec7811f507
muon-spectroscopy-computational-project
parents:
0
diff
changeset
|
440 f"encountered when trying to parse the file : {str(exc)}" |
0
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
441 ) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
442 sys.exit(1) |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
443 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
444 |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
445 if __name__ == "__main__": |
c70012022f0f
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff
changeset
|
446 main() |