MaterialsGalaxy / larch-tools

Galaxy tool wrappers for Larch analysis tools for X-ray spectroscopy
MIT License
2 stars 0 forks source link

EXAFS fitting crashes when allowing R to vary for all paths #80

Closed tomlunderwood closed 1 month ago

tomlunderwood commented 2 months ago

To reproduce the EXAFS data in paper 8 the fitting procedure requires 'R' to vary for all paths without being constrained to take the same value for all paths. Upon doing this with Larch Artemis I find that it crashes; see below for the stack trace and error messages.

Link to an example job which throws the error: https://materialsgalaxy.stfc.ac.uk/datasets/662df1f0acc2bfec/details

Stack trace (tool)

NameError <ast.Module object at 0x148605fa9060> name 'alpha' is not defined Traceback (most recent call last): File "/srv/galaxy/var/shed_tools/toolshed.g2.bx.psu.edu/repos/muon-spectroscopy-computational-project/larch_artemis/39ab361e6d59/larch_artemis/larch_artemis.py", line 346, in main(prj_file, gds_file, sp_file, fit_vars, plot_graph) File "/srv/galaxy/var/shed_tools/toolshed.g2.bx.psu.edu/repos/muon-spectroscopy-computational-project/larch_artemis/39ab361e6d59/larch_artemis/larch_artemis.py", line 209, in main dset, out = run_fit(data_group, gds, selected_paths, fit_vars) File "/srv/galaxy/var/shed_tools/toolshed.g2.bx.psu.edu/repos/muon-spectroscopy-computational-project/larch_artemis/39ab361e6d59/larch_artemis/larch_artemis.py", line 184, in run_fit out = feffit(gds, dset) File "/usr/local/lib/python3.10/site-packages/larch/xafs/feffit.py", line 688, in feffit ds.prepare_fit(params=params, other_hashkeys=dset_hashkeys) File "/usr/local/lib/python3.10/site-packages/larch/xafs/feffit.py", line 388, in prepare_fit path.create_path_params(params=params, dataset=self.hashkey) File "/usr/local/lib/python3.10/site-packages/larch/xafs/feffdat.py", line 393, in create_path_params self.params.add(parname, **kws) File "/usr/local/lib/python3.10/site-packages/lmfit/parameter.py", line 434, in add self.setitem(name, Parameter(value=value, name=name, vary=vary, File "/usr/local/lib/python3.10/site-packages/lmfit/parameter.py", line 156, in setitem self._asteval.symtable[key] = par.value File "/usr/local/lib/python3.10/site-packages/lmfit/parameter.py", line 949, in value return self._getval() File "/usr/local/lib/python3.10/site-packages/lmfit/parameter.py", line 943, in _getval check_ast_errors(self._expr_eval) File "/usr/local/lib/python3.10/site-packages/lmfit/parameter.py", line 27, in check_ast_errors expr_eval.raise_exception(None) File "/usr/local/lib/python3.10/site-packages/asteval/asteval.py", line 241, in raise_exception raise exc(self.error_msg) NameError: name 'alpha' is not defined at expr='<ast.Module object at 0x148605fa9060>'

Stack trace (Galaxy runner)

Traceback (most recent call last): File "/mnt/nfs/data/job_work_dir/005/5224/metadata/set.py", line 5, in from galaxy_ext.metadata.set_metadata import set_metadata; set_metadata() ModuleNotFoundError: No module named 'galaxy_ext'*

patrick-austin commented 2 months ago

@tomlunderwood This should be fixed by #78 . When generating a path-unique value for deltar, in the selected paths the unique label is being appended to alpha*reff->alpha*reff_UNIQUE rather than alpha_UNIQUE*reff, which is what matches the gds file. I ran into this when working with paper 1.

Feel free to checkout and test that branch locally if you want to verify - otherwise I'm hoping to get a review from @subindev-d and merge/release a patched version of the tool ASAP and can ping you when it's on the production server.

tomlunderwood commented 1 month ago

@patrick-austin thanks for fixing this; it does what I want now without issue, so I'm closing the issue.