Mercurial > repos > muon-spectroscopy-computational-project > larch_select_paths
changeset 4:204c4afe2f1e draft default tip
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_select_paths commit 4814f53888643f1d3667789050914675fffb7d59
author | muon-spectroscopy-computational-project |
---|---|
date | Fri, 23 Aug 2024 14:10:59 +0000 |
parents | 1d08395c1a9f |
children | |
files | larch_select_paths.py larch_select_paths.xml test-data/gds_altered_defaults.csv test-data/gds_default.csv test-data/gds_include_path_3_custom_name.csv test-data/gds_include_path_3_custom_name_value.csv test-data/gds_merge_custom.csv test-data/sp_criteria.csv test-data/sp_default.csv test-data/sp_include_path_3.csv test-data/sp_include_path_3_custom_name.csv test-data/sp_merge_custom.csv test-data/sp_merge_default.csv test-data/sp_select_all_false.csv |
diffstat | 14 files changed, 113 insertions(+), 82 deletions(-) [+] |
line wrap: on
line diff
--- a/larch_select_paths.py Thu Apr 11 09:02:33 2024 +0000 +++ b/larch_select_paths.py Fri Aug 23 14:10:59 2024 +0000 @@ -58,9 +58,10 @@ class GDSWriter: def __init__(self, default_variables: "dict[str, dict]"): self.default_properties = { + "degen": {"name": "degen"}, "s02": {"name": "s02"}, "e0": {"name": "e0"}, - "deltar": {"name": "alpha*reff"}, + "deltar": {"name": "alpha"}, "sigma2": {"name": "sigma2"}, } self.rows = [ @@ -113,9 +114,14 @@ raise ValueError(f"{formatted_name} already used as variable name") self.names.add(formatted_name) + if value is not None: + formatted_value = str(value) + else: + formatted_value = "" + self.rows.append( - f"{len(self.rows):4d}, {formatted_name:>24s}, {str(value):>5s}, " - f"{expr:>4s}, {str(vary):>4s}\n" + f"{len(self.rows):4d}, {formatted_name:>24s}, " + f"{formatted_value:>5s}, {expr:>4s}, {str(vary):>4s}\n" ) def parse_gds( @@ -179,8 +185,8 @@ class PathsWriter: def __init__(self, default_variables: "dict[str, dict]"): self.rows = [ - f"{'id':>4s}, {'filename':>24s}, {'label':>24s}, {'s02':>3s}, " - f"{'e0':>4s}, {'sigma2':>24s}, {'deltar':>10s}\n" + f"{'id':>4s}, {'filename':>24s}, {'label':>24s}, {'degen':>5s}, " + f"{'s02':>3s}, {'e0':>4s}, {'sigma2':>24s}, {'deltar':>10s}\n" ] self.gds_writer = GDSWriter(default_variables=default_variables) self.all_combinations = [[0]] # 0 corresponds to the header row @@ -323,10 +329,11 @@ filename: str, path_label: str, directory_label: str = "", + degen: str = "degen", s02: str = "s02", e0: str = "e0", sigma2: str = "sigma2", - deltar: str = "alpha*reff", + deltar: str = "alpha", ) -> int: """Format and append row representing a selected FEFF path. @@ -336,13 +343,15 @@ path_label (str): Label indicating the atoms involved in this path. directory_label (str, optional): Label to indicate paths from a separate directory. Defaults to "". + degen (str, optional): Path degeneracy variable name. + Defaults to "degen". s02 (str, optional): Electron screening factor variable name. Defaults to "s02". e0 (str, optional): Energy shift variable name. Defaults to "e0". sigma2 (str, optional): Mean squared displacement variable name. Defaults to "sigma2". deltar (str, optional): Change in path length variable. - Defaults to "alpha*reff". + Defaults to "alpha". Returns: int: The id of the added row. @@ -356,8 +365,8 @@ row_id = len(self.rows) self.rows.append( - f"{row_id:>4d}, {filename:>24s}, {label:>24s}, " - f"{s02:>3s}, {e0:>4s}, {sigma2:>24s}, {deltar:>10s}\n" + f"{row_id:>4d}, {filename:>24s}, {label:>24s}, {degen:>5s}, " + f"{s02:>3s}, {e0:>4s}, {sigma2:>24s}, {deltar + '*reff':>10s}\n" ) return row_id
--- a/larch_select_paths.xml Thu Apr 11 09:02:33 2024 +0000 +++ b/larch_select_paths.xml Fri Aug 23 14:10:59 2024 +0000 @@ -2,7 +2,7 @@ <description>select FEFF paths for XAFS data</description> <macros> <!-- version of underlying tool (PEP 440) --> - <token name="@TOOL_VERSION@">0.9.75</token> + <token name="@TOOL_VERSION@">0.9.80</token> <!-- version of this tool wrapper (integer) --> <token name="@WRAPPER_VERSION@">0</token> <!-- citation should be updated with every underlying tool version --> @@ -45,6 +45,11 @@ </configfiles> <inputs> <section name="variables" expanded="false" title="GDS variable defaults" help="Define default values for variables in the EXAFS equation to use for the paths selected below."> + <section name="degen" expanded="false" title="N: path degeneracy"> + <param name="is_common" type="boolean" checked="true" label="Use path default" help="If set, a single variable 'degen' will be used for all paths. Otherwise, each path has a distinct variable."/> + <param name="value" type="float" optional="true" min="0.0" label="Value" help="The initial value for 'degen'. This will depend on the structure and path in question. If unset, then the path default will be used."/> + <expand macro="vary"/> + </section> <section name="s02" expanded="false" title="S02: passive electron reduction factor"> <param name="is_common" type="boolean" checked="true" label="Common to all paths" help="If set, a single variable 's02' will be used for all paths. Otherwise, each path has a distinct variable."/> <param name="value" type="float" value="1.0" min="0.0" max="1.0" label="Value" help="The initial value for 's02'. This is typically between 0.7 and 1.0."/> @@ -80,6 +85,12 @@ <when value="all"> <repeat name="paths" title="Define path variables" help="Overwrite the default variables defined above for chosen paths."> <param name="id" type="integer" value="1" min="1" label="Path ID" help="Numerical id of a path to select, this appears at the end of the label and filename in the path summary CSV."/> + <section name="degen" expanded="false" title="N: path degeneracy"> + <expand macro="name"/> + <param name="value" type="float" optional="true" min="0.0" label="Value" help="The initial value for 'degen'. This will depend on the structure and path in question."/> + <expand macro="expr"/> + <expand macro="vary"/> + </section> <section name="s02" expanded="false" title="S02: passive electron reduction factor"> <expand macro="name"/> <param name="value" type="float" value="1.0" min="0.0" max="1.0" label="Value" help="The initial value for 's02'. This is typically between 0.7 and 1.0."/> @@ -123,6 +134,12 @@ <when value="manual"> <repeat name="paths" title="Select paths" help="Identify paths to use in the fitting by their id, and optionally define their variables. This will overwrite and defaults set above."> <param name="id" type="integer" value="1" min="1" label="Path ID" help="Numerical id of a path to select, this appears at the end of the label and filename in the path summary CSV."/> + <section name="degen" expanded="false" title="N: path degeneracy"> + <expand macro="name"/> + <param name="value" type="float" value="1.0" min="0.0" optional="true" label="Value" help="The initial value for 'degen'. This will depend on the structure and path in question. If unset, then the path default will be used."/> + <expand macro="expr"/> + <expand macro="vary"/> + </section> <section name="s02" expanded="false" title="S02: passive electron reduction factor"> <expand macro="name"/> <param name="value" type="float" value="1.0" min="0.0" max="1.0" label="Value" help="The initial value for 's02'. This is typically between 0.7 and 1.0."/>
--- a/test-data/gds_altered_defaults.csv Thu Apr 11 09:02:33 2024 +0000 +++ b/test-data/gds_altered_defaults.csv Fri Aug 23 14:10:59 2024 +0000 @@ -1,5 +1,6 @@ id, name, value, expr, vary - 1, s02, 0.1, , False - 2, e0, 0.1, , True - 3, alpha, 10.0, , False - 4, sigma2, 0.003, , True + 1, degen, , , True + 2, s02, 0.1, , False + 3, e0, 0.1, , True + 4, alpha, 10.0, , False + 5, sigma2, 0.003, , True
--- a/test-data/gds_default.csv Thu Apr 11 09:02:33 2024 +0000 +++ b/test-data/gds_default.csv Fri Aug 23 14:10:59 2024 +0000 @@ -1,5 +1,6 @@ id, name, value, expr, vary - 1, s02, 1.0, , True - 2, e0, 0.0, , True - 3, alpha, 0.0, , True - 4, sigma2, 0.003, , True + 1, degen, , , True + 2, s02, 1.0, , True + 3, e0, 0.0, , True + 4, alpha, 0.0, , True + 5, sigma2, 0.003, , True
--- a/test-data/gds_include_path_3_custom_name.csv Thu Apr 11 09:02:33 2024 +0000 +++ b/test-data/gds_include_path_3_custom_name.csv Fri Aug 23 14:10:59 2024 +0000 @@ -1,6 +1,7 @@ id, name, value, expr, vary - 1, s02, 1.0, , True - 2, e0, 0.0, , True - 3, alpha, 0.0, , True - 4, sigma2, 0.003, , True - 5, custom_name, 0.003, , True + 1, degen, , , True + 2, s02, 1.0, , True + 3, e0, 0.0, , True + 4, alpha, 0.0, , True + 5, sigma2, 0.003, , True + 6, custom_name, 0.003, , True
--- a/test-data/gds_include_path_3_custom_name_value.csv Thu Apr 11 09:02:33 2024 +0000 +++ b/test-data/gds_include_path_3_custom_name_value.csv Fri Aug 23 14:10:59 2024 +0000 @@ -1,6 +1,7 @@ id, name, value, expr, vary - 1, s02, 1.0, , True - 2, e0, 0.0, , True - 3, alpha, 0.0, , True - 4, sigma2, 0.003, , True - 5, custom_name, 0.005, , False + 1, degen, , , True + 2, s02, 1.0, , True + 3, e0, 0.0, , True + 4, alpha, 0.0, , True + 5, sigma2, 0.003, , True + 6, custom_name, 0.005, , False
--- a/test-data/gds_merge_custom.csv Thu Apr 11 09:02:33 2024 +0000 +++ b/test-data/gds_merge_custom.csv Fri Aug 23 14:10:59 2024 +0000 @@ -1,7 +1,8 @@ id, name, value, expr, vary - 1, s02, 1.0, , True - 2, e0, 0.0, , True - 3, alpha, 0.0, , True - 4, sigma2, 0.003, , True - 5, custom_name_1, 0.003, , True - 6, custom_name_2, 0.003, , True + 1, degen, , , True + 2, s02, 1.0, , True + 3, e0, 0.0, , True + 4, alpha, 0.0, , True + 5, sigma2, 0.003, , True + 6, custom_name_1, 0.003, , True + 7, custom_name_2, 0.003, , True
--- a/test-data/sp_criteria.csv Thu Apr 11 09:02:33 2024 +0000 +++ b/test-data/sp_criteria.csv Fri Aug 23 14:10:59 2024 +0000 @@ -1,4 +1,4 @@ - id, filename, label, s02, e0, sigma2, deltar - 1, feff/feff0001.dat, S.Fe.1, s02, e0, sigma2, alpha*reff - 2, feff/feff0002.dat, S.Fe.2, s02, e0, sigma2, alpha*reff - 3, feff/feff0005.dat, S.Fe.5, s02, e0, sigma2, alpha*reff + id, filename, label, degen, s02, e0, sigma2, deltar + 1, feff/feff0001.dat, S.Fe.1, degen, s02, e0, sigma2, alpha*reff + 2, feff/feff0002.dat, S.Fe.2, degen, s02, e0, sigma2, alpha*reff + 3, feff/feff0005.dat, S.Fe.5, degen, s02, e0, sigma2, alpha*reff
--- a/test-data/sp_default.csv Thu Apr 11 09:02:33 2024 +0000 +++ b/test-data/sp_default.csv Fri Aug 23 14:10:59 2024 +0000 @@ -1,9 +1,9 @@ - id, filename, label, s02, e0, sigma2, deltar - 1, feff/feff0001.dat, S.Fe.1, s02, e0, sigma2, alpha*reff - 2, feff/feff0002.dat, S.Fe.2, s02, e0, sigma2, alpha*reff - 3, feff/feff0003.dat, Fe.Fe.3, s02, e0, sigma2, alpha*reff - 4, feff/feff0004.dat, S.Fe.4, s02, e0, sigma2, alpha*reff - 5, feff/feff0005.dat, S.Fe.5, s02, e0, sigma2, alpha*reff - 6, feff/feff0006.dat, S.S.Fe.6, s02, e0, sigma2, alpha*reff - 7, feff/feff0007.dat, S.S.Fe.7, s02, e0, sigma2, alpha*reff - 8, feff/feff0008.dat, Fe.Fe.8, s02, e0, sigma2, alpha*reff + id, filename, label, degen, s02, e0, sigma2, deltar + 1, feff/feff0001.dat, S.Fe.1, degen, s02, e0, sigma2, alpha*reff + 2, feff/feff0002.dat, S.Fe.2, degen, s02, e0, sigma2, alpha*reff + 3, feff/feff0003.dat, Fe.Fe.3, degen, s02, e0, sigma2, alpha*reff + 4, feff/feff0004.dat, S.Fe.4, degen, s02, e0, sigma2, alpha*reff + 5, feff/feff0005.dat, S.Fe.5, degen, s02, e0, sigma2, alpha*reff + 6, feff/feff0006.dat, S.S.Fe.6, degen, s02, e0, sigma2, alpha*reff + 7, feff/feff0007.dat, S.S.Fe.7, degen, s02, e0, sigma2, alpha*reff + 8, feff/feff0008.dat, Fe.Fe.8, degen, s02, e0, sigma2, alpha*reff
--- a/test-data/sp_include_path_3.csv Thu Apr 11 09:02:33 2024 +0000 +++ b/test-data/sp_include_path_3.csv Fri Aug 23 14:10:59 2024 +0000 @@ -1,4 +1,4 @@ - id, filename, label, s02, e0, sigma2, deltar - 1, feff/feff0001.dat, S.Fe.1, s02, e0, sigma2, alpha*reff - 2, feff/feff0002.dat, S.Fe.2, s02, e0, sigma2, alpha*reff - 3, feff/feff0003.dat, Fe.Fe.3, s02, e0, sigma2, alpha*reff + id, filename, label, degen, s02, e0, sigma2, deltar + 1, feff/feff0001.dat, S.Fe.1, degen, s02, e0, sigma2, alpha*reff + 2, feff/feff0002.dat, S.Fe.2, degen, s02, e0, sigma2, alpha*reff + 3, feff/feff0003.dat, Fe.Fe.3, degen, s02, e0, sigma2, alpha*reff
--- a/test-data/sp_include_path_3_custom_name.csv Thu Apr 11 09:02:33 2024 +0000 +++ b/test-data/sp_include_path_3_custom_name.csv Fri Aug 23 14:10:59 2024 +0000 @@ -1,4 +1,4 @@ - id, filename, label, s02, e0, sigma2, deltar - 1, feff/feff0001.dat, S.Fe.1, s02, e0, sigma2, alpha*reff - 2, feff/feff0002.dat, S.Fe.2, s02, e0, sigma2, alpha*reff - 3, feff/feff0003.dat, Fe.Fe.3, s02, e0, custom_name, alpha*reff + id, filename, label, degen, s02, e0, sigma2, deltar + 1, feff/feff0001.dat, S.Fe.1, degen, s02, e0, sigma2, alpha*reff + 2, feff/feff0002.dat, S.Fe.2, degen, s02, e0, sigma2, alpha*reff + 3, feff/feff0003.dat, Fe.Fe.3, degen, s02, e0, custom_name, alpha*reff
--- a/test-data/sp_merge_custom.csv Thu Apr 11 09:02:33 2024 +0000 +++ b/test-data/sp_merge_custom.csv Fri Aug 23 14:10:59 2024 +0000 @@ -1,7 +1,7 @@ - id, filename, label, s02, e0, sigma2, deltar - 1, primary/feff0001.dat, primary.S.Fe.1, s02, e0, sigma2, alpha*reff - 2, primary/feff0002.dat, primary.S.Fe.2, s02, e0, sigma2, alpha*reff - 3, primary/feff0003.dat, primary.Fe.Fe.3, s02, e0, custom_name_1, alpha*reff - 4, secondary/feff0001.dat, secondary.S.Fe.1, s02, e0, sigma2, alpha*reff - 5, secondary/feff0002.dat, secondary.S.Fe.2, s02, e0, sigma2, alpha*reff - 6, secondary/feff0003.dat, secondary.Fe.Fe.3, s02, e0, custom_name_2, alpha*reff + id, filename, label, degen, s02, e0, sigma2, deltar + 1, primary/feff0001.dat, primary.S.Fe.1, degen, s02, e0, sigma2, alpha*reff + 2, primary/feff0002.dat, primary.S.Fe.2, degen, s02, e0, sigma2, alpha*reff + 3, primary/feff0003.dat, primary.Fe.Fe.3, degen, s02, e0, custom_name_1, alpha*reff + 4, secondary/feff0001.dat, secondary.S.Fe.1, degen, s02, e0, sigma2, alpha*reff + 5, secondary/feff0002.dat, secondary.S.Fe.2, degen, s02, e0, sigma2, alpha*reff + 6, secondary/feff0003.dat, secondary.Fe.Fe.3, degen, s02, e0, custom_name_2, alpha*reff
--- a/test-data/sp_merge_default.csv Thu Apr 11 09:02:33 2024 +0000 +++ b/test-data/sp_merge_default.csv Fri Aug 23 14:10:59 2024 +0000 @@ -1,17 +1,17 @@ - id, filename, label, s02, e0, sigma2, deltar - 1, 1/feff0001.dat, 1.S.Fe.1, s02, e0, sigma2, alpha*reff - 2, 1/feff0002.dat, 1.S.Fe.2, s02, e0, sigma2, alpha*reff - 3, 1/feff0003.dat, 1.Fe.Fe.3, s02, e0, sigma2, alpha*reff - 4, 1/feff0004.dat, 1.S.Fe.4, s02, e0, sigma2, alpha*reff - 5, 1/feff0005.dat, 1.S.Fe.5, s02, e0, sigma2, alpha*reff - 6, 1/feff0006.dat, 1.S.S.Fe.6, s02, e0, sigma2, alpha*reff - 7, 1/feff0007.dat, 1.S.S.Fe.7, s02, e0, sigma2, alpha*reff - 8, 1/feff0008.dat, 1.Fe.Fe.8, s02, e0, sigma2, alpha*reff - 9, 2/feff0001.dat, 2.S.Fe.1, s02, e0, sigma2, alpha*reff - 10, 2/feff0002.dat, 2.S.Fe.2, s02, e0, sigma2, alpha*reff - 11, 2/feff0003.dat, 2.Fe.Fe.3, s02, e0, sigma2, alpha*reff - 12, 2/feff0004.dat, 2.S.Fe.4, s02, e0, sigma2, alpha*reff - 13, 2/feff0005.dat, 2.S.Fe.5, s02, e0, sigma2, alpha*reff - 14, 2/feff0006.dat, 2.S.S.Fe.6, s02, e0, sigma2, alpha*reff - 15, 2/feff0007.dat, 2.S.S.Fe.7, s02, e0, sigma2, alpha*reff - 16, 2/feff0008.dat, 2.Fe.Fe.8, s02, e0, sigma2, alpha*reff + id, filename, label, degen, s02, e0, sigma2, deltar + 1, 1/feff0001.dat, 1.S.Fe.1, degen, s02, e0, sigma2, alpha*reff + 2, 1/feff0002.dat, 1.S.Fe.2, degen, s02, e0, sigma2, alpha*reff + 3, 1/feff0003.dat, 1.Fe.Fe.3, degen, s02, e0, sigma2, alpha*reff + 4, 1/feff0004.dat, 1.S.Fe.4, degen, s02, e0, sigma2, alpha*reff + 5, 1/feff0005.dat, 1.S.Fe.5, degen, s02, e0, sigma2, alpha*reff + 6, 1/feff0006.dat, 1.S.S.Fe.6, degen, s02, e0, sigma2, alpha*reff + 7, 1/feff0007.dat, 1.S.S.Fe.7, degen, s02, e0, sigma2, alpha*reff + 8, 1/feff0008.dat, 1.Fe.Fe.8, degen, s02, e0, sigma2, alpha*reff + 9, 2/feff0001.dat, 2.S.Fe.1, degen, s02, e0, sigma2, alpha*reff + 10, 2/feff0002.dat, 2.S.Fe.2, degen, s02, e0, sigma2, alpha*reff + 11, 2/feff0003.dat, 2.Fe.Fe.3, degen, s02, e0, sigma2, alpha*reff + 12, 2/feff0004.dat, 2.S.Fe.4, degen, s02, e0, sigma2, alpha*reff + 13, 2/feff0005.dat, 2.S.Fe.5, degen, s02, e0, sigma2, alpha*reff + 14, 2/feff0006.dat, 2.S.S.Fe.6, degen, s02, e0, sigma2, alpha*reff + 15, 2/feff0007.dat, 2.S.S.Fe.7, degen, s02, e0, sigma2, alpha*reff + 16, 2/feff0008.dat, 2.Fe.Fe.8, degen, s02, e0, sigma2, alpha*reff
--- a/test-data/sp_select_all_false.csv Thu Apr 11 09:02:33 2024 +0000 +++ b/test-data/sp_select_all_false.csv Fri Aug 23 14:10:59 2024 +0000 @@ -1,3 +1,3 @@ - id, filename, label, s02, e0, sigma2, deltar - 1, feff/feff0001.dat, S.Fe.1, s02, e0, sigma2, alpha*reff - 2, feff/feff0002.dat, S.Fe.2, s02, e0, sigma2, alpha*reff + id, filename, label, degen, s02, e0, sigma2, deltar + 1, feff/feff0001.dat, S.Fe.1, degen, s02, e0, sigma2, alpha*reff + 2, feff/feff0002.dat, S.Fe.2, degen, s02, e0, sigma2, alpha*reff