Extract anatric config parsing
This commit is contained in:
parent
bbbc0ef8ec
commit
97d1280df9
@ -1,3 +1,3 @@
|
|||||||
from pyzebra.anatric import anatric
|
from pyzebra.anatric import *
|
||||||
from pyzebra.h5 import *
|
from pyzebra.h5 import *
|
||||||
from pyzebra.xtal import *
|
from pyzebra.xtal import *
|
||||||
|
@ -1,4 +1,92 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
|
||||||
def anatric(config_file):
|
def anatric(config_file):
|
||||||
subprocess.run(["anatric", config_file], check=True)
|
subprocess.run(["anatric", config_file], check=True)
|
||||||
|
|
||||||
|
|
||||||
|
class AnatricConfig:
|
||||||
|
def __init__(self, filename=None):
|
||||||
|
if filename:
|
||||||
|
self.load_from_file(filename)
|
||||||
|
|
||||||
|
def load_from_file(self, filename):
|
||||||
|
tree = ET.parse(filename)
|
||||||
|
|
||||||
|
logfile_elem = tree.find("logfile")
|
||||||
|
self.logfile = logfile_elem.attrib["file"]
|
||||||
|
self.logfile_verbosity = logfile_elem.attrib["verbosity"]
|
||||||
|
|
||||||
|
filelist_elem = tree.find("FileList")
|
||||||
|
if filelist_elem is None:
|
||||||
|
filelist_elem = tree.find("SinqFileList")
|
||||||
|
self.filelist_type = "SINQ"
|
||||||
|
else:
|
||||||
|
self.filelist_type = "TRICS"
|
||||||
|
|
||||||
|
self.filelist_format = filelist_elem.attrib["format"]
|
||||||
|
self.filelist_datapath = filelist_elem.find("datapath").attrib["value"]
|
||||||
|
range_vals = filelist_elem.find("range").attrib
|
||||||
|
self.filelist_ranges = (int(range_vals["start"]), int(range_vals["end"]))
|
||||||
|
|
||||||
|
crystal_elem = tree.find("crystal")
|
||||||
|
self.crystal_sample = crystal_elem.find("Sample").attrib["name"]
|
||||||
|
|
||||||
|
lambda_elem = crystal_elem.find("lambda")
|
||||||
|
if lambda_elem is not None:
|
||||||
|
self.crystal_lambda = lambda_elem.attrib["value"]
|
||||||
|
else:
|
||||||
|
self.crystal_lambda = None
|
||||||
|
|
||||||
|
zeroOM_elem = crystal_elem.find("zeroOM")
|
||||||
|
if zeroOM_elem is not None:
|
||||||
|
self.crystal_zeroOM = zeroOM_elem.attrib["value"]
|
||||||
|
else:
|
||||||
|
self.crystal_zeroOM = None
|
||||||
|
|
||||||
|
zeroSTT_elem = crystal_elem.find("zeroSTT")
|
||||||
|
if zeroSTT_elem is not None:
|
||||||
|
self.crystal_zeroSTT = zeroSTT_elem.attrib["value"]
|
||||||
|
else:
|
||||||
|
self.crystal_zeroSTT = None
|
||||||
|
|
||||||
|
zeroCHI_elem = crystal_elem.find("zeroCHI")
|
||||||
|
if zeroCHI_elem is not None:
|
||||||
|
self.crystal_zeroCHI = zeroCHI_elem.attrib["value"]
|
||||||
|
else:
|
||||||
|
self.crystal_zeroCHI = None
|
||||||
|
|
||||||
|
self.crystal_UB = crystal_elem.find("UB").text
|
||||||
|
|
||||||
|
dataFactory_elem = tree.find("DataFactory")
|
||||||
|
self.dist1 = dataFactory_elem.find("dist1").attrib["value"]
|
||||||
|
|
||||||
|
reflectionPrinter_elem = tree.find("ReflectionPrinter")
|
||||||
|
self.reflectionPrinter_format = reflectionPrinter_elem.attrib["format"]
|
||||||
|
|
||||||
|
alg_elem = tree.find("Algorithm")
|
||||||
|
self.algorithm = alg_elem.attrib["implementation"]
|
||||||
|
if self.algorithm == "adaptivemaxcog":
|
||||||
|
self.threshold = float(alg_elem.find("threshold").attrib["value"])
|
||||||
|
self.shell = float(alg_elem.find("shell").attrib["value"])
|
||||||
|
self.steepness = float(alg_elem.find("steepness").attrib["value"])
|
||||||
|
self.duplicateDistance = float(alg_elem.find("duplicateDistance").attrib["value"])
|
||||||
|
self.maxequal = float(alg_elem.find("maxequal").attrib["value"])
|
||||||
|
# self.apd_window = float(alg_elem.find("window").attrib["value"])
|
||||||
|
|
||||||
|
elif self.algorithm == "adaptivedynamic":
|
||||||
|
# self.admi_window = float(alg_elem.find("window").attrib["value"])
|
||||||
|
# self.border = float(alg_elem.find("border").attrib["value"])
|
||||||
|
# self.minWindow = float(alg_elem.find("minWindow").attrib["value"])
|
||||||
|
# self.reflectionFile = float(alg_elem.find("reflectionFile").attrib["value"])
|
||||||
|
self.targetMonitor = float(alg_elem.find("targetMonitor").attrib["value"])
|
||||||
|
self.smoothSize = float(alg_elem.find("smoothSize").attrib["value"])
|
||||||
|
self.loop = float(alg_elem.find("loop").attrib["value"])
|
||||||
|
self.minPeakCount = float(alg_elem.find("minPeakCount").attrib["value"])
|
||||||
|
# self.displacementCurve = float(alg_elem.find("threshold").attrib["value"])
|
||||||
|
else:
|
||||||
|
raise ValueError("Unknown processing mode.")
|
||||||
|
|
||||||
|
def export(self, filename):
|
||||||
|
pass
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import xml.etree.ElementTree as ET
|
|
||||||
|
|
||||||
from bokeh.layouts import column, row
|
from bokeh.layouts import column, row
|
||||||
from bokeh.models import Button, Panel, RadioButtonGroup, Select, Spinner, TextAreaInput, TextInput
|
from bokeh.models import Button, Panel, RadioButtonGroup, Select, Spinner, TextAreaInput, TextInput
|
||||||
|
|
||||||
@ -8,78 +6,45 @@ import pyzebra
|
|||||||
|
|
||||||
def create():
|
def create():
|
||||||
def fileinput_callback(_attr, _old, new):
|
def fileinput_callback(_attr, _old, new):
|
||||||
tree = ET.parse(new)
|
config = pyzebra.AnatricConfig(new)
|
||||||
|
|
||||||
logfile_elem = tree.find("logfile")
|
logfile_textinput.value = config.logfile
|
||||||
logfile_textinput.value = logfile_elem.attrib["file"]
|
logfile_verbosity_select.value = config.logfile_verbosity
|
||||||
logfile_verbosity_select.value = logfile_elem.attrib["verbosity"]
|
|
||||||
|
|
||||||
filelist_elem = tree.find("FileList")
|
filelist_type.value = config.filelist_type
|
||||||
if filelist_elem is None:
|
filelist_format_textinput.value = config.filelist_format
|
||||||
filelist_elem = tree.find("SinqFileList")
|
filelist_datapath_textinput.value = config.filelist_datapath
|
||||||
filelist_type.value = "SINQ"
|
filelist_ranges_textareainput.value = str(config.filelist_ranges)
|
||||||
else:
|
|
||||||
filelist_type.value = "TRICS"
|
|
||||||
|
|
||||||
filelist_format_textinput.value = filelist_elem.attrib["format"]
|
crystal_sample_textinput.value = config.crystal_sample
|
||||||
filelist_datapath_textinput.value = filelist_elem.find("datapath").attrib["value"]
|
lambda_textinput.value = config.crystal_lambda
|
||||||
range_vals = filelist_elem.find("range").attrib
|
zeroOM_textinput.value = config.crystal_zeroOM
|
||||||
filelist_ranges_textareainput.value = str(
|
zeroSTT_textinput.value = config.crystal_zeroSTT
|
||||||
(int(range_vals["start"]), int(range_vals["end"]))
|
zeroCHI_textinput.value = config.crystal_zeroCHI
|
||||||
)
|
ub_textareainput.value = config.crystal_UB
|
||||||
|
|
||||||
crystal_elem = tree.find("crystal")
|
dist1_textinput.value = config.dist1
|
||||||
crystal_sample_textinput.value = crystal_elem.find("Sample").attrib["name"]
|
reflectionPrinter_format_select.value = config.reflectionPrinter_format
|
||||||
|
|
||||||
lambda_elem = crystal_elem.find("lambda")
|
set_active_widgets(config.algorithm)
|
||||||
if lambda_elem is not None:
|
if config.algorithm == "adaptivemaxcog":
|
||||||
lambda_textinput.value = lambda_elem.attrib["value"]
|
threshold_spinner.value = float(config.threshold)
|
||||||
|
shell_spinner.value = float(config.shell)
|
||||||
|
steepness_spinner.value = float(config.steepness)
|
||||||
|
duplicateDistance_spinner.value = float(config.duplicateDistance)
|
||||||
|
maxequal_spinner.value = float(config.maxequal)
|
||||||
|
# apd_window_spinner.value = float(config.apd_window)
|
||||||
|
|
||||||
zeroOM_elem = crystal_elem.find("zeroOM")
|
elif config.algorithm == "adaptivedynamic":
|
||||||
if zeroOM_elem is not None:
|
# admi_window_spinner.value = float(config.admi_window)
|
||||||
zeroOM_textinput.value = zeroOM_elem.attrib["value"]
|
# border_spinner.value = float(config.border)
|
||||||
|
# minWindow_spinner.value = float(config.minWindow)
|
||||||
zeroSTT_elem = crystal_elem.find("zeroSTT")
|
# reflectionFile_spinner.value = float(config.reflectionFile)
|
||||||
if zeroSTT_elem is not None:
|
targetMonitor_spinner.value = float(config.targetMonitor)
|
||||||
zeroSTT_textinput.value = zeroSTT_elem.attrib["value"]
|
smoothSize_spinner.value = float(config.smoothSize)
|
||||||
|
loop_spinner.value = float(config.loop)
|
||||||
zeroCHI_elem = crystal_elem.find("zeroCHI")
|
minPeakCount_spinner.value = float(config.minPeakCount)
|
||||||
if zeroCHI_elem is not None:
|
# displacementCurve_spinner.value = float(config.displacementCurve)
|
||||||
zeroCHI_textinput.value = zeroCHI_elem.attrib["value"]
|
|
||||||
|
|
||||||
ub_textareainput.value = crystal_elem.find("UB").text
|
|
||||||
|
|
||||||
dataFactory_elem = tree.find("DataFactory")
|
|
||||||
dist1_textinput.value = dataFactory_elem.find("dist1").attrib["value"]
|
|
||||||
|
|
||||||
reflectionPrinter_elem = tree.find("ReflectionPrinter")
|
|
||||||
reflectionPrinter_format_select.value = reflectionPrinter_elem.attrib["format"]
|
|
||||||
|
|
||||||
alg_elem = tree.find("Algorithm")
|
|
||||||
if alg_elem.attrib["implementation"] == "adaptivemaxcog":
|
|
||||||
set_active_widgets("adaptivemaxcog")
|
|
||||||
|
|
||||||
threshold_spinner.value = float(alg_elem.find("threshold").attrib["value"])
|
|
||||||
shell_spinner.value = float(alg_elem.find("shell").attrib["value"])
|
|
||||||
steepness_spinner.value = float(alg_elem.find("steepness").attrib["value"])
|
|
||||||
duplicateDistance_spinner.value = float(
|
|
||||||
alg_elem.find("duplicateDistance").attrib["value"]
|
|
||||||
)
|
|
||||||
maxequal_spinner.value = float(alg_elem.find("maxequal").attrib["value"])
|
|
||||||
# apd_window_spinner.value = float(alg_elem.find("window").attrib["value"])
|
|
||||||
|
|
||||||
elif alg_elem.attrib["implementation"] == "adaptivedynamic":
|
|
||||||
set_active_widgets("adaptivedynamic")
|
|
||||||
|
|
||||||
# admi_window_spinner.value = float(alg_elem.find("window").attrib["value"])
|
|
||||||
# .value = float(alg_elem.find("border").attrib["value"])
|
|
||||||
# minWindow_spinner.value = float(alg_elem.find("minWindow").attrib["value"])
|
|
||||||
# reflectionFile_spinner.value = float(alg_elem.find("reflectionFile").attrib["value"])
|
|
||||||
targetMonitor_spinner.value = float(alg_elem.find("targetMonitor").attrib["value"])
|
|
||||||
smoothSize_spinner.value = float(alg_elem.find("smoothSize").attrib["value"])
|
|
||||||
loop_spinner.value = float(alg_elem.find("loop").attrib["value"])
|
|
||||||
minPeakCount_spinner.value = float(alg_elem.find("minPeakCount").attrib["value"])
|
|
||||||
# displacementCurve_spinner.value = float(alg_elem.find("threshold").attrib["value"])
|
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown processing mode.")
|
raise ValueError("Unknown processing mode.")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user