Apply formatting
This commit is contained in:
parent
165c06bc22
commit
b57348b369
@ -2,11 +2,7 @@ import subprocess
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
DATA_FACTORY_IMPLEMENTATION = [
|
||||
"trics",
|
||||
"morph",
|
||||
"d10",
|
||||
]
|
||||
DATA_FACTORY_IMPLEMENTATION = ["trics", "morph", "d10"]
|
||||
|
||||
REFLECTION_PRINTER_FORMATS = [
|
||||
"rafin",
|
||||
|
@ -31,13 +31,16 @@ bokeh_logger.setLevel(logging.WARNING)
|
||||
bokeh_logger.addHandler(bokeh_handler)
|
||||
bokeh_log_textareainput = TextAreaInput(title="server output:", height=150)
|
||||
|
||||
|
||||
def proposal_textinput_callback(_attr, _old, _new):
|
||||
apply_button.disabled = False
|
||||
|
||||
|
||||
proposal_textinput = TextInput(title="Proposal number:", name="")
|
||||
proposal_textinput.on_change("value_input", proposal_textinput_callback)
|
||||
doc.proposal_textinput = proposal_textinput
|
||||
|
||||
|
||||
def apply_button_callback():
|
||||
proposal = proposal_textinput.value.strip()
|
||||
if proposal:
|
||||
@ -52,6 +55,7 @@ def apply_button_callback():
|
||||
|
||||
proposal_textinput.name = proposal_path
|
||||
|
||||
|
||||
apply_button = Button(label="Apply", button_type="primary")
|
||||
apply_button.on_click(apply_button_callback)
|
||||
|
||||
|
@ -39,7 +39,7 @@ def main():
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--anatric-path", type=str, default=ANATRIC_PATH, help="path to anatric executable",
|
||||
"--anatric-path", type=str, default=ANATRIC_PATH, help="path to anatric executable"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
@ -49,9 +49,7 @@ def main():
|
||||
help="path to Sxtal_Refgen executable",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--spind-path", type=str, default=None, help="path to spind scripts folder",
|
||||
)
|
||||
parser.add_argument("--spind-path", type=str, default=None, help="path to spind scripts folder")
|
||||
|
||||
parser.add_argument(
|
||||
"--args",
|
||||
|
@ -2,8 +2,7 @@ from bokeh.application.handlers import Handler
|
||||
|
||||
|
||||
class PyzebraHandler(Handler):
|
||||
"""Provides a mechanism for generic bokeh applications to build up new streamvis documents.
|
||||
"""
|
||||
"""Provides a mechanism for generic bokeh applications to build up new streamvis documents."""
|
||||
|
||||
def __init__(self, anatric_path, spind_path):
|
||||
"""Initialize a pyzebra handler for bokeh applications.
|
||||
|
@ -537,7 +537,7 @@ def create():
|
||||
|
||||
n = len(params)
|
||||
fitparams = dict(
|
||||
param=params, value=[None] * n, vary=[True] * n, min=[None] * n, max=[None] * n,
|
||||
param=params, value=[None] * n, vary=[True] * n, min=[None] * n, max=[None] * n
|
||||
)
|
||||
|
||||
if function == "linear":
|
||||
|
@ -517,7 +517,7 @@ def create():
|
||||
|
||||
n = len(params)
|
||||
fitparams = dict(
|
||||
param=params, value=[None] * n, vary=[True] * n, min=[None] * n, max=[None] * n,
|
||||
param=params, value=[None] * n, vary=[True] * n, min=[None] * n, max=[None] * n
|
||||
)
|
||||
|
||||
if function == "linear":
|
||||
|
@ -348,7 +348,7 @@ def create():
|
||||
# Define resolution function
|
||||
def _res_fun(stt, wave, res_mult):
|
||||
expr = np.tan(stt / 2 * np.pi / 180)
|
||||
fwhm = np.sqrt(0.4639 * expr ** 2 - 0.4452 * expr + 0.1506) * res_mult # res in deg
|
||||
fwhm = np.sqrt(0.4639 * expr**2 - 0.4452 * expr + 0.1506) * res_mult # res in deg
|
||||
return fwhm
|
||||
|
||||
def plot_file_callback():
|
||||
@ -598,7 +598,7 @@ def create():
|
||||
|
||||
ellipse_source.data.update(x=el_x, y=el_y, w=el_w, h=el_h, c=el_c)
|
||||
scan_source.data.update(
|
||||
xs=scan_xs, ys=scan_ys, x=scan_x, y=scan_y, m=scan_m, s=scan_s, c=scan_c, l=scan_l,
|
||||
xs=scan_xs, ys=scan_ys, x=scan_x, y=scan_y, m=scan_m, s=scan_s, c=scan_c, l=scan_l
|
||||
)
|
||||
|
||||
arrow1.visible = True
|
||||
@ -691,7 +691,7 @@ def create():
|
||||
)
|
||||
|
||||
k_vectors = TextAreaInput(
|
||||
title="k vectors:", value="0.0 0.0 0.0\n0.5 0.0 0.0\n0.5 0.5 0.0", width=150,
|
||||
title="k vectors:", value="0.0 0.0 0.0\n0.5 0.0 0.0\n0.5 0.5 0.0", width=150
|
||||
)
|
||||
res_mult_ni = NumericInput(title="Resolution mult:", value=10, mode="int", width=100)
|
||||
|
||||
|
@ -169,7 +169,7 @@ def create():
|
||||
config.dataFactory_implementation = new
|
||||
|
||||
dataFactory_implementation_select = Select(
|
||||
title="DataFactory implement.:", options=DATA_FACTORY_IMPLEMENTATION, width=145,
|
||||
title="DataFactory implement.:", options=DATA_FACTORY_IMPLEMENTATION, width=145
|
||||
)
|
||||
dataFactory_implementation_select.on_change("value", dataFactory_implementation_select_callback)
|
||||
|
||||
@ -200,7 +200,7 @@ def create():
|
||||
config.reflectionPrinter_format = new
|
||||
|
||||
reflectionPrinter_format_select = Select(
|
||||
title="ReflectionPrinter format:", options=REFLECTION_PRINTER_FORMATS, width=145,
|
||||
title="ReflectionPrinter format:", options=REFLECTION_PRINTER_FORMATS, width=145
|
||||
)
|
||||
reflectionPrinter_format_select.on_change("value", reflectionPrinter_format_select_callback)
|
||||
|
||||
|
@ -322,9 +322,7 @@ def create():
|
||||
# ---- tools
|
||||
wheelzoomtool = WheelZoomTool(maintain_focus=False)
|
||||
overview_plot_x.toolbar.logo = None
|
||||
overview_plot_x.add_tools(
|
||||
PanTool(), BoxZoomTool(), wheelzoomtool, ResetTool(),
|
||||
)
|
||||
overview_plot_x.add_tools(PanTool(), BoxZoomTool(), wheelzoomtool, ResetTool())
|
||||
overview_plot_x.toolbar.active_scroll = wheelzoomtool
|
||||
|
||||
# ---- axes
|
||||
@ -360,9 +358,7 @@ def create():
|
||||
# ---- tools
|
||||
wheelzoomtool = WheelZoomTool(maintain_focus=False)
|
||||
overview_plot_y.toolbar.logo = None
|
||||
overview_plot_y.add_tools(
|
||||
PanTool(), BoxZoomTool(), wheelzoomtool, ResetTool(),
|
||||
)
|
||||
overview_plot_y.add_tools(PanTool(), BoxZoomTool(), wheelzoomtool, ResetTool())
|
||||
overview_plot_y.toolbar.active_scroll = wheelzoomtool
|
||||
|
||||
# ---- axes
|
||||
|
@ -128,7 +128,7 @@ def create():
|
||||
|
||||
spind_out_file = os.path.join(temp_dir, "spind.txt")
|
||||
spind_res = dict(
|
||||
label=[], crystal_id=[], match_rate=[], matched_peaks=[], column_5=[], ub_matrix=[],
|
||||
label=[], crystal_id=[], match_rate=[], matched_peaks=[], column_5=[], ub_matrix=[]
|
||||
)
|
||||
try:
|
||||
with open(spind_out_file) as f_out:
|
||||
|
@ -175,7 +175,7 @@ def parse_1D(fileobj, data_type):
|
||||
|
||||
# "om" -> "omega"
|
||||
scan["scan_motor"] = "omega"
|
||||
scan["scan_motors"] = ["omega", ]
|
||||
scan["scan_motors"] = ["omega"]
|
||||
# overwrite metadata, because it only refers to the scan center
|
||||
half_dist = (scan["n_points"] - 1) / 2 * scan["angle_step"]
|
||||
scan["omega"] = np.linspace(
|
||||
@ -354,7 +354,7 @@ def export_ccl_compare(dataset1, dataset2, path, export_target, hkl_precision=2)
|
||||
area_n1, area_s1 = scan1["area"]
|
||||
area_n2, area_s2 = scan2["area"]
|
||||
area_n = area_n1 - area_n2
|
||||
area_s = np.sqrt(area_s1 ** 2 + area_s2 ** 2)
|
||||
area_s = np.sqrt(area_s1**2 + area_s2**2)
|
||||
area_str = f"{area_n:10.2f}{area_s:10.2f}"
|
||||
|
||||
ang_str = ""
|
||||
|
@ -18,9 +18,7 @@ PARAM_PRECISIONS = {
|
||||
"ub": 0.01,
|
||||
}
|
||||
|
||||
MAX_RANGE_GAP = {
|
||||
"omega": 0.5,
|
||||
}
|
||||
MAX_RANGE_GAP = {"omega": 0.5}
|
||||
|
||||
MOTOR_POS_PRECISION = 0.01
|
||||
|
||||
|
@ -2,9 +2,10 @@ import h5py
|
||||
import numpy as np
|
||||
from lmfit.models import Gaussian2dModel, GaussianModel
|
||||
|
||||
META_MATRIX = ("UB", )
|
||||
META_CELL = ("cell", )
|
||||
META_STR = ("name", )
|
||||
META_MATRIX = ("UB",)
|
||||
META_CELL = ("cell",)
|
||||
META_STR = ("name",)
|
||||
|
||||
|
||||
def read_h5meta(filepath):
|
||||
"""Open and parse content of a h5meta file.
|
||||
@ -137,7 +138,7 @@ def read_detector_data(filepath, cami_meta=None):
|
||||
else:
|
||||
raise ValueError("No angles that vary")
|
||||
|
||||
scan["scan_motors"] = [scan["scan_motor"], ]
|
||||
scan["scan_motors"] = [scan["scan_motor"]]
|
||||
|
||||
# optional parameters
|
||||
if "/entry1/sample/magnetic_field" in h5f:
|
||||
|
@ -362,8 +362,7 @@ def angtohkl(wave, ddist, gammad, om, ch, ph, nud, x, y):
|
||||
|
||||
|
||||
def ang2hkl(wave, ddist, gammad, om, ch, ph, nud, ub, x, y):
|
||||
"""Calculate hkl-indices of a reflection from its position (x,y,angles) at the 2d-detector
|
||||
"""
|
||||
"""Calculate hkl-indices of a reflection from its position (x,y,angles) at the 2d-detector"""
|
||||
ga, nu = det2pol(ddist, gammad, nud, x, y)
|
||||
z1 = z1frmd(wave, ga, om, ch, ph, nu)
|
||||
ubinv = np.linalg.inv(ub)
|
||||
@ -373,8 +372,7 @@ def ang2hkl(wave, ddist, gammad, om, ch, ph, nud, ub, x, y):
|
||||
|
||||
|
||||
def ang2hkl_1d(wave, ddist, ga, om, ch, ph, nu, ub):
|
||||
"""Calculate hkl-indices of a reflection from its position (angles) at the 1d-detector
|
||||
"""
|
||||
"""Calculate hkl-indices of a reflection from its position (angles) at the 1d-detector"""
|
||||
z1 = z1frmd(wave, ga, om, ch, ph, nu)
|
||||
ubinv = np.linalg.inv(ub)
|
||||
hkl = ubinv @ z1
|
||||
@ -383,8 +381,7 @@ def ang2hkl_1d(wave, ddist, ga, om, ch, ph, nu, ub):
|
||||
|
||||
|
||||
def ang_proc(wave, ddist, gammad, om, ch, ph, nud, x, y):
|
||||
"""Utility function to calculate ch, ph, ga, om
|
||||
"""
|
||||
"""Utility function to calculate ch, ph, ga, om"""
|
||||
ga, nu = det2pol(ddist, gammad, nud, x, y)
|
||||
z1 = z1frmd(wave, ga, om, ch, ph, nu)
|
||||
ch2, ph2 = eqchph(z1)
|
||||
@ -403,4 +400,4 @@ def gauss(x, *p):
|
||||
Gaussian function
|
||||
"""
|
||||
A, mu, sigma = p
|
||||
return A * np.exp(-((x - mu) ** 2) / (2.0 * sigma ** 2))
|
||||
return A * np.exp(-((x - mu) ** 2) / (2.0 * sigma**2))
|
||||
|
Loading…
x
Reference in New Issue
Block a user