annotate build_file.py @ 1:844b73d2f40c draft

planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit 1f0d5da860dd5cd0ffceac7a292773ed53617324
author muon-spectroscopy-computational-project
date Thu, 15 Sep 2022 10:18:52 +0000
parents c70012022f0f
children 331d0776abb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 """
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
14 with open(file_name, "w") as f:
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
15 f.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
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 #######################################################
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
18 #Muspinsim Input 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
19 #Generated using Muon Galaxy Tool Muspinsim_Input
c70012022f0f planemo upload 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 )
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
22 f.write("".join(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
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(
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
50 "Could not parse entry {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
51 "brackets mismatch - unexpected ')' "
c70012022f0f planemo upload 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 "found on char {1}".format(entry, 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
53 )
c70012022f0f planemo upload 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 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
55 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
56 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
57
c70012022f0f planemo upload 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 # 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
59 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
60 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
61 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
62 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
63
c70012022f0f planemo upload 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 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
65 raise 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
66 "Could not parse entry {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 "brackets mismatch - unclosed '(' found on char(s): {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
68 entry, 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
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 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
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
c70012022f0f planemo upload 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 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
75 """
c70012022f0f planemo upload 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 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
77 :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
78 :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
79 :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
80 :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
81 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
82 """
c70012022f0f planemo upload 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 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
85 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
86
c70012022f0f planemo upload 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 # 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
88 # 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
89 # 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
90
c70012022f0f planemo upload 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 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
92 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
93 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
94 raise 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
95 "Could not parse entry {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
96 " incorrect number 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
97 " found {1}:\n({2})\nBut expected {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
98 entry, len(chars), 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
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 )
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
101 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
102
c70012022f0f planemo upload 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
c70012022f0f planemo upload 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 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
105 """
c70012022f0f planemo upload 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 Helper function to parse and format 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
107 to be readable by Muspinsim
c70012022f0f planemo upload 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 :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
109 :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
110 :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
111 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
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 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
114 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
115 " ".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
116 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
117 ]
c70012022f0f planemo upload 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
c70012022f0f planemo upload 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 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
121 """
c70012022f0f planemo upload 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 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
123 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
124 (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
125
c70012022f0f planemo upload 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 :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
127 :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
128 """
c70012022f0f planemo upload 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
c70012022f0f planemo upload 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 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
131 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
132 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
133 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
134 "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
135 "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
136 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
137 ),
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
138 "hyperfine": 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
139 "hyperfine {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
140 options["hfine_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
141 options["hfine_e_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
142 if options["hfine_e_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
143 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
144 ).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
145 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
146 ),
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
147 "dipolar": 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
148 "dipolar {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
149 options["di_index"], options["di_index_2"]
c70012022f0f planemo upload 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 ),
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
151 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
152 ),
c70012022f0f planemo upload 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 "quadrupolar": 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
154 "quadrupolar {0}".format(options["quad_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
155 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
156 ),
c70012022f0f planemo upload 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 "dissipation": 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
158 "dissipation {0}".format(options["dis_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
159 [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
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 }.get(interaction_type)(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
162 except ValueError as e:
c70012022f0f planemo upload 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 raise ValueError("Error occurred when parsing {0}".format(e))
c70012022f0f planemo upload 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
c70012022f0f planemo upload 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 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
167 """
c70012022f0f planemo upload 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 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
169 :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
170 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
171 :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
172 """
c70012022f0f planemo upload 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 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
175 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
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 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
178 "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
179 " ".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
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 "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
182 " ".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
183 ),
c70012022f0f planemo upload 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 "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
185 " ".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
186 " ".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
187 ),
c70012022f0f planemo upload 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 "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
189 " ".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
190 " ".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
191 " ".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
192 ),
c70012022f0f planemo upload 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 "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
194 " ".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
195 " ".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
196 " ".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
197 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
198 ),
c70012022f0f planemo upload 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 }.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
200
c70012022f0f planemo upload 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 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
203 """
c70012022f0f planemo upload 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 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
205 :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
206 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
207 :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
208 """
c70012022f0f planemo upload 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 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
210 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
211 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
212 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
213 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
214 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
215 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
216 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
217 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
218
c70012022f0f planemo upload 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
c70012022f0f planemo upload 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 def parse_field(field):
c70012022f0f planemo upload 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 """
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
222 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
223 :param field: a dictionary containing one set of field 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
224 :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
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 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
227 return " ".join(split_into_args(field["field"], 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
228 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
229 return " ".join(split_into_args(field["field"], 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
230
c70012022f0f planemo upload 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
c70012022f0f planemo upload 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 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
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 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
235 :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
236 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
237 :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
238 """
c70012022f0f planemo upload 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 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
240 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
241 " ".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
242 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
243 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
244 " ".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
245 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
246 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
247 " ".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
248 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
249 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
250 ).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
251
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
252
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
253 def parse_spin(spin):
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
254 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
255 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
256 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
257 elem_name = spin["spin"].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
258 if elem_name not in ['e', 'mu']:
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
259 elem_name = elem_name.capitalize()
c70012022f0f planemo upload 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 return "{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
261 int(spin["atomic_mass"]) if spin["atomic_mass"] 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
262 elem_name
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
263 ).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
264
c70012022f0f planemo upload 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 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
267 "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
268 "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
269 [
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
270 " ".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
271 [
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
272 parse_spin(entry["spin_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
273 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
274 ]
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
275 )
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
276 ],
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
277 ),
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
278 # 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
279 "fields": 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
280 "field", [parse_field(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
281 ),
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
282 # 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
283 "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
284 "time",
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
285 [
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
286 " ".join(split_into_args(entry["time"], 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
287 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
288 ],
c70012022f0f planemo upload 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 ),
c70012022f0f planemo upload 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 # 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
291 "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
292 "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
293 [
c70012022f0f planemo upload 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 " ".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
295 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
296 ],
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
297 ),
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
298 "x_axis": lambda value: build_block("x_axis", [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
299 "y_axis": lambda value: build_block("y_axis", [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
300 "average_axes": 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
301 "average_axes", 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
302 ),
c70012022f0f planemo upload 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 "experiment_preset": 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
304 "experiment", [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
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 "orientations": 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
307 "orientation {0}".format(euler_convention),
c70012022f0f planemo upload 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 [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
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 "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
311 [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
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 "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
314 "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
315 [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
316 ),
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
317 "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
318 "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
319 ),
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
320 "fitting_method": 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
321 "fitting_method", [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
322 ),
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
323 "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
324 "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
325 [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
326 ),
c70012022f0f planemo upload 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 "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
328 "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
329 [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
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 }
c70012022f0f planemo upload 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 euler_convention = 'ZYZ'
c70012022f0f planemo upload 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
c70012022f0f planemo upload 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 def 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
336 input_json_path = sys.argv[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
337 mu_params = json.load(open(input_json_path, "r"))
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
338
c70012022f0f planemo upload 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 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
340
c70012022f0f planemo upload 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 # 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
342 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
343 **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
344 **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
345 **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
346 **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
347 }
c70012022f0f planemo upload 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
c70012022f0f planemo upload 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 # 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
350 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
351 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
352
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
353 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
354 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
355 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
356
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
357 global euler_convention
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
358 euler_convention = mu_params["euler_convention"]
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
359
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
360 err_found = False
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
361 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
362 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
363 ]
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
364 for keyword, val in mu_params.items():
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
365 if val and val not in ["None"]:
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
366 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
367 keyword_func = parse_func_dict.get(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
368 if keyword_func:
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
369 file_contents.append(keyword_func(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
370
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
371 except ValueError as e:
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
372 sys.stderr.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
373 "Error occurred when parsing {0}\n{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
374 keyword, str(e)
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
375 )
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
376 )
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
377 err_found = True
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
378
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
379 if err_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
380 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
381
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
382 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
383
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
384 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
385 MuSpinInput(open("outfile.in"))
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
386 except Exception as e:
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
387 sys.stdout.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
388 "Warning, This created file may not work properly. "
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
389 "Error(s) encountered when trying to parse the file : {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
390 str(e)
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
391 )
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
392 )
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
393 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
394
c70012022f0f planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_config commit d130cf2c46d933fa9d0214ddbd5ddf860f322dc4
muon-spectroscopy-computational-project
parents:
diff changeset
395
c70012022f0f planemo upload 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 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
397 main()