Skip to content

Commit

Permalink
updates to geometry mode
Browse files Browse the repository at this point in the history
  • Loading branch information
BM32ESRF committed Nov 22, 2022
1 parent 1f9ca18 commit cb786c7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 38 deletions.
31 changes: 16 additions & 15 deletions lauetoolsnn/lauetools/FitOrient.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

RAD = 1.0 / DEG
IDENTITYMATRIX = np.eye(3)
DETECTOR_GEOM = DictLT.DEFAULT_TOP_GEOMETRY

def remove_harmonic(hkl, uflab, yz):

Expand Down Expand Up @@ -70,7 +71,7 @@ def xy_from_Quat(varying_parameter_values, DATA_Q, nspots, varying_parameter_ind
verbose=0,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
kf_direction="Z>0"):
kf_direction=DETECTOR_GEOM):
"""
compute x and y pixel positions of Laue spots given hkl list
Expand Down Expand Up @@ -159,7 +160,7 @@ def calc_XY_pixelpositions(calibration_parameters, DATA_Q, nspots, UBmatrix=None
verbose=0,
pixelsize=0.079,
dim=(2048, 2048),
kf_direction="Z>0"):
kf_direction=DETECTOR_GEOM):
"""
must: len(varying_parameter_values)=len(varying_parameter_indices)
Expand Down Expand Up @@ -232,7 +233,7 @@ def error_function_on_demand_calibration(param_calib,
dim=(2048, 2048),
weights=None,
allspots_info=0,
kf_direction="Z>0"):
kf_direction=DETECTOR_GEOM):
"""
#All miller indices must be entered in DATA_Q,
selection is done in xy_from_Quat with nspots (array of indices)
Expand Down Expand Up @@ -352,7 +353,7 @@ def fit_on_demand_calibration(starting_param, miller, allparameters,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
weights=None,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
**kwd):
"""
#All miller indices must be entered in miller,
Expand Down Expand Up @@ -471,7 +472,7 @@ def error_function_on_demand_strain(param_strain,
pixelsize=165.0 / 2048.,
dim=(2048, 2048),
weights=None,
kf_direction="Z>0"):
kf_direction=DETECTOR_GEOM):
"""
#All miller indices must be entered in DATA_Q, selection is done in xy_from_Quat with nspots (array of indices)
# allparameters must contain 5 detector calibration parameters + 5 parameters of strain + 3 angles of elementary rotation
Expand Down Expand Up @@ -785,7 +786,7 @@ def fit_on_demand_strain(starting_param,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
weights=None,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
fitycen=False,
**kwd):
"""
Expand Down Expand Up @@ -927,7 +928,7 @@ def plot_refinement_oneparameter(starting_param,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
weights=None,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
**kwd):

