Calibration of the 9-Mythen detector at the Cristal beamline at Soleil

Mythen detectors are 1D-strip detector sold by Dectris. On the Cristal beamline at Soleil, 9 of them are mounted on the goniometer.

This notebook explains how to calibrate precisely their position (including the wavelength used) as function of the goniometer position.

All input data are provided in a Nexus file wich contrains both the (approximate) energy, the goniometer positions (500 points have been measured) and the measured signal.

As pyFAI is not made for 1D data, the Mythen detector will be considered as a 1x1280 image.

We start by importing a whole bunch of modules:

[1]:
%matplotlib nbagg
[2]:
from collections import OrderedDict
from matplotlib import pyplot as plt
import numpy
import os
import h5py
from silx.resources import ExternalResources

from pyFAI import goniometer
from pyFAI.detectors import Detector
from pyFAI.goniometer import ExtendedTransformation, GoniometerRefinement
from pyFAI.control_points import ControlPoints
from pyFAI.geometryRefinement import GeometryRefinement
from pyFAI.gui import jupyter
from pyFAI.units import hc
from pyFAI.calibrant import get_calibrant
from pyFAI.containers import Integrate1dResult

import ipywidgets as widgets

from scipy.signal import find_peaks_cwt
from scipy.interpolate import interp1d
from scipy.optimize import bisect, minimize
from scipy.spatial import distance_matrix
import time

start_time = time.time()
[3]:
#Nota: Useful to configure a proxy if you are behind a firewall
#os.environ["http_proxy"] = "http://proxy.company.fr:3128"

downloader = ExternalResources("detector_calibration", "http://www.silx.org/pub/pyFAI/gonio/")
mythen_ring_file = downloader.getfile("LaB6_17keV_att3_tth2C_24_01_2018_19-43-20_1555.nxs")

The data file can be downoaded from: http://www.silx.org/pub/pyFAI/gonio/LaB6_17keV_att3_tth2C_24_01_2018_19-43-20_1555.nxs

[4]:
#Open the Nexus file and retrieve the actual positions:

h5 = h5py.File(mythen_ring_file, mode="r")
position = h5["/LaB6_17keV_att3_1555/scan_data/actuator_1_1"][:]
print("Positions: ", position[:5], "...")
Positions:  [90.00000001 89.79994445 89.5998889  89.39994445 89.19994445] ...
[5]:
#Read all data

data = {}
ds_names = []
for idx in range(1,13):
    name = "data_%02i"%idx
    ds = h5["/LaB6_17keV_att3_1555/scan_data/"+name][:]
    print(name, ds.shape)
    if ds.shape[1]<2000:
        #Keep only the single modules
        data[name] = ds
        ds_names.append(name)

print(ds_names)

data_01 (501, 5120)
data_02 (501, 1280)
data_03 (501, 1280)
data_04 (501, 1280)
data_05 (501, 1280)
data_06 (501, 5120)
data_07 (501, 1280)
data_08 (501, 1280)
data_09 (501, 1280)
data_10 (501, 1280)
data_11 (501, 1280)
data_12 (501, 1280)
['data_02', 'data_03', 'data_04', 'data_05', 'data_07', 'data_08', 'data_09', 'data_10', 'data_11', 'data_12']
[6]:
#Define a Mythen-detector mounted vertically:

class MythenV(Detector):
    "Verical Mythen dtrip detector from Dectris"
    aliases = ["MythenV 1280"]
    force_pixel = True
    MAX_SHAPE = (1280, 1)

    def __init__(self,pixel1=50e-6, pixel2=8e-3):
        super(MythenV, self).__init__(pixel1=pixel1, pixel2=pixel2)


[7]:
#Define all modules as single detectors of class MythenV.
# Each one has a mask defined from dummy-values in the dataset

modules = {}
for name, ds in data.items():
    one_module = MythenV()
    mask = ds[0]<0
    #discard the first 20 and last 20 pixels as their intensities are less reliable
    mask[:20] = True
    mask[-20:] = True
    one_module.mask = mask.reshape(-1,1)
    modules[name] = one_module

for k,v in modules.items():
    print(k, v.name)
data_02 MythenV 1280
data_03 MythenV 1280
data_04 MythenV 1280
data_05 MythenV 1280
data_07 MythenV 1280
data_08 MythenV 1280
data_09 MythenV 1280
data_10 MythenV 1280
data_11 MythenV 1280
data_12 MythenV 1280
[8]:
# Define a peak-picking function based on the dataset-name and the frame_id:

def peak_picking(module_name, frame_id,
                 threshold=500):
    """Peak-picking base on find_peaks_cwt from scipy plus
    second-order tailor exapention refinement for sub-pixel resolution.

    The half-pixel offset is accounted here, i.e pixel #0 has its center at 0.5

    """
    module = modules[module_name]
    msk = module.mask.ravel()

    spectrum = data[module_name][frame_id]
    guess = find_peaks_cwt(spectrum, [20])

    valid = numpy.logical_and(numpy.logical_not(msk[guess]),
                               spectrum[guess]>threshold)
    guess = guess[valid]

    #Based on maximum is f'(x) = 0 ~ f'(x0) + (x-x0)*(f''(x0))
    df = numpy.gradient(spectrum)
    d2f = numpy.gradient(df)
    bad = d2f==0
    d2f[bad] = 1e-10 #prevent devision by zero. Discared later on
    cor = df / d2f
    cor[abs(cor)>1] = 0
    cor[bad] = 0
    ref = guess - cor[guess] + 0.5 #half a pixel offset
    x = numpy.zeros_like(ref) + 0.5 #half a pixel offset
    return numpy.vstack((ref,x)).T

%timeit peak_picking(ds_names[0], 93)
print(peak_picking(ds_names[0], 93))
18.1 ms ± 25.5 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
[[287.06072343   0.5       ]]
[9]:
nrj = h5["/LaB6_17keV_att3_1555/CRISTAL/Monochromator/energy"][0]
wl = hc / nrj *1e-10
print("Energy (keV): ",nrj, "\nWavelength (A): ",wl)

LaB6 = get_calibrant("LaB6")
LaB6.wavelength = wl
print(LaB6)
Energy (keV):  17.027082549190933
Wavelength (A):  7.281587849134994e-11
LaB6 Calibrant with 109 reflections at wavelength 7.281587849134994e-11
[10]:
#This cell defines the transformation of coordinates for a simple goniometer mounted vertically.

trans = ExtendedTransformation(dist_expr="dist",
                                   poni1_expr="poni1",
                                   poni2_expr="poni2",
                                   rot1_expr="rot1",
                                   rot2_expr="pi*(offset+scale*angle)/180.",
                                   rot3_expr="0.0",
                                   wavelength_expr="hc/nrj*1e-10",
                                   param_names=["dist", "poni1", "poni2", "rot1", "offset", "scale", "nrj"],
                                   pos_names=["angle"],
                                   constants={"hc": hc})
[11]:
def get_position(idx):
    "Returns the postion of the goniometer for the given frame_id"
    return position[idx]

#Approximate offset for the module #0 at 0°
print("Approximated offset for the first module: ",get_position(36))
Approximated offset for the first module:  82.79994445106844
[12]:
#This interactive plot lets one visualize any spectra acquired by any module

fig, ax = plt.subplots()
line = ax.plot(data[ds_names[0]][250])[0]
ligne = plt.Line2D(xdata=[640,640], ydata=[-500, 1000], figure=fig, linestyle="--", color='red', axes=ax)
ax.add_line(ligne)
ax.set_title("spectrum")
fig.show()

def update(module_id, frame_id):
   spectrum = data[ds_names[module_id]][frame_id]
   line.set_data(numpy.arange(spectrum.size), spectrum)
   ax.set_title("Module %i, Frame %i"%(module_id, frame_id))

   fig.canvas.draw()


interactive_plot = widgets.interactive(update,
                                       module_id=(0, len(data)-1),
                                       frame_id=(0, data[ds_names[0]].shape[0]-1))
display(interactive_plot)
[13]:
#Work with the first module corresponding to:
name = ds_names[0]
print(name)
ds = data[name]
module = modules[name]

#Use the previous widget to select:
## the index where the beam-center is in the middle of the module
zero_pos = 36

## The frame index where the first LaB6 peak enters the right-hand side of the spectrum
peak_zero_start = 74

## The frame index where this first LaB6 leaves the spectrum or the second LaB6 peak appears:
peak_zero_end = 94

# The frames between peak_zero_start and peak_zero_end will be used to calibrate roughly the goniometer
# and used later for finer peak extraction
data_02
[14]:
param0 = {"dist": 0.72,
          "poni1": 640*50e-6,
          "poni2": 4e-3,
          "rot1":0,
          "offset": -get_position(zero_pos),
          "scale":1,
          "nrj": nrj}

#Lock enegy for now and a couple of other parameters
bounds0 = {"nrj": (nrj, nrj),
           "dist": (0.71, 0.73),
           "poni2": (4e-3, 4e-3),
           "rot1": (0,0),
           "scale":(1,1),
          }

gonioref0 = GoniometerRefinement(param0,
                                 get_position,
                                 trans,
                                 detector=module,
                                 wavelength=wl,
                                 bounds=bounds0
                                 )
goniometers = {name:  gonioref0}
print(gonioref0)
GoniometerRefinement with 0 geometries labeled: .
[15]:
# Extract the frames where only the peak zero from LaB6 is present.

for i in range(peak_zero_start, peak_zero_end):
    cp = ControlPoints(calibrant=LaB6, wavelength=wl)
    peak = peak_picking(name, i)
    if len(peak)!=1:
        continue
    cp.append([peak[0]], ring=0)
    img = ds[i].reshape((-1,1)) #Images are vertical ... transpose the spectrum
    sg = gonioref0.new_geometry("%s_%04i"%(name,i),
                                image=img,
                                metadata=i,
                                control_points=cp,
                                calibrant=LaB6)
    sg.geometry_refinement.data = numpy.array(cp.getList())

print(gonioref0)
print("Residual error before fit:")
print(gonioref0.chi2())
GoniometerRefinement with 20 geometries labeled: data_02_0074, data_02_0075, data_02_0076, data_02_0077, data_02_0078, data_02_0079, data_02_0080, data_02_0081, data_02_0082, data_02_0083, data_02_0084, data_02_0085, data_02_0086, data_02_0087, data_02_0088, data_02_0089, data_02_0090, data_02_0091, data_02_0092, data_02_0093.
Residual error before fit:
6.737384336276989e-07
[16]:
#First refinement:
gonioref0.refine2()
Cost function before refinement: 6.737384336276989e-07
[ 7.20000000e-01  3.20000000e-02  4.00000000e-03  0.00000000e+00
 -8.27999445e+01  1.00000000e+00  1.70270825e+01]
     fun: 2.490988798391531e-11
     jac: array([ 1.58414573e-07,  2.91897065e-08,  5.74391333e-11, -6.39962716e-10,
        3.42479452e-11,  1.40698490e-07, -1.59997085e-11])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.19994724e-01,  3.14085784e-02,  4.00000000e-03,  0.00000000e+00,
       -8.27999519e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 2.490988798391531e-11
