%%latex
\tableofcontents
\newpage
__version__ = '2.5'
print("JupyLabBook version: %s"%__version__)
print("More info on: %s"%"https://gitlab.com/soleil-data-treatment/soleil-beamlines/soleil-beamline-sirius/JupyLabBook")
# import custom libraries
import lib.frontend as FE
from lib.extraction.common import PyNexus as PN
from lib.extraction import GIXD as GIXD
from lib.extraction import GIXS as GIXS
from lib.extraction import PilatusSum as PilatusSum
from lib.extraction import Isotherm as Isotherm
from lib.extraction import Sensors1D as Sensors1D
from lib.extraction import XRF as XRF
from lib.extraction import XRR as XRR
#import useful libraries
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import set_matplotlib_formats, Javascript, display
# necessary for plotting in the notebook
%matplotlib inline
# to avoid having a large notebook
set_matplotlib_formats('png', 'pdf')
# to have all the cells expanded (not collapsed)
display(Javascript('IPython.OutputArea.prototype._should_scroll = function(lines) {return false;}'))
# define the class experiment
class Experiment:
"""
Class Experiment is used to pass arguments concerning the current experiment only.
"""
def __init__(self):
pass
# test if the expt already exists (avoid loosing info when reloading this cell)
try:
expt.notebook_name
except:
expt = Experiment()
# necessary for saving in pdf
expt.notebook_name = 'Example.ipynb'
# directory where the data will be saved
expt.working_dir = "working/"
# directory where the nexus files are
#expt.recording_dir = "Z:\\com-sirius\\users\\2021\\week15\\"
expt.recording_dir = "recording/"
# directory where the logs are
#expt.logs_dir = "Z:\\com-sirius\\commissionning\\2021\\week15\\logs\\"
expt.logs_dir = "logs/"
FE.Action.Check_and_init(expt)
JupyLabBook version: 2.5 More info on: https://gitlab.com/soleil-data-treatment/soleil-beamlines/soleil-beamline-sirius/JupyLabBook
Data reduction will be saved in the folder: working/ The original nexus files should be in the folder: recording/ The log files should be in the folder: logs/
$\LARGE \textbf{SIRIUS Beamline}:\textbf{Experiment 1234}$
$\Large \color{red}{\bf Example\ }$
Here we show functions used during beamline aligment.
LaTeX formula can be used: $$\frac{786-558}{2 \times 2069} \times 0.0355 = 1.9mrad$$
Fit with erf function.
xData, yData, yFit = \
Sensors1D.GaussianRepartitionFit(nxs_filename='SIRIUS_2020_03_11_0744.nxs', recording_dir = expt.recording_dir, \
xLabel='basez', yLabel='camxdeflected', verbose=False)
xData, yData, yFit = \
Sensors1D.GaussianFit(nxs_filename='SIRIUS_2020_03_11_0752.nxs', recording_dir = expt.recording_dir, \
xLabel='delta', yLabel='pilatusroi1', verbose=False)
calib_thetaz_data = np.array([
# gamma channel
[0, 970],
[-1, 899],
[-2, 827],
[-3, 755],
[-4, 683],
[-5, 611],
[-6, 539],
])
expt.thetazfactor=GIXD.Calib_thetaz(calib_thetaz_data)
Extraction of the Vineyard.
Extraction of the Vineyard.expt.channel0 = \
GIXD.Extract_channel0(nxs_filename='SIRIUS_2020_03_12_0756.nxs', recording_dir=expt.recording_dir, \
binsize=10, logx=False, logy=False, logz=False, nblevels=50, cmap='jet', show_data_stamps = True, verbose=True)
- Open Nexus Data File :
recording/SIRIUS_2020_03_12_0756.nxs
. Number of data points: 101
. Available Counters:
0 -------> delta
1 -------> zs
2 -------> gamma
3 -------> hu36energy
4 -------> xs
5 -------> energydcm
6 -------> current
7 -------> mon2
8 -------> surfacepressure
9 -------> areapermolecule
10 -------> qxy
11 -------> pilatus
12 -------> pilatusroi1
13 -------> integration_time
14 -------> sensorsRelTimestamps
15 -------> sensorsTimestamps
. Pilatus data found, (column 11, alias pilatus)
. qxy data found, (column 10, alias qxy)
. Valid data between points 0 and 100
. Surface pressure data found, mean value 19.74 ± 0.006119 mN/m
. Area per molecule data found, mean value 0.3557 ± 3.944e-05 nm2 per molecule
. Gamma motor data found, mean value -0.0004471 deg
Data not saved. To save data, run a GIXD on the scan. Channel0: 607
Classic GIXD with: $$q_{xy} = \frac{4\pi}{\lambda}\sin{\left(\frac{2\theta}{2}\right)}$$
Generates:
x, y, daty, datyTop, datyBottom, datyFirstQuarter, mat, mat_binned, ch_binned, mean_pi, mean_area, mean_gamma = \
GIXD.Treat(nxs_filename='SIRIUS_2020_03_12_0756.nxs', recording_dir=expt.recording_dir, channel0=607.0, \
thetazfactor=0.00024318628377198605, wavelength=0.155, thetac=0.0028, binsize=10, computeqz=True, \
absorbers='29 - Vide', logx=False, logy=False, logz=False, nblevels=50, cmap='jet', working_dir=expt.working_dir, \
moytocreate=[10, 20, 40], show_data_stamps=True, plot=True, save=True, verbose=True)
- Open Nexus Data File :
recording/SIRIUS_2020_03_12_0756.nxs
. Number of data points: 101
. Available Counters:
0 -------> delta
1 -------> zs
2 -------> gamma
3 -------> hu36energy
4 -------> xs
5 -------> energydcm
6 -------> current
7 -------> mon2
8 -------> surfacepressure
9 -------> areapermolecule
10 -------> qxy
11 -------> pilatus
12 -------> pilatusroi1
13 -------> integration_time
14 -------> sensorsRelTimestamps
15 -------> sensorsTimestamps
. Pilatus data found, (column 11, alias pilatus)
. qxy data found, (column 10, alias qxy)
. Valid data between points 0 and 100
. Surface pressure data found, mean value 19.74 ± 0.006119 mN/m
. Area per molecule data found, mean value 0.3557 ± 3.944e-05 nm2 per molecule
. Gamma motor data found, mean value -0.0004471 deg
Absorbers: 29 - Vide
. Original, non binned, matrix saved in: working/SIRIUS_2020_03_12_0756_1D.mat . Scalar data saved in: working/SIRIUS_2020_03_12_0756_1D.dat . qz values saved in: working/SIRIUS_2020_03_12_0756_1D_qz.dat10 . Binned matrix saved in: working/SIRIUS_2020_03_12_0756_1D.mat10 . XYZ data saved in: working/SIRIUS_2020_03_12_0756_1D.moy10 . qz values saved in: working/SIRIUS_2020_03_12_0756_1D_qz.dat20 . Binned matrix saved in: working/SIRIUS_2020_03_12_0756_1D.mat20 . XYZ data saved in: working/SIRIUS_2020_03_12_0756_1D.moy20 . qz values saved in: working/SIRIUS_2020_03_12_0756_1D_qz.dat40 . Binned matrix saved in: working/SIRIUS_2020_03_12_0756_1D.mat40 . XYZ data saved in: working/SIRIUS_2020_03_12_0756_1D.moy40
area, pressure, time = \
Isotherm.Treat(nxs_filename='SIRIUS_Isotherm_2019_02_17_01544.nxs', recording_dir=expt.recording_dir, \
working_dir=expt.working_dir, fast=True, show_data_stamps=False, plot=True, save=True, verbose=False)
Add a 1D plot by clicking on '''Add plot to report'''.
Generates SIRIUS_2020_03_12_0760.dat
Add a 1D plot by clicking on '''Add plot to report'''.
Generates SIRIUS_2020_03_12_0760.datxData, yData = \
Sensors1D.Treat(nxs_filename='SIRIUS_2020_03_12_0760.nxs', recording_dir=expt.recording_dir, \
xLabel='zs', yLabel='camxreflected', working_dir=expt.working_dir, show_data_stamps=False, \
plot=True, save=True, verbose=False)
GIXS: $q_z$ vs $q_{xy}$.
Image and profiles with the approximation $q_{xy} = \frac{4\pi}{\lambda}\sin{\left(\frac{2\theta}{2}\right)}$.
Generates:
images_sum, integrated_qxy, integrated_qz, qxy_array, qz_array = \
GIXS.Treat(nxs_filename='SIRIUS_2019_11_07_00325.nxs', recording_dir=expt.recording_dir, \
wavelength=0.1208, distance=435.5, pixel_PONI_x=565.5, pixel_PONI_y=996.5, pixel_size=0.172, \
force_gamma=True, force_delta=True, force_thetai=True, fgamma=0.0, fdelta=11.578, fthetai=0.0, \
qxymin=0.0, qxymax=18.0, qzmin=0.0, qzmax=19.0, \
absorbers='29 - Vide', logz=True, cmap='viridis', working_dir=expt.working_dir, \
show_data_stamps=False, plot=True, save=True, verbose=False)
Absorbers: 29 - Vide gamma is forced to the value: gamma = 0 deg delta is forced to the value: delta = 11.58 deg thetai is forced to the value: thetai = 0 deg
Plot the sum of the images from the Pilatus (time integration).
Generates:
images_sum, integrated_x, integrated_y = \
PilatusSum.Treat(nxs_filename='SIRIUS_2019_11_07_00325.nxs', recording_dir=expt.recording_dir, \
xmin=0.0, xmax=600.0, ymin=200.0, ymax=900.0, \
absorbers='29 - Vide', logz=True, cmap='Greys', working_dir=expt.working_dir, \
show_data_stamps=False, plot=True, save=True, verbose=False)
Absorbers: 29 - Vide
Plot XRF from the 4-elements detector, in channels and without peak identification.
Generates:
channels, eVs, spectrums = \
XRF.Treat(nxs_filename='SIRIUS_2017_12_11_08042.nxs', recording_dir=expt.recording_dir, \
list_elems=[0, 1, 2], absorbers='Al 200micron', logz=True, first_channel=100, last_channel=800, use_eV=True, \
gain=10.0, eV0=0.0, arr_peaks=[(None, None)], working_dir=expt.working_dir, fast=True, \
show_data_stamps=False, plot_spectrogram=True, plot_sum=True, plot_first_last=True, save=True, verbose=False)
Absorbers: Al 200micron
Plot XRF from the 1-element detector, in eVs and with peak identification.
Generates:
channels, eVs, spectrums = \
XRF.Treat(nxs_filename='SIRIUS_Fluo_2020_07_03_0042.nxs', recording_dir=expt.recording_dir, \
list_elems=[4], absorbers='Al 800micron', logz=True, first_channel=170, last_channel=1250, use_eV=True, \
gain=9.89, eV0=6.0, arr_peaks=[('Elastic', '12000'), ('Compton', '11670'), ('Cl (Ka1)', '2622'), ('Fe (Ka1)', '6400'), \
('K (Ka1)', '3314')], working_dir=expt.working_dir, fast=True, \
show_data_stamps=False, plot_spectrogram=True, plot_sum=True, plot_first_last=True, save=True, verbose=False)
Absorbers: Al 800micron
To start the calibration click on '''Calib. XRR'''.
# For each line of the table:
# 1) Move m4pitch and zs to their suggested values
# 2) Move c10tablepitch and gamma to their suggested value
# 3) Adjust the attenuators
# 4) Align gamma so that the reflection is in the center of the ROI
# 5) Align c10tablepitch and zs around their suggested values
# 6) Replace the values in the table
#
# When done, execute the cell
# Use the value of each fit in the XRR scripts
#
calib_XRR_data = np.array([
# m4pitch c10tablepitch gamma zs
[-0.08, -3335, 5.6, 34.5],
[-0.31, -7935, 3.72396, 16.744],
[-0.54, -12535, 1.84793, -1.012],
[-0.77, -17135, -0.0281093, -18.768],
[-1, -21735, -1.90415, -36.524],
])
expt.distance = 435.5
XRR.Calib(calib_XRR_data, distance=expt.distance)
Select the first scan of the XRR series and click on '''Plot XRR'''. Here we show only a few point for the example.
m4pitch, theta, qz, gains, I0, I, Inorm = \
XRR.Treat(nxs_filename='SIRIUS_2021_04_14_4298.nxs', recording_dir=expt.recording_dir, \
direct_nxs_filename='SIRIUS_2021_04_14_4297.nxs', ROIx0=550, ROIy0=905, ROIsizex=40, ROIsizey=40, \
m4pitch0=-0.0375, wavelength=0.1208, force_direct=False, fdirect=1.0, working_dir=expt.working_dir, \
plot_gains=False, plot_XRR_m4pitch=True, plot_XRR_qz=True, save=True, verbose=False)
Direct extracted from SIRIUS_2021_04_14_4297.nxs: direct=2.45544e+12
Script inserted (with automatic scan numbering) using '''Insert script'''.
%shopen
%amove delta -40
%run reset_motors.ipy
%amove delta -35
%continuous_ascan delta -35 -25 250 5 #123
%run reset_motors.ipy
for i in range(4):
%amove delta -20
%continuous_ascan delta -10 -3 175 5 #124 #126 #128 #130
%run reset_motors.ipy
%run cont_regh_abs.ipy #125 #127 #129 #131
for i in range(3):
%amove delta -20
%continuous_ascan delta -10 -3 175 5 #132 #135 #138
%run reset_motors.ipy
%run cont_regh_abs.ipy #133 #136 #139
%run cont_regh_abs.ipy #134 #137 #140
for i in range(2):
%amove delta -20
%tscan 10 100 #141 #142
%continuous_ascan delta -35 -25 250 5 #143
%amove delta -40
%shclose
Positions extracted from the logs, using '''Insert positions'''.
| m4roll | m4pitch | m4tracks_mot | m4tz |
|---|---|---|---|
| 2.10 | -0.0802 | 1.001 | 2.42 |
| deg | deg | mm | mm |
| deltacodeur | euchi | euth | euphi | kappa_h | kappa_k |
|---|---|---|---|---|---|
| 1.00196 | -89.57961 | 90.42039 | -0.00580 | -0.08252 | |
| Degrees | deg | deg | deg |
| kappa_l | qxy | qxy0 | qz | basexPoint | basexTrait |
|---|---|---|---|---|---|
| -0.18486 | 2.0556 | 23.82 | -0.92 | -15.7275 | -15.7274 |
| nm-1 | nm-1 | nm-1 |
| basezPlan | basezPoint | basezTrait | basepitch | baseroll | basex |
|---|---|---|---|---|---|
| 71.1257 | 71.1257 | 71.1257 | -0.0000 | 0.000 | -15.727 |
| mrad | mrad | mm |
| baseyaw | basez | alphax | alphay | delta | delta0 |
|---|---|---|---|---|---|
| -0.000 | 71.126 | 0.2998 | 0.2000 | -2.9110 | -34.2322 |
| mrad | mm |
| deltaa | etaa | gamma | kappav | mu | kphi |
|---|---|---|---|---|---|
| 0.0000 | 0.0000 | 1.2997 | 1.3080 | -179.9997 | 0.0000 |
| thetaa | thetah | komega | xs | ky | ys |
|---|---|---|---|---|---|
| 0.0000 | 0.0185 | 0.0000 | 0.0000 | -0.1000 | 0.0000 |
| kz | zs | kx |
|---|---|---|
| 0.0000 | -41.9999 | -0.1000 |
Commands extracted from the logs, using '''Insert commands'''.
Wed, 11 Mar 2020 16:44:04 amove basez -67
Wed, 11 Mar 2020 16:44:11 amove basez 67
Wed, 11 Mar 2020 16:44:58 amove basez 75
Wed, 11 Mar 2020 16:46:26 shopen
Wed, 11 Mar 2020 16:46:34 ct 1
Wed, 11 Mar 2020 16:46:47 ct 1
Wed, 11 Mar 2020 16:46:56 dmove basez 1
Human-readable logs generated in the folder /working/readable_logs/ by clicking on '''Convert logs'''.
Using the command "Insert image".

PDF generated by clicking on '''Export to pdf'''.
FE.Action.Choose(expt)
Export in progress...