"""
Expand Down Expand Up @@ -1097,7 +1098,7 @@ def fit_on_demand_strain_2grains(starting_param,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
weights=None,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
**kwd):
"""
Fit a model of two grains of the same material
Expand Down Expand Up @@ -1409,7 +1410,7 @@ def error_function_general(varying_parameters_values_array,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
weights=None,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
returnalldata=False):
"""
q = T_LT UzUyUz Ustart T_c B0 G*
Expand Down Expand Up @@ -1662,7 +1663,7 @@ def fit_function_general(varying_parameters_values_array,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
weights=None,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
**kwd):
"""
Expand Down Expand Up @@ -1784,7 +1785,7 @@ def fit_function_latticeparameters(varying_parameters_values_array,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
weights=None,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
additional_expression="none",
**kwd):
"""
Expand Down Expand Up @@ -1921,7 +1922,7 @@ def error_function_latticeparameters(varying_parameters_values_array,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
weights=None,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
returnalldata=False,
additional_expression="none"):
"""
Expand Down Expand Up @@ -2115,7 +2116,7 @@ def error_function_strain(varying_parameters_values_array,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
weights=None,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
returnalldata=False):
"""
q = refinedStrain refinedUzUyUz Ustart B0 G*
Expand Down Expand Up @@ -2302,7 +2303,7 @@ def fit_function_strain(varying_parameters_values_array,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
weights=None,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
**kwd):
"""
fit strain components in sample frame
Expand Down Expand Up @@ -2438,7 +2439,7 @@ def error_strain_from_elongation(varying_parameters_values_array,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
weights=None,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
returnalldata=False):
"""
calculate array of the sum of 3 distances from aligned points composing one single Laue spot
Expand Down
11 changes: 6 additions & 5 deletions lauetoolsnn/lauetools/LaueGeometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@
import lauetoolsnn.lauetools.IOLaueTools as IOLT
import lauetoolsnn.lauetools.CrystalParameters as CP
import lauetoolsnn.lauetools.dict_LaueTools as DictLT

# ----------- CONSTANTS ------------------
RECTPIX = DictLT.RECTPIX # see above camera skewness

DETECTOR_GEOM = DictLT.DEFAULT_TOP_GEOMETRY
PI = np.pi
DEG = PI / 180.0

Expand All @@ -107,7 +108,7 @@
def calc_uflab(xcam, ycam, detectorplaneparameters, offset=0, returnAngles=1, verbose=0,
pixelsize=165.0 / 2048,
rectpix=RECTPIX,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
version=1):
r"""
Computes scattered unit vector :math:`{\bf u_f}=\frac{\bf k_f}{\|k_f\|}` in laboratory frame corresponding to :math:`k_f`
Expand Down Expand Up @@ -1079,7 +1080,7 @@ def calc_xycam_transmission_2(uflabframe0, calib, energy=0, offset=None, verbose

def calc_xycam_from2thetachi(twicetheta, chi, calib, offset=0, verbose=0,
pixelsize=165.0 / 2048,
kf_direction="Z>0", version=1):
kf_direction=DETECTOR_GEOM, version=1):
r"""
calculate spots coordinates in pixel units in detector plane
from 2theta, chi angles (kf)
Expand Down Expand Up @@ -1281,7 +1282,7 @@ def qvector_from_xy_E(xcamList, ycamList, energy, detectorplaneparameters, pixel
verbose=0,
pixelsize=pixelsize,
rectpix=RECTPIX,
kf_direction="Z>0")
kf_direction=DETECTOR_GEOM)

thetarad = twtheta * DEG / 2.0
chirad = chi * DEG
Expand Down Expand Up @@ -1793,7 +1794,7 @@ def matxmas_to_matstarlab(satocr, calib):


def Compute_data2thetachi(filename, sorting_intensity="yes", detectorparams=None,
kf_direction="Z>0",
kf_direction=DETECTOR_GEOM,
verbose=1,
pixelsize=165.0 / 2048,
dim=(2048, 2048),
Expand Down
28 changes: 10 additions & 18 deletions lauetoolsnn/lauetoolsneuralnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def resource_path(relative_path, verbose=0):
# gif_path = resource_path("frames_medres.gif", verbose=0)

default_detector_geom = dictLT.DEFAULT_TOP_GEOMETRY
geom_key = dictLT.DICT_LAUE_GEOMETRIES

default_initialization = True
if default_initialization:
Expand Down Expand Up @@ -353,7 +354,9 @@ def __init__(self, winx=None, winy=None):
if version_package != latest_version:
self.setDisplayText("New version available at PYPI (please update to Lauetoolsnn v"+ str(latest_version)+")", colormode="red")
##add a notification to say new update is available


self.setDisplayText("LaueNN Geometry is set to "+ geom_key[default_detector_geom]+ "(if this is not intended, please change the mode in terminal using the lauenn_geometry command)", colormode="red")

self.setDisplayText(frame_title)
self.setDisplayText("Uses base libraries of LaueTools (micha@esrf.fr) to simulate Laue patterns for a given detector geometry \nFollows convention of BM32 beamline at ESRF")
self.setDisplayText("Polefigure and IPF plot modules are taken and modified from PYMICRO repository; HKL multiplicity and conditions are taken from xrayutilities library")
Expand Down Expand Up @@ -2592,23 +2595,6 @@ def grid_search_hyperparams(self,):
QApplication.processEvents()
text_file.close()

# class gif_window(QWidget):
# def __init__(self):
# QWidget.__init__(self)
# app_icon = QtGui.QIcon()
# app_icon.addFile(Logo, QtCore.QSize(16,16))
# self.setWindowIcon(app_icon)
# self.layout = QVBoxLayout()
# self.setLayout(self.layout)
# # create label
# self.label = QtWidgets.QLabel()
# self.label.setObjectName("label")
# self.layout.addWidget(self.label)
# # set qmovie as label
# self.movie = QMovie(gif_path)
# self.label.setMovie(self.movie)
# self.movie.start()

class sample_commands(QWidget):
def __init__(self):
QWidget.__init__(self)
Expand All @@ -2634,6 +2620,12 @@ def __init__(self):
self.setDisplayText("lauenn_pymatgen : Query the PYMATGEN rest API for lattice parameters and spacegroup")
self.setDisplayText("usage : lauenn_pymatgen -e Cu Si")
self.setDisplayText("----------")
self.setDisplayText("lauenn_adddet : Add user defined detectors to the library")
self.setDisplayText("usage : lauenn_adddet -n detector1 -dx 2048 -dy 2048 -p 0.0735 -f tif")
self.setDisplayText("----------")
self.setDisplayText("lauenn_geometry : Change the default Laue geometry (Z>0 : Top reflection mode, X<0 : Back reflection mode, X>0 : Transmission mode)")
self.setDisplayText("usage : lauenn_geometry -m Z>0")
self.setDisplayText("----------")
self.setDisplayText("lauenn_example : Copies example script of LaueNN from installation directory to current user directory (terminal cwd)")
self.setDisplayText("usage : lauenn_example")

Expand Down

0 comments on commit cb786c7

Please sign in to comment.