GonioParam(dist=0.7199947243683663, poni1=0.03140857835160603, poni2=0.004, rot1=0.0, offset=-82.7999518865857, scale=1.0, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.032 --> 0.03140857835160603
[16]:
array([ 7.19994724e-01,  3.14085784e-02,  4.00000000e-03,  0.00000000e+00,
       -8.27999519e+01,  1.00000000e+00,  1.70270825e+01])
[17]:
#Here we extract all spectra for peaks,
# If there are as many peaks as expected from the theoritical LaB6. perform the assignment.

#Peaks from LaB6:
tths = LaB6.get_2th()

for i in range(peak_zero_end, ds.shape[0]):
    peak = peak_picking(name, i)
    ai=gonioref0.get_ai(get_position(i))
    tth = ai.array_from_unit(unit="2th_rad", scale=False)
    tth_low = tth[20]
    tth_hi = tth[-20]
    ttmin, ttmax = min(tth_low, tth_hi), max(tth_low, tth_hi)
    valid_peaks = numpy.logical_and(ttmin<=tths, tths<ttmax)
    cnt = valid_peaks.sum()
    if (len(peak) ==  cnt):
        cp = ControlPoints(calibrant=LaB6, wavelength=wl)
        #revert the order of assignment if needed !!
        if tth_hi < tth_low:
            peak = peak[-1::-1]
        for p, r in zip(peak, numpy.where(valid_peaks)[0]):
            #print(p,r)
            cp.append([p], ring=r)
        img = ds[i].reshape((-1,1))
        sg = gonioref0.new_geometry("%s_%04i"%(name,i),
                                    image=img,
                                    metadata=i,
                                    control_points=cp,
                                    calibrant=LaB6)
        sg.geometry_refinement.data = numpy.array(cp.getList())
        #print(sg.label, len(sg.geometry_refinement.data))

#print(gonioref0)
print(" Number of peaks found and used for refinement")
print(sum([len(sg.geometry_refinement.data) for sg in gonioref0.single_geometries.values()]))
print("Residual error before fitting: ", gonioref0.chi2())
 Number of peaks found and used for refinement
1203
Residual error before fitting:  3.118672809442448e-06
[18]:
gonioref0.refine2()
Cost function before refinement: 3.118672809442448e-06
[ 7.19994724e-01  3.14085784e-02  4.00000000e-03  0.00000000e+00
 -8.27999519e+01  1.00000000e+00  1.70270825e+01]
     fun: 2.734250432678472e-06
     jac: array([-5.58224542e-08, -3.65304231e-10,  3.63058044e-06, -2.62495314e-06,
        6.31729336e-10,  1.53969062e-04,  9.87797637e-06])
 message: 'Optimization terminated successfully.'
    nfev: 65
     nit: 7
    njev: 7
  status: 0
 success: True
       x: array([ 7.23095347e-01,  3.18453768e-02,  4.00000000e-03,  0.00000000e+00,
       -8.27999466e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 2.734250432678472e-06
GonioParam(dist=0.7230953467494027, poni1=0.03184537681912273, poni2=0.004, rot1=0.0, offset=-82.79994661694376, scale=1.0, nrj=17.027082549190933)
maxdelta on: dist (0) 0.7199947243683663 --> 0.7230953467494027
[18]:
array([ 7.23095347e-01,  3.18453768e-02,  4.00000000e-03,  0.00000000e+00,
       -8.27999466e+01,  1.00000000e+00,  1.70270825e+01])
[19]:
gonioref0.set_bounds("poni1", -1, 1)
gonioref0.set_bounds("poni2", -1, 1)
gonioref0.set_bounds("rot1", -1, 1)
gonioref0.set_bounds("scale", 0.9, 1.1)
gonioref0.refine2()
Cost function before refinement: 2.734250432678472e-06
[ 7.23095347e-01  3.18453768e-02  4.00000000e-03  0.00000000e+00
 -8.27999466e+01  1.00000000e+00  1.70270825e+01]
     fun: 2.6891723022540698e-06
     jac: array([-5.14464347e-07, -1.24120874e-07,  5.95670514e-07, -4.28660144e-07,
       -9.28110921e-10, -8.53860058e-08, -1.60467593e-06])
 message: 'Optimization terminated successfully.'
    nfev: 36
     nit: 4
    njev: 4
  status: 0
 success: True
       x: array([ 7.23096248e-01,  3.20537111e-02,  3.98485468e-03,  1.09479202e-05,
       -8.27999440e+01,  9.99415047e-01,  1.70270825e+01])
Cost function after refinement: 2.6891723022540698e-06
GonioParam(dist=0.7230962484347616, poni1=0.03205371109950758, poni2=0.003984854679408886, rot1=1.0947920188414968e-05, offset=-82.7999439896301, scale=0.9994150470263444, nrj=17.027082549190933)
maxdelta on: scale (5) 1.0 --> 0.9994150470263444
[19]:
array([ 7.23096248e-01,  3.20537111e-02,  3.98485468e-03,  1.09479202e-05,
       -8.27999440e+01,  9.99415047e-01,  1.70270825e+01])
[20]:
# Perform the azimuthal intgration of all data for the first module:

mg = gonioref0.get_mg(position)
mg.radial_range = (0, 95)
images = [i.reshape(-1, 1) for i in ds]
res_mg = mg.integrate1d(images, 50000)
results={name: res_mg}
print(results)
{'data_02': (array([9.50000113e-04, 2.85000034e-03, 4.75000057e-03, ...,
       9.49952613e+01, 9.49971613e+01, 9.49990613e+01]), array([0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,
       1.27163419e+08, 1.30591592e+08, 1.33665230e+08]))}
[21]:
# Plot the integrated pattern vs expected peak positions:

LaB6_new = get_calibrant("LaB6")
LaB6_new.wavelength = hc/gonioref0.param[-1]*1e-10
p = jupyter.plot1d(res_mg, calibrant=LaB6_new)
p.figure.show()
[22]:
#Peak profile function based on a bilinear interpolations:

def calc_fwhm(integrate_result, calibrant, tth_min=None, tth_max=None):
    "calculate the tth position and FWHM for each peak"
    delta = integrate_result.intensity[1:] - integrate_result.intensity[:-1]
    maxima = numpy.where(numpy.logical_and(delta[:-1]>0, delta[1:]<0))[0]
    minima = numpy.where(numpy.logical_and(delta[:-1]<0, delta[1:]>0))[0]
    maxima += 1
    minima += 1
    tth = []
    FWHM = []
    if tth_min is None:
        tth_min = integrate_result.radial[0]
    if tth_max is None:
        tth_max = integrate_result.radial[-1]
    for tth_rad in calibrant.get_2th():
        tth_deg = tth_rad*integrate_result.unit.scale
        if (tth_deg<=tth_min) or (tth_deg>=tth_max):
            continue
        idx_theo = abs(integrate_result.radial-tth_deg).argmin()
        id0_max = abs(maxima-idx_theo).argmin()
        id0_min = abs(minima-idx_theo).argmin()
        I_max = integrate_result.intensity[maxima[id0_max]]
        I_min = integrate_result.intensity[minima[id0_min]]
        tth_maxi = integrate_result.radial[maxima[id0_max]]
        I_thres = (I_max + I_min)/2.0
        if minima[id0_min]>maxima[id0_max]:
            if id0_min == 0:
                min_lo = integrate_result.radial[0]
            else:
                min_lo = integrate_result.radial[minima[id0_min-1]]
            min_hi = integrate_result.radial[minima[id0_min]]
        else:
            if id0_min == len(minima) -1:
                min_hi = integrate_result.radial[-1]
            else:
                min_hi = integrate_result.radial[minima[id0_min+1]]
            min_lo = integrate_result.radial[minima[id0_min]]

        f = interp1d(integrate_result.radial, integrate_result.intensity-I_thres)
        try:
            tth_lo = bisect(f, min_lo, tth_maxi)
            tth_hi = bisect(f, tth_maxi, min_hi)
        except:
            pass
        else:
            FWHM.append(tth_hi-tth_lo)
            tth.append(tth_deg)
    return tth, FWHM

[23]:
# Peak error:

def calc_peak_error(integrate_result, calibrant, tth_min=10, tth_max=95):
    "calculate the tth position and FWHM for each peak"
    peaks = find_peaks_cwt(integrate_result.intensity, [10])
    df = numpy.gradient(integrate_result.intensity)
    d2f = numpy.gradient(df)
    bad = d2f==0
    d2f[bad] = 1e-10
    cor = df / d2f
    print((abs(cor)>1).sum())
    cor[abs(cor)>1] = 0
    cor[bad] = 0
    got = numpy.interp(peaks-cor[peaks],
                       numpy.arange(len(integrate_result.radial)),
                       integrate_result.radial)
    mask = numpy.logical_and(got>=tth_min,
                             got<=tth_max)
    got = got[mask]
    target = numpy.array(calibrant.get_2th())*integrate_result.unit.scale
    mask = numpy.logical_and(target>=tth_min,
                             target<=tth_max)
    target = target[mask]
    print(len(got), len(target))
    d2 = distance_matrix(target.reshape(-1, 1 ),
                         got.reshape(-1, 1), p=1)

    return target, target-got[d2.argmin(axis=-1)]

[24]:
fig, ax = plt.subplots()
ax.plot(*calc_fwhm(res_mg, LaB6_new), "o", label="FWHM")
ax.plot(*calc_peak_error(res_mg, LaB6_new), "o", label="offset")
ax.set_title("Peak shape & error as function of the angle")
ax.set_xlabel(res_mg.unit.label)
ax.legend()
fig.show()
29209
81 60

Module 1

We can apply the same procdure for the second module … and try to rationalize the procedure.

[25]:
module_id = 1
name = ds_names[module_id]
ds = data[name]
zero_pos = 64
frame_start = 103
frame_stop = 123
[26]:
param1 = {"dist": 0.72,
          "poni1": 640*50e-6,
          "poni2": 4e-3,
          "rot1":0,
          "offset": -get_position(zero_pos),
          "scale":1,
          "nrj": nrj}

#Lock enegy for now and a couple of other parameters
bounds1 = {"nrj": (nrj, nrj),
           "dist": (0.7, 0.8),
           "poni2": (4e-3, 4e-3),
           "rot1": (0,0),
           "scale":(1,1), }

gonioref1 = GoniometerRefinement(param1,
                                 get_position,
                                 trans,
                                 detector=modules[name],
                                 wavelength=wl,
                                 bounds=bounds1
                                 )
print(gonioref1)
goniometers[name]=gonioref1
GoniometerRefinement with 0 geometries labeled: .
[27]:
#Exctract frames with peak#0
for i in range(frame_start, frame_stop):
    cp = ControlPoints(calibrant=LaB6, wavelength=wl)
    peak = peak_picking(name, i)
    if len(peak)!=1:
        continue
    cp.append([peak[0]], ring=0)
    img = (ds[i]).reshape((-1,1))
    sg = gonioref1.new_geometry("%s_%04i"%(name,i),
                                image=img,
                                metadata=i,
                                control_points=cp,
                                calibrant=LaB6)
    sg.geometry_refinement.data = numpy.array(cp.getList())

print(gonioref1)
print(gonioref1.chi2())
GoniometerRefinement with 20 geometries labeled: data_03_0103, data_03_0104, data_03_0105, data_03_0106, data_03_0107, data_03_0108, data_03_0109, data_03_0110, data_03_0111, data_03_0112, data_03_0113, data_03_0114, data_03_0115, data_03_0116, data_03_0117, data_03_0118, data_03_0119, data_03_0120, data_03_0121, data_03_0122.
1.4524700202830549e-06
[28]:
gonioref1.refine2()
Cost function before refinement: 1.4524700202830549e-06
[ 7.20000000e-01  3.20000000e-02  4.00000000e-03  0.00000000e+00
 -7.72000000e+01  1.00000000e+00  1.70270825e+01]
     fun: 2.3431861472723482e-11
     jac: array([ 1.37377624e-07,  1.03462536e-07,  2.38592839e-09, -2.23238045e-09,
        9.89688559e-10,  1.85837277e-07, -5.81633804e-10])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.20006378e-01,  3.28683965e-02,  4.00000000e-03,  0.00000000e+00,
       -7.71999891e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 2.3431861472723482e-11
GonioParam(dist=0.7200063780313144, poni1=0.03286839651397956, poni2=0.004, rot1=0.0, offset=-77.19998908850266, scale=1.0, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.032 --> 0.03286839651397956
[28]:
array([ 7.20006378e-01,  3.28683965e-02,  4.00000000e-03,  0.00000000e+00,
       -7.71999891e+01,  1.00000000e+00,  1.70270825e+01])
[29]:
#Exctract all frames with peak>0
tths = LaB6.get_2th()
#print(tths)
for i in range(frame_stop, ds.shape[0]):
    frame_name = "%s_%04i"%(name, i)
    if frame_name in gonioref1.single_geometries:
        continue
    peak = peak_picking(name, i)
    ai=gonioref1.get_ai(get_position(i))
    tth = ai.array_from_unit(unit="2th_rad", scale=False)
    tth_low = tth[20]
    tth_hi = tth[-20]
    ttmin, ttmax = min(tth_low, tth_hi), max(tth_low, tth_hi)
    valid_peaks = numpy.logical_and(ttmin<=tths, tths<ttmax)
    cnt = valid_peaks.sum()
    if (len(peak) ==  cnt) and cnt>0:
        cp = ControlPoints(calibrant=LaB6, wavelength=wl)
        #revert the order of assignment if needed !!
        if tth_hi < tth_low:
            peak = peak[-1::-1]
        for p, r in zip(peak, numpy.where(valid_peaks)[0]):
            cp.append([p], ring=r)
        img = ds[i].reshape((-1,1))
        sg = gonioref1.new_geometry(frame_name,
                                    image=img,
                                    metadata=i,
                                    control_points=cp,
                                    calibrant=LaB6)
        sg.geometry_refinement.data = numpy.array(cp.getList())
        #print(frame_name, len(sg.geometry_refinement.data))

print(" Number of peaks found and used for refinement")
print(sum([len(sg.geometry_refinement.data) for sg in gonioref1.single_geometries.values()]))
print("Residual error before fitting: ", gonioref1.chi2())
 Number of peaks found and used for refinement
1183
Residual error before fitting:  6.334769973618362e-07
[30]:
gonioref1.refine2()
gonioref1.set_bounds("poni1", -1, 1)
gonioref1.set_bounds("poni2", -1, 1)
gonioref1.set_bounds("rot1", -1, 1)
gonioref1.set_bounds("scale", 0.9, 1.1)
gonioref1.refine2()
Cost function before refinement: 6.334769973618362e-07
[ 7.20006378e-01  3.28683965e-02  4.00000000e-03  0.00000000e+00
 -7.71999891e+01  1.00000000e+00  1.70270825e+01]
     fun: 1.3797542164386038e-07
     jac: array([-4.62580205e-07,  2.40834463e-08,  5.10766142e-06, -3.67570741e-06,
        1.35589318e-11,  2.65546301e-04,  1.99388955e-05])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.20006340e-01,  3.33754761e-02,  4.00000000e-03,  0.00000000e+00,
       -7.71999827e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 1.3797542164386038e-07
GonioParam(dist=0.7200063395001164, poni1=0.033375476115602126, poni2=0.004, rot1=0.0, offset=-77.19998271232215, scale=1.0, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.03286839651397956 --> 0.033375476115602126
Cost function before refinement: 1.3797542164386038e-07
[ 7.20006340e-01  3.33754761e-02  4.00000000e-03  0.00000000e+00
 -7.71999827e+01  1.00000000e+00  1.70270825e+01]
     fun: 8.828686563664207e-10
     jac: array([ 6.56076518e-08,  6.55451977e-07, -1.75522725e-07,  1.26240119e-07,
        7.93555705e-09,  2.91447578e-07,  1.05708096e-07])
 message: 'Optimization terminated successfully.'
    nfev: 117
     nit: 13
    njev: 13
  status: 0
 success: True
       x: array([ 7.20682081e-01,  3.36782425e-02,  4.05801126e-03, -4.44860018e-05,
       -7.71999788e+01,  9.98967223e-01,  1.70270825e+01])
Cost function after refinement: 8.828686563664207e-10
GonioParam(dist=0.7206820809610033, poni1=0.033678242508301, poni2=0.00405801125545738, rot1=-4.448600179438364e-05, offset=-77.19997879310895, scale=0.9989672227193093, nrj=17.027082549190933)
maxdelta on: scale (5) 1.0 --> 0.9989672227193093
[30]:
array([ 7.20682081e-01,  3.36782425e-02,  4.05801126e-03, -4.44860018e-05,
       -7.71999788e+01,  9.98967223e-01,  1.70270825e+01])
[31]:
mg1 = gonioref1.get_mg(position)
mg1.radial_range = (0, 95)
images = [i.reshape(-1, 1) for i in data[name]]
res_mg1 = mg1.integrate1d(images, 50000)
results[name] = res_mg1
area_pixel=0.04011793214486481 area_sum=0.05472285778563535, Error= -0.3640498116411517
area_pixel=0.06755918226705582 area_sum=0.07017344439747103, Error= -0.038695881783785545
area_pixel=0.06470384723321665 area_sum=0.06854713835898787, Error= -0.05939818558112286
area_pixel=0.038258287348172715 area_sum=0.05426051394830549, Error= -0.4182682422373795
area_pixel=0.06290299608614092 area_sum=0.06750646087344028, Error= -0.07318355362589196
area_pixel=0.06866181632504009 area_sum=0.0710979827571788, Error= -0.03548065813764767
area_pixel=0.045481003274128184 area_sum=0.05690843539150094, Error= -0.2512572567604998
area_pixel=0.051372066242729275 area_sum=0.060437735665688296, Error= -0.17647079601829507
area_pixel=0.08412331180916155 area_sum=0.08447601010651973, Error= -0.004192634476377893
area_pixel=0.07467387290401106 area_sum=0.07603231757541912, Error= -0.018191699701370204
area_pixel=0.0624099895059711 area_sum=0.0673026438866445, Error= -0.07839537259023732
area_pixel=0.04195900037770173 area_sum=0.05573620360979919, Error= -0.32834917676968967
area_pixel=0.05715571439263911 area_sum=0.06402386234646332, Error= -0.12016555171793514
area_pixel=0.08038761552922224 area_sum=0.08112738452122062, Error= -0.009202524382993493
area_pixel=0.07843450940492147 area_sum=0.07937664635982263, Error= -0.012011765765465969
area_pixel=0.05907229451306506 area_sum=0.06522039353885213, Error= -0.10407753882706032
area_pixel=0.040121002784973214 area_sum=0.055076739171659624, Error= -0.3727657672676088
area_pixel=0.061909101662060095 area_sum=0.06698716844120342, Error= -0.08202455927825762
area_pixel=0.07486883011958412 area_sum=0.0762213872653684, Error= -0.01806569093738887
area_pixel=0.08390728427714045 area_sum=0.08427957645881265, Error= -0.004436947100355958
area_pixel=0.052353526345367385 area_sum=0.061054313175336744, Error= -0.16619294701510143
area_pixel=0.05061563353131504 area_sum=0.060016745022665983, Error= -0.18573533186213373
area_pixel=0.08664846785681313 area_sum=0.08667317488344674, Error= -0.000285140952225944
area_pixel=0.07201199510202194 area_sum=0.07377214053011852, Error= -0.024442392209838324
area_pixel=0.062293472479096224 area_sum=0.06710802538833513, Error= -0.07728824092852621
area_pixel=0.04161483391746934 area_sum=0.055387896893291044, Error= -0.3309652275228704
area_pixel=0.06664231871870818 area_sum=0.06966942981335798, Error= -0.045423255865795896
area_pixel=0.06246630299088629 area_sum=0.06709144439642731, Error= -0.07404218249022702
area_pixel=0.04218618802653751 area_sum=0.05535486043373737, Error= -0.312156016535934
[32]:
LaB6_new = get_calibrant("LaB6")
LaB6_new.wavelength = hc/gonioref1.param[-1]*1e-10
p = jupyter.plot1d(res_mg1, calibrant=LaB6_new)
p.figure.show()
[33]:
fig, ax = plt.subplots()
ax.plot(*calc_fwhm(res_mg1, LaB6_new, 10, 88), "o", label="FWHM")
ax.plot(*calc_peak_error(res_mg1, LaB6_new, 10, 88), "o", label="error")
ax.set_title("Peak shape & error as function of the angle")
ax.set_xlabel(res_mg.unit.label)
ax.legend()
fig.show()
27712
72 53

All other Modules

We define now an automatic procedure for any module. The detection used 3 parameter visually extracted from the Figure1:

  • zero_pos: the frame where the beam-stop is in the center of the module

  • frame_start: the frame where the first peak of LaB6 appears (positive)

  • frame_stop: the frame where the second peak of LaB6 appears (positive)

This is enough for boot-strapping the goniometer configuration.

[34]:
def add_module(name,
               zero_pos,
               frame_start,
               frame_stop,
                ):
    ds = data[name]
    param = {"dist": 0.72,
          "poni1": 640*50e-6,
          "poni2": 4e-3,
          "rot1":0,
          "offset": -get_position(zero_pos),
          "scale":1,
          "nrj": nrj}

    #Lock enegy for now and a couple of other parameters
    bounds = {"nrj": (nrj, nrj),
              "dist": (0.7, 0.8),
              "poni2": (4e-3, 4e-3),
              "rot1": (0,0),
              "scale": (1,1)}

    gonioref = GoniometerRefinement(param,
                                    get_position,
                                    trans,
                                    detector=modules[name],
                                    wavelength=wl,
                                    bounds=bounds
                                      )
    goniometers[name] = gonioref

    for i in range(frame_start, frame_stop):
        cp = ControlPoints(calibrant=LaB6, wavelength=wl)
        peak = peak_picking(name, i)
        if len(peak)!=1:
            continue
        cp.append([peak[0]], ring=0)
        img = (ds[i]).reshape((-1,1))
        sg = gonioref.new_geometry("%s_%04i"%(name, i),
                                    image=img,
                                    metadata=i,
                                    control_points=cp,
                                    calibrant=LaB6)
        sg.geometry_refinement.data = numpy.array(cp.getList())

    print(gonioref.chi2())
    gonioref.refine2()

    tths = LaB6.get_2th()
    #print(tths)
    for i in range(frame_stop, ds.shape[0]):
        frame_name = "%s_%04i"%(name, i)
        if frame_name in gonioref.single_geometries:
            continue
        peak = peak_picking(name, i)
        ai=gonioref.get_ai(get_position(i))
        tth = ai.array_from_unit(unit="2th_rad", scale=False)
        tth_low = tth[20]
        tth_hi = tth[-20]
        ttmin, ttmax = min(tth_low, tth_hi), max(tth_low, tth_hi)
        valid_peaks = numpy.logical_and(ttmin<=tths, tths<ttmax)
        cnt = valid_peaks.sum()
        if (len(peak) ==  cnt) and cnt>0:
            cp = ControlPoints(calibrant=LaB6, wavelength=wl)
            #revert the order of assignment if needed !!
            if tth_hi < tth_low:
                peak = peak[-1::-1]

            for p, r in zip(peak, numpy.where(valid_peaks)[0]):
                cp.append([p], ring=r)
            img = (ds[i]).reshape((-1,1))
            sg = gonioref.new_geometry(frame_name,
                                        image=img,
                                        metadata=i,
                                        control_points=cp,
                                        calibrant=LaB6)
            sg.geometry_refinement.data = numpy.array(cp.getList())
            #print(frame_name, len(sg.geometry_refinement.data))


    print(" Number of peaks found and used for refinement")
    print(sum([len(sg.geometry_refinement.data) for sg in gonioref.single_geometries.values()]))

    gonioref.refine2()
    gonioref.set_bounds("poni1", -1, 1)
    gonioref.set_bounds("poni2", -1, 1)
    gonioref.set_bounds("rot1", -1, 1)
    gonioref.set_bounds("scale", 0.9, 1.1)
    gonioref.refine2()

    mg = gonioref.get_mg(position)
    mg.radial_range = (0, 95)
    images = [i.reshape(-1, 1) for i in ds]
    res_mg = mg.integrate1d(images, 50000)
    results[name] = res_mg

    LaB6_new = get_calibrant("LaB6")
    LaB6_new.wavelength = hc/gonioref.param[-1]*1e-10
    p = jupyter.plot1d(res_mg, calibrant=LaB6_new)
    p.figure.show()

    fig, ax = plt.subplots()
    ax.plot(*calc_fwhm(res_mg, LaB6_new), "o", label="FWHM")
    ax.plot(*calc_peak_error(res_mg, LaB6_new, 10, 89), "o", label="error")
    ax.set_title("Peak shape & error as function of the angle")
    ax.set_xlabel(res_mg.unit.label)
    ax.legend()
    fig.show()
[35]:
add_module(ds_names[2],
           92,
           131,
           151)
8.406338771704969e-06
Cost function before refinement: 8.406338771704969e-06
[ 7.20000000e-01  3.20000000e-02  4.00000000e-03  0.00000000e+00
 -7.15999445e+01  1.00000000e+00  1.70270825e+01]
     fun: 1.808572002652971e-11
     jac: array([ 4.57424569e-08,  8.17041295e-07,  2.47626008e-08, -1.79775418e-08,
        9.91633086e-09,  6.60392633e-07, -5.86643086e-09])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.20018961e-01,  3.40893083e-02,  4.00000000e-03,  0.00000000e+00,
       -7.15999182e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 1.808572002652971e-11
GonioParam(dist=0.7200189605020697, poni1=0.03408930832642036, poni2=0.004, rot1=0.0, offset=-71.59991818229837, scale=1.0, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.032 --> 0.03408930832642036
 Number of peaks found and used for refinement
1093
Cost function before refinement: 5.55731697942323e-07
[ 7.20018961e-01  3.40893083e-02  4.00000000e-03  0.00000000e+00
 -7.15999182e+01  1.00000000e+00  1.70270825e+01]
     fun: 1.1961227626432414e-07
     jac: array([-9.44231683e-07,  2.30905108e-08,  4.88576803e-06, -3.51407454e-06,
       -1.74829040e-11,  2.33600314e-04,  1.70705134e-05])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.20018345e-01,  3.45650482e-02,  4.00000000e-03,  0.00000000e+00,
       -7.15999122e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 1.1961227626432414e-07
GonioParam(dist=0.7200183446976933, poni1=0.034565048153275144, poni2=0.004, rot1=0.0, offset=-71.59991220000985, scale=1.0, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.03408930832642036 --> 0.034565048153275144
Cost function before refinement: 1.1961227626432414e-07
[ 7.20018345e-01  3.45650482e-02  4.00000000e-03  0.00000000e+00
 -7.15999122e+01  1.00000000e+00  1.70270825e+01]
     fun: 6.570539910514945e-10
     jac: array([ 2.18222064e-08,  1.73947572e-08, -1.60806027e-07,  1.15807314e-07,
       -1.82359884e-10,  8.08015633e-09,  8.85008258e-08])
 message: 'Optimization terminated successfully.'
    nfev: 90
     nit: 10
    njev: 10
  status: 0
 success: True
       x: array([ 7.20686437e-01,  3.48247495e-02,  4.04316666e-03, -3.37686772e-05,
       -7.15999088e+01,  9.98982863e-01,  1.70270825e+01])
Cost function after refinement: 6.570539910514945e-10
GonioParam(dist=0.7206864370148651, poni1=0.03482474946152798, poni2=0.004043166657976692, rot1=-3.376867719168802e-05, offset=-71.5999088132962, scale=0.9989828627069963, nrj=17.027082549190933)
maxdelta on: scale (5) 1.0 --> 0.9989828627069963
area_pixel=0.04101321524826673 area_sum=0.04635522282228846, Error= -0.13025088478639793
area_pixel=0.04805074298699985 area_sum=0.050770187552341764, Error= -0.056595265677320754
area_pixel=0.05470148979267009 area_sum=0.056228786108716095, Error= -0.027920561612394357
area_pixel=0.062098761379894896 area_sum=0.062392206682634205, Error= -0.004725461445907599
area_pixel=0.040415219606433794 area_sum=0.046336505956633724, Error= -0.1465112996505234
area_pixel=0.06211637552982907 area_sum=0.062425234207049, Error= -0.004972258516139761
area_pixel=0.0545957431661801 area_sum=0.05610676727387377, Error= -0.027676591984367248
area_pixel=0.046408760633763535 area_sum=0.04924681820885727, Error= -0.06115348775396895
area_pixel=0.04985697246649501 area_sum=0.05218296613471554, Error= -0.04665332757185872
area_pixel=0.0522213978747601 area_sum=0.05417632538646705, Error= -0.03743537307054384
area_pixel=0.06152426635945751 area_sum=0.06185028694021803, Error= -0.005299056779575941
area_pixel=0.04466499326386497 area_sum=0.04810216511625828, Error= -0.07695449167735718
area_pixel=0.043420597173687625 area_sum=0.04734951311542082, Error= -0.09048507384679808
25667
218 54
[36]:
add_module(ds_names[3],
           121,
           159,
           179)
1.0825408441330163e-06
Cost function before refinement: 1.0825408441330163e-06
[ 7.20000000e-01  3.20000000e-02  4.00000000e-03  0.00000000e+00
 -6.57999444e+01  1.00000000e+00  1.70270825e+01]
     fun: 2.4921939380829473e-11
     jac: array([-8.60015175e-08,  7.99451827e-08,  1.64794931e-09, -8.07493243e-10,
        6.18853503e-10, -1.33401994e-08, -3.62117520e-10])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.20006745e-01,  3.27496622e-02,  4.00000000e-03,  0.00000000e+00,
       -6.57999350e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 2.4921939380829473e-11
GonioParam(dist=0.7200067449851295, poni1=0.032749662244436796, poni2=0.004, rot1=0.0, offset=-65.79993502488618, scale=1.0, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.032 --> 0.032749662244436796
 Number of peaks found and used for refinement
978
Cost function before refinement: 4.705197877733383e-07
[ 7.20006745e-01  3.27496622e-02  4.00000000e-03  0.00000000e+00
 -6.57999350e+01  1.00000000e+00  1.70270825e+01]
     fun: 9.924141633593764e-08
     jac: array([-1.34035538e-09, -8.95816754e-12,  4.47653376e-06, -3.22526285e-06,
       -3.95764310e-10,  1.97125028e-04,  1.39658085e-05])
 message: 'Optimization terminated successfully.'
    nfev: 64
     nit: 7
    njev: 7
  status: 0
 success: True
       x: array([ 7.20481821e-01,  3.31886380e-02,  4.00000000e-03,  0.00000000e+00,
       -6.57999293e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 9.924141633593764e-08
GonioParam(dist=0.7204818213178118, poni1=0.03318863803715359, poni2=0.004, rot1=0.0, offset=-65.7999293473278, scale=1.0, nrj=17.027082549190933)
maxdelta on: dist (0) 0.7200067449851295 --> 0.7204818213178118
Cost function before refinement: 9.924141633593764e-08
[ 7.20481821e-01  3.31886380e-02  4.00000000e-03  0.00000000e+00
 -6.57999293e+01  1.00000000e+00  1.70270825e+01]
     fun: 5.124963686571038e-10
     jac: array([-5.05292020e-07, -5.37136276e-09, -1.29798578e-07,  9.55532346e-08,
       -4.36381951e-10,  2.56600519e-09,  8.43817010e-08])
 message: 'Optimization terminated successfully.'
    nfev: 46
     nit: 5
    njev: 5
  status: 0
 success: True
       x: array([ 7.20482931e-01,  3.34099564e-02,  3.97791142e-03,  1.59099880e-05,
       -6.57999266e+01,  9.98999110e-01,  1.70270825e+01])
Cost function after refinement: 5.124963686571038e-10
GonioParam(dist=0.7204829305671493, poni1=0.033409956436720734, poni2=0.003977911420613329, rot1=1.5909988045817424e-05, offset=-65.79992655965417, scale=0.9989991098968561, nrj=17.027082549190933)
maxdelta on: scale (5) 1.0 --> 0.9989991098968561
24026
427 54
[37]:
add_module(ds_names[4],
           150,
           188,
           208)
2.3192859672732885e-07
Cost function before refinement: 2.3192859672732885e-07
[ 7.20000000e-01  3.20000000e-02  4.00000000e-03  0.00000000e+00
 -6.00000556e+01  1.00000000e+00  1.70270825e+01]
     fun: 2.0856624751999954e-10
     jac: array([-2.72031959e-07,  2.34632462e-08, -3.13650477e-11,  1.14575097e-09,
       -9.14368789e-11, -1.88744526e-07,  5.83778581e-11])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.19996884e-01,  3.16531473e-02,  4.00000000e-03,  0.00000000e+00,
       -6.00000599e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 2.0856624751999954e-10
GonioParam(dist=0.719996884236354, poni1=0.031653147292955666, poni2=0.004, rot1=0.0, offset=-60.00005992106343, scale=1.0, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.032 --> 0.031653147292955666
 Number of peaks found and used for refinement
864
Cost function before refinement: 3.883355149577502e-07
[ 7.19996884e-01  3.16531473e-02  4.00000000e-03  0.00000000e+00
 -6.00000599e+01  1.00000000e+00  1.70270825e+01]
     fun: 8.35586015918641e-08
     jac: array([-2.49360177e-09, -2.03934647e-11,  4.26768070e-06, -3.07547620e-06,
       -2.94530622e-10,  1.68280037e-04,  1.16002486e-05])
 message: 'Optimization terminated successfully.'
    nfev: 64
     nit: 7
    njev: 7
  status: 0
 success: True
       x: array([ 7.20644233e-01,  3.20496137e-02,  4.00000000e-03,  0.00000000e+00,
       -6.00000548e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 8.35586015918641e-08
GonioParam(dist=0.7206442326818199, poni1=0.032049613716226354, poni2=0.004, rot1=0.0, offset=-60.000054800019825, scale=1.0, nrj=17.027082549190933)
maxdelta on: dist (0) 0.719996884236354 --> 0.7206442326818199
Cost function before refinement: 8.35586015918641e-08
[ 7.20644233e-01  3.20496137e-02  4.00000000e-03  0.00000000e+00
 -6.00000548e+01  1.00000000e+00  1.70270825e+01]
     fun: 3.3388878229483034e-10
     jac: array([-3.34948071e-07, -1.35145738e-09, -1.13491295e-07,  8.31385815e-08,
       -3.43393425e-10,  3.68209766e-09,  5.32985622e-08])
 message: 'Optimization terminated successfully.'
    nfev: 46
     nit: 5
    njev: 5
  status: 0
 success: True
       x: array([ 7.20645314e-01,  3.22371238e-02,  3.97565133e-03,  1.75424155e-05,
       -6.00000524e+01,  9.99011856e-01,  1.70270825e+01])
Cost function after refinement: 3.3388878229483034e-10
GonioParam(dist=0.7206453140156728, poni1=0.03223712376780837, poni2=0.003975651331253134, rot1=1.7542415484114082e-05, offset=-60.000052437600765, scale=0.999011855791219, nrj=17.027082549190933)
maxdelta on: scale (5) 1.0 --> 0.999011855791219
22258
663 54
[38]:
add_module(ds_names[5],
           178,
           216,
           236)
1.496585538687667e-06
Cost function before refinement: 1.496585538687667e-06
[ 7.20000000e-01  3.20000000e-02  4.00000000e-03  0.00000000e+00
 -5.43998333e+01  1.00000000e+00  1.70270825e+01]
     fun: 2.0171535150920134e-10
     jac: array([-2.79014458e-07,  1.12723053e-07,  2.76456642e-09, -8.39426390e-10,
        1.01678678e-09, -1.46581687e-07, -5.97716569e-10])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.20008138e-01,  3.28813990e-02,  4.00000000e-03,  0.00000000e+00,
       -5.43998223e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 2.0171535150920134e-10
GonioParam(dist=0.7200081378039512, poni1=0.03288139900481467, poni2=0.004, rot1=0.0, offset=-54.399822256631786, scale=1.0, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.032 --> 0.03288139900481467
 Number of peaks found and used for refinement
754
Cost function before refinement: 3.084426464441637e-07
[ 7.20008138e-01  3.28813990e-02  4.00000000e-03  0.00000000e+00
 -5.43998223e+01  1.00000000e+00  1.70270825e+01]
     fun: 6.551090453612858e-08
     jac: array([-1.59759495e-09, -1.69126935e-11,  3.81129886e-06, -2.74614198e-06,
       -3.33598038e-10,  1.33732118e-04,  8.98242363e-06])
 message: 'Optimization terminated successfully.'
    nfev: 64
     nit: 7
    njev: 7
  status: 0
 success: True
       x: array([ 7.20526837e-01,  3.32363709e-02,  4.00000000e-03,  0.00000000e+00,
       -5.43998177e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 6.551090453612858e-08
GonioParam(dist=0.7205268365472406, poni1=0.03323637090038128, poni2=0.004, rot1=0.0, offset=-54.39981766227154, scale=1.0, nrj=17.027082549190933)
maxdelta on: dist (0) 0.7200081378039512 --> 0.7205268365472406
Cost function before refinement: 6.551090453612858e-08
[ 7.20526837e-01  3.32363709e-02  4.00000000e-03  0.00000000e+00
 -5.43998177e+01  1.00000000e+00  1.70270825e+01]
     fun: 2.9801782405594906e-10
     jac: array([-6.28824819e-07, -6.16534335e-09, -8.41801711e-08,  6.31905195e-08,
       -4.25490289e-10,  1.87107307e-09,  5.29587814e-08])
 message: 'Optimization terminated successfully.'
    nfev: 46
     nit: 5
    njev: 5
  status: 0
 success: True
       x: array([ 7.20528271e-01,  3.33948197e-02,  3.97295090e-03,  1.94838596e-05,
       -5.43998157e+01,  9.99025942e-01,  1.70270825e+01])
Cost function after refinement: 2.9801782405594906e-10
GonioParam(dist=0.7205282706408196, poni1=0.033394819722196205, poni2=0.003972950903091611, rot1=1.948385963684671e-05, offset=-54.399815665191156, scale=0.999025941539747, nrj=17.027082549190933)
maxdelta on: scale (5) 1.0 --> 0.999025941539747
20560
923 54
[39]:
add_module(ds_names[6],
           207,
           245,
           266)
7.414763745399852e-08
Cost function before refinement: 7.414763745399852e-08
[ 7.20000000e-01  3.20000000e-02  4.00000000e-03  0.00000000e+00
 -4.85998889e+01  1.00000000e+00  1.70270825e+01]
     fun: 5.6513401976066356e-11
     jac: array([-2.81311437e-07,  1.90457697e-08, -2.47022619e-10,  1.33814411e-09,
       -1.23389936e-10, -2.00557892e-07,  7.73080818e-11])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.19998572e-01,  3.18038587e-02,  4.00000000e-03,  0.00000000e+00,
       -4.85998914e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 5.6513401976066356e-11
GonioParam(dist=0.719998571752675, poni1=0.031803858748058605, poni2=0.004, rot1=0.0, offset=-48.599891358709684, scale=1.0, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.032 --> 0.031803858748058605
 Number of peaks found and used for refinement
626
Cost function before refinement: 2.383350348017308e-07
[ 7.19998572e-01  3.18038587e-02  4.00000000e-03  0.00000000e+00
 -4.85998914e+01  1.00000000e+00  1.70270825e+01]
     fun: 5.1984312387232055e-08
     jac: array([-2.19915020e-09, -2.37196929e-11,  3.57712533e-06, -2.57769667e-06,
       -2.59923194e-10,  1.07698151e-04,  7.05422505e-06])
 message: 'Optimization terminated successfully.'
    nfev: 64
     nit: 7
    njev: 7
  status: 0
 success: True
       x: array([ 7.20606858e-01,  3.21138531e-02,  4.00000000e-03,  0.00000000e+00,
       -4.85998873e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 5.1984312387232055e-08
GonioParam(dist=0.7206068584664383, poni1=0.03211385308050831, poni2=0.004, rot1=0.0, offset=-48.599887342357356, scale=1.0, nrj=17.027082549190933)
maxdelta on: dist (0) 0.719998571752675 --> 0.7206068584664383
Cost function before refinement: 5.1984312387232055e-08
[ 7.20606858e-01  3.21138531e-02  4.00000000e-03  0.00000000e+00
 -4.85998873e+01  1.00000000e+00  1.70270825e+01]
     fun: 2.5561187046317613e-10
     jac: array([-6.63680455e-07,  8.68967625e-08, -6.74647493e-08,  5.12958215e-08,
        7.87452992e-10,  2.88084273e-09,  4.15782562e-08])
 message: 'Optimization terminated successfully.'
    nfev: 54
     nit: 6
    njev: 6
  status: 0
 success: True
       x: array([ 7.20609298e-01,  3.22472627e-02,  3.96893520e-03,  2.23757106e-05,
       -4.85998857e+01,  9.99040899e-01,  1.70270825e+01])
Cost function after refinement: 2.5561187046317613e-10
GonioParam(dist=0.7206092976334295, poni1=0.03224726268736372, poni2=0.003968935202854616, rot1=2.237571059770315e-05, offset=-48.599885660072495, scale=0.9990408988314912, nrj=17.027082549190933)
maxdelta on: scale (5) 1.0 --> 0.9990408988314912
area_pixel=0.041071116230573246 area_sum=0.04123092083600752, Error= -0.0038909243307907342
area_pixel=0.0404747680993891 area_sum=0.04058389121931238, Error= -0.0026960777058762783
18647
1232 54
[40]:
add_module(ds_names[7],
           236,
           273,
           293)
4.37748174147368e-06
Cost function before refinement: 4.37748174147368e-06
[ 7.20000000e-01  3.20000000e-02  4.00000000e-03  0.00000000e+00
 -4.27998889e+01  1.00000000e+00  1.70270825e+01]
     fun: 9.109058243486396e-11
     jac: array([-3.53771074e-07,  3.50167703e-09, -7.17406458e-10,  1.96667227e-09,
       -3.65232464e-10, -2.61708398e-07,  2.20481224e-10])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.19986034e-01,  3.04925065e-02,  4.00000000e-03,  0.00000000e+00,
       -4.27999078e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 9.109058243486396e-11
GonioParam(dist=0.7199860338026991, poni1=0.030492506521307684, poni2=0.004, rot1=0.0, offset=-42.79990784447931, scale=1.0, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.032 --> 0.030492506521307684
 Number of peaks found and used for refinement
543
Cost function before refinement: 1.9115723976987742e-07
[ 7.19986034e-01  3.04925065e-02  4.00000000e-03  0.00000000e+00
 -4.27999078e+01  1.00000000e+00  1.70270825e+01]
     fun: 4.1213792481813325e-08
     jac: array([-3.06070636e-09, -2.41167086e-11,  3.21647439e-06, -2.31812136e-06,
       -3.62528230e-10,  8.61096023e-05,  5.54324342e-06])
 message: 'Optimization terminated successfully.'
    nfev: 64
     nit: 7
    njev: 7
  status: 0
 success: True
       x: array([ 7.20705559e-01,  3.07684347e-02,  4.00000000e-03,  0.00000000e+00,
       -4.27999042e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 4.1213792481813325e-08
GonioParam(dist=0.7207055592224313, poni1=0.030768434748054685, poni2=0.004, rot1=0.0, offset=-42.79990417388946, scale=1.0, nrj=17.027082549190933)
maxdelta on: dist (0) 0.7199860338026991 --> 0.7207055592224313
Cost function before refinement: 4.1213792481813325e-08
[ 7.20705559e-01  3.07684347e-02  4.00000000e-03  0.00000000e+00
 -4.27999042e+01  1.00000000e+00  1.70270825e+01]
     fun: 1.9055962541521217e-10
     jac: array([-5.20672544e-07, -3.45117956e-07, -5.78527760e-08,  4.38009067e-08,
       -4.68311260e-09,  9.35212499e-08,  5.08197212e-08])
 message: 'Optimization terminated successfully.'
    nfev: 45
     nit: 5
    njev: 5
  status: 0
 success: True
       x: array([ 7.20707163e-01,  3.08633971e-02,  3.96520588e-03,  2.50699030e-05,
       -4.27999030e+01,  9.99050597e-01,  1.70270825e+01])
Cost function after refinement: 1.9055962541521217e-10
GonioParam(dist=0.7207071627511924, poni1=0.03086339714237221, poni2=0.003965205877861361, rot1=2.5069903048049418e-05, offset=-42.79990297383393, scale=0.99905059684665, nrj=17.027082549190933)
maxdelta on: scale (5) 1.0 --> 0.99905059684665
area_pixel=0.04131177354259297 area_sum=0.04228396460577287, Error= -0.023533026539699672
area_pixel=0.0435894947035802 area_sum=0.04387578172532226, Error= -0.006567798587455262
16809
1413 54
[41]:
add_module(ds_names[8],
           264,
           302,
           322)
9.734044802496035e-08
Cost function before refinement: 9.734044802496035e-08
[ 7.20000000e-01  3.20000000e-02  4.00000000e-03  0.00000000e+00
 -3.72000000e+01  1.00000000e+00  1.70270825e+01]
     fun: 1.3838347147363678e-10
     jac: array([-5.98673543e-07,  2.23605236e-08, -1.03159942e-10,  2.50403027e-09,
       -2.11195058e-10, -4.33428498e-07,  1.29258940e-10])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.19998053e-01,  3.17753501e-02,  4.00000000e-03,  0.00000000e+00,
       -3.72000028e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 1.3838347147363678e-10
GonioParam(dist=0.7199980533232613, poni1=0.03177535006475983, poni2=0.004, rot1=0.0, offset=-37.20000282727144, scale=1.0, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.032 --> 0.03177535006475983
 Number of peaks found and used for refinement
454
Cost function before refinement: 1.430842008138168e-07
[ 7.19998053e-01  3.17753501e-02  4.00000000e-03  0.00000000e+00
 -3.72000028e+01  1.00000000e+00  1.70270825e+01]
     fun: 3.226849481117596e-08
     jac: array([-3.92485422e-09, -5.23527888e-11,  2.95969591e-06, -2.13336162e-06,
       -3.04084313e-10,  6.79809093e-05,  4.29992953e-06])
 message: 'Optimization terminated successfully.'
    nfev: 64
     nit: 7
    njev: 7
  status: 0
 success: True
       x: array([ 7.20809333e-01,  3.20129561e-02,  4.00000000e-03,  0.00000000e+00,
       -3.71999997e+01,  1.00000000e+00,  1.70270825e+01])
Cost function after refinement: 3.226849481117596e-08
GonioParam(dist=0.7208093328161905, poni1=0.032012956081398876, poni2=0.004, rot1=0.0, offset=-37.19999969780997, scale=1.0, nrj=17.027082549190933)
maxdelta on: dist (0) 0.7199980533232613 --> 0.7208093328161905
Cost function before refinement: 3.226849481117596e-08
[ 7.20809333e-01  3.20129561e-02  4.00000000e-03  0.00000000e+00
 -3.71999997e+01  1.00000000e+00  1.70270825e+01]
     fun: 1.8511910126699818e-10
     jac: array([-5.57402301e-07,  1.08439870e-09, -4.85885850e-08,  3.72815016e-08,
       -3.49842101e-10,  3.44041984e-09,  3.16520936e-08])
 message: 'Optimization terminated successfully.'
    nfev: 45
     nit: 5
    njev: 5
  status: 0
 success: True
       x: array([ 7.20810790e-01,  3.20817605e-02,  3.95963325e-03,  2.90908690e-05,
       -3.71999988e+01,  9.99058845e-01,  1.70270825e+01])
Cost function after refinement: 1.8511910126699818e-10
GonioParam(dist=0.7208107904725951, poni1=0.03208176053609102, poni2=0.003959633245361843, rot1=2.9090869024017394e-05, offset=-37.1999988266373, scale=0.9990588449954669, nrj=17.027082549190933)
maxdelta on: scale (5) 1.0 --> 0.9990588449954669
area_pixel=0.04876436188373834 area_sum=0.050127698054059644, Error= -0.027957633764832325
area_pixel=0.057546003803974344 area_sum=0.05775905585124136, Error= -0.0037022909182844216
area_pixel=0.049658293833474865 area_sum=0.05076774880169413, Error= -0.022341785884543948
area_pixel=0.05525805937418937 area_sum=0.055742972286024095, Error= -0.00877542420646828
area_pixel=0.05413146279471537 area_sum=0.05471036770655596, Error= -0.010694425791447673
area_pixel=0.045739492253746405 area_sum=0.04707526635197212, Error= -0.029203955540549473
area_pixel=0.04829832444085547 area_sum=0.04934824839708468, Error= -0.021738310146036582
area_pixel=0.05408463708295397 area_sum=0.054632906002321624, Error= -0.010137239499762784
area_pixel=0.04180745340076797 area_sum=0.04491414146774922, Error= -0.0743094308376167
area_pixel=0.04855682651641935 area_sum=0.04971370658799365, Error= -0.023825281728061563
area_pixel=0.05821213808510883 area_sum=0.058390691277043244, Error= -0.0030672845528085186
area_pixel=0.053533284197945896 area_sum=0.0542348167245984, Error= -0.013104604680305085
area_pixel=0.05444126075367084 area_sum=0.055046238495225275, Error= -0.011112485882569193
area_pixel=0.05139325908436465 area_sum=0.052436334224842895, Error= -0.020295952408193915
16876
1336 54
[42]:
len(goniometers)
[42]:
9
[43]:
# print all the parameters to be able to compare them visually
goniometers["data_12"] = goniometers["data_11"]
for name in ds_names:
    print(name, *["%8.4e"%i for i in goniometers[name].param])
data_02 7.2310e-01 3.2054e-02 3.9849e-03 1.0948e-05 -8.2800e+01 9.9942e-01 1.7027e+01
data_03 7.2068e-01 3.3678e-02 4.0580e-03 -4.4486e-05 -7.7200e+01 9.9897e-01 1.7027e+01
data_04 7.2069e-01 3.4825e-02 4.0432e-03 -3.3769e-05 -7.1600e+01 9.9898e-01 1.7027e+01
data_05 7.2048e-01 3.3410e-02 3.9779e-03 1.5910e-05 -6.5800e+01 9.9900e-01 1.7027e+01
data_07 7.2065e-01 3.2237e-02 3.9757e-03 1.7542e-05 -6.0000e+01 9.9901e-01 1.7027e+01
data_08 7.2053e-01 3.3395e-02 3.9730e-03 1.9484e-05 -5.4400e+01 9.9903e-01 1.7027e+01
data_09 7.2061e-01 3.2247e-02 3.9689e-03 2.2376e-05 -4.8600e+01 9.9904e-01 1.7027e+01
data_10 7.2071e-01 3.0863e-02 3.9652e-03 2.5070e-05 -4.2800e+01 9.9905e-01 1.7027e+01
data_11 7.2081e-01 3.2082e-02 3.9596e-03 2.9091e-05 -3.7200e+01 9.9906e-01 1.7027e+01
data_12 7.2081e-01 3.2082e-02 3.9596e-03 2.9091e-05 -3.7200e+01 9.9906e-01 1.7027e+01

Use the negative part of the spectum …

Until now, we used only the data where 2th >0 For the last modules, this thows away half of the data.

We setup here a way to assign the peaks for the negative part of the spectrum.

[44]:
def complete_gonio(module_id=None, name=None):
    "Scan missing frames for un-indexed peaks"
    if name is None:
        name = ds_names[module_id]
    gonioref = goniometers[name]
    ds = data[name]
    print("Number of peaks previously found:",
           sum([len(sg.geometry_refinement.data) for sg in gonioref.single_geometries.values()]))

    tths = LaB6.get_2th()

    for i in range(ds.shape[0]):
        frame_name = "%s_%04i"%(name, i)
        if frame_name in gonioref.single_geometries:
                continue
        peak = peak_picking(name, i)
        ai=gonioref.get_ai(get_position(i))
        tth = ai.array_from_unit(unit="2th_rad", scale=False)
        tth_low = tth[20]
        tth_hi = tth[-20]
        ttmin, ttmax = min(tth_low, tth_hi), max(tth_low, tth_hi)
        valid_peaks = numpy.logical_and(ttmin<=tths, tths<ttmax)
        cnt = valid_peaks.sum()
        if (len(peak) ==  cnt) and cnt>0:
            cp = ControlPoints(calibrant=LaB6, wavelength=wl)
            #revert the order of assignment if needed !!
            if tth_hi < tth_low:
                peak = peak[-1::-1]
            for p, r in zip(peak, numpy.where(valid_peaks)[0]):
                cp.append([p], ring=r)
            img = ds[i].reshape((-1,1))
            sg = gonioref.new_geometry(frame_name,
                                        image=img,
                                        metadata=i,
                                        control_points=cp,
                                        calibrant=LaB6)
            sg.geometry_refinement.data = numpy.array(cp.getList())
            #print(frame_name, len(sg.geometry_refinement.data))

    print("Number of peaks found after re-scan:",
            sum([len(sg.geometry_refinement.data) for sg in gonioref.single_geometries.values()]))
    return gonioref
[45]:
gonio8 = complete_gonio(module_id=8)
gonio8.refine2()
Number of peaks previously found: 454
Number of peaks found after re-scan: 1006
Cost function before refinement: 4.70706125439368e-09
[ 7.20810790e-01  3.20817605e-02  3.95963325e-03  2.90908690e-05
 -3.71999988e+01  9.99058845e-01  1.70270825e+01]
     fun: 9.802737682604375e-10
     jac: array([-8.29338917e-07,  1.79786978e-08, -2.22576465e-07,  1.63791395e-07,
       -1.37361011e-10, -3.00380388e-08,  3.83178298e-08])
 message: 'Optimization terminated successfully.'
    nfev: 37
     nit: 4
    njev: 4
  status: 0
 success: True
       x: array([ 7.20813440e-01,  3.20849228e-02,  3.96153953e-03,  2.77060750e-05,
       -3.71999988e+01,  9.98991349e-01,  1.70270825e+01])
Cost function after refinement: 9.802737682604375e-10
GonioParam(dist=0.7208134400755615, poni1=0.03208492277691861, poni2=0.003961539527372513, rot1=2.770607503862905e-05, offset=-37.19999878574453, scale=0.9989913487191389, nrj=17.027082549190933)
maxdelta on: scale (5) 0.9990588449954669 --> 0.9989913487191389
[45]:
array([ 7.20813440e-01,  3.20849228e-02,  3.96153953e-03,  2.77060750e-05,
       -3.71999988e+01,  9.98991349e-01,  1.70270825e+01])
[46]:
gonio7 = complete_gonio(module_id=7)
Number of peaks previously found: 543
Number of peaks found after re-scan: 1004
[47]:
gonio7.refine2()
Cost function before refinement: 2.049750654664114e-09
[ 7.20707163e-01  3.08633971e-02  3.96520588e-03  2.50699030e-05
 -4.27999030e+01  9.99050597e-01  1.70270825e+01]
     fun: 6.982178014396509e-10
     jac: array([-6.61610503e-07,  1.82061135e-08, -2.31096076e-07,  1.69227578e-07,
       -1.05927128e-10, -2.98934004e-08,  2.67495021e-08])
 message: 'Optimization terminated successfully.'
    nfev: 37
     nit: 4
    njev: 4
  status: 0
 success: True
       x: array([ 7.20709219e-01,  3.08662496e-02,  3.96669042e-03,  2.39916666e-05,
       -4.27999029e+01,  9.99006679e-01,  1.70270825e+01])
Cost function after refinement: 6.982178014396509e-10
GonioParam(dist=0.7207092190734912, poni1=0.030866249621701404, poni2=0.0039666904208374675, rot1=2.3991666571782472e-05, offset=-42.799902936952186, scale=0.9990066787571606, nrj=17.027082549190933)
maxdelta on: scale (5) 0.99905059684665 --> 0.9990066787571606
[47]:
array([ 7.20709219e-01,  3.08662496e-02,  3.96669042e-03,  2.39916666e-05,
       -4.27999029e+01,  9.99006679e-01,  1.70270825e+01])
[48]:
gonio6 = complete_gonio(module_id=6)
gonio6.refine2()
Number of peaks previously found: 626
Number of peaks found after re-scan: 990
Cost function before refinement: 9.054048566564434e-10
[ 7.20609298e-01  3.22472627e-02  3.96893520e-03  2.23757106e-05
 -4.85998857e+01  9.99040899e-01  1.70270825e+01]
     fun: 6.093728642246349e-10
     jac: array([-8.02155920e-07,  3.63691515e-08, -2.33166253e-07,  1.71261021e-07,
        1.53140861e-10, -6.90587253e-08,  3.30203031e-08])
 message: 'Optimization terminated successfully.'
    nfev: 37
     nit: 4
    njev: 4
  status: 0
 success: True
       x: array([ 7.20611756e-01,  3.22490408e-02,  3.97006720e-03,  2.15500507e-05,
       -4.85998856e+01,  9.99018033e-01,  1.70270825e+01])
Cost function after refinement: 6.093728642246349e-10
GonioParam(dist=0.7206117564391414, poni1=0.03224904075932756, poni2=0.003970067202282311, rot1=2.1550050733043843e-05, offset=-48.599885636781195, scale=0.9990180333619139, nrj=17.027082549190933)
maxdelta on: scale (5) 0.9990408988314912 --> 0.9990180333619139
[48]:
array([ 7.20611756e-01,  3.22490408e-02,  3.97006720e-03,  2.15500507e-05,
       -4.85998856e+01,  9.99018033e-01,  1.70270825e+01])
[49]:
gonio5 = complete_gonio(module_id=5)
gonio5.refine2()
Number of peaks previously found: 754
Number of peaks found after re-scan: 1038
Cost function before refinement: 5.322312447273672e-10
[ 7.20528271e-01  3.33948197e-02  3.97295090e-03  1.94838596e-05
 -5.43998157e+01  9.99025942e-01  1.70270825e+01]
     fun: 5.247814297615004e-10
     jac: array([-6.54781369e-07,  1.29256630e-07, -1.62656541e-07,  1.19840950e-07,
        1.28911966e-09, -2.77499652e-07,  2.46511989e-08])
 message: 'Optimization terminated successfully.'
    nfev: 37
     nit: 4
    njev: 4
  status: 0
 success: True
       x: array([ 7.20530687e-01,  3.33953448e-02,  3.97363667e-03,  1.89799990e-05,
       -5.43998157e+01,  9.99021890e-01,  1.70270825e+01])
Cost function after refinement: 5.247814297615004e-10
GonioParam(dist=0.7205306865337416, poni1=0.033395344810677706, poni2=0.0039736366657854355, rot1=1.8979998986411344e-05, offset=-54.39981565735447, scale=0.999021890228638, nrj=17.027082549190933)
maxdelta on: scale (5) 0.999025941539747 --> 0.999021890228638
[49]:
array([ 7.20530687e-01,  3.33953448e-02,  3.97363667e-03,  1.89799990e-05,
       -5.43998157e+01,  9.99021890e-01,  1.70270825e+01])
[50]:
gonio4 = complete_gonio(module_id=4)
gonio4.refine2()
Number of peaks previously found: 864
Number of peaks found after re-scan: 1081
Cost function before refinement: 4.522981580650044e-10
[ 7.20645314e-01  3.22371238e-02  3.97565133e-03  1.75424155e-05
 -6.00000524e+01  9.99011856e-01  1.70270825e+01]
     fun: 4.329968320302878e-10
     jac: array([-3.23619143e-07, -1.33810126e-08, -8.07893403e-08,  5.95277891e-08,
       -4.92710775e-10,  3.16598865e-08,  5.83323419e-08])
 message: 'Optimization terminated successfully.'
    nfev: 37
     nit: 4
    njev: 4
  status: 0
 success: True
       x: array([ 7.20646423e-01,  3.22359951e-02,  3.97581932e-03,  1.74168753e-05,
       -6.00000525e+01,  9.99019702e-01,  1.70270825e+01])
Cost function after refinement: 4.329968320302878e-10
GonioParam(dist=0.7206464234341815, poni1=0.032235995133433754, poni2=0.0039758193176266145, rot1=1.7416875286579755e-05, offset=-60.00005245067518, scale=0.9990197021796172, nrj=17.027082549190933)
maxdelta on: scale (5) 0.999011855791219 --> 0.9990197021796172
[50]:
array([ 7.20646423e-01,  3.22359951e-02,  3.97581932e-03,  1.74168753e-05,
       -6.00000525e+01,  9.99019702e-01,  1.70270825e+01])
[51]:
gonio3 = complete_gonio(module_id=3)
gonio3.refine2()
Number of peaks previously found: 978
Number of peaks found after re-scan: 1156
Cost function before refinement: 7.053238687700532e-10
[ 7.20482931e-01  3.34099564e-02  3.97791142e-03  1.59099880e-05
 -6.57999266e+01  9.98999110e-01  1.70270825e+01]
     fun: 6.316819601296489e-10
     jac: array([-4.99814708e-07, -1.63155748e-08,  9.67096626e-09, -4.95315009e-09,
       -5.75364555e-10,  3.90058487e-08,  1.04654441e-07])
 message: 'Optimization terminated successfully.'
    nfev: 37
     nit: 4
    njev: 4
  status: 0
 success: True
       x: array([ 7.20484799e-01,  3.34074959e-02,  3.97770054e-03,  1.60543912e-05,
       -6.57999266e+01,  9.99015617e-01,  1.70270825e+01])
Cost function after refinement: 6.316819601296489e-10
GonioParam(dist=0.7204847991260711, poni1=0.03340749593129299, poni2=0.003977700542249465, rot1=1.605439120863723e-05, offset=-65.79992658922357, scale=0.9990156171464057, nrj=17.027082549190933)
maxdelta on: scale (5) 0.9989991098968561 --> 0.9990156171464057
[51]:
array([ 7.20484799e-01,  3.34074959e-02,  3.97770054e-03,  1.60543912e-05,
       -6.57999266e+01,  9.99015617e-01,  1.70270825e+01])
[52]:
gonio2 = complete_gonio(module_id=2)
gonio2.refine2()
Number of peaks previously found: 1093
Number of peaks found after re-scan: 1229
Cost function before refinement: 8.306533586355894e-10
[ 7.20686437e-01  3.48247495e-02  4.04316666e-03 -3.37686772e-05
 -7.15999088e+01  9.98982863e-01  1.70270825e+01]
     fun: 7.771891010372871e-10
     jac: array([ 9.15257278e-08, -1.05189468e-09,  5.61627546e-08, -4.08345480e-08,
       -4.25668376e-10,  2.85157377e-09,  1.17395008e-07])
 message: 'Optimization terminated successfully.'
    nfev: 37
     nit: 4
    njev: 4
  status: 0
 success: True
       x: array([ 7.20686041e-01,  3.48226304e-02,  4.04289725e-03, -3.35729680e-05,
       -7.15999088e+01,  9.98998235e-01,  1.70270825e+01])
Cost function after refinement: 7.771891010372871e-10
GonioParam(dist=0.7206860412873665, poni1=0.0348226304357366, poni2=0.004042897251336869, rot1=-3.357296798617952e-05, offset=-71.59990883821092, scale=0.9989982349992665, nrj=17.027082549190933)
maxdelta on: scale (5) 0.9989828627069963 --> 0.9989982349992665
[52]:
array([ 7.20686041e-01,  3.48226304e-02,  4.04289725e-03, -3.35729680e-05,
       -7.15999088e+01,  9.98998235e-01,  1.70270825e+01])
[53]:
gonio1 = complete_gonio(module_id=1)
gonio1.refine2()

Number of peaks previously found: 1183
Number of peaks found after re-scan: 1285
Cost function before refinement: 9.822658405373417e-10
[ 7.20682081e-01  3.36782425e-02  4.05801126e-03 -4.44860018e-05
 -7.71999788e+01  9.98967223e-01  1.70270825e+01]
     fun: 9.683803822381625e-10
     jac: array([ 1.05204414e-07, -1.40910812e-09, -2.64455137e-09,  1.49411766e-09,
       -3.43193224e-10,  4.36284460e-09,  1.50605559e-07])
 message: 'Optimization terminated successfully.'
    nfev: 37
     nit: 4
    njev: 4
  status: 0
 success: True
       x: array([ 7.20681597e-01,  3.36766788e-02,  4.05808287e-03, -4.45357208e-05,
       -7.71999788e+01,  9.98975895e-01,  1.70270825e+01])
Cost function after refinement: 9.683803822381625e-10
GonioParam(dist=0.7206815966774245, poni1=0.03367667883450645, poni2=0.004058082874451283, rot1=-4.4535720801764846e-05, offset=-77.19997881123506, scale=0.9989758952763078, nrj=17.027082549190933)
maxdelta on: scale (5) 0.9989672227193093 --> 0.9989758952763078
[53]:
array([ 7.20681597e-01,  3.36766788e-02,  4.05808287e-03, -4.45357208e-05,
       -7.71999788e+01,  9.98975895e-01,  1.70270825e+01])
[54]:
gonio0 = complete_gonio(module_id=0)
gonio0.refine2()
Number of peaks previously found: 1203
Number of peaks found after re-scan: 1255
Cost function before refinement: 2.580092692155849e-06
[ 7.23096248e-01  3.20537111e-02  3.98485468e-03  1.09479202e-05
 -8.27999440e+01  9.99415047e-01  1.70270825e+01]
     fun: 2.5799877551962334e-06
     jac: array([-1.43881863e-07,  3.61314392e-08,  5.52834337e-07, -3.99174581e-07,
        1.01925934e-09, -1.14581923e-07, -1.57262758e-06])
 message: 'Optimization terminated successfully.'
    nfev: 37
     nit: 4
    njev: 4
  status: 0
 success: True
       x: array([ 7.23096999e-01,  3.20658547e-02,  3.98130190e-03,  1.35139061e-05,
       -8.27999438e+01,  9.99396229e-01,  1.70270825e+01])
Cost function after refinement: 2.5799877551962334e-06
GonioParam(dist=0.7230969991414224, poni1=0.03206585469442816, poni2=0.003981301898312368, rot1=1.351390607705048e-05, offset=-82.79994383949249, scale=0.9993962290572798, nrj=17.027082549190933)
maxdelta on: scale (5) 0.9994150470263444 --> 0.9993962290572798
[54]:
array([ 7.23096999e-01,  3.20658547e-02,  3.98130190e-03,  1.35139061e-05,
       -8.27999438e+01,  9.99396229e-01,  1.70270825e+01])
[55]:
#Rescan module0 which looks much different:
gonio0.single_geometries.clear()
gonio0 = complete_gonio(module_id=0)
gonio0.refine2()
Number of peaks previously found: 0
Number of peaks found after re-scan: 1250
Cost function before refinement: 9.454138761636617e-07
[ 7.23096999e-01  3.20658547e-02  3.98130190e-03  1.35139061e-05
 -8.27999438e+01  9.99396229e-01  1.70270825e+01]
     fun: 9.315197221462237e-07
     jac: array([-1.20646249e-08, -1.14537357e-08,  1.03723337e-07, -7.48339701e-08,
        1.34221523e-10, -9.52891099e-09, -5.30292098e-07])
 message: 'Optimization terminated successfully.'
    nfev: 82
     nit: 9
    njev: 9
  status: 0
 success: True
       x: array([ 7.21973759e-01,  3.22003255e-02,  3.94381184e-03,  4.51413618e-05,
       -8.27999423e+01,  9.99140776e-01,  1.70270825e+01])
Cost function after refinement: 9.315197221462237e-07
GonioParam(dist=0.7219737589812981, poni1=0.03220032545666352, poni2=0.003943811844450548, rot1=4.5141361782464955e-05, offset=-82.79994226310926, scale=0.9991407764529461, nrj=17.027082549190933)
maxdelta on: dist (0) 0.7230969991414224 --> 0.7219737589812981
[55]:
array([ 7.21973759e-01,  3.22003255e-02,  3.94381184e-03,  4.51413618e-05,
       -8.27999423e+01,  9.99140776e-01,  1.70270825e+01])

Discard wronly assigned peaks

We have seen previously that some modules have a much higher residual error, while all have almost the same number of peaks recorded and fitted.

Some frames are contributing much more than all the other in those badly-fitted data. Let’s spot them and re-assign them

[56]:
#search for mis-assigned peaks in module #0
labels = []
errors = []

for lbl,sg in gonio0.single_geometries.items():
    labels.append(lbl)
    errors.append(sg.geometry_refinement.chi2())

s = numpy.argsort(errors)
for i in s[-10:]:
    print(labels[i], errors[i])
data_02_0455 6.313051349592421e-07
data_02_0464 6.523630272471416e-07
data_02_0465 6.891655641669719e-07
data_02_0457 7.370430556294668e-07
data_02_0456 7.376242032882277e-07
data_02_0460 7.45857621330519e-07
data_02_0466 7.67143438989774e-07
data_02_0461 7.935716411266278e-07
data_02_0462 7.971563845471846e-07
data_02_0480 0.001130766003993148
[57]:
#remove wrongly assigned peak for frame 480
print(gonio0.single_geometries.pop("data_02_0480").control_points)
gonio0.refine2()
gonio0 = complete_gonio(module_id=0)

gonio0.refine2()
ControlPoints instance containing 4 group of point:
LaB6 Calibrant with 109 reflections at wavelength 7.281587849134994e-11
Containing 4 groups of points:
#psg ring 52: 1 points
#psh ring 53: 1 points
#psi ring 54: 1 points
#psj ring 55: 1 points
Cost function before refinement: 8.041228082228945e-09
[ 7.21973759e-01  3.22003255e-02  3.94381184e-03  4.51413618e-05
 -8.27999423e+01  9.99140776e-01  1.70270825e+01]
     fun: 9.214430277838577e-10
     jac: array([-3.08678332e-08, -3.82866689e-08, -1.82877549e-07,  1.31905635e-07,
       -8.44315805e-10, -1.61540448e-08,  1.38174042e-07])
 message: 'Optimization terminated successfully.'
    nfev: 82
     nit: 9
    njev: 9
  status: 0
 success: True
       x: array([ 7.20595797e-01,  3.22844186e-02,  4.04252687e-03, -2.05352660e-05,
       -8.27999410e+01,  9.98975164e-01,  1.70270825e+01])
Cost function after refinement: 9.214430277838577e-10
GonioParam(dist=0.720595797367119, poni1=0.03228441857336863, poni2=0.0040425268658778706, rot1=-2.0535266006967913e-05, offset=-82.79994103917592, scale=0.9989751641349021, nrj=17.027082549190933)
maxdelta on: dist (0) 0.7219737589812981 --> 0.720595797367119
Number of peaks previously found: 1246
Number of peaks found after re-scan: 1263
Cost function before refinement: 9.385263673786183e-10
[ 7.20595797e-01  3.22844186e-02  4.04252687e-03 -2.05352660e-05
 -8.27999410e+01  9.98975164e-01  1.70270825e+01]
     fun: 9.382286239666452e-10
     jac: array([-2.66626459e-08, -1.46606972e-06, -1.81711541e-07,  1.31048747e-07,
       -1.88137349e-08, -4.38931502e-08,  2.40047863e-07])
 message: 'Optimization terminated successfully.'
    nfev: 11
     nit: 1
    njev: 1
  status: 0
 success: True
       x: array([ 7.20595804e-01,  3.22848040e-02,  4.04257464e-03, -2.05697223e-05,
       -8.27999410e+01,  9.98975176e-01,  1.70270825e+01])
Cost function after refinement: 9.382286239666452e-10
GonioParam(dist=0.7205958043774563, poni1=0.032284804043109315, poni2=0.00404257464280098, rot1=-2.0569722299120257e-05, offset=-82.79994103422928, scale=0.9989751756756091, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.03228441857336863 --> 0.032284804043109315
[57]:
array([ 7.20595804e-01,  3.22848040e-02,  4.04257464e-03, -2.05697223e-05,
       -8.27999410e+01,  9.98975176e-01,  1.70270825e+01])
[58]:
def search_outliers(module_id=None, name=None, threshold=1.2):
    "Search for wrongly assigned peaks"
    if name is None:
        name = ds_names[module_id]
    gonioref = goniometers[name]
    labels = []
    errors = []

    for lbl,sg in gonioref.single_geometries.items():
        labels.append(lbl)
        errors.append(sg.geometry_refinement.chi2())
    s = numpy.argsort(errors)
    last = errors[s[-1]]
    to_remove = []
    for i in s[-1::-1]:
        lbl = labels[i]
        current = errors[i]
        print(lbl , current, last, last/current)
        if threshold*current<last:
            break
        last=current
        to_remove.append(lbl)
    return to_remove



for lbl in search_outliers(8):
    gonio8.single_geometries.pop(lbl)
gonio8.refine2()
gonio8 = complete_gonio(module_id=8)
gonio8.refine2()
data_11_0495 1.4653542984471542e-06 1.4653542984471542e-06 1.0
data_11_0496 1.4360982661347142e-06 1.4653542984471542e-06 1.0203718874970744
data_11_0499 1.4166548534532985e-06 1.4360982661347142e-06 1.0137248763409235
data_11_0497 1.4084572221561037e-06 1.4166548534532985e-06 1.0058202912862668
data_11_0498 1.3833016059917487e-06 1.4084572221561037e-06 1.0181851998547489
data_11_0500 1.3709107012975464e-06 1.3833016059917487e-06 1.0090384477139718
data_11_0492 1.3295890859461896e-06 1.3709107012975464e-06 1.0310784856675854
data_11_0489 1.3287700089647162e-06 1.3295890859461896e-06 1.0006164174205825
data_11_0491 1.3216144771699174e-06 1.3287700089647162e-06 1.0054142353298985
data_11_0490 1.301822888645974e-06 1.3216144771699174e-06 1.015202980909737
data_11_0494 1.2865582016523121e-06 1.301822888645974e-06 1.0118647465571768
data_11_0493 1.2861450147452866e-06 1.2865582016523121e-06 1.0003212599685793
data_11_0483 1.2244483499124188e-06 1.2861450147452866e-06 1.0503873151017604
data_11_0486 1.207372827265345e-06 1.2244483499124188e-06 1.0141427090799693
data_11_0485 1.201809830402108e-06 1.207372827265345e-06 1.0046288495255324
data_11_0484 1.1994812838848202e-06 1.201809830402108e-06 1.0019412945817263
data_11_0487 1.1764652443222126e-06 1.1994812838848202e-06 1.019563722493024
data_11_0477 1.1389594650443204e-06 1.1764652443222126e-06 1.0329298631153943
data_11_0478 1.1156745972945301e-06 1.1389594650443204e-06 1.0208706622936967
data_11_0481 1.1104824081112956e-06 1.1156745972945301e-06 1.0046756158812686
data_11_0479 1.1057757403752895e-06 1.1104824081112956e-06 1.0042564396777314
data_11_0480 1.1002412230846842e-06 1.1057757403752895e-06 1.0050302762471384
data_11_0482 8.673291356185134e-07 1.1002412230846842e-06 1.26853944817624
Cost function before refinement: 1.059476333549205e-09
[ 7.20813440e-01  3.20849228e-02  3.96153953e-03  2.77060750e-05
 -3.71999988e+01  9.98991349e-01  1.70270825e+01]
     fun: 1.0589449037804424e-09
     jac: array([-8.45058784e-07, -1.25301789e-06, -2.51805109e-07,  1.84923760e-07,
       -1.61392479e-08,  9.17399903e-08,  8.34009091e-08])
 message: 'Optimization terminated successfully.'
    nfev: 11
     nit: 1
    njev: 1
  status: 0
 success: True
       x: array([ 7.20813810e-01,  3.20854710e-02,  3.96164970e-03,  2.76251683e-05,
       -3.71999988e+01,  9.98991309e-01,  1.70270825e+01])
Cost function after refinement: 1.0589449037804424e-09
GonioParam(dist=0.7208138098008553, poni1=0.032085470990150605, poni2=0.00396164969570614, rot1=2.762516825116013e-05, offset=-37.19999877868338, scale=0.9989913085815821, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.03208492277691861 --> 0.032085470990150605
Number of peaks previously found: 918
Number of peaks found after re-scan: 1006
Cost function before refinement: 9.804599649789273e-10
[ 7.20813810e-01  3.20854710e-02  3.96164970e-03  2.76251683e-05
 -3.71999988e+01  9.98991309e-01  1.70270825e+01]
     fun: 9.798014434813442e-10
     jac: array([-8.28830624e-07,  2.04374424e-06, -2.22646167e-07,  1.63839575e-07,
        2.53636863e-08,  1.00410517e-06,  4.36574660e-08])
 message: 'Optimization terminated successfully.'
    nfev: 11
     nit: 1
    njev: 1
  status: 0
 success: True
       x: array([ 7.20813997e-01,  3.20850099e-02,  3.96169993e-03,  2.75882029e-05,
       -3.71999988e+01,  9.98991082e-01,  1.70270825e+01])
Cost function after refinement: 9.798014434813442e-10
GonioParam(dist=0.7208139968009581, poni1=0.032085009882209824, poni2=0.0039616999289563675, rot1=2.7588202897190342e-05, offset=-37.19999878440591, scale=0.9989910820361755, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.032085470990150605 --> 0.032085009882209824
[58]:
array([ 7.20813997e-01,  3.20850099e-02,  3.96169993e-03,  2.75882029e-05,
       -3.71999988e+01,  9.98991082e-01,  1.70270825e+01])
[59]:
print(gonio7.chi2())
for lbl in search_outliers(7):
    gonio7.single_geometries.pop(lbl)
gonio7.refine2()
gonio7 = complete_gonio(module_id=7)
gonio7.refine2()
6.982178014396509e-10
data_10_0292 4.478307386585731e-06 4.478307386585731e-06 1.0
data_10_0291 4.441611877573707e-06 4.478307386585731e-06 1.0082617549717265
data_10_0288 4.42110785615644e-06 4.441611877573707e-06 1.0046377564367075
data_10_0285 4.41519072824658e-06 4.42110785615644e-06 1.0013401749265336
data_10_0290 4.411402144902852e-06 4.41519072824658e-06 1.0008588161358412
data_10_0289 4.40449960049467e-06 4.411402144902852e-06 1.001567157460386
data_10_0284 4.3863439763980785e-06 4.40449960049467e-06 1.004139124563482
data_10_0275 4.376867017048265e-06 4.3863439763980785e-06 1.0021652381287574
data_10_0286 4.374938577698873e-06 4.376867017048265e-06 1.0004407923254561
data_10_0283 4.360023596330053e-06 4.374938577698873e-06 1.0034208487727851
data_10_0281 4.358112634515273e-06 4.360023596330053e-06 1.000438483805959
data_10_0282 4.355265304875879e-06 4.358112634515273e-06 1.0006537672082128
data_10_0278 4.352327511323348e-06 4.355265304875879e-06 1.0006749936774948
data_10_0280 4.35154401569245e-06 4.352327511323348e-06 1.000180050030075
data_10_0277 4.349860479592271e-06 4.35154401569245e-06 1.0003870322066828
data_10_0276 4.339663932302855e-06 4.349860479592271e-06 1.0023496168017796
data_10_0279 4.33808469320417e-06 4.339663932302855e-06 1.0003640406332222
data_10_0274 4.337318248584353e-06 4.33808469320417e-06 1.000176709334176
data_10_0287 4.319683506474051e-06 4.337318248584353e-06 1.0040824153167407
data_10_0496 1.9508464721227965e-06 4.319683506474051e-06 2.2142611262349234
Cost function before refinement: 6.590257595658292e-10
[ 7.20709219e-01  3.08662496e-02  3.96669042e-03  2.39916666e-05
 -4.27999029e+01  9.99006679e-01  1.70270825e+01]
     fun: 6.580251686582122e-10
     jac: array([-6.41067336e-07,  7.99913209e-09, -1.44533165e-07,  1.06757288e-07,
       -2.37724944e-10, -3.75138453e-07,  6.15574400e-09])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.20709357e-01,  3.08656493e-02,  3.96672263e-03,  2.39678916e-05,
       -4.27999029e+01,  9.99006434e-01,  1.70270825e+01])
Cost function after refinement: 6.580251686582122e-10
GonioParam(dist=0.720709357471267, poni1=0.030865649336609666, poni2=0.003966722633045513, rot1=2.3967891595469488e-05, offset=-42.79990294443424, scale=0.999006433638064, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.030866249621701404 --> 0.030865649336609666
Number of peaks previously found: 985
Number of peaks found after re-scan: 1004
Cost function before refinement: 6.991420234285395e-10
[ 7.20709357e-01  3.08656493e-02  3.96672263e-03  2.39678916e-05
 -4.27999029e+01  9.99006434e-01  1.70270825e+01]
     fun: 6.980031455333567e-10
     jac: array([-6.60879262e-07,  1.52170131e-07, -2.32103327e-07,  1.69950571e-07,
        1.58023172e-09,  9.61263490e-08,  3.00039453e-08])
 message: 'Optimization terminated successfully.'
    nfev: 19
     nit: 2
    njev: 2
  status: 0
 success: True
       x: array([ 7.20709502e-01,  3.08662430e-02,  3.96677226e-03,  2.39315396e-05,
       -4.27999029e+01,  9.99006765e-01,  1.70270825e+01])
Cost function after refinement: 6.980031455333567e-10
GonioParam(dist=0.7207095017700934, poni1=0.03086624296585714, poni2=0.003966772262865057, rot1=2.393153960923883e-05, offset=-42.79990293688988, scale=0.9990067647525397, nrj=17.027082549190933)
maxdelta on: poni1 (1) 0.030865649336609666 --> 0.03086624296585714
[59]:
array([ 7.20709502e-01,  3.08662430e-02,  3.96677226e-03,  2.39315396e-05,
       -4.27999029e+01,  9.99006765e-01,  1.70270825e+01])
[60]:
print(gonio0.chi2())
print(len(search_outliers(0)))
# for lbl in search_outliers(7):
#     gonio7.single_geometries.pop(lbl)
# gonio7.refine2()
# gonio7 = complete_gonio(module_id=7)
# gonio7.refine2()
9.382286239666452e-10
data_02_0462 7.971563845471846e-07 7.971563845471846e-07 1.0
data_02_0461 7.935716411266278e-07 7.971563845471846e-07 1.004517227222822
data_02_0466 7.67143438989774e-07 7.935716411266278e-07 1.034450144254191
data_02_0460 7.45857621330519e-07 7.67143438989774e-07 1.0285387144282092
data_02_0456 7.376242032882277e-07 7.45857621330519e-07 1.0111620768483298
data_02_0457 7.370430556294668e-07 7.376242032882277e-07 1.000788485359603
data_02_0465 6.891655641669719e-07 7.370430556294668e-07 1.0694716827883974
data_02_0464 6.523630272471416e-07 6.891655641669719e-07 1.056414197897037
data_02_0455 6.313051349592421e-07 6.523630272471416e-07 1.0333561238801883
data_02_0463 6.240813179531244e-07 6.313051349592421e-07 1.0115751213797115
data_02_0459 6.163901121421231e-07 6.240813179531244e-07 1.0124778215281103
data_02_0448 6.082027920092041e-07 6.163901121421231e-07 1.013461497119854
data_02_0454 5.868929875551012e-07 6.082027920092041e-07 1.036309523040778
data_02_0439 5.868112798407111e-07 5.868929875551012e-07 1.0001392401904958
data_02_0435 5.859910233268107e-07 5.868112798407111e-07 1.0013997765857292
data_02_0426 5.755884184129568e-07 5.859910233268107e-07 1.0180729920566098
data_02_0458 5.724220421407079e-07 5.755884184129568e-07 1.0055315414836359
data_02_0453 5.590340754134061e-07 5.724220421407079e-07 1.0239483911913623
data_02_0434 5.570146124178882e-07 5.590340754134061e-07 1.0036255117020212
data_02_0444 5.524804844432388e-07 5.570146124178882e-07 1.0082068563547881
data_02_0430 5.489356696711307e-07 5.524804844432388e-07 1.0064576141940855
data_02_0443 5.459478619353463e-07 5.489356696711307e-07 1.005472697933449
data_02_0447 5.424219010224628e-07 5.459478619353463e-07 1.0065004029266464
data_02_0468 5.360729258271283e-07 5.424219010224628e-07 1.0118434916024501
data_02_0425 5.340453928849802e-07 5.360729258271283e-07 1.0037965554410928
data_02_0467 5.066740382282769e-07 5.340453928849802e-07 1.0540216245387561
data_02_0438 5.014377962589753e-07 5.066740382282769e-07 1.0104424556911487
data_02_0429 4.994042990677361e-07 5.014377962589753e-07 1.0040718455869027
data_02_0442 4.988918594371316e-07 4.994042990677361e-07 1.0010271557270602
data_02_0421 4.887207364704953e-07 4.988918594371316e-07 1.020811727859332
data_02_0452 4.818408313589759e-07 4.887207364704953e-07 1.0142783771398438
data_02_0441 4.708090789077316e-07 4.818408313589759e-07 1.0234314777379352
data_02_0433 4.6907543413049604e-07 4.708090789077316e-07 1.0036958762942876
data_02_0437 4.6744164098782785e-07 4.6907543413049604e-07 1.0034951810010242
data_02_0420 4.599765374239142e-07 4.6744164098782785e-07 1.0162293137943985
data_02_0451 4.5329173383081183e-07 4.599765374239142e-07 1.0147472435391849
data_02_0446 4.4537990827667195e-07 4.5329173383081183e-07 1.0177642174851431
data_02_0428 4.424570034888956e-07 4.4537990827667195e-07 1.006606076442973
data_02_0424 4.374993360555643e-07 4.424570034888956e-07 1.0113318284732244
data_02_0432 4.3734600098152413e-07 4.374993360555643e-07 1.0003506035809087
data_02_0436 4.331873497281146e-07 4.3734600098152413e-07 1.0096001216471804
data_02_0450 4.2621140965589126e-07 4.331873497281146e-07 1.0163673236196455
data_02_0445 4.1944505996655087e-07 4.2621140965589126e-07 1.016131670950851
data_02_0427 4.184060457298792e-07 4.1944505996655087e-07 1.0024832677426043
data_02_0423 4.1312003395546793e-07 4.184060457298792e-07 1.012795341159807
data_02_0419 3.876880857648326e-07 4.1312003395546793e-07 1.06559899342912
data_02_0408 3.542342460674882e-07 3.876880857648326e-07 1.0944398800193103
data_02_0418 3.436569950091102e-07 3.542342460674882e-07 1.0307785123305802
data_02_0412 3.4365083733233073e-07 3.436569950091102e-07 1.0000179184105218
data_02_0398 3.357907683844476e-07 3.4365083733233073e-07 1.0234076385890518
data_02_0389 3.271544614435567e-07 3.357907683844476e-07 1.0263982551324031
data_02_0394 3.2138316313793743e-07 3.271544614435567e-07 1.0179576871708809
data_02_0416 3.194683144152933e-07 3.2138316313793743e-07 1.0059938611631918
data_02_0403 3.071333103624269e-07 3.194683144152933e-07 1.0401617266401704
data_02_0411 3.0688042859822684e-07 3.071333103624269e-07 1.0008240400515445
data_02_0407 3.0628793103577707e-07 3.0688042859822684e-07 1.0019344463245616
data_02_0402 3.0490188744369036e-07 3.0628793103577707e-07 1.0045458675369554
data_02_0393 2.980904108777663e-07 3.0490188744369036e-07 1.022850371287915
data_02_0388 2.945092984652161e-07 2.980904108777663e-07 1.0121595903124707
data_02_0397 2.920821886183787e-07 2.945092984652161e-07 1.0083096811151624
data_02_0384 2.824639030221881e-07 2.920821886183787e-07 1.034051379639242
data_02_0406 2.8172340654452183e-07 2.824639030221881e-07 1.0026284520933098
data_02_0401 2.8153081654147476e-07 2.8172340654452183e-07 1.000684081428147
data_02_0417 2.810860465158435e-07 2.8153081654147476e-07 1.0015823269463011
data_02_0392 2.739808285543106e-07 2.810860465158435e-07 1.0259332669333994
data_02_0410 2.7025873527903e-07 2.739808285543106e-07 1.0137723329143744
data_02_0415 2.650180952687086e-07 2.7025873527903e-07 1.0197746497461155
data_02_0405 2.6433948563352065e-07 2.650180952687086e-07 1.002567189814876
data_02_0414 2.5775864796179354e-07 2.6433948563352065e-07 1.0255310063261294
data_02_0396 2.5700799922953914e-07 2.5775864796179354e-07 1.0029207212791225
data_02_0391 2.4851756352407427e-07 2.5700799922953914e-07 1.0341643286094844
data_02_0387 2.4757346323797714e-07 2.4851756352407427e-07 1.0038134147083027
data_02_0383 2.436319262841532e-07 2.4757346323797714e-07 1.016178244838186
data_02_0400 2.411208711876606e-07 2.436319262841532e-07 1.0104140926669858
data_02_0395 2.386282639357738e-07 2.411208711876606e-07 1.0104455658804845
data_02_0399 2.307240689353976e-07 2.386282639357738e-07 1.0342582160450255
data_02_0386 2.2832923413210657e-07 2.307240689353976e-07 1.0104885159028976
data_02_0409 2.2099257445959475e-07 2.2832923413210657e-07 1.033198670545617
data_02_0404 2.2006310772588735e-07 2.2099257445959475e-07 1.004223637225305
data_02_0390 2.185528631262913e-07 2.2006310772588735e-07 1.0069102027673889
data_02_0382 2.1738267272521252e-07 2.185528631262913e-07 1.0053830895830322
data_02_0381 2.0686178374626022e-07 2.1738267272521252e-07 1.0508595100961586
data_02_0413 2.0388171846465108e-07 2.0686178374626022e-07 1.014616638039206
data_02_0385 2.014026959293881e-07 2.0388171846465108e-07 1.0123087852614054
data_02_0360 1.9864831310383662e-07 2.014026959293881e-07 1.013865624039363
data_02_0375 1.9263499624078313e-07 1.9864831310383662e-07 1.0312161184644622
data_02_0370 1.9202965590739344e-07 1.9263499624078313e-07 1.003152327334699
data_02_0365 1.9112544339834668e-07 1.9202965590739344e-07 1.0047309897257488
data_02_0380 1.896068545228752e-07 1.9112544339834668e-07 1.0080091454462068
data_02_0369 1.7565509702989891e-07 1.896068545228752e-07 1.0794270005760294
data_02_0355 1.7104015084110744e-07 1.7565509702989891e-07 1.0269816541092662
data_02_0374 1.699946080760567e-07 1.7104015084110744e-07 1.006150446634066
data_02_0364 1.694066729270692e-07 1.699946080760567e-07 1.0034705548419607
data_02_0350 1.6598878773796802e-07 1.694066729270692e-07 1.0205910606112547
data_02_0363 1.5748085176203178e-07 1.6598878773796802e-07 1.0540252092920637
data_02_0373 1.5391498398723758e-07 1.5748085176203178e-07 1.0231677753680557
data_02_0354 1.5253285693309903e-07 1.5391498398723758e-07 1.0090611759454866
data_02_0358 1.511161110628414e-07 1.5253285693309903e-07 1.0093752139351209
data_02_0349 1.4524762167521378e-07 1.511161110628414e-07 1.0404033423745145
data_02_0368 1.4209107029916782e-07 1.4524762167521378e-07 1.0222149876793802
data_02_0359 1.3720480308760376e-07 1.4209107029916782e-07 1.0356129457687004
data_02_0379 1.37066156653446e-07 1.3720480308760376e-07 1.0010115293048474
data_02_0367 1.3261291173680126e-07 1.37066156653446e-07 1.033580779264414
data_02_0378 1.3251823783043865e-07 1.3261291173680126e-07 1.000714421712155
data_02_0362 1.282724946539807e-07 1.3251823783043865e-07 1.0330994044195598
data_02_0372 1.2748563415571346e-07 1.282724946539807e-07 1.0061721503248449
data_02_0344 1.2737953092948706e-07 1.2748563415571346e-07 1.000832969201976
data_02_0353 1.2704886278297964e-07 1.2737953092948706e-07 1.0026026848195584
data_02_0345 1.2601025966375946e-07 1.2704886278297964e-07 1.0082422107691196
data_02_0343 1.2167382799218998e-07 1.2601025966375946e-07 1.0356398063834058
data_02_0357 1.1836424233191197e-07 1.2167382799218998e-07 1.0279610260250507
data_02_0348 1.1627425873642544e-07 1.1836424233191197e-07 1.0179746026179723
data_02_0371 1.1505385901264026e-07 1.1627425873642544e-07 1.0106072037414329
data_02_0366 1.1444835172079907e-07 1.1505385901264026e-07 1.0052906597844096
data_02_0352 1.1166457889201498e-07 1.1444835172079907e-07 1.0249297750137591
data_02_0356 1.1066756046305904e-07 1.1166457889201498e-07 1.0090091299092903
data_02_0377 1.0535372743708623e-07 1.1066756046305904e-07 1.0504380163402007
data_02_0351 1.0243849172311388e-07 1.0535372743708623e-07 1.0284584013776001
data_02_0361 1.0153729138473774e-07 1.0243849172311388e-07 1.0088755601620432
data_02_0347 1.0133967083838374e-07 1.0153729138473774e-07 1.001950080799741
data_02_0376 9.832281368484997e-08 1.0133967083838374e-07 1.03068318572741
data_02_0342 9.289884923302538e-08 9.832281368484997e-08 1.0583857011858053
data_02_0329 9.160009106881351e-08 9.289884923302538e-08 1.014178568482385
data_02_0346 9.116900169134509e-08 9.160009106881351e-08 1.0047284643845051
data_02_0111 9.091539210337593e-08 9.116900169134509e-08 1.0027895121178247
data_02_0074 9.069381193217852e-08 9.091539210337593e-08 1.0024431674717027
data_02_0137 9.03293903149745e-08 9.069381193217852e-08 1.0040343637428892
data_02_0095 8.74523334288432e-08 9.03293903149745e-08 1.0328985719800405
data_02_0148 8.648891600653159e-08 8.74523334288432e-08 1.0111392010305558
data_02_0125 8.424378155556433e-08 8.648891600653159e-08 1.026650447184478
data_02_0334 8.326823915639806e-08 8.424378155556433e-08 1.011715660245126
data_02_0112 8.320651139064705e-08 8.326823915639806e-08 1.00074186220188
data_02_0075 8.138214185974406e-08 8.320651139064705e-08 1.022417320178758
data_02_0126 8.103496124197184e-08 8.138214185974406e-08 1.0042843312621021
data_02_0096 8.045245724801484e-08 8.103496124197184e-08 1.0072403505608447
data_02_0076 8.031554364195923e-08 8.045245724801484e-08 1.0017046962499059
data_02_0341 7.826151987085865e-08 8.031554364195923e-08 1.026245641210265
data_02_0138 7.734375527363778e-08 7.826151987085865e-08 1.0118660465085239
data_02_0313 7.682133122854972e-08 7.734375527363778e-08 1.00680050757691
data_02_0097 7.680635206094798e-08 7.682133122854972e-08 1.0001950251144573
data_02_0176 7.667712300125079e-08 7.680635206094798e-08 1.0016853665687884
data_02_0328 7.592352186880232e-08 7.667712300125079e-08 1.0099257926120802
data_02_0113 7.555625875837318e-08 7.592352186880232e-08 1.0048607900452515
data_02_0327 7.544587994012269e-08 7.555625875837318e-08 1.0014630198274326
data_02_0127 7.131617497589785e-08 7.544587994012269e-08 1.0579069890613246
data_02_0312 6.911458700835583e-08 7.131617497589785e-08 1.0318541723656087
data_02_0139 6.909281513713483e-08 6.911458700835583e-08 1.0003151104956105
data_02_0340 6.902017219074813e-08 6.909281513713483e-08 1.0010524886287728
data_02_0333 6.774003441754105e-08 6.902017219074813e-08 1.0188978022260289
data_02_0307 6.766423353429927e-08 6.774003441754105e-08 1.001120250378708
data_02_0185 6.763913389841048e-08 6.766423353429927e-08 1.0003710815683489
data_02_0150 6.745605433758126e-08 6.763913389841048e-08 1.0027140567681738
data_02_0177 6.735816862166664e-08 6.745605433758126e-08 1.0014532122520199
data_02_0193 6.662196525645216e-08 6.735816862166664e-08 1.0110504600454304
data_02_0208 6.626142349356137e-08 6.662196525645216e-08 1.0054412015903313
data_02_0098 6.592232057059097e-08 6.626142349356137e-08 1.0051439773362845
data_02_0302 6.58293955726229e-08 6.592232057059097e-08 1.0014116033902445
data_02_0140 6.57617458135232e-08 6.58293955726229e-08 1.0010287099021296
data_02_0077 6.529890651328317e-08 6.57617458135232e-08 1.0070880099676076
data_02_0201 6.303178713082955e-08 6.529890651328317e-08 1.0359678740783276
data_02_0114 6.24588267473577e-08 6.303178713082955e-08 1.0091734093211426
data_02_0318 6.23915354946696e-08 6.24588267473577e-08 1.0010785317616337
data_02_0178 6.168559077605915e-08 6.23915354946696e-08 1.0114442402144332
data_02_0326 6.156183810355442e-08 6.168559077605915e-08 1.0020102173085956
data_02_0215 6.154477086377611e-08 6.156183810355442e-08 1.0002773142143317
data_02_0311 6.138443821108707e-08 6.154477086377611e-08 1.0026119429836222
data_02_0099 6.072998722692139e-08 6.138443821108707e-08 1.0107764057601443
data_02_0301 6.069678376201197e-08 6.072998722692139e-08 1.000547038291841
data_02_0186 6.061842645466519e-08 6.069678376201197e-08 1.0012926318271456
data_02_0078 6.05546756955427e-08 6.061842645466519e-08 1.0010527801262288
data_02_0079 5.9490831431307015e-08 6.05546756955427e-08 1.0178824911106525
data_02_0306 5.912412014746122e-08 5.9490831431307015e-08 1.0062023973114724
data_02_0332 5.727287901213354e-08 5.912412014746122e-08 1.0323231722808188
data_02_0141 5.719393063976436e-08 5.727287901213354e-08 1.001380362767274
data_02_0115 5.7162314210649325e-08 5.719393063976436e-08 1.000553099179969
data_02_0128 5.695517599620114e-08 5.7162314210649325e-08 1.0036368637410935
data_02_0168 5.679691102721794e-08 5.695517599620114e-08 1.0027865066272241
data_02_0100 5.6595898537117144e-08 5.679691102721794e-08 1.0035517147937667
data_02_0216 5.525228959512556e-08 5.6595898537117144e-08 1.024317706140998
data_02_0217 5.47644402484414e-08 5.525228959512556e-08 1.0089081408386722
data_02_0278 5.440662246210061e-08 5.47644402484414e-08 1.0065767322092094
data_02_0194 5.3362822837444934e-08 5.440662246210061e-08 1.0195604274503116
data_02_0169 5.3331502269719944e-08 5.3362822837444934e-08 1.0005872808076282
data_02_0325 5.306137939665337e-08 5.3331502269719944e-08 1.005090762361214
data_02_0284 5.276534268889967e-08 5.306137939665337e-08 1.0056104384557703
data_02_0151 5.236684455771947e-08 5.276534268889967e-08 1.007609741135748
data_02_0116 5.2353104395197217e-08 5.236684455771947e-08 1.0002624517243244
data_02_0129 5.1837121282096003e-08 5.2353104395197217e-08 1.009953930703313
data_02_0209 5.183704252339118e-08 5.1837121282096003e-08 1.0000015193518186
data_02_0101 5.166940982917213e-08 5.183704252339118e-08 1.0032443315062678
data_02_0331 5.10784819468508e-08 5.166940982917213e-08 1.0115690181030872
data_02_0117 5.101344618415161e-08 5.10784819468508e-08 1.001274874911693
data_02_0170 4.9929536344196644e-08 5.101344618415161e-08 1.0217087904138118
data_02_0202 4.9799913904246315e-08 4.9929536344196644e-08 1.0026028647398781
data_02_0187 4.912196530061741e-08 4.9799913904246315e-08 1.0138013330590496
data_02_0195 4.909538480270249e-08 4.912196530061741e-08 1.000541405226209
data_02_0179 4.884846763021287e-08 4.909538480270249e-08 1.0050547577942222
data_02_0152 4.873638547160228e-08 4.884846763021287e-08 1.0022997634626782
data_02_0338 4.8632146045461504e-08 4.873638547160228e-08 1.0021434264086009
data_02_0080 4.7763280379444634e-08 4.8632146045461504e-08 1.0181910802422773
data_02_0300 4.730742686172498e-08 4.7763280379444634e-08 1.0096359820848442
data_02_0289 4.716153229696035e-08 4.730742686172498e-08 1.0030935077309613
data_02_0305 4.6948242098731506e-08 4.716153229696035e-08 1.0045430923223984
data_02_0130 4.678355070538744e-08 4.6948242098731506e-08 1.003520284178112
data_02_0317 4.676546738965695e-08 4.678355070538744e-08 1.0003866809579773
data_02_0142 4.632745138531294e-08 4.676546738965695e-08 1.009454783098275
data_02_0203 4.572488727574456e-08 4.632745138531294e-08 1.0131780337901022
data_02_0180 4.515676608235293e-08 4.572488727574456e-08 1.0125810867934064
data_02_0236 4.490529491814043e-08 4.515676608235293e-08 1.0056000336858029
data_02_0210 4.4003898110153527e-08 4.490529491814043e-08 1.020484476300951
data_02_0081 4.364487731859856e-08 4.4003898110153527e-08 1.0082259548797488
data_02_0131 4.354469124643211e-08 4.364487731859856e-08 1.002300764325081
data_02_0310 4.337805656983698e-08 4.354469124643211e-08 1.0038414509494415
data_02_0153 4.3177978520711517e-08 4.337805656983698e-08 1.0046337984310565
data_02_0339 4.314187273202065e-08 4.3177978520711517e-08 1.0008369082379696
data_02_0196 4.237750464559882e-08 4.314187273202065e-08 1.0180371188160844
data_02_0188 4.222868848388736e-08 4.237750464559882e-08 1.0035240536008654
data_02_0229 4.208902026815251e-08 4.222868848388736e-08 1.0033184002584286
data_02_0290 4.1538712914667085e-08 4.208902026815251e-08 1.0132480598187026
data_02_0172 4.1159063517690975e-08 4.1538712914667085e-08 1.0092239561479073
data_02_0102 4.110134448475783e-08 4.1159063517690975e-08 1.0014043100939083
data_02_0330 4.090674876110997e-08 4.110134448475783e-08 1.0047570567092554
data_02_0337 4.0521522816559524e-08 4.090674876110997e-08 1.0095066995950364
data_02_0309 3.9743834361041264e-08 4.0521522816559524e-08 1.019567524573839
data_02_0232 3.95881697490978e-08 3.9743834361041264e-08 1.0039320992339387
data_02_0171 3.952375116045423e-08 3.95881697490978e-08 1.0016298703122093
data_02_0230 3.9452258328963335e-08 3.952375116045423e-08 1.00181213533823
data_02_0242 3.92165458923428e-08 3.9452258328963335e-08 1.0060105353813569
data_02_0316 3.9097426632861917e-08 3.92165458923428e-08 1.0030467288959821
data_02_0239 3.897250747507658e-08 3.9097426632861917e-08 1.003205314871393
data_02_0237 3.875841552078056e-08 3.897250747507658e-08 1.005523754039461
data_02_0299 3.8590389027237044e-08 3.875841552078056e-08 1.0043541020906765
data_02_0324 3.826943275819106e-08 3.8590389027237044e-08 1.0083867527139474
data_02_0249 3.810908415306902e-08 3.826943275819106e-08 1.0042076215864433
data_02_0143 3.810734842935843e-08 3.810908415306902e-08 1.0000455482677786
data_02_0118 3.8100868267354914e-08 3.810734842935843e-08 1.0001700791162564
data_02_0189 3.800238507610693e-08 3.8100868267354914e-08 1.0025915002716475
data_02_0082 3.7741970920329645e-08 3.800238507610693e-08 1.0068998557687143
data_02_0238 3.7560067152157576e-08 3.7741970920329645e-08 1.0048430096632992
data_02_0323 3.7514981288697336e-08 3.7560067152157576e-08 1.0012018095681103
data_02_0181 3.706262245040685e-08 3.7514981288697336e-08 1.0122052571669957
data_02_0231 3.682093806366573e-08 3.706262245040685e-08 1.0065637759234496
data_02_0103 3.677818704763357e-08 3.682093806366573e-08 1.001162401397785
data_02_0255 3.628478717876916e-08 3.677818704763357e-08 1.0135979816123355
data_02_0204 3.6164805825293285e-08 3.628478717876916e-08 1.003317627476157
data_02_0272 3.59921912272354e-08 3.6164805825293285e-08 1.0047958902243013
data_02_0154 3.59388385340999e-08 3.59921912272354e-08 1.001484541385078
data_02_0083 3.589470383774043e-08 3.59388385340999e-08 1.001229560120038
data_02_0315 3.540817833102809e-08 3.589470383774043e-08 1.01374048396853
data_02_0271 3.5405106755531584e-08 3.540817833102809e-08 1.0000867551542132
data_02_0132 3.539125941837753e-08 3.5405106755531584e-08 1.0003912643229325
data_02_0211 3.531821770801946e-08 3.539125941837753e-08 1.0020681029536063
data_02_0283 3.508204848587925e-08 3.531821770801946e-08 1.0067319108299866
data_02_0304 3.46937021763495e-08 3.508204848587925e-08 1.0111935678572375
data_02_0266 3.438001280908393e-08 3.46937021763495e-08 1.009124178312775
data_02_0282 3.424029328669515e-08 3.438001280908393e-08 1.0040805585752115
data_02_0308 3.4026021582491746e-08 3.424029328669515e-08 1.0062972893755424
data_02_0259 3.394370834991172e-08 3.4026021582491746e-08 1.002424992335295
data_02_0119 3.39277719321542e-08 3.394370834991172e-08 1.0004697160128697
data_02_0253 3.390653579404228e-08 3.39277719321542e-08 1.0006263140015517
data_02_0197 3.38095060042918e-08 3.390653579404228e-08 1.002869896701187
data_02_0251 3.3593072697069164e-08 3.38095060042918e-08 1.0064427957863324
data_02_0144 3.3247539466691447e-08 3.3593072697069164e-08 1.0103927459270747
data_02_0182 3.304665329402803e-08 3.3247539466691447e-08 1.0060788658650563
data_02_0336 3.2916725727484065e-08 3.304665329402803e-08 1.0039471594963494
data_02_0264 3.2731613308230714e-08 3.2916725727484065e-08 1.0056554627329293
data_02_0104 3.252823750998902e-08 3.2731613308230714e-08 1.0062522845936317
data_02_0298 3.2495750930895934e-08 3.252823750998902e-08 1.0009997177527046
data_02_0250 3.242473482590026e-08 3.2495750930895934e-08 1.0021901830616962
data_02_0256 3.2363258701190245e-08 3.242473482590026e-08 1.0018995653459257
data_02_0173 3.2333215504007045e-08 3.2363258701190245e-08 1.000929174433006
data_02_0258 3.22692930607046e-08 3.2333215504007045e-08 1.0019809062188687
data_02_0243 3.217059036351489e-08 3.22692930607046e-08 1.0030681033849367
data_02_0190 3.2140929821276446e-08 3.217059036351489e-08 1.0009228277589781
data_02_0262 3.193213502090787e-08 3.2140929821276446e-08 1.0065387046695082
data_02_0269 3.151811464075576e-08 3.193213502090787e-08 1.013135950067798
data_02_0120 3.150485879015733e-08 3.151811464075576e-08 1.0004207557534768
data_02_0191 3.141975700735102e-08 3.150485879015733e-08 1.0027085436334342
data_02_0261 3.124494956345661e-08 3.141975700735102e-08 1.0055947423931468
data_02_0218 3.055804122628002e-08 3.124494956345661e-08 1.0224788078558469
data_02_0252 3.01864634170887e-08 3.055804122628002e-08 1.0123094184322687
data_02_0322 3.011726260592752e-08 3.01864634170887e-08 1.0022977125134724
data_02_0314 3.009776780454749e-08 3.011726260592752e-08 1.0006477158541
data_02_0265 3.00514365542048e-08 3.009776780454749e-08 1.0015417316326667
data_02_0268 2.9905581231323254e-08 3.00514365542048e-08 1.0048771940512822
data_02_0155 2.9791563025984525e-08 2.9905581231323254e-08 1.0038271978291062
data_02_0267 2.959671671172861e-08 2.9791563025984525e-08 1.0065833759924694
data_02_0198 2.8804718503755165e-08 2.959671671172861e-08 1.027495433009359
data_02_0084 2.854152152077937e-08 2.8804718503755165e-08 1.0092215470287447
data_02_0257 2.84619388223748e-08 2.854152152077937e-08 1.0027961095307396
data_02_0303 2.8461846228197857e-08 2.84619388223748e-08 1.0000032532737406
data_02_0281 2.8445514310204485e-08 2.8461846228197857e-08 1.000574147396854
data_02_0219 2.827617732882481e-08 2.8445514310204485e-08 1.0059886801320579
data_02_0174 2.7830138583431962e-08 2.827617732882481e-08 1.01602718376898
data_02_0212 2.7693009266450745e-08 2.7830138583431962e-08 1.0049517665509666
data_02_0133 2.7647470492804285e-08 2.7693009266450745e-08 1.0016471226059653
data_02_0297 2.7423848405637794e-08 2.7647470492804285e-08 1.0081542927111762
data_02_0205 2.7191991306331825e-08 2.7423848405637794e-08 1.0085266686317298
data_02_0321 2.696072330617148e-08 2.7191991306331825e-08 1.008577959780011
data_02_0277 2.69174511955274e-08 2.696072330617148e-08 1.001607585737957
data_02_0105 2.6823918307999324e-08 2.69174511955274e-08 1.0034869211296464
data_02_0199 2.6596816541850855e-08 2.6823918307999324e-08 1.0085386822814346
data_02_0145 2.6321883880191714e-08 2.6596816541850855e-08 1.0104450222070176
data_02_0134 2.5886482512495037e-08 2.6321883880191714e-08 1.0168196419689897
data_02_0244 2.5860887274560485e-08 2.5886482512495037e-08 1.00098972775616
data_02_0288 2.5814184934311998e-08 2.5860887274560485e-08 1.0018091735364618
data_02_0280 2.5567408398686068e-08 2.5814184934311998e-08 1.0096519964705775
data_02_0200 2.5161825000061712e-08 2.5567408398686068e-08 1.0161189976729972
data_02_0286 2.5066528318774607e-08 2.5161825000061712e-08 1.0038017502892784
data_02_0085 2.5059766982601205e-08 2.5066528318774607e-08 1.0002698084215267
data_02_0270 2.501467899802678e-08 2.5059766982601205e-08 1.001802461050089
data_02_0263 2.4817500914856054e-08 2.501467899802678e-08 1.007945122429821
data_02_0156 2.4613349978552404e-08 2.4817500914856054e-08 1.008294317371733
data_02_0276 2.4560296850560702e-08 2.4613349978552404e-08 1.0021601175390715
data_02_0285 2.4538500163829094e-08 2.4560296850560702e-08 1.0008882648322466
data_02_0121 2.405843208864701e-08 2.4538500163829094e-08 1.0199542544340878
data_02_0296 2.4058301360074324e-08 2.405843208864701e-08 1.00000543382389
data_02_0207 2.3903461559909207e-08 2.4058301360074324e-08 1.0064777145258665
data_02_0449 2.373280894028847e-08 2.3903461559909207e-08 1.007190578243397
data_02_0275 2.351749156807309e-08 2.373280894028847e-08 1.0091556266361201
data_02_0183 2.3500539027225123e-08 2.351749156807309e-08 1.000721368170676
data_02_0206 2.3061812947513062e-08 2.3500539027225123e-08 1.0190239197894184
data_02_0220 2.2994988953888147e-08 2.3061812947513062e-08 1.0029060241672183
data_02_0146 2.2740881631130188e-08 2.2994988953888147e-08 1.011174031283383
data_02_0221 2.2573026012461166e-08 2.2740881631130188e-08 1.007436115059468
data_02_0295 2.222224858006809e-08 2.2573026012461166e-08 1.0157849657350924
data_02_0106 2.2203112981640488e-08 2.222224858006809e-08 1.0008618430417133
data_02_0287 2.1985254420659646e-08 2.2203112981640488e-08 1.0099093036092464
data_02_0335 2.174038356223434e-08 2.1985254420659646e-08 1.011263410221091
data_02_0157 2.1600786574131115e-08 2.174038356223434e-08 1.0064625881851175
data_02_0086 2.1280953876238953e-08 2.1600786574131115e-08 1.0150290583660946
data_02_0135 2.0605224158770496e-08 2.1280953876238953e-08 1.032794096888329
data_02_0245 2.0214746920241275e-08 2.0605224158770496e-08 1.0193164544710789
data_02_0147 2.012235348938875e-08 2.0214746920241275e-08 1.0045915817402395
data_02_0122 2.0049202575832967e-08 2.012235348938875e-08 1.003648569726357
data_02_0107 1.938714534962891e-08 2.0049202575832967e-08 1.0341492888336308
data_02_0184 1.9329784881362546e-08 1.938714534962891e-08 1.002967465422839
data_02_0233 1.9242219372987482e-08 1.9329784881362546e-08 1.004550696916905
data_02_0175 1.9131945757118e-08 1.9242219372987482e-08 1.0057638474031558
data_02_0192 1.9060909360862577e-08 1.9131945757118e-08 1.0037268104532977
data_02_0214 1.8668523669383202e-08 1.9060909360862577e-08 1.0210185710679895
data_02_0246 1.8085116798197382e-08 1.8668523669383202e-08 1.0322589495935117
data_02_0224 1.7865119734937927e-08 1.8085116798197382e-08 1.012314334665735
data_02_0123 1.7783980521679194e-08 1.7865119734937927e-08 1.0045624888736142
data_02_0234 1.7743067624651617e-08 1.7783980521679194e-08 1.0023058525105735
data_02_0087 1.7689307353746686e-08 1.7743067624651617e-08 1.00303913939816
data_02_0136 1.685611853058975e-08 1.7689307353746686e-08 1.0494294591987414
data_02_0222 1.685223127976849e-08 1.685611853058975e-08 1.0002306668331764
data_02_0223 1.684111800097649e-08 1.685223127976849e-08 1.0006598896101409
data_02_0108 1.6692689326756842e-08 1.684111800097649e-08 1.0088918370979163
data_02_0124 1.649772171738971e-08 1.6692689326756842e-08 1.0118178505315447
data_02_0274 1.646811134730673e-08 1.649772171738971e-08 1.0017980428634776
data_02_0158 1.609217982956011e-08 1.646811134730673e-08 1.0233611307932355
data_02_0240 1.5068640073540352e-08 1.609217982956011e-08 1.0679251578791795
data_02_0320 1.503683121703211e-08 1.5068640073540352e-08 1.0021153962593006
data_02_0247 1.4173933717675753e-08 1.503683121703211e-08 1.0608791826280568
data_02_0248 1.4169011127970798e-08 1.4173933717675753e-08 1.0003474194254276
data_02_0088 1.387514072593158e-08 1.4169011127970798e-08 1.0211796339830987
data_02_0235 1.3468333617225374e-08 1.387514072593158e-08 1.030204709822893
data_02_0160 1.3120004952502951e-08 1.3468333617225374e-08 1.026549430886912
data_02_0161 1.2298582595302832e-08 1.3120004952502951e-08 1.0667900020864065
data_02_0260 1.216723491447803e-08 1.2298582595302832e-08 1.010795195600975
data_02_0159 1.199993752002408e-08 1.216723491447803e-08 1.0139415221266597
data_02_0294 1.1975844891213482e-08 1.199993752002408e-08 1.002011768608349
data_02_0273 1.1970496190147518e-08 1.1975844891213482e-08 1.0004468236722188
data_02_0241 1.180009018680682e-08 1.1970496190147518e-08 1.0144410763513674
data_02_0109 1.175617850876184e-08 1.180009018680682e-08 1.0037352000067243
data_02_0254 1.1681359586635138e-08 1.175617850876184e-08 1.0064049840749962
data_02_0089 1.0944685681180611e-08 1.1681359586635138e-08 1.0673088224654308
data_02_0319 1.071026016339414e-08 1.0944685681180611e-08 1.0218879386877733
data_02_0291 9.647626338630572e-09 1.071026016339414e-08 1.1101445876389946
data_02_0110 9.297424836505559e-09 9.647626338630572e-09 1.0376665053262895
data_02_0090 8.94600182435908e-09 9.297424836505559e-09 1.0392826895238931
data_02_0440 8.921549332760699e-09 8.94600182435908e-09 1.002740834656217
data_02_0292 8.845576776004658e-09 8.921549332760699e-09 1.008588762347542
data_02_0293 8.013141726493833e-09 8.845576776004658e-09 1.103883729743422
data_02_0091 5.400087708579987e-09 8.013141726493833e-09 1.4838910326886112
376

Overlay of the differents results

We are getting to an end. Here are the first actually integrated data

[61]:
fig, ax = plt.subplots()
summed, counted, radial = None, None, None

for i in range(9):
    name = ds_names[i]
    ds = data[name]
    gonioref = goniometers[name]
    mg = gonioref.get_mg(position)
    mg.radial_range = (0, 95)
    images = [i.reshape(-1, 1) for i in ds]
    res_mg = mg.integrate1d(images, 50000)
    results[name] = res_mg
    if summed is None:
        summed = res_mg.sum
        counted = res_mg.count
    else:
        summed += res_mg.sum
        counted += res_mg.count
    radial = res_mg.radial
    jupyter.plot1d(res_mg, label="%i %s"%(i, name), calibrant=LaB6, ax=ax )

ax.plot(radial, summed/counted, label="Merged")
ax.legend()
fig.show()
area_pixel=0.05054585816712631 area_sum=0.05084240089824814, Error= -0.005866805745810646
area_pixel=0.05448433978731071 area_sum=0.05460194376540826, Error= -0.002158491385903477
area_pixel=0.05706893234299759 area_sum=0.057097754167008734, Error= -0.0005050352762500703
area_pixel=0.04575136894640419 area_sum=0.046103520693760155, Error= -0.007697075638731046
area_pixel=0.0503875602291064 area_sum=0.05041948354020665, Error= -0.0006335554044510445
area_pixel=0.050887046288177196 area_sum=0.05090400923674137, Error= -0.0003333451202514585
area_pixel=0.047764037615231736 area_sum=0.047787742717740125, Error= -0.0004962960355099896
area_pixel=0.054600585079026764 area_sum=0.05461392295287675, Error= -0.00024428078619822223
area_pixel=0.04398098576245957 area_sum=0.0451093409852144, Error= -0.025655523704017393
area_pixel=0.05413585962925449 area_sum=0.054261047973434326, Error= -0.0023124846458000116
area_pixel=0.05074179597564754 area_sum=0.051022305153632666, Error= -0.005528168102677118
area_pixel=0.05670749981502521 area_sum=0.0567493721010123, Error= -0.0007383906207058524
area_pixel=0.0522725582237884 area_sum=0.052599157191360185, Error= -0.006248000455105984
area_pixel=0.04886833409786284 area_sum=0.05916004122953074, Error= -0.21060073607293242
area_pixel=0.05605479751870135 area_sum=0.06334656311501353, Error= -0.13008281037639038
area_pixel=0.07613865216960036 area_sum=0.07747175549456228, Error= -0.01750889051716343
area_pixel=0.08243566371888811 area_sum=0.0829475211134128, Error= -0.006209174178182975
area_pixel=0.05072162137920344 area_sum=0.060175244255315306, Error= -0.18638250550854787
area_pixel=0.05147481897381212 area_sum=0.060582440472418876, Error= -0.17693353138823606
area_pixel=0.07995593516658417 area_sum=0.08078232411070743, Error= -0.010335554732760278
area_pixel=0.07870547782261994 area_sum=0.07967188659348057, Error= -0.012278799361826395
area_pixel=0.05682851643920728 area_sum=0.06386061246732938, Error= -0.12374238267586556
area_pixel=0.0400252869217077 area_sum=0.05503561919587382, Error= -0.3750212285430305
area_pixel=0.06340122634469303 area_sum=0.06793436007101032, Error= -0.07149914895450184
area_pixel=0.07356612496032433 area_sum=0.07505451304442162, Error= -0.020231976128958933
area_pixel=0.08519548136319521 area_sum=0.08544563508127642, Error= -0.0029362322282655237
area_pixel=0.053160030339890696 area_sum=0.06157431522706344, Error= -0.1582821686401251
area_pixel=0.045930287163253425 area_sum=0.057201385537067204, Error= -0.2453957741163707
area_pixel=0.06732209973204561 area_sum=0.07040744500060567, Error= -0.045829605446655645
area_pixel=0.07017129920940413 area_sum=0.0721841810894871, Error= -0.02868525882748959
area_pixel=0.048616431082022515 area_sum=0.058747282374172344, Error= -0.2083832783829341
area_pixel=0.05084741072757204 area_sum=0.06014651274983808, Error= -0.1828825084543311
area_pixel=0.08582264210207136 area_sum=0.08598966627233767, Error= -0.0019461550725468225
area_pixel=0.07293769354366653 area_sum=0.07452580505574181, Error= -0.021773536218615323
area_pixel=0.06333498912628421 area_sum=0.06785807669315522, Error= -0.07141530501966896
area_pixel=0.03963769199827816 area_sum=0.054891531459535764, Error= -0.3848316764235472
area_pixel=0.06112439445008455 area_sum=0.0664864916591485, Error= -0.08772434078578469
area_pixel=0.07314430360340829 area_sum=0.07481382789893049, Error= -0.022825076093067092
area_pixel=0.0854466193934389 area_sum=0.08560825287900438, Error= -0.0018916311343020336
area_pixel=0.04673599374915405 area_sum=0.057774642096181, Error= -0.23619158300719262
area_pixel=0.05583010601315941 area_sum=0.06324832936851839, Error= -0.13287138221823314
area_pixel=0.07322943409217153 area_sum=0.07499526481604342, Error= -0.02411367431365501
area_pixel=0.0852345027976682 area_sum=0.08533894045176349, Error= -0.0012252978625710697
area_pixel=0.04599237073951734 area_sum=0.05746828088313036, Error= -0.24951769084938125
area_pixel=0.06070260492291091 area_sum=0.061073736040080526, Error= -0.006113924067030317
area_pixel=0.044319725410217004 area_sum=0.047768636124481664, Error= -0.07781886467801953
area_pixel=0.044174329257337774 area_sum=0.047917627993498656, Error= -0.0847392320176335
area_pixel=0.05696363265076698 area_sum=0.05803312066746481, Error= -0.018774926508894813
area_pixel=0.058320415107782964 area_sum=0.059174815319163986, Error= -0.014650105109882882
area_pixel=0.042924164383912 area_sum=0.04741622416589007, Error= -0.10465107117290089
area_pixel=0.06337332199284873 area_sum=0.06344873015210023, Error= -0.0011899038409255117
area_pixel=0.052121672519851 area_sum=0.05393823010119017, Error= -0.03485225038869034
area_pixel=0.0479534333591225 area_sum=0.05044117779204517, Error= -0.05187833818471332
area_pixel=0.04600451074681722 area_sum=0.048891635204346216, Error= -0.06275742118893726
area_pixel=0.05666618800179535 area_sum=0.057795805715150514, Error= -0.01993459862377502
area_pixel=0.053340349058393244 area_sum=0.055062805328933664, Error= -0.03229180725185726
area_pixel=0.04918182529843129 area_sum=0.05170780411764328, Error= -0.051360005528151
area_pixel=0.0542987243748243 area_sum=0.05587411994858145, Error= -0.029013491419838604
area_pixel=0.048922568471164496 area_sum=0.05165291259833061, Error= -0.05580950086002555
area_pixel=0.041726822421832566 area_sum=0.042106909997024614, Error= -0.00910895086497591
area_pixel=0.039582151362063556 area_sum=0.04069836796135787, Error= -0.02819999825386246
area_pixel=0.05048661327088855 area_sum=0.051104638944560715, Error= -0.012241377142018202
area_pixel=0.05462653755615676 area_sum=0.054859630660605146, Error= -0.004267030547355515
area_pixel=0.052955102565457324 area_sum=0.053292036127629394, Error= -0.006362626939596422
area_pixel=0.05776491656818106 area_sum=0.05779778818874337, Error= -0.0005690585655657377
area_pixel=0.04640522109095535 area_sum=0.0470074553630645, Error= -0.012977726599529699
area_pixel=0.04660652023051526 area_sum=0.04708417266487089, Error= -0.010248618261847633
area_pixel=0.055970272141323996 area_sum=0.05607648098314985, Error= -0.0018975938076141565
area_pixel=0.04137995412261919 area_sum=0.04379345464441353, Error= -0.058325355186294676
area_pixel=0.04876562355702152 area_sum=0.04919111397280354, Error= -0.008725212244738255
area_pixel=0.052309101601506036 area_sum=0.05260266489758367, Error= -0.005612088280812288
area_pixel=0.043221450987522836 area_sum=0.044503584967261894, Error= -0.029664297482960136
area_pixel=0.042611371967804956 area_sum=0.04391185184599117, Error= -0.030519549550500034
/mntdirect/_scisoft/users/kieffer/.jupy37/lib/python3.7/site-packages/ipykernel_launcher.py:22: RuntimeWarning: invalid value encountered in true_divide

Multi-Gonio fit

Can we fit everything togeather ? Just assume energy and scale parameter of the goniometer are the same for all modules and fit everything.

[62]:
from scipy.optimize import minimize
class MultiGoniometer:
    def __init__(self, list_of_goniometers,
                param_name_split,
                param_name_common):
        self.nb_gonio = len(list_of_goniometers)
        self.goniometers = list_of_goniometers
        self.names_split = param_name_split
        self.names_common = param_name_common
        self.param = None

    def init_param(self):
        param = []
        for gonio in self.goniometers:
            param += list(gonio.param[:len(self.names_split)])
        param += list(gonio.param[len(self.names_split):])
        self.param = numpy.array(param)

    def residu2(self, param):
        "Actually performs the calulation of the average of the error squared"
        sumsquare = 0.0
        npt = 0
        for idx, gonio in enumerate(self.goniometers):
            gonio_param = numpy.concatenate((param[len(self.names_split)*idx:len(self.names_split)*(1+idx)],
                                             param[len(self.names_split)*len(self.goniometers):]))
            sumsquare += gonio.residu2(gonio_param)
        return sumsquare

    def chi2(self, param=None):
        """Calculate the average of the square of the error for a given parameter set
        """
        if param is not None:
            return self.residu2(param)
        else:
            if self.param is None:
                self.init_param()
            return self.residu2(self.param)
    def refine2(self, method="slsqp", **options):
        """Geometry refinement tool

        See https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.optimize.minimize.html

        :param method: name of the minimizer
        :param options: options for the minimizer
        """
        if method.lower() in ["simplex", "nelder-mead"]:
            method = "Nelder-Mead"

        former_error = self.chi2()
        print("Cost function before refinement: %s" % former_error)
        param = numpy.asarray(self.param, dtype=numpy.float64)
        print(param)
        res = minimize(self.residu2, param, method=method,
                       tol=1e-12,
                       options=options)
        print(res)
        newparam = res.x
        new_error = res.fun
        print("Cost function after refinement: %s" % new_error)

        if new_error < former_error:
            self.param = newparam
        return self.param

    def integrate(self, list_of_dataset, npt=50000, radial_range=(0,100)):
        summed = None
        counted = None
        param = self.param
        for idx, ds in enumerate(list_of_dataset):
            gonio = self.goniometers[idx]
            gonio_param = numpy.concatenate((param[len(self.names_split)*idx:len(self.names_split)*(1+idx)],
                                             param[len(self.names_split)*len(self.goniometers):]))
            print(gonio_param)
            gonio.param = gonio_param
            mg = gonio.get_mg(position)
            mg.radial_range = radial_range
            images = [i.reshape(-1, 1) for i in ds]
            res_mg = mg.integrate1d(images, 50000)
            if summed is None:
                summed = res_mg.sum
                counted = res_mg.count
            else:
                summed += res_mg.sum
                counted += res_mg.count
            radial = res_mg.radial
        res = Integrate1dResult(radial, summed/numpy.maximum(counted, 1e-10))
        res._set_unit(res_mg.unit)
        res._set_count(counted)
        res._set_sum(summed)
        return res
[63]:
multigonio = MultiGoniometer([goniometers[ds_names[i]] for i in range(9)],
                 ["dist", "poni1", "poni2", "rot1", "offset"],
                ["scale", "nrj"])

[64]:
%time print(multigonio.chi2())
multigonio.param = numpy.array([ 7.20594053e-01,  3.22408604e-02,  4.05228023e-03, -2.75578440e-05,
       -8.27999414e+01,  7.20612302e-01,  3.36369797e-02,  4.02094516e-03,
       -1.74996556e-05, -7.71999791e+01,  7.20636130e-01,  3.47920978e-02,
        4.01341931e-03, -1.21330600e-05, -7.15999090e+01,  7.20757808e-01,
        3.33850817e-02,  3.95036100e-03,  3.46517345e-05, -6.57999267e+01,
        7.20813915e-01,  3.22167822e-02,  3.97128822e-03,  2.00055269e-05,
       -6.00000525e+01,  7.20881596e-01,  3.33801850e-02,  3.97760147e-03,
        1.47074593e-05, -5.43998157e+01,  7.21048510e-01,  3.22346939e-02,
        4.02104962e-03, -1.69519259e-05, -4.85998856e+01,  7.21074630e-01,
        3.08484557e-02,  4.09385968e-03, -6.91378973e-05, -4.27999030e+01,
        7.21154891e-01,  3.20619921e-02,  4.24950906e-03, -1.81328256e-04,
       -3.71999987e+01,  9.99038595e-01,  1.70266104e+01])
%time print(multigonio.chi2())

8.603112017040267e-09
CPU times: user 10.1 s, sys: 382 ms, total: 10.5 s
Wall time: 663 ms
6.1395983620232986e-09
CPU times: user 9.9 s, sys: 392 ms, total: 10.3 s
Wall time: 651 ms
[65]:
%time multigonio.refine2()
Cost function before refinement: 6.1395983620232986e-09
[ 7.20594053e-01  3.22408604e-02  4.05228023e-03 -2.75578440e-05
 -8.27999414e+01  7.20612302e-01  3.36369797e-02  4.02094516e-03
 -1.74996556e-05 -7.71999791e+01  7.20636130e-01  3.47920978e-02
  4.01341931e-03 -1.21330600e-05 -7.15999090e+01  7.20757808e-01
  3.33850817e-02  3.95036100e-03  3.46517345e-05 -6.57999267e+01
  7.20813915e-01  3.22167822e-02  3.97128822e-03  2.00055269e-05
 -6.00000525e+01  7.20881596e-01  3.33801850e-02  3.97760147e-03
  1.47074593e-05 -5.43998157e+01  7.21048510e-01  3.22346939e-02
  4.02104962e-03 -1.69519259e-05 -4.85998856e+01  7.21074630e-01
  3.08484557e-02  4.09385968e-03 -6.91378973e-05 -4.27999030e+01
  7.21154891e-01  3.20619921e-02  4.24950906e-03 -1.81328256e-04
 -3.71999987e+01  9.99038595e-01  1.70266104e+01]
     fun: 6.1395983620232986e-09
     jac: array([ 5.90883473e-08, -1.08561671e-07, -2.52646911e-08,  1.79747064e-08,
       -1.72926662e-09,  1.79298213e-08,  9.69570013e-09,  4.03865801e-08,
       -2.91714863e-08, -1.94683714e-10,  2.72323741e-08, -6.07769467e-08,
        2.33525472e-08, -1.69337616e-08, -1.17130239e-09,  2.09023376e-07,
       -5.80926751e-09,  1.58839289e-08, -1.22906173e-08, -4.71553241e-10,
        1.47614749e-07, -1.33281402e-07, -1.82833877e-08,  1.25890469e-08,
       -2.00339789e-09,  2.45125083e-07, -6.85051675e-08, -3.08888884e-08,
        2.12864152e-08, -1.23765842e-09,  2.99788196e-07, -2.02647332e-08,
       -7.85245061e-08,  5.54326079e-08, -5.67168867e-10,  2.54716680e-07,
        1.39967174e-07, -1.44580129e-07,  1.03263413e-07,  1.46673401e-09,
        1.30733052e-08,  8.84376917e-08, -1.94036564e-07,  1.39886310e-07,
        7.47406914e-10, -3.89892417e-08,  6.53007231e-07])
 message: 'Optimization terminated successfully.'
    nfev: 49
     nit: 1
    njev: 1
  status: 0
 success: True
       x: array([ 7.20594053e-01,  3.22408604e-02,  4.05228023e-03, -2.75578440e-05,
       -8.27999414e+01,  7.20612302e-01,  3.36369797e-02,  4.02094516e-03,
       -1.74996556e-05, -7.71999791e+01,  7.20636130e-01,  3.47920978e-02,
        4.01341931e-03, -1.21330600e-05, -7.15999090e+01,  7.20757808e-01,
        3.33850817e-02,  3.95036100e-03,  3.46517345e-05, -6.57999267e+01,
        7.20813915e-01,  3.22167822e-02,  3.97128822e-03,  2.00055269e-05,
       -6.00000525e+01,  7.20881596e-01,  3.33801850e-02,  3.97760147e-03,
        1.47074593e-05, -5.43998157e+01,  7.21048510e-01,  3.22346939e-02,
        4.02104962e-03, -1.69519259e-05, -4.85998856e+01,  7.21074630e-01,
        3.08484557e-02,  4.09385968e-03, -6.91378973e-05, -4.27999030e+01,
        7.21154891e-01,  3.20619921e-02,  4.24950906e-03, -1.81328256e-04,
       -3.71999987e+01,  9.99038595e-01,  1.70266104e+01])
Cost function after refinement: 6.1395983620232986e-09
CPU times: user 7min 48s, sys: 17.8 s, total: 8min 6s
Wall time: 30.6 s
[65]:
array([ 7.20594053e-01,  3.22408604e-02,  4.05228023e-03, -2.75578440e-05,
       -8.27999414e+01,  7.20612302e-01,  3.36369797e-02,  4.02094516e-03,
       -1.74996556e-05, -7.71999791e+01,  7.20636130e-01,  3.47920978e-02,
        4.01341931e-03, -1.21330600e-05, -7.15999090e+01,  7.20757808e-01,
        3.33850817e-02,  3.95036100e-03,  3.46517345e-05, -6.57999267e+01,
        7.20813915e-01,  3.22167822e-02,  3.97128822e-03,  2.00055269e-05,
       -6.00000525e+01,  7.20881596e-01,  3.33801850e-02,  3.97760147e-03,
        1.47074593e-05, -5.43998157e+01,  7.21048510e-01,  3.22346939e-02,
        4.02104962e-03, -1.69519259e-05, -4.85998856e+01,  7.21074630e-01,
        3.08484557e-02,  4.09385968e-03, -6.91378973e-05, -4.27999030e+01,
        7.21154891e-01,  3.20619921e-02,  4.24950906e-03, -1.81328256e-04,
       -3.71999987e+01,  9.99038595e-01,  1.70266104e+01])
[66]:
LaB6_new = get_calibrant("LaB6")
LaB6_new.wavelength = 1e-10*hc/multigonio.param[-1]
print(LaB6,"\n", LaB6_new)
LaB6 Calibrant with 109 reflections at wavelength 7.281789761742598e-11
 LaB6 Calibrant with 109 reflections at wavelength 7.281789768115395e-11
[67]:
%time res = multigonio.integrate([data[ds_names[i]] for i in range(9)])
[ 7.20594053e-01  3.22408604e-02  4.05228023e-03 -2.75578440e-05
 -8.27999414e+01  9.99038595e-01  1.70266104e+01]
area_pixel=0.053413862261281864 area_sum=0.055214882933248166, Error= -0.033718225863472326
area_pixel=0.045333067243413794 area_sum=0.04986384765291535, Error= -0.09994427213966664
area_pixel=0.03918749031126367 area_sum=0.04563241935519968, Error= -0.16446393970995232
area_pixel=0.04641997394066166 area_sum=0.05056017758649528, Error= -0.0891901329183427
area_pixel=0.04963019502342725 area_sum=0.052784706110374724, Error= -0.06356032019335069
area_pixel=0.041808779534353135 area_sum=0.04729034242949584, Error= -0.13111033032281305
area_pixel=0.053529818242976646 area_sum=0.05553764984245543, Error= -0.03750865714441734
area_pixel=0.05746249488342414 area_sum=0.05828939512131753, Error= -0.014390259935127214
area_pixel=0.03804626259786659 area_sum=0.04468957516491201, Error= -0.17461143653615904
area_pixel=0.0579645518625469 area_sum=0.05860457337617547, Error= -0.011041602031984604
area_pixel=0.0514530597536762 area_sum=0.05403218600224738, Error= -0.05012580905622247
area_pixel=0.04708587038231293 area_sum=0.05104328125237842, Error= -0.08404667552990643
area_pixel=0.0414210821500145 area_sum=0.04727614277194664, Error= -0.1413546029707022
area_pixel=0.057188034039880264 area_sum=0.05760891916847055, Error= -0.0073596712259208176
[ 7.20612302e-01  3.36369797e-02  4.02094516e-03 -1.74996556e-05
 -7.71999791e+01  9.99038595e-01  1.70266104e+01]
[ 7.20636130e-01  3.47920978e-02  4.01341931e-03 -1.21330600e-05
 -7.15999090e+01  9.99038595e-01  1.70266104e+01]
[ 7.20757808e-01  3.33850817e-02  3.95036100e-03  3.46517345e-05
 -6.57999267e+01  9.99038595e-01  1.70266104e+01]
area_pixel=0.06406776393820302 area_sum=0.06431614060731783, Error= -0.003876780674824036
area_pixel=0.036519974544861 area_sum=0.045063743745274665, Error= -0.23394784106211602
area_pixel=0.06022365655235262 area_sum=0.06045501049825683, Error= -0.0038415791924405825
area_pixel=0.06470520384919531 area_sum=0.06480584410676266, Error= -0.0015553657446454841
area_pixel=0.042761484590993604 area_sum=0.04894851144272455, Error= -0.14468690483758498
area_pixel=0.05556804666999149 area_sum=0.0572738285392099, Error= -0.030697171692011003
area_pixel=0.05157759645584292 area_sum=0.054703089692101546, Error= -0.06059788456669262
area_pixel=0.04628344743831292 area_sum=0.051193164385785, Error= -0.1060793268266329
area_pixel=0.04441767384784612 area_sum=0.04995426406033848, Error= -0.12464836027789516
area_pixel=0.05377034832596905 area_sum=0.05619131504982555, Error= -0.04502419640616803
area_pixel=0.05745532746690074 area_sum=0.0586344668434077, Error= -0.020522716143011228
area_pixel=0.04107664840957703 area_sum=0.047752702889470366, Error= -0.16252675761970906
area_pixel=0.05946818134114551 area_sum=0.05993335889343876, Error= -0.00782229322979813
area_pixel=0.07058082407797173 area_sum=0.07058105681613237, Error= -3.2974701512325326e-06
area_pixel=0.046987941054872806 area_sum=0.05167050922411581, Error= -0.09965467871372943
area_pixel=0.051123579128637076 area_sum=0.05437612755835594, Error= -0.063621297357425
area_pixel=0.05248017980128061 area_sum=0.055180053859511885, Error= -0.05144559466934963
area_pixel=0.047912061925078575 area_sum=0.05226569446005236, Error= -0.09086715035937463
area_pixel=0.04572012763952671 area_sum=0.05084193350468269, Error= -0.11202518736470006
[ 7.20813915e-01  3.22167822e-02  3.97128822e-03  2.00055269e-05
 -6.00000525e+01  9.99038595e-01  1.70266104e+01]
[ 7.20881596e-01  3.33801850e-02  3.97760147e-03  1.47074593e-05
 -5.43998157e+01  9.99038595e-01  1.70266104e+01]
[ 7.21048510e-01  3.22346939e-02  4.02104962e-03 -1.69519259e-05
 -4.85998856e+01  9.99038595e-01  1.70266104e+01]
[ 7.21074630e-01  3.08484557e-02  4.09385968e-03 -6.91378973e-05
 -4.27999030e+01  9.99038595e-01  1.70266104e+01]
area_pixel=0.0991017473223863 area_sum=0.10463027384689139, Error= -0.05578636778744499
area_pixel=0.07069194828200054 area_sum=0.08784192624601114, Error= -0.24260157458946852
area_pixel=0.07363944575302739 area_sum=0.08917599048958212, Error= -0.21098128289369983
area_pixel=0.11866235123215318 area_sum=0.12004419996868715, Error= -0.011645216213780306
area_pixel=0.042113113396123225 area_sum=0.07678977886848182, Error= -0.8234172844497124
area_pixel=0.10206300321222628 area_sum=0.10662320384564644, Error= -0.044680251314355705
area_pixel=0.09032959255696227 area_sum=0.09890206075850298, Error= -0.09490210194554875
area_pixel=0.05405730719101953 area_sum=0.0803776405557316, Error= -0.4868968643167011
area_pixel=0.06486418102965885 area_sum=0.08504369583806178, Error= -0.3111041330989122
area_pixel=0.07961206312065627 area_sum=0.09217586427332167, Error= -0.15781278188487957
area_pixel=0.11567416847953638 area_sum=0.11751408489279526, Error= -0.015906026707979987
area_pixel=0.03899188493468486 area_sum=0.07583816249914746, Error= -0.9449729764586564
area_pixel=0.10530031424726971 area_sum=0.10890885634782618, Error= -0.03426905348148129
area_pixel=0.08974770209027838 area_sum=0.09849411368900213, Error= -0.09745554922315022
area_pixel=0.05474040940657332 area_sum=0.08072049604999723, Error= -0.47460526738961833
area_pixel=0.06644918714957981 area_sum=0.08579443366184009, Error= -0.29112841468945794
area_pixel=0.07815101996878226 area_sum=0.09155079246491357, Error= -0.17145998224314793
area_pixel=0.11811873530334793 area_sum=0.11959505854816217, Error= -0.012498637417872821
area_pixel=0.0413972494959971 area_sum=0.07656418842293432, Error= -0.8494994076922351
area_pixel=0.10302869305435536 area_sum=0.10744525208257137, Error= -0.04286727218684554
area_pixel=0.09483751702327226 area_sum=0.10192184423145179, Error= -0.07469962764251938
area_pixel=0.04968735428679949 area_sum=0.07918713886310795, Error= -0.5937080973567899
area_pixel=0.12624685135862634 area_sum=0.12658534425443493, Error= -0.002681198716370686
area_pixel=0.07292481749928825 area_sum=0.08901112957273391, Error= -0.22058762195191864
area_pixel=0.07174377634256857 area_sum=0.08841385728354262, Error= -0.23235577761304713
area_pixel=0.12450135731947398 area_sum=0.1250951579271622, Error= -0.004769430795557527
area_pixel=0.04788770278107535 area_sum=0.07864101722504067, Error= -0.6421964859028207
area_pixel=0.09665547391303164 area_sum=0.10315078444549604, Error= -0.0672006485458726
area_pixel=0.10207284410790507 area_sum=0.10684959089949136, Error= -0.04679743014250308
area_pixel=0.042451700156050265 area_sum=0.0768864287184544, Error= -0.8111507533461285
area_pixel=0.11913084304184807 area_sum=0.12046110661371978, Error= -0.011166407774050775
area_pixel=0.08064791594041765 area_sum=0.09288655545895187, Error= -0.1517539464699383
area_pixel=0.06402646673778989 area_sum=0.08456843952285309, Error= -0.32083564550250054
area_pixel=0.05908485149852538 area_sum=0.082224048127862, Error= -0.3916265513490226
area_pixel=0.08552527294591528 area_sum=0.09559064428749622, Error= -0.11768885377245293
area_pixel=0.1130597812463634 area_sum=0.1152323204339288, Error= -0.019215844605530538
area_pixel=0.03630453556874613 area_sum=0.07491578714204401, Error= -1.0635379565780083
area_pixel=0.10811519768928335 area_sum=0.11098173966156559, Error= -0.026513774506711926
area_pixel=0.09033065463596301 area_sum=0.09884960024462953, Error= -0.09430846751856599
area_pixel=0.054267862709590275 area_sum=0.08066441123732206, Error= -0.486412163843463
area_pixel=0.0660267344673997 area_sum=0.08556065653189811, Error= -0.295848677389053
area_pixel=0.07857345851699904 area_sum=0.09182668967701964, Error= -0.16867312970770298
area_pixel=0.12006247452697849 area_sum=0.1212559689588405, Error= -0.009940611640432457
area_pixel=0.043405378913874415 area_sum=0.07716694788085048, Error= -0.7778199341138401
area_pixel=0.10101357172294456 area_sum=0.10609344882377486, Error= -0.0502890553634036
area_pixel=0.09613856114754782 area_sum=0.10276910367737876, Error= -0.06896860584021826
area_pixel=0.0483056484857336 area_sum=0.0787464207027933, Error= -0.6301700354162506
area_pixel=0.12487824294881023 area_sum=0.1253883621026603, Error= -0.004084932185178019
area_pixel=0.07046401268653213 area_sum=0.08773584962849086, Error= -0.2451157162847741
area_pixel=0.07408554985093474 area_sum=0.08955623311268268, Error= -0.20882187272519442
area_pixel=0.12263118597297762 area_sum=0.12342299996291214, Error= -0.006456872969564248
area_pixel=0.04610184051389865 area_sum=0.077977834716309, Error= -0.6914256317554276
area_pixel=0.09827120932201439 area_sum=0.10420386190981694, Error= -0.06037020027261983
area_pixel=0.09671215194481775 area_sum=0.10311234681820346, Error= -0.06617777336851678
area_pixel=0.04760569306460383 area_sum=0.07848600072570878, Error= -0.648668377103522
area_pixel=0.12413022185356226 area_sum=0.12469829377225909, Error= -0.004576419104180694
area_pixel=0.06980256509773852 area_sum=0.08738524192866963, Error= -0.25189155737058655
area_pixel=0.0746069729825436 area_sum=0.08975411958430458, Error= -0.20302588345602884
area_pixel=0.11830304345944853 area_sum=0.11971177541148283, Error= -0.011907825114551468
area_pixel=0.04176754779718905 area_sum=0.07662006234205823, Error= -0.8344400469499132
area_pixel=0.10237967149596372 area_sum=0.10685275736700003, Error= -0.04369115280090212
[ 7.21154891e-01  3.20619921e-02  4.24950906e-03 -1.81328256e-04
 -3.71999987e+01  9.99038595e-01  1.70266104e+01]
area_pixel=0.3162483597934198 area_sum=0.3174253016954389, Error= -0.003721574723068656
area_pixel=0.24311057254745805 area_sum=0.2600497496702889, Error= -0.0696768427030219
area_pixel=0.16860365236765773 area_sum=0.21967653369346593, Error= -0.3029168147226045
area_pixel=0.09285566528839695 area_sum=0.19579635166280646, Error= -1.108609647614821
area_pixel=0.01576774945500148 area_sum=0.18814793828945114, Error= -10.932453570903947
area_pixel=0.06752863879084003 area_sum=0.19124575955043382, Error= -1.8320689262342347
area_pixel=0.14373310781029858 area_sum=0.20978466196882295, Error= -0.4595430737203592
area_pixel=0.2186034780352415 area_sum=0.24470325423963207, Error= -0.11939323399137768
area_pixel=0.29216108377022465 area_sum=0.2964675523040342, Error= -0.014740048463115846
area_pixel=0.2878799981328086 area_sum=0.29298295310643363, Error= -0.01772597959817564
area_pixel=0.2141720790742454 area_sum=0.24241780051917625, Error= -0.13188330414973987
area_pixel=0.13916339910938547 area_sum=0.20843974100945917, Error= -0.4978057617407073
area_pixel=0.0628024143954562 area_sum=0.1908539162651179, Error= -2.0389582646193034
area_pixel=0.02057417287076646 area_sum=0.18799678892623883, Error= -8.137513819248632
area_pixel=0.09756650515308962 area_sum=0.1966136235495598, Error= -1.0151754256346208
area_pixel=0.17331785333976057 area_sum=0.22152013322326974, Error= -0.2781149140418713
area_pixel=0.24768782015379998 area_sum=0.26307840899106155, Error= -0.062137043427104736
area_pixel=0.32077011484482654 area_sum=0.32158395824315333, Error= -0.002537154680761005
area_pixel=0.3351439885154548 area_sum=0.33514501546596653, Error= -3.064206869080088e-06
area_pixel=0.2622778760051361 area_sum=0.2734626246584369, Error= -0.04264465163307102
area_pixel=0.18810753539353442 area_sum=0.22869440854779, Error= -0.21576420673071356
area_pixel=0.112597089661854 area_sum=0.2004521249652375, Error= -0.780260267536447
area_pixel=0.03576657783084869 area_sum=0.18854905950201395, Error= -4.271655018093185
area_pixel=0.04773197420838926 area_sum=0.18923075728158525, Error= -2.964444388062342
area_pixel=0.12433631227782627 area_sum=0.20352544620810403, Error= -0.6368946647969718
area_pixel=0.1996043725727077 area_sum=0.23418135417408037, Error= -0.1732275759078259
area_pixel=0.27356688770897364 area_sum=0.2817900736563061, Error= -0.030059142084770358
area_pixel=0.30870886862268065 area_sum=0.31065734495751024, Error= -0.006311695363734788
area_pixel=0.23532601277882037 area_sum=0.2552151726304691, Error= -0.08451747266181867
area_pixel=0.1606497150495585 area_sum=0.21645063902789305, Error= -0.3473453031716903
area_pixel=0.08461056606855522 area_sum=0.1941600618585331, Error= -1.2947495907451565
area_pixel=0.007332538774193154 area_sum=0.1882600255178571, Error= -24.674603478462007
area_pixel=0.07599244125652405 area_sum=0.19260768104550913, Error= -1.534563673186029
area_pixel=0.15213168229737306 area_sum=0.21286801714864104, Error= -0.39923528047593765
area_pixel=0.22694519825502368 area_sum=0.24981889990694206, Error= -0.1007895378610948
area_pixel=0.30045187561808007 area_sum=0.30355525113576626, Error= -0.010329026940843773
area_pixel=0.28385714726268674 area_sum=0.2899091102978157, Error= -0.021320453240264367
area_pixel=0.2100425868147937 area_sum=0.24016681336221424, Error= -0.14341961315674875
area_pixel=0.1348303695541304 area_sum=0.20700277247283105, Error= -0.5352829867437658
area_pixel=0.0583768113827432 area_sum=0.19030045072148266, Error= -2.2598637406519515
area_pixel=0.02517023462095125 area_sum=0.1882066162598655, Error= -6.477348506843306
area_pixel=0.10217425061892982 area_sum=0.19774440981658253, Error= -0.9353644251729548
area_pixel=0.17791520734201782 area_sum=0.22364028455116752, Error= -0.2570048839121967
area_pixel=0.25227715387468663 area_sum=0.26636300595097906, Error= -0.05583483030448836
area_pixel=0.32534669913203373 area_sum=0.32585733184571547, Error= -0.0015695032869367097
area_pixel=0.3325208268647728 area_sum=0.332574505940386, Error= -0.00016143071734583676
area_pixel=0.25955692012336584 area_sum=0.2715951569509286, Error= -0.046379949422427555
area_pixel=0.1852598537926653 area_sum=0.22735970352347062, Error= -0.22724755994853388
area_pixel=0.10962093428884856 area_sum=0.1996581937297021, Error= -0.8213509584182843
area_pixel=0.03270177267216923 area_sum=0.18846476744745183, Error= -4.7631361252732445
area_pixel=0.050905655057214005 area_sum=0.18960967509690219, Error= -2.72472714247161
area_pixel=0.12750526999172962 area_sum=0.2045753610924949, Error= -0.6044463190091225
area_pixel=0.20284220619853954 area_sum=0.23605078743082697, Error= -0.16371632834531125
area_pixel=0.2767808299573389 area_sum=0.2843384019164127, Error= -0.027305257955323996
area_pixel=0.3091107047459474 area_sum=0.311041079994932, Error= -0.0062449317326981335
area_pixel=0.23571594882840685 area_sum=0.25550239591555235, Error= -0.08394191053041283
area_pixel=0.16096577478506902 area_sum=0.2166355213576317, Error= -0.34584834351834237
area_pixel=0.08487537174418236 area_sum=0.1942563498502238, Error= -1.2887245835661247
area_pixel=0.007541255126128021 area_sum=0.1883390724048897, Error= -23.974499503717286
area_pixel=0.07587563674286457 area_sum=0.1927295874102262, Error= -1.5400720927505192
area_pixel=0.15205655202905177 area_sum=0.21297699584831323, Error= -0.40064333306480643
area_pixel=0.22698276515797033 area_sum=0.24989298302707477, Error= -0.1009337332425213
area_pixel=0.3005084896190553 area_sum=0.3036349158753642, Error= -0.01040378679574792
area_pixel=0.28301025224994447 area_sum=0.28927039620193623, Error= -0.02211984867058111
area_pixel=0.20910608233180739 area_sum=0.2396737877741661, Error= -0.14618276571149272
area_pixel=0.1338366984023267 area_sum=0.20668548113632879, Error= -0.5443109670488975
area_pixel=0.05732856593776603 area_sum=0.19028903236880437, Error= -2.319270755444603
area_pixel=0.02633581865649859 area_sum=0.18833998696365073, Error= -6.151476451907305
area_pixel=0.10334170301746326 area_sum=0.19810608231739957, Error= -0.9170003641600767
area_pixel=0.17911164193798612 area_sum=0.2242924149012735, Error= -0.2522492255357155
area_pixel=0.2535589826204898 area_sum=0.26731587383154576, Error= -0.05425519170680039
area_pixel=0.3266280719613661 area_sum=0.32707163550693535, Error= -0.0013580080331298092
area_pixel=0.2633131348180413 area_sum=0.27429164136797396, Error= -0.04169372924567242
area_pixel=0.18902017801996607 area_sum=0.22923213673949794, Error= -0.2127389739061843
area_pixel=0.11342920572148785 area_sum=0.20075891426654055, Error= -0.7699049639779775
area_pixel=0.03652948116938859 area_sum=0.18868389615681366, Error= -4.165249823338012
area_pixel=0.04716666270215342 area_sum=0.18943842789912257, Error= -3.0163627665451442
area_pixel=0.12387038478473755 area_sum=0.2036488774743464, Error= -0.6440481542722922
area_pixel=0.19928650128962033 area_sum=0.23423648635203115, Error= -0.17537557655055866
area_pixel=0.2733680167453443 area_sum=0.28170080809666015, Error= -0.030481954145639048
area_pixel=0.3151046330341387 area_sum=0.31633237117646545, Error= -0.003896287180879773
area_pixel=0.24177139290826233 area_sum=0.25938686981480646, Error= -0.07286005467664303
area_pixel=0.16712300479208864 area_sum=0.21924139304837004, Error= -0.31185645759014385
area_pixel=0.0910896551757503 area_sum=0.195600147785569, Error= -1.1473365708561962
area_pixel=0.013839860300606688 area_sum=0.18831736949485467, Error= -12.606883697128037
area_pixel=0.06971547380450005 area_sum=0.1919289271858045, Error= -1.7530319556318605
area_pixel=0.1460448710809601 area_sum=0.21093711727245834, Error= -0.4443308807162778
area_pixel=0.2211077637641452 area_sum=0.2464380208952605, Error= -0.11456068615543955
area_pixel=0.2947892935060068 area_sum=0.29874459478635623, Error= -0.01341738444197885
area_pixel=0.2931110358344142 area_sum=0.29731957113173924, Error= -0.014358160501682777
area_pixel=0.21932969808296576 area_sum=0.2454634010956124, Error= -0.1191525964840432
area_pixel=0.14425529718059948 area_sum=0.2103559341545839, Error= -0.45821982461573074
area_pixel=0.0678768532043108 area_sum=0.19170761485521115, Error= -1.8243444680348846
area_pixel=0.015722368042034418 area_sum=0.18830140786212451, Error= -10.976656910631574
area_pixel=0.09294335108705098 area_sum=0.19596483295523684, Error= -1.1084330472622583
area_pixel=0.16891666467091682 area_sum=0.21997849216163964, Error= -0.3022900528506255
area_pixel=0.24357351180874787 area_sum=0.2605144924477917, Error= -0.06955181831243516
area_pixel=0.3168708228495447 area_sum=0.3179731509015596, Error= -0.003478793162784448
area_pixel=0.2710631871144926 area_sum=0.27991283223707675, Error= -0.03264790478113202
area_pixel=0.19696115396294545 area_sum=0.23316205130188028, Error= -0.18379714278961504
area_pixel=0.1214387298301034 area_sum=0.20303492624664138, Error= -0.6719124659051822
area_pixel=0.0446689612829303 area_sum=0.18930859299093517, Error= -3.238034365560167
area_pixel=0.03903613195652156 area_sum=0.18885585878134378, Error= -3.8379757244311867
area_pixel=0.11591426957792095 area_sum=0.20145300012799877, Error= -0.7379482341695316
area_pixel=0.19150018698596227 area_sum=0.23045358088976126, Error= -0.20341177999295856
area_pixel=0.2657337485833722 area_sum=0.2760045347974807, Error= -0.038650665445627994
area_pixel=0.3222386194771545 area_sum=0.3229856609524451, Error= -0.002318286605443799
area_pixel=0.2490296734347055 area_sum=0.26414082364545255, Error= -0.06068011896867032
area_pixel=0.17448194563318253 area_sum=0.2223541778052593, Error= -0.2743678264152308
area_pixel=0.09859402488583413 area_sum=0.1971960039311532, Error= -1.0000806758776117
area_pixel=0.021441183690896537 area_sum=0.18837731126207918, Error= -7.785770131807607
area_pixel=0.06218567341007741 area_sum=0.19086877457137236, Error= -2.0693367797548268
area_pixel=0.13869416433347936 area_sum=0.20839072580829415, Error= -0.5025197837973544
area_pixel=0.21387740728798832 area_sum=0.24236963199299888, Error= -0.1332175523646846
area_pixel=0.2877265125863744 area_sum=0.29298711444407266, Error= -0.018283340698814
area_pixel=0.3004402363939178 area_sum=0.303600641483933, Error= -0.010519247115328041
area_pixel=0.2268235323436727 area_sum=0.24984623093141892, Error= -0.10150048520037716
area_pixel=0.15189401551023707 area_sum=0.21303058804816452, Error= -0.40249493920191404
area_pixel=0.07560254653373022 area_sum=0.19280996485282426, Error= -1.5503104550426978
area_pixel=0.007855636670086596 area_sum=0.1883701121219128, Error= -22.978974592753957
area_pixel=0.08524286926645885 area_sum=0.19435012991211917, Error= -1.2799576267734991
area_pixel=0.16136464619074076 area_sum=0.21680879610280904, Error= -0.3435953985021641
area_pixel=0.23612869121810576 area_sum=0.2557847081568589, Error= -0.08324281491315001
area_pixel=0.3095662602127476 area_sum=0.31145228925042306, Error= -0.006092489008263765
area_pixel=0.27737650871887354 area_sum=0.28484318767074285, Error= -0.02691893046875478
area_pixel=0.20335720410827207 area_sum=0.2364081307812203, Error= -0.16252646085432584
area_pixel=0.12796221102990302 area_sum=0.20484257754165658, Error= -0.6008052368975374
area_pixel=0.05132761493532456 area_sum=0.18980200252948415, Error= -2.697853538853197
area_pixel=0.032348638250020656 area_sum=0.18852647031578124, Error= -4.827956925378794
area_pixel=0.10935502368892713 area_sum=0.19961445968068325, Error= -0.8253798769090792
area_pixel=0.18502779705186612 area_sum=0.22726292353672958, Error= -0.2282636833914437
area_pixel=0.25940934304914265 area_sum=0.2715159237570396, Error= -0.04666979440907595
area_pixel=0.33239200799186364 area_sum=0.3324826590476647, Error= -0.0002727233315528516
area_pixel=0.32806663025375826 area_sum=0.32842573916217543, Error= -0.0010946218703785946
area_pixel=0.25501563476734646 area_sum=0.2683640057705975, Error= -0.05234334363627901
area_pixel=0.1805523038249106 area_sum=0.22502046808368545, Error= -0.24628965300768216
area_pixel=0.10484839677616975 area_sum=0.19849448753573104, Error= -0.8931571072038123
area_pixel=0.027780706427876112 area_sum=0.18839753156619068, Error= -5.781596143183247
area_pixel=0.055901844324466765 area_sum=0.19019891689204785, Error= -2.4023728410120233
area_pixel=0.13245086773965653 area_sum=0.20621132104509224, Error= -0.5568891662561106
area_pixel=0.2077403838853087 area_sum=0.23890216466206007, Error= -0.15000348123913876
area_pixel=0.28168838271031404 area_sum=0.2882412679482228, Error= -0.023262887787061096
area_pixel=0.3036679509148854 area_sum=0.3063570335937469, Error= -0.008855339099038458
area_pixel=0.23013353029770656 area_sum=0.2519202767485691, Error= -0.09467002232433774
area_pixel=0.15527976347109984 area_sum=0.21418418731666777, Error= -0.37934385349917815
area_pixel=0.07912305701536582 area_sum=0.1932629017618802, Error= -1.442561107369098
area_pixel=0.004270495138143815 area_sum=0.188569657946917, Error= -43.15639213884679
area_pixel=0.08171443432242143 area_sum=0.19372282563559082, Error= -1.370729568673471
area_pixel=0.15785913032920718 area_sum=0.21533079423596513, Error= -0.36406930525275116
area_pixel=0.23267664257012655 area_sum=0.25358055258180084, Error= -0.08984103337907696
area_pixel=0.30615817813110624 area_sum=0.30851641426865656, Error= -0.007702672363501097
area_pixel=0.2827987436141157 area_sum=0.28907071497267317, Error= -0.022178215074094083
area_pixel=0.20893762266676674 area_sum=0.23950680288442894, Error= -0.1463076866075804
area_pixel=0.13369499035069055 area_sum=0.20655228590143038, Error= -0.5449515749216217
area_pixel=0.05717610973642451 area_sum=0.19016647747794538, Error= -2.3259779015150146
area_pixel=0.026447626860885975 area_sum=0.18843138062414674, Error= -6.124698999093276
area_pixel=0.10350506590110342 area_sum=0.19822878807513072, Error= -0.9151602518135057
area_pixel=0.17925718032221027 area_sum=0.2244265387471306, Error= -0.25198074823964944
area_pixel=0.2537146360561806 area_sum=0.2674670217120998, Error= -0.054204147895015264
area_pixel=0.32676999984669663 area_sum=0.32721468540180676, Error= -0.0013608518386594483
area_pixel=0.33228527791060714 area_sum=0.33234618542055966, Error= -0.00018329885192478853
area_pixel=0.2593125452043026 area_sum=0.27137676375823494, Error= -0.04652385230505303
area_pixel=0.1850399926603572 area_sum=0.22717013127999455, Error= -0.22768125967756417
area_pixel=0.10939551576598205 area_sum=0.19950410594224735, Error= -0.8236954645291387
area_pixel=0.0324803256059738 area_sum=0.188350920570647, Error= -4.798923411531484
area_pixel=0.05116354009351909 area_sum=0.1897881212412188, Error= -2.7094407637609765
area_pixel=0.12777032001296362 area_sum=0.20477853245211183, Error= -0.6027081440457763
area_pixel=0.20311429628934263 area_sum=0.2362889406485346, Error= -0.16332993277801403
area_pixel=0.27710401884821323 area_sum=0.2846414590272934, Error= -0.02720076096481611
area_pixel=0.3064926910713126 area_sum=0.3087457943571933, Error= -0.007351246380477145
area_pixel=0.23304752811979768 area_sum=0.25371599247601223, Error= -0.08868776477899379
area_pixel=0.15832508960892255 area_sum=0.2153977937851785, Error= -0.36047795278203065
area_pixel=0.08224645176300527 area_sum=0.19358374996717953, Error= -1.3537033612707674
area_pixel=0.0048831529783157634 area_sum=0.18833217194333302, Error= -37.567739487098805
area_pixel=0.07843739213718948 area_sum=0.1931715652964236, Error= -1.4627484422042032
area_pixel=0.15459365008597103 area_sum=0.21394863116266327, Error= -0.38394190863392097
area_pixel=0.2294679376169313 area_sum=0.25152957536458437, Error= -0.09614257214653789
area_pixel=0.30292545925210845 area_sum=0.3057232072472447, Error= -0.009235763814780104
area_pixel=0.28499139748399926 area_sum=0.2907294346234526, Error= -0.020134071379384253
area_pixel=0.2112129043374864 area_sum=0.2407098282028552, Error= -0.13965493234370352
area_pixel=0.1360951441490741 area_sum=0.20730767684290902, Error= -0.5232554999598743
area_pixel=0.05965767815867906 area_sum=0.1903207599058092, Error= -2.190213997259314
area_pixel=0.023880824440844606 area_sum=0.1883405233019016, Error= -6.88668430474172
area_pixel=0.10089743077433866 area_sum=0.1975985528551173, Error= -0.9584101531490405
area_pixel=0.1766548864688673 area_sum=0.22318010267156244, Error= -0.2633678418564125
area_pixel=0.25109088769037413 area_sum=0.2655975809287263, Error= -0.057774670247056986
area_pixel=0.32417700640380787 area_sum=0.32478500869308446, Error= -0.0018755256457617078
area_pixel=0.33145182584890165 area_sum=0.3315266847325048, Error= -0.00022585147452852428
area_pixel=0.2585468538588884 area_sum=0.2707660793719313, Error= -0.0472611649713285
area_pixel=0.18431353138899453 area_sum=0.22673224761704203, Error= -0.230144341049614
area_pixel=0.10871529186361073 area_sum=0.19921525714434177, Error= -0.832449269365603
area_pixel=0.031879361127160166 area_sum=0.18817886639838455, Error= -4.902843085461407
area_pixel=0.0516786050759066 area_sum=0.18972920865569384, Error= -2.6713299125821153
area_pixel=0.12821845710443824 area_sum=0.20480976716609148, Error= -0.5973501147285452
area_pixel=0.20348000269607525 area_sum=0.23646917599420864, Error= -0.1621248911983118
area_pixel=0.27742223519467046 area_sum=0.2848668964954997, Error= -0.026835128394107295
area_pixel=0.30448904708695324 area_sum=0.3069801039112242, Error= -0.008181104864371699
area_pixel=0.23109311817280087 area_sum=0.25240391903066006, Error= -0.09221737551666921
area_pixel=0.1563911444396311 area_sum=0.21450563771866094, Error= -0.37159708426753507
area_pixel=0.08034023396766088 area_sum=0.19312989938141578, Error= -1.403900136252476
area_pixel=0.003030390955018447 area_sum=0.18826638002902615, Error= -61.12610281100846
area_pixel=0.08016458138626348 area_sum=0.19330112071777367, Error= -1.411303313446811
area_pixel=0.15625257357013567 area_sum=0.2146009744277408, Error= -0.3734236148847482
area_pixel=0.23094086131234093 area_sum=0.25241853923906143, Error= -0.09300077000090755
area_pixel=0.3043974758491643 area_sum=0.3069515382822804, Error= -0.008390550631180861
area_pixel=0.2794759217164895 area_sum=0.2863588885133661, Error= -0.024628120929354843
area_pixel=0.2056873359875837 area_sum=0.23752623815656224, Error= -0.15479271981479928
area_pixel=0.1305269986732256 area_sum=0.20527723159311873, Error= -0.5726802399481381
area_pixel=0.05410651131387567 area_sum=0.1895974495526617, Error= -2.5041521796294273
area_pixel=0.029328670887437625 area_sum=0.18822537933908215, Error= -5.417794384937672
area_pixel=0.10622409484210493 area_sum=0.19865334343013114, Error= -0.8701344899706244
area_pixel=0.18179639942024295 area_sum=0.22559809131176356, Error= -0.2409381705644678
area_pixel=0.25606986659449404 area_sum=0.26906495574232875, Error= -0.05074821696382342
area_pixel=0.32897514851033804 area_sum=0.32921667662545373, Error= -0.0007341834670775917
area_pixel=0.324203523021545 area_sum=0.32475121655333133, Error= -0.0016893509567135576
area_pixel=0.2512669572231374 area_sum=0.26555627768050605, Error= -0.05686907906748367
area_pixel=0.17697580562618498 area_sum=0.22307486174973945, Error= -0.26048225044346823
area_pixel=0.10136939449070326 area_sum=0.19729598245497995, Error= -0.9463072009675886
area_pixel=0.024478376357279785 area_sum=0.18793028725846134, Error= -6.6774000250458405
area_pixel=0.05889322163771027 area_sum=0.19029184769810842, Error= -2.231133268081594
area_pixel=0.13523648926715737 area_sum=0.20704031204379167, Error= -0.5309500650729485
area_pixel=0.21030702373043653 area_sum=0.2402176739630025, Error= -0.14222373414833878
area_pixel=0.28401961730821057 area_sum=0.28994393843399036, Error= -0.020858844828844585
CPU times: user 1min 59s, sys: 4.61 s, total: 2min 3s
Wall time: 7.97 s
[68]:
ax = jupyter.plot1d(res, calibrant=LaB6_new)
ax.figure.show()
/mntdirect/_scisoft/users/kieffer/.jupy37/lib/python3.7/site-packages/matplotlib/pyplot.py:514: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)
[69]:
fig, ax = plt.subplots()
ax.plot(*calc_fwhm(res, LaB6_new, 10, 95), "o", label="FWHM")
ax.plot(*calc_peak_error(res, LaB6_new, 10, 95), "o", label="error")
ax.set_title("Peak shape & error as function of the angle")
ax.set_xlabel(res.unit.label)
ax.legend()
fig.show()
28457
68 60
[70]:
print("total run time: ", time.time()-start_time)
total run time:  1788.4090461730957

Conclusion

The calibration works and the FWHM of every single peak is pretty small: 0.02°. The geometry has been refined with the wavelength: The goniometer scale parameter refines to 0.999 instead of 1 and the wavelength is fitted with a change at the 5th digit which is pretty precise.