Mercurial > repos > muon-spectroscopy-computational-project > larch_artemis
annotate larch_artemis.py @ 0:2752b2dd7ad6 draft
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
| author | muon-spectroscopy-computational-project | 
|---|---|
| date | Tue, 14 Nov 2023 15:34:23 +0000 | 
| parents | |
| children | 84c8e04bc1a1 | 
| rev | line source | 
|---|---|
| 0 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 1 import csv | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 2 import faulthandler | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 3 import gc | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 4 import json | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 5 import os | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 6 import sys | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 7 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 8 from common import get_group | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 9 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 10 from larch.fitting import guess, param, param_group | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 11 from larch.io import read_athena | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 12 from larch.symboltable import Group | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 13 from larch.xafs import ( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 14 FeffPathGroup, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 15 FeffitDataSet, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 16 TransformGroup, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 17 autobk, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 18 feffit, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 19 feffit_report, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 20 pre_edge, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 21 xftf, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 22 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 23 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 24 import matplotlib | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 25 import matplotlib.pyplot as plt | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 26 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 27 import numpy as np | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 28 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 29 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 30 def read_csv_data(input_file, id_field="id"): | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 31 csv_data = {} | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 32 try: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 33 with open(input_file, encoding="utf8") as csvfile: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 34 reader = csv.DictReader(csvfile, skipinitialspace=True) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 35 for row in reader: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 36 csv_data[int(row[id_field])] = row | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 37 except FileNotFoundError: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 38 print("The specified file does not exist") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 39 return csv_data | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 40 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 41 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 42 def calc_with_defaults(xafs_group: Group) -> Group: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 43 """Calculate pre_edge and background with default arguments""" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 44 pre_edge(xafs_group) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 45 autobk(xafs_group) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 46 xftf(xafs_group) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 47 return xafs_group | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 48 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 49 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 50 def dict_to_gds(data_dict): | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 51 dgs_group = param_group() | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 52 for par_idx in data_dict: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 53 # gds file structure: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 54 gds_name = data_dict[par_idx]["name"] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 55 gds_val = 0.0 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 56 gds_expr = "" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 57 try: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 58 gds_val = float(data_dict[par_idx]["value"]) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 59 except ValueError: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 60 gds_val = 0.00 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 61 gds_expr = data_dict[par_idx]["expr"] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 62 gds_vary = ( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 63 True | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 64 if str(data_dict[par_idx]["vary"]).strip().capitalize() == "True" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 65 else False | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 66 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 67 one_par = None | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 68 if gds_vary: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 69 # equivalent to a guess parameter in Demeter | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 70 one_par = guess( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 71 name=gds_name, value=gds_val, vary=gds_vary, expr=gds_expr | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 72 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 73 else: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 74 # equivalent to a defined parameter in Demeter | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 75 one_par = param( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 76 name=gds_name, value=gds_val, vary=gds_vary, expr=gds_expr | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 77 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 78 if one_par is not None: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 79 dgs_group.__setattr__(gds_name, one_par) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 80 return dgs_group | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 81 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 82 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 83 def plot_rmr(path: str, data_set, rmin, rmax): | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 84 plt.figure() | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 85 plt.plot(data_set.data.r, data_set.data.chir_mag, color="b") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 86 plt.plot(data_set.data.r, data_set.data.chir_re, color="b", label="expt.") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 87 plt.plot(data_set.model.r, data_set.model.chir_mag, color="r") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 88 plt.plot(data_set.model.r, data_set.model.chir_re, color="r", label="fit") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 89 plt.ylabel( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 90 "Magnitude of Fourier Transform of " | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 91 r"$k^2 \cdot \chi$/$\mathrm{\AA}^{-3}$" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 92 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 93 plt.xlabel(r"Radial distance/$\mathrm{\AA}$") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 94 plt.xlim(0, 5) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 95 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 96 plt.fill( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 97 [rmin, rmin, rmax, rmax], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 98 [-rmax, rmax, rmax, -rmax], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 99 color="g", | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 100 alpha=0.1, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 101 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 102 plt.text(rmax - 0.65, -rmax + 0.5, "fit range") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 103 plt.legend() | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 104 plt.savefig(path, format="png") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 105 plt.close("all") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 106 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 107 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 108 def plot_chikr(path: str, data_set, rmin, rmax, kmin, kmax): | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 109 fig = plt.figure(figsize=(16, 4)) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 110 ax1 = fig.add_subplot(121) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 111 ax2 = fig.add_subplot(122) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 112 ax1.plot( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 113 data_set.data.k, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 114 data_set.data.chi * data_set.data.k**2, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 115 color="b", | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 116 label="expt.", | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 117 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 118 ax1.plot( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 119 data_set.model.k, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 120 data_set.model.chi * data_set.data.k**2, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 121 color="r", | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 122 label="fit", | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 123 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 124 ax1.set_xlim(0, 15) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 125 ax1.set_xlabel(r"$k (\mathrm{\AA})^{-1}$") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 126 ax1.set_ylabel(r"$k^2$ $\chi (k)(\mathrm{\AA})^{-2}$") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 127 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 128 ax1.fill( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 129 [kmin, kmin, kmax, kmax], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 130 [-rmax, rmax, rmax, -rmax], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 131 color="g", | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 132 alpha=0.1, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 133 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 134 ax1.text(kmax - 1.65, -rmax + 0.5, "fit range") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 135 ax1.legend() | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 136 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 137 ax2.plot(data_set.data.r, data_set.data.chir_mag, color="b", label="expt.") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 138 ax2.plot(data_set.model.r, data_set.model.chir_mag, color="r", label="fit") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 139 ax2.set_xlim(0, 5) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 140 ax2.set_xlabel(r"$R(\mathrm{\AA})$") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 141 ax2.set_ylabel(r"$|\chi(R)|(\mathrm{\AA}^{-3})$") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 142 ax2.legend(loc="upper right") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 143 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 144 ax2.fill( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 145 [rmin, rmin, rmax, rmax], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 146 [-rmax, rmax, rmax, -rmax], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 147 color="g", | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 148 alpha=0.1, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 149 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 150 ax2.text(rmax - 0.65, -rmax + 0.5, "fit range") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 151 fig.savefig(path, format="png") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 152 plt.close("all") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 153 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 154 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 155 def read_gds(gds_file): | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 156 gds_pars = read_csv_data(gds_file) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 157 dgs_group = dict_to_gds(gds_pars) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 158 return dgs_group | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 159 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 160 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 161 def read_selected_paths_list(file_name): | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 162 sp_dict = read_csv_data(file_name) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 163 sp_list = [] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 164 for path_id in sp_dict: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 165 filename = sp_dict[path_id]["filename"] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 166 print(f"Reading selected path for file {filename}") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 167 new_path = FeffPathGroup( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 168 filename=filename, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 169 label=sp_dict[path_id]["label"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 170 s02=sp_dict[path_id]["s02"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 171 e0=sp_dict[path_id]["e0"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 172 sigma2=sp_dict[path_id]["sigma2"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 173 deltar=sp_dict[path_id]["deltar"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 174 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 175 sp_list.append(new_path) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 176 return sp_list | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 177 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 178 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 179 def run_fit(data_group, gds, selected_paths, fv): | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 180 # create the transform group (prepare the fit space). | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 181 trans = TransformGroup( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 182 fitspace=fv["fitspace"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 183 kmin=fv["kmin"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 184 kmax=fv["kmax"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 185 kweight=fv["kweight"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 186 dk=fv["dk"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 187 window=fv["window"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 188 rmin=fv["rmin"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 189 rmax=fv["rmax"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 190 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 191 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 192 dset = FeffitDataSet( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 193 data=data_group, pathlist=selected_paths, transform=trans | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 194 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 195 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 196 out = feffit(gds, dset) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 197 return dset, out | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 198 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 199 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 200 def main( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 201 prj_file: str, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 202 gds_file: str, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 203 sp_file: str, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 204 fit_vars: dict, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 205 plot_graph: bool, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 206 series_id: str = "", | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 207 ) -> Group: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 208 report_path = f"report/fit_report{series_id}.txt" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 209 rmr_path = f"rmr/rmr{series_id}.png" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 210 chikr_path = f"chikr/chikr{series_id}.png" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 211 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 212 athena_project = read_athena(prj_file) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 213 athena_group = get_group(athena_project) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 214 # calc_with_defaults will hang indefinitely (>6 hours recorded) if the | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 215 # data contains any NaNs - consider adding an early error here if this is | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 216 # not fixed in Larch? | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 217 data_group = calc_with_defaults(athena_group) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 218 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 219 print(f"Fitting project from file {data_group.filename}") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 220 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 221 gds = read_gds(gds_file) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 222 selected_paths = read_selected_paths_list(sp_file) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 223 dset, out = run_fit(data_group, gds, selected_paths, fit_vars) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 224 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 225 fit_report = feffit_report(out) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 226 with open(report_path, "w") as fit_report_file: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 227 fit_report_file.write(fit_report) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 228 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 229 if plot_graph: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 230 plot_rmr(rmr_path, dset, fit_vars["rmin"], fit_vars["rmax"]) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 231 plot_chikr( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 232 chikr_path, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 233 dset, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 234 fit_vars["rmin"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 235 fit_vars["rmax"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 236 fit_vars["kmin"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 237 fit_vars["kmax"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 238 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 239 return out | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 240 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 241 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 242 def check_threshold( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 243 series_id: str, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 244 threshold: float, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 245 variable: str, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 246 value: float, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 247 early_stopping: bool = False, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 248 ): | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 249 if abs(value) > threshold: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 250 if early_stopping: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 251 message = ( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 252 "ERROR: Stopping series fit after project " | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 253 f"{series_id} as {variable} > {threshold}" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 254 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 255 else: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 256 message = ( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 257 f"WARNING: Project {series_id} has {variable} > {threshold}" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 258 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 259 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 260 print(message) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 261 return early_stopping | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 262 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 263 return False | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 264 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 265 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 266 def series_execution( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 267 filepaths: "list[str]", | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 268 gds_file: str, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 269 sp_file: str, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 270 fit_vars: dict, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 271 plot_graph: bool, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 272 report_criteria: "list[dict]", | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 273 stop_on_error: bool, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 274 ) -> "list[list[str]]": | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 275 report_criteria = input_values["execution"]["report_criteria"] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 276 id_length = len(str(len(filepaths))) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 277 stop = False | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 278 rows = [[f"{c['variable']:>12s}" for c in report_criteria]] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 279 for series_index, series_file in enumerate(filepaths): | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 280 series_id = str(series_index).zfill(id_length) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 281 try: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 282 out = main( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 283 series_file, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 284 gds_file, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 285 sp_file, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 286 fit_vars, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 287 plot_graph, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 288 f"_{series_id}", | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 289 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 290 except ValueError as e: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 291 rows.append([np.NaN for _ in report_criteria]) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 292 if stop_on_error: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 293 print( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 294 f"ERROR: fitting failed for {series_id}" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 295 f" due to following error, stopping:\n{e}" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 296 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 297 break | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 298 else: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 299 print( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 300 f"WARNING: fitting failed for {series_id} due to following" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 301 f" error, continuing to next project:\n{e}" | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 302 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 303 continue | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 304 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 305 row = [] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 306 for criterium in report_criteria: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 307 stop = parse_row(series_id, out, row, criterium) or stop | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 308 rows.append(row) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 309 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 310 gc.collect() | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 311 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 312 if stop: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 313 break | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 314 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 315 return rows | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 316 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 317 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 318 def parse_row(series_id: str, group: Group, row: "list[str]", criterium: dict): | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 319 action = criterium["action"]["action"] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 320 variable = criterium["variable"] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 321 try: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 322 value = group.__getattribute__(variable) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 323 except AttributeError: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 324 value = group.params[variable].value | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 325 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 326 row.append(f"{value:>12f}") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 327 if action == "stop": | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 328 return check_threshold( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 329 series_id, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 330 criterium["action"]["threshold"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 331 variable, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 332 value, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 333 True, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 334 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 335 elif action == "warn": | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 336 return check_threshold( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 337 series_id, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 338 criterium["action"]["threshold"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 339 variable, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 340 value, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 341 False, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 342 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 343 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 344 return False | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 345 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 346 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 347 if __name__ == "__main__": | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 348 faulthandler.enable() | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 349 # larch imports set this to an interactive backend, so need to change it | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 350 matplotlib.use("Agg") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 351 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 352 prj_file = sys.argv[1] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 353 gds_file = sys.argv[2] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 354 sp_file = sys.argv[3] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 355 input_values = json.load(open(sys.argv[4], "r", encoding="utf-8")) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 356 fit_vars = input_values["fit_vars"] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 357 plot_graph = input_values["plot_graph"] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 358 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 359 if input_values["execution"]["execution"] == "parallel": | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 360 main(prj_file, gds_file, sp_file, fit_vars, plot_graph) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 361 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 362 else: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 363 if os.path.isdir(prj_file): | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 364 # Sort the unzipped directory, all filenames should be zero-padded | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 365 filepaths = [ | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 366 os.path.join(prj_file, p) for p in os.listdir(prj_file) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 367 ] | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 368 filepaths.sort() | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 369 else: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 370 # DO NOT sort if we have multiple Galaxy datasets - the filenames | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 371 # are arbitrary but should be in order | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 372 filepaths = prj_file.split(",") | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 373 | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 374 rows = series_execution( | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 375 filepaths, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 376 gds_file, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 377 sp_file, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 378 fit_vars, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 379 plot_graph, | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 380 input_values["execution"]["report_criteria"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 381 input_values["execution"]["stop_on_error"], | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 382 ) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 383 if len(rows[0]) > 0: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 384 with open("criteria_report.csv", "w") as f: | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 385 writer = csv.writer(f) | 
| 
2752b2dd7ad6
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_artemis commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 386 writer.writerows(rows) | 
