Run the integrated benchmarks.
See the documentation of pyFAI.benchmark.run_benchmark
Runs the test suite of the installed version
Parameters: | deprecation – enable/disables deprecation warning in the tests |
---|
Utilities, mainly for image treatment
Bases: exceptions.RuntimeError
Exception returned if creation of an ImageReductionFilter is not possible
Bases: object
Process images to generate an average using different algorithms.
Constructor
Defines another algorithm which will be computed on the source.
Parameters: | algorithm (ImageReductionFilter) – An averaging algorithm. |
---|
Returns the number of frames used for the process.
Return type: | int |
---|
Returns source images as fabio images.
Return type: | list(fabio.fabioimage.FabioImage) |
---|
Returns the result of an algorithm. The process must be already done.
Parameters: | algorithm (ImageReductionFilter) – An averaging algorithm |
---|---|
Return type: | numpy.ndarray |
Process source images to all defined averaging algorithms defined using defined parameters. To access to the results you have to define a writer (AverageWriter). To follow the process forward you have to define an observer (AverageObserver).
Defines if the dark must be applied on the flat.
Parameters: | correct_flat_from_dark (bool) – If true, the dark is applied. |
---|
Defines images used as dark.
Parameters: | dark_list (list) – List of dark used |
---|
Defines images used as flat.
Parameters: | flat_list (list) – List of dark used |
---|
Defines the set set of source images to used to process an average.
Parameters: | image_list (list) – List of filename, numpy arrays, fabio images used as source for the computation. |
---|
Defines the monitor name used to correct images before processing the average. This monitor must be part of the file header, else the image is skipped.
Parameters: | monitor_name (str) – Name of the monitor available on the header file |
---|
Set an observer to the average process.
Parameters: | observer (AverageObserver) – An observer |
---|
Defines the filter applied on each pixels of the images before processing the average.
Parameters: |
|
---|
Defines the object write which will be used to store the result.
Parameters: | writer (AverageWriter) – The writer to use. |
---|
Bases: pyFAI.average.ImageStackFilter
Filter based on the algorithm of average_dark
TODO: Must be split according to each filter_name, and removed
Return a dictionary containing filter parameters
Bases: object
Called when an algorithm is finished
Called when an algorithm is started
Called after providing a frame to an algorithm
Called when an input image is loaded
Called when the full process is finished
Called when the full processing is started
Called before the result of an algorithm is computed
Interface for using writer in Average process.
Close the writer. Must not be used anymore.
Write the header of the average
Parameters: |
|
---|
Write one reduction
Parameters: |
|
---|
Bases: pyFAI.average.ImageReductionFilter
Filter applied in a set of images in which it is possible to reduce data step by step into a single merged image.
Add an image to the filter.
Parameters: | image (numpy.ndarray) – image to add |
---|
Get the result of the filter.
Returns: | result filter |
---|---|
Return type: | numpy.ndarray |
Bases: object
Generic filter applied in a set of images.
Add an image to the filter.
Parameters: | image (numpy.ndarray) – image to add |
---|
Return a dictionary containing filter parameters
Return type: | dict |
---|
Get the result of the filter.
Returns: | result filter |
---|
Initialize the filter before using it.
Parameters: | max_images (int) – Max images supported by the filter |
---|
Bases: pyFAI.average.ImageReductionFilter
Filter creating a stack from all images and computing everything at the end.
Add an image to the filter.
Parameters: | image (numpy.ndarray) – image to add |
---|
Bases: pyFAI.average.ImageAccumulatorFilter
Bases: pyFAI.average.SumAveraging
Bases: pyFAI.average.ImageAccumulatorFilter
Bases: exceptions.Exception
Raised when monitor information in not found or is not valid.
Bases: pyFAI.average.AverageWriter
Write reductions into multi files. File headers are duplicated.
Parameters: |
|
---|
Close the writer. Must not be used anymore.
Get the constructed fabio image
Return type: | fabio.fabioimage.FabioImage |
---|
Bases: pyFAI.average.ImageAccumulatorFilter
Averages a serie of dark (or flat) images. Centers the result on the mean or the median ... but averages all frames within cutoff*std
Parameters: |
|
---|---|
Returns: | 2D image averaged |
Parameters: |
|
---|---|
Returns: | filename with the data or the data ndarray in case format=None |
Tries to guess the bounding box around a valid massif
Parameters: | img – 2D array like |
---|---|
Returns: | 4-typle (d0_min, d1_min, d0_max, d1_max) |
Return the common prefix of a list of strings
TODO: move it into utils package
Parameters: | string_list (list(str)) – List of strings |
---|---|
Return type: | str |
Factory to create algorithm according to parameters
Parameters: |
|
---|---|
Returns: | An algorithm |
Return type: | ImageReductionFilter |
Raises AlgorithmCreationError: | |
If it is not possible to create the algorithm |
alias of SumAveraging
Return true if the name is a name of a filter algorithm
Remove saturated fixes from an array inplace.
Parameters: |
|
---|---|
Returns: | the input dataset |
Bases: pyFAI.geometry.Geometry
This class is an azimuthal integrator based on P. Boesecke’s geometry and histogram algorithm by Manolo S. del Rio and V.A Sole
All geometry calculation are done in the Geometry class
main methods are:
>>> tth, I = ai.integrate1d(data, npt, unit="2th_deg")
>>> q, I, sigma = ai.integrate1d(data, npt, unit="q_nm^-1", error_model="poisson")
>>> regrouped = ai.integrate2d(data, npt_rad, npt_azim, unit="q_nm^-1")[0]
Parameters: |
|
---|
Combines various masks into another one.
Parameters: |
|
---|---|
Returns: | the new mask |
Return type: | ndarray of bool |
This method combine two masks (dynamic mask from data & dummy and mask) to generate a new one with the ‘or’ binary operation. One can adjust the level, with the dummy and the delta_dummy parameter, when you consider the data values needs to be masked out.
This method can work in two different mode:
- “normal”: False for valid pixels, True for bad pixels
- “numpy”: True for valid pixels, false for others
This method tries to accomodate various types of masks (like valid=0 & masked=-1, ...) and guesses if an input mask needs to be inverted.
Correct for Dark-current effects. If dark is not defined, correct for a dark set by “set_darkfiles”
Parameters: |
|
---|---|
Returns: | 2tuple: corrected_data, dark_actually used (or None) |
Correct for flat field. If flat is not defined, correct for a flat set by “set_flatfiles”
Parameters: |
|
---|---|
Returns: | 2tuple: corrected_data, flat_actually used (or None) |
Calculate the azimuthal integrated Saxs curve in q(nm^-1) by default
Multi algorithm implementation (tries to be bullet proof), suitable for SAXS, WAXS, ... and much more
Parameters: |
|
---|---|
Returns: | q/2th/r bins center positions and regrouped intensity (and error array if variance or variance model provided), uneless all==True. |
Return type: | Integrate1dResult, dict |
Calculate the azimuthal regrouped 2d image in q(nm^-1)/chi(deg) by default
Multi algorithm implementation (tries to be bullet proof)
Parameters: |
|
---|---|
Returns: | azimuthaly regrouped intensity, q/2theta/r pos. and chi pos. |
Return type: | Integrate2dResult, dict |
Reset azimuthal integrator in addition to other arrays.
Parameters: |
|
---|
This method save the result of a 1D integration.
Parameters: |
|
---|
This method save the result of a 2D integration.
decorator that deprecates the use of a function
Separate bragg signal from powder/amorphous signal using azimuthal integration, median filering and projected back before subtraction.
Parameters: |
|
---|---|
Returns: | bragg, amorphous |
Parameters: |
|
---|
Set the dark current from one or mutliple files, avaraged according to the method provided
Parameters: |
|
---|
Set the flat field from one or mutliple files, averaged according to the method provided
Prepare a look-up-table
Parameters: |
|
---|
This method is called when a look-up table needs to be set-up. The shape parameter, correspond to the shape of the original datatset. It is possible to customize the number of point of the output histogram with the npt parameter which can be either an integer for an 1D integration or a 2-tuple of integer in case of a 2D integration. The LUT will have a different shape: (npt, lut_max_size), the later parameter being calculated during the instanciation of the splitBBoxLUT class.
It is possible to prepare the LUT with a predefine mask. This operation can speedup the computation of the later integrations. Instead of applying the patch on the dataset, it is taken into account during the histogram computation. If provided the mask_checksum prevent the re-calculation of the mask. When the mask changes, its checksum is used to reset (or not) the LUT (which is a very time consuming operation !)
It is also possible to restrain the range of the 1D or 2D pattern with the pos1_range and pos2_range.
The unit parameter is just propagated to the LUT integrator for further checkings: The aim is to prevent an integration to be performed in 2th-space when the LUT was setup in q space.
Prepare a look-up-table
Parameters: |
|
---|
This method is called when a look-up table needs to be set-up. The shape parameter, correspond to the shape of the original datatset. It is possible to customize the number of point of the output histogram with the npt parameter which can be either an integer for an 1D integration or a 2-tuple of integer in case of a 2D integration. The LUT will have a different shape: (npt, lut_max_size), the later parameter being calculated during the instanciation of the splitBBoxLUT class.
It is possible to prepare the LUT with a predefine mask. This operation can speedup the computation of the later integrations. Instead of applying the patch on the dataset, it is taken into account during the histogram computation. If provided the mask_checksum prevent the re-calculation of the mask. When the mask changes, its checksum is used to reset (or not) the LUT (which is a very time consuming operation !)
It is also possible to restrain the range of the 1D or 2D pattern with the pos1_range and pos2_range.
The unit parameter is just propagated to the LUT integrator for further checkings: The aim is to prevent an integration to be performed in 2th-space when the LUT was setup in q space.
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
Module for treating simultaneously multiple detector configuration within a single integration
Bases: object
This is an Azimuthal integrator containing multiple geometries (when the detector is on a goniometer arm)
Constructor of the multi-geometry integrator :param ais: list of azimuthal integrators :param radial_range: common range for integration :param azimuthal_range: common range for integration :param empty: value for empty pixels :param chi_disc: if 0, set the chi_discontinuity at
Perform 1D azimuthal integration
Parameters: |
|
---|---|
Returns: | 2th/I or a dict with everything depending on “all” |
Return type: | Integrate1dResult, dict |
Performs 2D azimuthal integration of multiples frames, one for each geometry
Parameters: |
|
---|---|
Returns: | I/2th/chi or a dict with everything depending on “all” |
Return type: | Integrate2dResult, dict |
Changes the wavelength of a group of azimuthal integrators
pyFAI-integrate
A graphical tool for performing azimuthal integration on series of files.
Bases: PyQt4.QtGui.QWidget
assign unit to the corresponding widget
Dump the status of the current widget to a file in JSON
Parameters: | filename (string) – path where to save the config |
---|---|
Returns: | dict with configuration |
Read the configuration of the plugin and returns it as a dictionary
Returns: | dict with all information. |
---|
Return the method name for azimuthal intgration
Restore from JSON file the status of the current widget
Parameters: | filename (str) – path where the config was saved |
---|
Setup the widget from its description
Parameters: | dico (dict) – dictionary with description of the widget |
---|
Set all validators for text entries
This modules contrains only one (large) class in charge of:
Bases: object
This class is an azimuthal integrator based on P. Boesecke’s geometry and histogram algorithm by Manolo S. del Rio and V.A Sole
Detector is assumed to be corrected from “raster orientation” effect. It is not addressed here but rather in the Detector object or at read time. Considering there is no tilt:
Demonstration of the equation done using Mathematica:
Axis 1 is allong first dimension of detector (when not tilted), this is the slow dimension of the image array in C or Y
In[5]:= x1={1,0,0}
Out[5]= {1,0,0}
Axis 2 is allong second dimension of detector (when not tilted), this is the fast dimension of the image in C or X
In[6]:= x2={0,1,0}
Out[6]= {0,1,0}
Axis 3 is along the incident X-Ray beam
In[7]:= x3={0,0,1}
Out[7]= {0,0,1}
In[9]:= id3={x1,x2,x3}
Out[9]= {{1,0,0},{0,1,0},{0,0,1}}
In[10]:= {{1,0,0},{0,1,0},{0,0,1}}
Out[10]= {{1,0,0},{0,1,0},{0,0,1}}
In[11]:= rotM1=RotationMatrix[rot1,x1]
Out[11]= {{1,0,0},{0,Cos[rot1],-Sin[rot1]},{0,Sin[rot1],Cos[rot1]}}
In[12]:= rotM2 = RotationMatrix[rot2,x2]
Out[12]= {{Cos[rot2],0,Sin[rot2]},{0,1,0},{-Sin[rot2],0,Cos[rot2]}}
In[13]:= rotM3 = RotationMatrix[rot3,x3]
Out[13]= {{Cos[rot3],-Sin[rot3],0},{Sin[rot3],Cos[rot3],0},{0,0,1}}
Rotations of the detector are applied first Rot around axis 1, then axis 2 and finally around axis 3
In[14]:= R=rotM3.rotM2.rotM1
Out[14]= {{Cos[rot2] Cos[rot3],Cos[rot3] Sin[rot1] Sin[rot2]-Cos[rot1] Sin[rot3],Cos[rot1] Cos[rot3] Sin[rot2]+Sin[rot1] Sin[rot3]},{Cos[rot2] Sin[rot3],Cos[rot1] Cos[rot3]+Sin[rot1] Sin[rot2] Sin[rot3],-Cos[rot3] Sin[rot1]+Cos[rot1] Sin[rot2] Sin[rot3]},{-Sin[rot2],Cos[rot2] Sin[rot1],Cos[rot1] Cos[rot2]}}
In[15]:= CForm[R.x1]
Out[15]//CForm=
List(Cos(rot2)*Cos(rot3),Cos(rot2)*Sin(rot3),-Sin(rot2))
In[16]:= CForm[R.x2]
Out[16]//CForm=
List(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3),Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3),Cos(rot2)*Sin(rot1))
In[17]:= CForm[R.x3]
Out[17]//CForm=
List(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3),-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3),Cos(rot1)*Cos(rot2))
In[18]:= CForm[Det[R]]
Out[18]//CForm=
Power(Cos(rot1),2)*Power(Cos(rot2),2)*Power(Cos(rot3),2) + Power(Cos(rot2),2)*Power(Cos(rot3),2)*Power(Sin(rot1),2) + Power(Cos(rot1),2)*Power(Cos(rot3),2)*Power(Sin(rot2),2) +
Power(Cos(rot3),2)*Power(Sin(rot1),2)*Power(Sin(rot2),2) + Power(Cos(rot1),2)*Power(Cos(rot2),2)*Power(Sin(rot3),2) + Power(Cos(rot2),2)*Power(Sin(rot1),2)*Power(Sin(rot3),2) +
Power(Cos(rot1),2)*Power(Sin(rot2),2)*Power(Sin(rot3),2) + Power(Sin(rot1),2)*Power(Sin(rot2),2)*Power(Sin(rot3),2)
In[13]:=
Any pixel on detector plan at coordianate (d1, d2) in meters. Detector is at z=L
In[22]:= P={d1,d2,L}
CForm[R.P]
Out[22]= {d1,d2,L}
Out[23]//CForm=
List(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))
In[24]:= t1 = R.P.x1
CForm[t1]
Out[24]= d1 Cos[rot2] Cos[rot3]+d2 (Cos[rot3] Sin[rot1] Sin[rot2]-Cos[rot1] Sin[rot3])+L (Cos[rot1] Cos[rot3] Sin[rot2]+Sin[rot1] Sin[rot3])
Out[25]//CForm=
d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))
In[26]:= t2 = R.P.x2
CForm[t2]
Out[26]= d1 Cos[rot2] Sin[rot3]+L (-Cos[rot3] Sin[rot1]+Cos[rot1] Sin[rot2] Sin[rot3])+d2 (Cos[rot1] Cos[rot3]+Sin[rot1] Sin[rot2] Sin[rot3])
Out[27]//CForm=
d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3))
In[28]:= t3=R.P.x3
CForm[t3]
Out[28]= L Cos[rot1] Cos[rot2]+d2 Cos[rot2] Sin[rot1]-d1 Sin[rot2]
Out[29]//CForm=
L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2)
Distance sample to detector point (d1,d2)
(no Mathematica translations)
GraphicsBox[
TagBox[RasterBox[CompressedData["
1:eJxtUstqU1EUDY2iUdSOnBcERwGHDgQf+YNGOrAQSEBBBwlWQfsDcVKsI4sf
IAQnGSQtCQ4yyfvVvO69SW7J+9W8GtIkg8SwXfuQSpFu2Pdxzl5rr7XP2bDY
Nt+saTSaDzfx2DR/er6zY941XsPPi92Pry1afNxdJS9ejuFwqJNl+XMsFstE
o1HijEQio1Qq9bPZbD7SXBHtdnsjGAxK+Xyeut0uTadTms1mNBgMqFwuUyKR
+APOd5cxo9HoHjBqqVSis7Mzms/nlMlkyOfziX/GdzodSiaTpCjKqwscar6o
qkq9Xo/Oz89pb2+PjEYj2Ww22t7epn6/L/DcF/wdt9u9Di4tPAxarZbgZKzd
bmde4jCZTORyuUTPWq1G8Erwb0HdQ2gn+KZ6vU6np6eCm8PhcNDW1hZVKhWx
xvusH/P6jronwVCIcpJE2VxOvLvQ5Q8EyGAwkMfjERilUBCYCGrj8fiv8Xj8
IIAa1iVJMsnIIWZ4dHRE+1/3hW72pUgK5cALTzyfbzwX4Kt5WSb15IRU8M5w
BgcHB2S1WqkL3TxntVgU3CH0g7+XjGs0Gm/D4bDgZS/QQH6/n5xOp+iH/X8z
QY+0Xq9fZ9xyudRKknTIGpibZzOZTMQMcYeoWq1SNptlzMzr9T4G5PbFGS4W
C12hUHDwbNlHEbr4TMEn7hvW69DwDKV3kGv/3zfUPU2n0z+g6Rj+j/H+jXxv
Npvvr/por7qnq+C9G8hbq9Qhr18u+AttYAMa
"], {{0, 14}, {14, 0}}, {0, 255},
ColorFunction->RGBColor],
BoxForm`ImageTag["Byte", ColorSpace -> "RGB", Interleaving -> True],
Selectable->False],
BaseStyle->"ImageGraphics",
ImageSize->Magnification[1],
ImageSizeRaw->{14, 14},
PlotRange->{{0, 14}, {0, 14}}]
In[30]:= dist = Norm[R.P]
CForm[dist]
Out[30]= √(Abs[L Cos[rot1] Cos[rot2]+d2 Cos[rot2] Sin[rot1]-d1 Sin[rot2]]^2+Abs[d1 Cos[rot2] Cos[rot3]+d2 (Cos[rot3] Sin[rot1] Sin[rot2]-Cos[rot1] Sin[rot3])+L (Cos[rot1] Cos[rot3] Sin[rot2]+Sin[rot1] Sin[rot3])]^2+Abs[d1 Cos[rot2] Sin[rot3]+L (-Cos[rot3] Sin[rot1]+Cos[rot1] Sin[rot2] Sin[rot3])+d2 (Cos[rot1] Cos[rot3]+Sin[rot1] Sin[rot2] Sin[rot3])]^2)
Out[31]//CForm=
Sqrt(Power(Abs(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2)),2) + Power(Abs(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) +
L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))),2) + Power(Abs(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3))),
2))
cos(2theta) can be defined as (R.P component along x3) over the distance |R.P|
In[32]:= tthc = ArcCos [-(R.P).x3/Norm[R.P]]
CForm[tthc]
Out[32]= ArcCos[(-L Cos[rot1] Cos[rot2]-d2 Cos[rot2] Sin[rot1]+d1 Sin[rot2])/(√(Abs[L Cos[rot1] Cos[rot2]+d2 Cos[rot2] Sin[rot1]-d1 Sin[rot2]]^2+Abs[d1 Cos[rot2] Cos[rot3]+d2 (Cos[rot3] Sin[rot1] Sin[rot2]-Cos[rot1] Sin[rot3])+L (Cos[rot1] Cos[rot3] Sin[rot2]+Sin[rot1] Sin[rot3])]^2+Abs[d1 Cos[rot2] Sin[rot3]+L (-Cos[rot3] Sin[rot1]+Cos[rot1] Sin[rot2] Sin[rot3])+d2 (Cos[rot1] Cos[rot3]+Sin[rot1] Sin[rot2] Sin[rot3])]^2))]
Out[33]//CForm=
ArcCos((-(L*Cos(rot1)*Cos(rot2)) - d2*Cos(rot2)*Sin(rot1) + d1*Sin(rot2))/
Sqrt(Power(Abs(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2)),2) + Power(Abs(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) +
L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))),2) + Power(Abs(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) +
d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3))),2)))
In[41]:= ttht = ArcTan[t3,Sqrt[t1^2 + t2^2]]
CForm[ttht]
Out[41]= ArcTan[L Cos[rot1] Cos[rot2]+d2 Cos[rot2] Sin[rot1]-d1 Sin[rot2],√((d1 Cos[rot2] Cos[rot3]+d2 (Cos[rot3] Sin[rot1] Sin[rot2]-Cos[rot1] Sin[rot3])+L (Cos[rot1] Cos[rot3] Sin[rot2]+Sin[rot1] Sin[rot3]))^2+(d1 Cos[rot2] Sin[rot3]+L (-Cos[rot3] Sin[rot1]+Cos[rot1] Sin[rot2] Sin[rot3])+d2 (Cos[rot1] Cos[rot3]+Sin[rot1] Sin[rot2] Sin[rot3]))^2)]
Out[42]//CForm=
ArcTan(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
Tangeant of angle chi is defined as (R.P component along x1) over (R.P component along x2). Arctan2 should be used in actual calculation
In[36]:= chi =ArcTan[t1 , t2]
CForm[chi]
Out[36]= ArcTan[d1 Cos[rot2] Cos[rot3]+d2 (Cos[rot3] Sin[rot1] Sin[rot2]-Cos[rot1] Sin[rot3])+L (Cos[rot1] Cos[rot3] Sin[rot2]+Sin[rot1] Sin[rot3]),d1 Cos[rot2] Sin[rot3]+L (-Cos[rot3] Sin[rot1]+Cos[rot1] Sin[rot2] Sin[rot3])+d2 (Cos[rot1] Cos[rot3]+Sin[rot1] Sin[rot2] Sin[rot3])]
Out[37]//CForm=
ArcTan(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))
Coodinates of the Point of Normal Incidence
In[38]:= PONI = R.{0,0,L}
CForm[PONI]
Out[38]= {L (Cos[rot1] Cos[rot3] Sin[rot2]+Sin[rot1] Sin[rot3]),L (-Cos[rot3] Sin[rot1]+Cos[rot1] Sin[rot2] Sin[rot3]),L Cos[rot1] Cos[rot2]}
Out[39]//CForm=
List(L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)),L*Cos(rot1)*Cos(rot2))
Derivatives of 2Theta
In[43]:= CForm[D[ttht,d1]]
Out[43]//CForm=
((L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))*(2*Cos(rot2)*Cos(rot3)*(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) +
L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))) + 2*Cos(rot2)*Sin(rot3)*
(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))))/
(2.*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) +
Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))*
(Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) +
L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
+ (Sin(rot2)*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) +
Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))/
(Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))
In[44]:= CForm[D[ttht,d2]]
Out[44]//CForm=
((L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))*(2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3))*
(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))) +
2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3))*(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))))/
(2.*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) +
Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))*
(Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) +
L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
- (Cos(rot2)*Sin(rot1)*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) +
Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))/
(Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))
In[47]:= CForm[D[ttht,L]]
Out[47]//CForm=
((L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))*(2*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))*
(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))) +
2*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))*(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))))/
(2.*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) +
Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))*
(Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) +
L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
- (Cos(rot1)*Cos(rot2)*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) +
Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))/
(Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))
In[48]:= CForm[D[ttht,rot1]]
Out[48]//CForm=
((L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))*(2*(L*(-(Cos(rot3)*Sin(rot1)*Sin(rot2)) + Cos(rot1)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)))*
(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))) +
2*(d2*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + L*(-(Cos(rot1)*Cos(rot3)) - Sin(rot1)*Sin(rot2)*Sin(rot3)))*
(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))))/
(2.*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) +
Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))*
(Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) +
L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
- ((d2*Cos(rot1)*Cos(rot2) - L*Cos(rot2)*Sin(rot1))*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) +
Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))/
(Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))
In[49]:= CForm[D[ttht,rot2]]
Out[49]//CForm=
((L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))*(2*(L*Cos(rot1)*Cos(rot2)*Cos(rot3) + d2*Cos(rot2)*Cos(rot3)*Sin(rot1) - d1*Cos(rot3)*Sin(rot2))*
(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))) +
2*(L*Cos(rot1)*Cos(rot2)*Sin(rot3) + d2*Cos(rot2)*Sin(rot1)*Sin(rot3) - d1*Sin(rot2)*Sin(rot3))*
(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))))/
(2.*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) +
Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))*
(Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) +
L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
- ((-(d1*Cos(rot2)) - L*Cos(rot1)*Sin(rot2) - d2*Sin(rot1)*Sin(rot2))*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) +
L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
/(Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) +
L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))
In[50]:= CForm[D[ttht,rot3]]
Out[50]//CForm=
((L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))*(2*(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)))*
(-(d1*Cos(rot2)*Sin(rot3)) + L*(Cos(rot3)*Sin(rot1) - Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(-(Cos(rot1)*Cos(rot3)) - Sin(rot1)*Sin(rot2)*Sin(rot3))) +
2*(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)))*
(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))))/
(2.*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) +
Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))*
(Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) +
L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
Parameters: |
|
---|
Generate an array of position in different dimentions (R, Q, 2Theta)
Parameters: |
|
---|---|
Returns: | R, Q or 2Theta array depending on unit |
Return type: | ndarray |
Calculate the position of a set of points in space in the sample’s centers referential.
This is usually used for calculating the pixel position in space.
Parameters: |
|
---|---|
Returns: | 3-tuple of nd-array, with dim0=along the beam, dim1=along slowest dimension dim2=along fastest dimension |
Defines the absorption correction for a phosphor screen or a scintillator from t0, the normal transmission of the screen.
See reference on: J. Appl. Cryst. (2002). 35, 356–359 G. Wu et al. CCD phosphor
Parameters: |
|
---|---|
Returns: | actual |
Computes a 2D image from a 1D integrated profile
Parameters: |
|
---|---|
Returns: | 2D image reconstructed |
Generate a 2D array of the given shape with (i,j) (radial angle ) for all elements.
Parameters: | shape (2-tuple of integer) – expected shape |
---|---|
Returns: | 3d array with shape=(*shape,4,2) the two elements are: - dim3[0]: radial angle 2th, q, r... - dim3[1]: azimuthal angle chi |
Calculate the chi (azimuthal angle) for the centre of a pixel at coordinate d1,d2 which in the lab ref has coordinate:
X1 = p1*cos(rot2)*cos(rot3) + p2*(cos(rot3)*sin(rot1)*sin(rot2) - cos(rot1)*sin(rot3)) - L*(cos(rot1)*cos(rot3)*sin(rot2) + sin(rot1)*sin(rot3)) X2 = p1*cos(rot2)*sin(rot3) - L*(-(cos(rot3)*sin(rot1)) + cos(rot1)*sin(rot2)*sin(rot3)) + p2*(cos(rot1)*cos(rot3) + sin(rot1)*sin(rot2)*sin(rot3)) X3 = -(L*cos(rot1)*cos(rot2)) + p2*cos(rot2)*sin(rot1) - p1*sin(rot2) hence tan(Chi) = X2 / X1
Parameters: |
|
---|---|
Returns: | chi, the azimuthal angle in rad |
Generate an array of azimuthal angle chi(i,j) for all elements in the detector.
Azimuthal angles are in radians
Nota: Refers to the pixel centers !
Parameters: | shape – the shape of the chi array |
---|---|
Returns: | the chi array as numpy.ndarray |
Calculate the chi (azimuthal angle) for the corner of a pixel at coordinate d1,d2 which in the lab ref has coordinate:
X1 = p1*cos(rot2)*cos(rot3) + p2*(cos(rot3)*sin(rot1)*sin(rot2) - cos(rot1)*sin(rot3)) - L*(cos(rot1)*cos(rot3)*sin(rot2) + sin(rot1)*sin(rot3)) X2 = p1*cos(rot2)*sin(rot3) - L*(-(cos(rot3)*sin(rot1)) + cos(rot1)*sin(rot2)*sin(rot3)) + p2*(cos(rot1)*cos(rot3) + sin(rot1)*sin(rot2)*sin(rot3)) X3 = -(L*cos(rot1)*cos(rot2)) + p2*cos(rot2)*sin(rot1) - p1*sin(rot2) hence tan(Chi) = X2 / X1
Parameters: |
|
---|---|
Returns: | chi, the azimuthal angle in rad |
chi array in cache
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
decorator that deprecates the use of a function
Generate a 3D array of the given shape with (i,j) (radial angle 2th, azimuthal angle chi ) for all elements.
Parameters: | shape (2-tuple of integer) – expected shape |
---|---|
Returns: | 3d array with shape=(*shape,4,2) the two elements are: - dim3[0]: radial angle 2th, q, r... - dim3[1]: azimuthal angle chi |
Calculate the incidence angle (alpha) for current pixels (P). The poni being the point of normal incidence, it’s incidence angle is ${alpha} = 0$ hence $cos({alpha}) = 1$
Parameters: |
|
---|---|
Returns: | cosine of the incidence angle |
Generate a 3D array of the given shape with (i,j) with the max distance between the center and any corner in 2 theta
Parameters: | shape – The shape of the detector array: 2-tuple of integer |
---|---|
Returns: | 2D-array containing the max delta angle between a pixel center and any corner in 2theta-angle (rad) |
Generate a 3D array of the given shape with (i,j) with the max distance between the center and any corner in chi-angle (rad)
Parameters: | shape – The shape of the detector array: 2-tuple of integer |
---|---|
Returns: | 2D-array containing the max delta angle between a pixel center and any corner in chi-angle (rad) |
Generate a 2D array of the given shape with (i,j) with the max distance between the center and any corner in q_vector unit (nm^-1)
Parameters: | shape – The shape of the detector array: 2-tuple of integer |
---|---|
Returns: | array 2D containing the max delta Q between a pixel center and any corner in q_vector unit (nm^-1) |
Generate a 2D array of the given shape with (i,j) with the max distance between the center and any corner in radius unit (mm)
Parameters: | shape – The shape of the detector array: 2-tuple of integer |
---|---|
Returns: | array 2D containing the max delta Q between a pixel center and any corner in q_vector unit (nm^-1) |
Generate a 2D array of the given shape with (i,j) with the max distance between the center and any corner in unit: reciprocal spacing squarred (1/nm^2)
Parameters: | shape – The shape of the detector array: 2-tuple of integer |
---|---|
Returns: | array 2D containing the max delta (d*)^2 between a pixel center and any corner in reciprocal spacing squarred (1/nm^2) |
Generate a 2D array of the given shape with (i,j) (delta-radial angle) for all elements.
Parameters: | shape (2-tuple of integer) – expected shape |
---|---|
Returns: | 3d array with shape=(*shape,4,2) the two elements are:
|
Calculate the solid angle of the current pixels (P) versus the PONI (C)
Parameters: |
|
---|---|
Returns: | solid angle correction array |
solid angle array in cache
Export geometry setup with the geometry of Fit2D
Returns: | dict with parameters compatible with fit2D geometry |
---|
Export geometry setup with the geometry of PyFAI
Returns: | dict with the parameter-set of the PyFAI geometry |
---|
get the SPD like parameter set: For geometry description see Peter Boesecke J.Appl.Cryst.(2007).40, s423–s427
Basically the main difference with pyFAI is the order of the axis which are flipped
Returns: | dictionnary with those parameters: SampleDistance: distance from sample to detector at the PONI (orthogonal projection) Center_1, pixel position of the PONI along fastest axis Center_2: pixel position of the PONI along slowest axis Rot_1: rotation around the fastest axis (x) Rot_2: rotation around the slowest axis (y) Rot_3: rotation around the axis ORTHOGONAL to the detector plan PSize_1: pixel size in meter along the fastest dimention PSize_2: pixel size in meter along the slowst dimention splineFile: name of the file containing the spline BSize_1: pixel binning factor along the fastest dimention BSize_2: pixel binning factor along the slowst dimention WaveLength: wavelength used in meter |
---|
Guess what is the best shape ....
Parameters: | shape – force this value (2-tuple of int) |
---|---|
Returns: | 2-tuple of int |
Load the refined parameters from a file.
Parameters: | filename (string) – name of the file to load |
---|
Calculate the polarization correction accoding to the polarization factor:
The axis_offset parameter allows correction for the misalignement of the polarization plane (or ellipse main axis) and the the detector’s X axis.
Parameters: |
|
---|---|
Returns: | 2D array with polarization correction array (intensity/polarisation) |
decorator that deprecates the use of a function
Generate an array for the pixel position given the shape of the detector.
if corners is False, the coordinates of the center of the pixel is returned in an array of shape: (shape[0], shape[1], 3) where the 3 coordinates are: * z: along incident beam, * y: to the top/sky, * x: towards the center of the ring
If is True, the corner of each pixels are then returned. the output shape is then (shape[0], shape[1], 4, 3)
Parameters: |
|
---|---|
Returns: | 3D coodinates as nd-array of size (...,3) or (...,3) (default) |
Nota: this value is not cached and actually generated on demand (costly)
Generate an array of the given shape with q(i,j) for all elements.
decorator that deprecates the use of a function
Calculates the q value for the center of a given pixel (or set of pixels) in nm-1
q = 4pi/lambda sin( 2theta / 2 )
Parameters: |
|
---|---|
Returns: | q in in nm^(-1) |
Return type: | float or array of floats. |
Q array in cache
Generate an array of the given shape with r(i,j) for all elements; The radius r being in meters.
Parameters: | shape – expected shape of the detector |
---|---|
Returns: | 2d array of the given shape with radius in m from beam center on detector. |
decorator that deprecates the use of a function
Calculates the radius value for the center of a given pixel (or set of pixels) in m
r = distance to the incident beam
Parameters: |
|
---|---|
Returns: | r in in m |
Return type: | float or array of floats. |
R array in cache
Generate an array of the given shape with (d*(i,j))^2 for all pixels.
d*^2 is the reciprocal spacing squared in inverse nm squared
Parameters: | shape – expected shape of the detector |
---|---|
Returns: | 2d array of the given shape with reciprocal spacing squared |
Load the refined parameters from a file.
Parameters: | filename (string) – name of the file to load |
---|
reset most arrays that are cached: used when a parameter changes.
Save the geometry parameters.
Parameters: | filename (string) – name of the file where to save the parameters |
---|
Set the position of the discontinuity of the chi axis between -pi and +pi. This is the default behavour
Set the position of the discontinuity of the chi axis between 0 and 2pi. By default it is between pi and -pi
Set the Fit2D-like parameter set: For geometry description see HPR 1996 (14) pp-240
Warning: Fit2D flips automatically images depending on their file-format. By reverse engineering we noticed this behavour for Tiff and Mar345 images (at least). To obtaine correct result you will have to flip images using numpy.flipud.
Parameters: |
|
---|
decorator that deprecates the use of a function
set the geometry from a pyFAI-like dict
Set the SPD like parameter set: For geometry description see Peter Boesecke J.Appl.Cryst.(2007).40, s423–s427
Basically the main difference with pyFAI is the order of the axis which are flipped
Parameters: |
|
---|
A static method combining the constructor and the loader from a file
Parameters: | filename (string) – name of the file to load |
---|---|
Returns: | instance of Gerometry of AzimuthalIntegrator set-up with the parameter from the file. |
Generate an array for the solid angle correction given the shape of the detector.
solid_angle = cos(incidence)^3
Parameters: |
|
---|
SA = pix1*pix2/dist^2 * cos(incidence)^3
Calculates the 2theta value for the center of a given pixel (or set of pixels)
Parameters: |
|
---|---|
Returns: | 2theta in radians |
Return type: | float or array of floats. |
decorator that deprecates the use of a function
2theta array in cache
Generate an array of two-theta(i,j) in radians for each pixel in detector
the 2theta array values are in radians
Parameters: | shape – shape of the detector |
---|---|
Returns: | array of 2theta position in radians |
Save the geometry parameters.
Parameters: | filename (string) – name of the file where to save the parameters |
---|
Bases: pyFAI.azimuthalIntegrator.AzimuthalIntegrator
Parameters: |
|
---|
Parameters: |
|
---|
Confidence interval obtained from the second derivative of the error function next to its minimum value.
Note the confidence interval increases with the number of points which is “surprizing”
Parameters: | with_rot – if true include rot1 & rot2 in the parameter set. |
---|---|
Returns: | std_dev, confidence |
Refine the geometry and provide confidence interval Use curve_fit from scipy.optimize to not only refine the geometry (unconstrained fit)
Parameters: | with_rot – include rotation intro error measurment |
---|---|
Returns: | std_dev, confidence |
Poni can be guessed by the centroid of the ring with lowest 2Theta
run roca to optimise the parameter set
Set the tolerance for a refinement of the geometry; in percent of the original value
Parameters: | value – Tolerance as a percentage |
---|
Description of all detectors with a factory to instantiate them
Bases: pyFAI.detectors.Detector
ADSC Quantum 210r detector, 2x2 chips
Informations from http://www.adsc-xray.com/products/ccd-detectors/q210r-ccd-detector/
Question: how are the gaps handled ?
Bases: pyFAI.detectors.Detector
ADSC Quantum 270r detector, 2x2 chips
Informations from http://www.adsc-xray.com/products/ccd-detectors/q270-ccd-detector/
Question: how are the gaps handled ?
Bases: pyFAI.detectors.Detector
ADSC Quantum 315r detector, 3x3 chips
Informations from http://www.adsc-xray.com/products/ccd-detectors/q315r-ccd-detector/
Question: how are the gaps handled ?
Bases: pyFAI.detectors.Detector
ADSC Quantum 4r detector, 2x2 chips
Informations from http://proteincrystallography.org/detectors/adsc.php
Question: how are the gaps handled ?
Bases: pyFAI.detectors.Detector
Cylindrical detector made of a bent imaging-plate. Developped at the Danish university of Aarhus r = 1.2m or 0.3m
The image has to be laid-out horizontally
Nota: the detector is bending towards the sample, hence reducing the sample-detector distance. This is why z<0 (or p3<0)
TODO: update cython code for 3d detectors use expand2d instead of outer product with ones
Calculate the position of each pixel center in cartesian coordinate and in meter of a couple of coordinates. The half pixel offset is taken into account here !!! Adapted to Nexus detector definition
Parameters: |
|
---|---|
Returns: | position in meter of the center of each pixels. |
Return type: | ndarray |
d1 and d2 must have the same shape, returned array will have the same shape.
Calculate the position of the corner of the pixels
This should be overwritten by class representing non-contiguous detector (Xpad, ...)
Returns: | 4D array containing: pixel index (slow dimension) pixel index (fast dimension) corner index (A, B, C or D), triangles or hexagons can be handled the same way vertex position (z,y,x) |
---|
Bases: pyFAI.detectors.Detector
BrukerApex2 detector
Actually a derivative from the Fairchild detector with higher binning
Defaults to 2x2 binning
Bases: pyFAI.detectors.Detector
Basler camera are simple CCD camara over GigaE
Bases: object
Generic class representing a 2D detector
Parameters: |
|
---|
Calculate the position of each pixel center in cartesian coordinate and in meter of a couple of coordinates. The half pixel offset is taken into account here !!! Adapted to Nexus detector definition
Parameters: |
|
---|---|
Returns: | position in meter of the center of each pixels. |
Return type: | 3xndarray, the later being None if IS_FLAT |
d1 and d2 must have the same shape, returned array will have the same shape.
pos_z is None for flat detectors
Method calculating the mask for a given detector
Detectors with gaps should overwrite this method with something actually calculating the mask!
Returns: | the mask with valid pixel to 0 |
---|---|
Return type: | numpy ndarray of int8 or None |
A kind of factory...
Parameters: |
|
---|---|
Returns: | an instance of the right detector, set-up if possible |
Return type: | pyFAI.detectors.Detector |
Helper method to serialize the description of a detector using the Fit2d units
Returns: | representation of the detector easy to serialize |
---|---|
Return type: | dict |
Helper method to serialize the description of a detector using the pyFAI way with everything in S.I units.
Returns: | representation of the detector easy to serialize |
---|---|
Return type: | dict |
Get a meaningful name for detector
Calculate the position of the corner of the pixels
This should be overwritten by class representing non-contiguous detector (Xpad, ...)
Precision float32 is ok: precision of 1µm for a detector size of 1m
Returns: | 4D array containing: pixel index (slow dimension) pixel index (fast dimension) corner index (A, B, C or D), triangles or hexagons can be handled the same way vertex position (z,y,x) |
---|
Guess the binning/mode depending on the image shape :param data: 2-tuple with the shape of the image or the image with a .shape attribute.
Get a meaningful name for detector
Saves the detector description into a NeXus file, adapted from: http://download.nexusformat.org/sphinx/classes/base_classes/NXdetector.html Main differences:
- differentiate pixel center from pixel corner offsets
- store all offsets are ndarray according to slow/fast dimension (not x, y)
Parameters: | filename – name of the file on the disc |
---|
Twin method of getFit2D: setup a detector instance according to a description
Parameters: | kwarg – dictionary containing pixel1, pixel2 and splineFile |
---|
Twin method of getPyFAI: setup a detector instance according to a description
Parameters: | kwarg – dictionary containing detector, pixel1, pixel2 and splineFile |
---|
Set the “binning” of the detector,
Parameters: | bin_size ((int, int)) – binning as integer or tuple of integers. |
---|
Sets the configuration of the detector. This implies: - Orientation: integers - Binning - ROI
The configuration is either a python dictionary or a JSON string or a file containing this JSON configuration
keys in that dictionary are : “orientation”: integers from 0 to 7 “binning”: integer or 2-tuple of integers. If only one integer is provided, “offset”: coordinate (in pixels) of the start of the detector
set the pixel-wise displacement along X (dim2):
set the pixel-wise displacement along Y (dim1):
Bases: type
Metaclass used to register all detector classes inheriting from Detector
Bases: pyFAI.detectors.Detector
Dexela CMOS family detector
Bases: pyFAI.detectors.Detector
Eiger detector: generic description containing mask algorithm
Calculate the position of each pixel center in cartesian coordinate and in meter of a couple of coordinates. The half pixel offset is taken into account here !!!
Parameters: |
|
---|---|
Returns: | p1, p2 position in meter of the center of each pixels. |
Return type: | 2-tuple of numpy.ndarray |
d1 and d2 must have the same shape, returned array will have the same shape.
Returns a generic mask for Pilatus detectors...
Bases: pyFAI.detectors.Eiger
Eiger 16M detector
Bases: pyFAI.detectors.Eiger
Eiger 1M detector
Bases: pyFAI.detectors.Eiger
Eiger 4M detector
Bases: pyFAI.detectors.Eiger
Eiger 1M detector
Bases: pyFAI.detectors.Eiger
Eiger 9M detector
Bases: pyFAI.detectors.Detector
FReLoN detector: The spline is mandatory to correct for geometric distortion of the taper
TODO: create automatically a mask that removes pixels out of the “valid reagion”
Returns a generic mask for Frelon detectors... All pixels which (center) turns to be out of the valid region are by default discarded
Bases: pyFAI.detectors.Detector
Fairchild Condor 486:90 detector
Bases: pyFAI.detectors.Detector
ADSC HF-130K 1 module
Informations from http://www.adsc-xray.com/products/pixel-array-detectors/hf-130k/
Bases: pyFAI.detectors.Detector
ADSC HF-1M 2x4 modules
Informations from http://www.adsc-xray.com/products/pixel-array-detectors/hf-1m/
Nota: gaps between modules is not known/described
Bases: pyFAI.detectors.Detector
ADSC HF-262k 2 module
Informations from http://www.adsc-xray.com/products/pixel-array-detectors/hf-262k/
Nota: gaps between modules is not known/described
Bases: pyFAI.detectors.Detector
ADSC HF-1M 3x6 modules
Informations from http://www.adsc-xray.com/products/pixel-array-detectors/hf-2.4m/
Nota: gaps between modules is not known/described
Bases: pyFAI.detectors.Detector
ADSC HF-4M 4x8 modules
Informations from http://www.adsc-xray.com/products/pixel-array-detectors/hf-4m/
Bases: pyFAI.detectors.Detector
ADSC HF-130K 1 module
Informations from http://www.adsc-xray.com/products/pixel-array-detectors/hf-9-4m/
Bases: pyFAI.detectors.Detector
ImXPad detector: ImXPad s10 detector with 1x1modules
Calculate the position of each pixel center in cartesian coordinate and in meter of a couple of coordinates. The half pixel offset is taken into account here !!!
Parameters: |
|
---|---|
Returns: | position in meter of the center of each pixels. |
Return type: | ndarray |
d1 and d2 must have the same shape, returned array will have the same shape.
Calculate the mask
Calculate the position of the pixel edges
Calculate the position of the corner of the pixels
This should be overwritten by class representing non-contiguous detector (Xpad, ...)
Precision float32 is ok: precision of 1µm for a detector size of 1m
Returns: | 4D array containing: pixel index (slow dimension) pixel index (fast dimension) corner index (A, B, C or D), triangles or hexagons can be handled the same way vertex position (z,y,x) |
---|
Bases: pyFAI.detectors.ImXPadS10
ImXPad detector: ImXPad s140 detector with 2x7modules
Bases: pyFAI.detectors.ImXPadS10
ImXPad detector: ImXPad s70 detector with 1x7modules
Bases: pyFAI.detectors.Detector
Mar345 Imaging plate detector
In this detector, pixels are always square The valid image size are 2300, 2000, 1600, 1200, 3450, 3000, 2400, 1800
Guess the binning/mode depending on the image shape :param data: 2-tuple with the shape of the image or the image with a .shape attribute.
Bases: pyFAI.detectors.Detector
Class representing a 2D detector loaded from a NeXus file
Helper method to serialize the description of a detector using the Fit2d units
Returns: | representation of the detector easy to serialize |
---|---|
Return type: | dict |
Helper method to serialize the description of a detector using the pyFAI way with everything in S.I units.
Returns: | representation of the detector easy to serialize |
---|---|
Return type: | dict |
Loads the detector description from a NeXus file, adapted from: http://download.nexusformat.org/sphinx/classes/base_classes/NXdetector.html
Parameters: | filename – name of the file on the disk |
---|
Instantiate the detector description from a NeXus file, adapted from: http://download.nexusformat.org/sphinx/classes/base_classes/NXdetector.html
Parameters: | filename – name of the file on the disk |
---|---|
Returns: | Detector instance |
Bases: pyFAI.detectors.Detector
Perkin detector
Bases: pyFAI.detectors.Detector
Pilatus detector: generic description containing mask algorithm
Sub-classed by Pilatus1M, Pilatus2M and Pilatus6M
Calculate the position of each pixel center in cartesian coordinate and in meter of a couple of coordinates. The half pixel offset is taken into account here !!!
Parameters: |
|
---|---|
Returns: | position in meter of the center of each pixels. |
Return type: | ndarray |
d1 and d2 must have the same shape, returned array will have the same shape.
Returns a generic mask for Pilatus detectors...
In this case splinefile is a couple filenames
Bases: pyFAI.detectors.Pilatus
Pilatus 100k detector
Bases: pyFAI.detectors.Pilatus
Pilatus 1M detector
Bases: pyFAI.detectors.Pilatus
Pilatus 200k detector
Bases: pyFAI.detectors.Pilatus
Pilatus 2M detector
Bases: pyFAI.detectors.Pilatus
Pilatus 300k detector
Bases: pyFAI.detectors.Pilatus
Pilatus 300k-wide detector
Bases: pyFAI.detectors.Pilatus
Pilatus 6M detector
Bases: pyFAI.detectors.Pilatus
Pilatus CdTe detector: Like the Pilatus with an extra 3 pixel in the middle of every module (vertically)
Returns a generic mask for Pilatus detectors...
Bases: pyFAI.detectors.PilatusCdTe
Pilatus CdTe 1M detector
Bases: pyFAI.detectors.PilatusCdTe
Pilatus CdTe 2M detector
Bases: pyFAI.detectors.PilatusCdTe
Pilatus CdTe 300k detector
Bases: pyFAI.detectors.PilatusCdTe
Pilatus CdTe 300k-wide detector
Bases: pyFAI.detectors.Detector
PIXIUM 4700 detector
High energy X ray diffraction using the Pixium 4700 flat panel detector J E Daniels, M Drakopoulos, et al.; Journal of Synchrotron Radiation 16(Pt 4):463-8 · August 2009
Defaults to 2x2 binning
Bases: pyFAI.detectors.Detector
5 Mpix detector from Raspberry Pi
Bases: pyFAI.detectors.Detector
8 Mpix detector from Raspberry Pi
Bases: pyFAI.detectors.Detector
Guess the binning/mode depending on the image shape :param data: 2-tuple with the shape of the image or the image with a .shape attribute.
Set the “binning” of the detector,
Parameters: | bin_size (int or (int, int)) – set the binning of the detector |
---|
Bases: pyFAI.detectors.Rayonix
Rayonix 133 2D CCD detector detector also known as mar133
Personnal communication from M. Blum
What should be the default binning factor for those cameras ?
Circular detector
Circular mask
Bases: pyFAI.detectors.Rayonix
Rayonix lx170 2d CCD Detector (2x1 CCDs).
Nota: this is the same for lx170hs
Bases: pyFAI.detectors.Rayonix
Rayonix lx255 2d Detector (3x1 CCDs)
Nota: this detector is also called lx255hs
Bases: pyFAI.detectors.Rayonix
Rayonix mx170 2d CCD Detector (2x2 CCDs).
Nota: this is the same for mx170hs
Bases: pyFAI.detectors.Rayonix
Rayonix mx225 2D CCD detector detector
Nota: this is the same definition for mx225he Personnal communication from M. Blum
Bases: pyFAI.detectors.Rayonix
Rayonix mx225hs 2D CCD detector detector
Pixel size from a personnal communication from M. Blum
Bases: pyFAI.detectors.Rayonix
Rayonix mx300 2D detector (4x4 CCDs)
Pixel size from a personnal communication from M. Blum
Bases: pyFAI.detectors.Rayonix
Rayonix mx300hs 2D detector (4x4 CCDs)
Pixel size from a personnal communication from M. Blum
Bases: pyFAI.detectors.Rayonix
Rayonix mx325 and mx325he 2D detector (4x4 CCD chips)
Pixel size from a personnal communication from M. Blum
Bases: pyFAI.detectors.Rayonix
Rayonix mx340hs 2D detector (4x4 CCDs)
Pixel size from a personnal communication from M. Blum
Bases: pyFAI.detectors.Rayonix
Rayonix mx425hs 2D CCD camera (5x5 CCD chip)
Pixel size from a personnal communication from M. Blum
Bases: pyFAI.detectors.Rayonix
Rayonix sx165 2d Detector also known as MAR165.
Circular detector
Circular mask
Bases: pyFAI.detectors.Rayonix
Rayonix sx200 2d CCD Detector.
Pixel size are personnal communication from M. Blum.
Bases: pyFAI.detectors.Rayonix
Rayonix sx30hs 2D CCD camera (1 CCD chip)
Pixel size from a personnal communication from M. Blum
Bases: pyFAI.detectors.Rayonix
Rayonix sx85hs 2D CCD camera (1 CCD chip)
Pixel size from a personnal communication from M. Blum
Bases: pyFAI.detectors.Detector
Titan CCD detector from Agilent. Mask not handled
Bases: pyFAI.detectors.ImXPadS10
Xpad detector: generic description for ImXPad detector with 8x7modules
Calculate the position of each pixel center in cartesian coordinate and in meter of a couple of coordinates. The half pixel offset is taken into account here !!! Adapted to Nexus detector definition
Parameters: |
|
---|---|
Returns: | position in meter of the center of each pixels. |
Return type: | ndarray |
d1 and d2 must have the same shape, returned array will have the same shape.
Returns a generic mask for Xpad detectors... discards the first line and raw form all modules: those are 2.5x bigger and often mis - behaving
Calculate the position of the pixel edges, specific to the S540, d5 detector
Calculate the position of the corner of the pixels
Returns: | 4D array containing: pixel index (slow dimension) pixel index (fast dimension) corner index (A, B, C or D), triangles or hexagons can be handled the same way vertex position (z,y,x) |
---|
This is piece of software aims at manipulating spline files describing for geometric corrections of the 2D detectors using cubic-spline.
Mainly used at ESRF with FReLoN CCD camera.
Bases: object
This class is a python representation of the spline file
Those file represent cubic splines for 2D detector distortions and makes heavy use of fitpack (dierckx in netlib) — A Python-C wrapper to FITPACK (by P. Dierckx). FITPACK is a collection of FORTRAN programs for curve and surface fitting with splines and tensor product splines. See _http://www.cs.kuleuven.ac.be/cwis/research/nalag/research/topics/fitpack.html or _http://www.netlib.org/dierckx/index.html
This is the constructor of the Spline class.
Parameters: | filename (str) – name of the ascii file containing the spline |
---|
Calculates the spline coefficients from the displacements matrix using fitpack.
Parameters: |
|
---|
Performs the binning of a spline (same camera with different binning)
Parameters: | binning – binning factor as integer or 2-tuple of integers |
---|---|
Type: | int or (int, int) |
Compares the current spline distortion with a reference
Parameters: |
|
---|---|
Returns: | True or False depending if the splines are the same or not |
Return type: | bool |
Flip the spline :return: new spline object
Flip the spline left-right and up-down :return: new spline object
Flip the spline up-down :return: new spline object
Return the size of the pixel from as a 2-tuple of floats expressed in meters.
Returns: | the size of the pixel from a 2D detector |
---|---|
Return type: | 2-tuple of floats expressed in meter. |
read an ascii spline file from file
Parameters: | filename (str) – file containing the cubic spline distortion file |
---|
Sets the size of the pixel from a 2-tuple of floats expressed in meters.
Param: | pixel size in meter |
---|
Calculates the displacement matrix using fitpack bisplev(x, y, tck, dx = 0, dy = 0)
Parameters: | timing (bool) – profile the calculation or not |
---|---|
Returns: | Nothing ! |
Return type: | float or ndarray |
Evaluate a bivariate B-spline and its derivatives. Return a rank-2 array of spline function values (or spline derivative values) at points given by the cross-product of the rank-1 arrays x and y. In special cases, return an array or just a float if either x or y or both are floats.
Calculates the displacement matrix using fitpack for the X direction on the given grid.
Parameters: |
|
---|---|
Returns: | displacement matrix for the X direction |
Return type: | ndarray |
calculates the displacement matrix using fitpack for the Y direction
Parameters: |
|
---|---|
Returns: | displacement matrix for the Y direction |
Return type: | ndarray |
The tilt method apply a virtual tilt on the detector, the point of tilt is given by the center
Parameters: |
|
---|---|
Returns: | tilted Spline instance |
Return type: | Spline |
save the cubic spline in an ascii file usable with Fit2D or SPD
Parameters: | filename (str) – name of the file containing the cubic spline distortion file |
---|
save the distortion matrices into a couple of files called basename-x.edf and basename-y.edf
Parameters: | basename (str) – base of the name used to save the data |
---|
Defines a spline file with no ( zero ) displacement.
Parameters: |
|
---|
Defines a spline file with no ( zero ) displacement with the same shape as the other one given.
Parameters: | other (Spline instance) – another Spline instance |
---|
Some tests ....
Bases: object
Simple class that contains the structure of an OpenCL device
Simple container with some important data for the OpenCL device description:
Parameters: |
|
---|
Complete device description
Returns: | string |
---|
Bases: object
Simple class that wraps the structure ocl_tools_extended.h
This is a static class. ocl should be the only instance and shared among all python modules.
Choose a device and initiate a context.
Devicetypes can be GPU,gpu,CPU,cpu,DEF,ACC,ALL. Suggested are GPU,CPU. For each setting to work there must be such an OpenCL device and properly installed. E.g.: If Nvidia driver is installed, GPU will succeed but CPU will fail. The AMD SDK kit is required for CPU via OpenCL. :param devicetype: string in [“cpu”,”gpu”, “all”, “acc”] :param useFp64: boolean specifying if double precision will be used :param platformid: integer :param devid: integer :return: OpenCL context on the selected device
Retrieves the Device from the context
Parameters: | context – OpenCL context |
---|---|
Returns: | instance of Device |
Return a platform according
Parameters: | key (int or str) – identifier for a platform, either an Id (int) or it’s name |
---|
Select a device based on few parameters (at the end, keep the one with most memory)
Parameters: |
|
---|
Bases: object
Simple class that contains the structure of an OpenCL platform
Class containing all descriptions of a platform and all devices description within that platform.
Parameters: |
|
---|
Add new device to the platform
Parameters: | device – Device instance |
---|
Return a device according to key
Parameters: | key (int or str) – identifier for a device, either it’s id (int) or it’s name |
---|
Parameters: | buffers – the buffers info use to create the pyopencl.Buffer |
---|---|
Returns: | a dict containing the instanciated pyopencl.Buffer |
Return type: | dict(str, pyopencl.Buffer) |
This method instanciate the pyopencl.Buffer from the buffers description.
Parameters: | cl_buffer (dict(str, pyopencl.Buffer)) – the buffer you want to release |
---|
This method release the memory of the buffers store in the dict
C++ less implementation of Dimitris’ code based on PyOpenCL
Bases: object
Attempt to implements ocl_azim using pyopencl
Parameters: | filename – file in which profiling information are saved |
---|
Free OpenCL related resources allocated by the library.
clean() is used to reinitiate the library back in a vanilla state. It may be asked to preserve the context created by init or completely clean up OpenCL. Guard/Status flags that are set will be reset.
Parameters: | preserve_context (bool) – preserves or destroys all OpenCL resources |
---|
The method configure() allocates the OpenCL resources required and compiled the OpenCL kernels. An active context must exist before a call to configure() and getConfiguration() must have been called at least once. Since the compiled OpenCL kernels carry some information on the integration parameters, a change to any of the parameters of getConfiguration() requires a subsequent call to configure() for them to take effect.
If a configuration exists and configure() is called, the configuration is cleaned up first to avoid OpenCL memory leaks
Parameters: | kernel_path – is the path to the actual kernel |
---|
Perform a 1D azimuthal integration
execute() may be called only after an OpenCL device is configured and a Tth array has been loaded (at least once) It takes the input image and based on the configuration provided earlier it performs the 1D integration. Notice that if the provided image is bigger than N then only N points will be taked into account, while if the image is smaller than N the result may be catastrophic. set/unset and loadTth methods have a direct impact on the execute() method. All the rest of the methods will require at least a new configuration via configure().
Takes an image, integrate and return the histogram and weights
Parameters: | image – image to be processed as a numpy array |
---|---|
Returns: | tth_out, histogram, bins |
TODO: to improve performances, the image should be casted to float32 in an optimal way: currently using numpy machinery but would be better if done in OpenCL
getConfiguration gets the description of the integrations to be performed and keeps an internal copy
Parameters: |
|
---|
return a dictionnary with the status of the integrator: for compatibilty with former implementation
Initial configuration: Choose a device and initiate a context. Devicetypes can be GPU, gpu, CPU, cpu, DEF, ACC, ALL. Suggested are GPU,CPU. For each setting to work there must be such an OpenCL device and properly installed. E.g.: If Nvidia driver is installed, GPU will succeed but CPU will fail. The AMD SDK kit (AMD APP) is required for CPU via OpenCL.
Parameters: |
|
---|
Load the 2th arrays along with the min and max value.
loadTth maybe be recalled at any time of the execution in order to update the 2th arrays.
loadTth is required and must be called at least once after a configure()
log in a file all opencl events
Enables dummy value functionality and uploads the value to the OpenCL device.
Image values that are similar to the dummy value are set to 0.
Parameters: |
|
---|
Enables the use of a Mask during integration. The Mask can be updated by recalling setMask at any point.
The Mask must be a PyFAI Mask. Pixels with 0 are masked out. TODO: check and invert!
Parameters: | mask – numpy.ndarray of integer. |
---|
Instructs the program to use a user - defined range for 2th values
setRange is optional. By default the integration will use the tth_min and tth_max given by loadTth() as integration range. When setRange is called it sets a new integration range without affecting the 2th array. All values outside that range will then be discarded when interpolating. Currently, if the interval of 2th (2th + -d2th) is not all inside the range specified, it is discarded. The bins of the histogram are RESCALED to the defined range and not the original tth_max - tth_min range.
setRange can be called at any point and as many times required after a valid configuration is created.
Parameters: |
|
---|
Enables SolidAngle correction and uploads the suitable array to the OpenCL device.
By default the program will assume no solidangle correction unless setSolidAngle() is called. From then on, all integrations will be corrected via the SolidAngle array.
If the SolidAngle array needs to be changes, one may just call setSolidAngle() again with that array
Parameters: | solidAngle (ndarray) – the solid angle of the given pixel |
---|
Disable a dummy value. May be re-enabled at any time by setDummyValue
Disables the use of a Mask from that point. It may be re-enabled at any point via setMask
Disable the use of a user-defined 2th range and revert to tth_min,tth_max range
unsetRange instructs the program to revert to its default integration range. If the method is called when no user-defined range had been previously specified, no action will be performed
Instructs the program to not perform solidangle correction from now on.
SolidAngle correction may be turned back on at any point
Bases: object
Parameters: |
|
---|
Before performing azimuthal integration, the preprocessing is:
Integration is performed using the CSR representation of the look-up table
Parameters: |
|
---|---|
Returns: | averaged data, weighted histogram, unweighted histogram |
If we are in profiling mode, prints out all timing for every single OpenCL call
Bases: object
Parameters: |
|
---|
Before performing azimuthal integration, the preprocessing is:
Integration is performed using the CSR representation of the look-up table
Parameters: |
|
---|---|
Returns: | averaged data, weighted histogram, unweighted histogram |
If we are in profiling mode, prints out all timing for every single OpenCL call
Bases: object
Parameters: |
|
---|
If we are in profiling mode, prints out all timing for every single OpenCL call
Module for “high-performance” writing in either 1D with Ascii , or 2D with FabIO or even nD with n varying from 2 to 4 using HDF5
Stand-alone module which tries to offer interface to HDF5 via H5Py and capabilities to write EDF or other formats using fabio.
Can be imported without h5py but then limited to fabio & ascii formats.
TODO:
Bases: pyFAI.io.Writer
Ascii file writer (.xy or .dat)
Creates the directory that will host the output file(s)
Bases: pyFAI.io.Writer
Constructor of the historical writer of azimuthalIntegrator.
Parameters: |
|
---|---|
Returns: | the header |
Return type: | str |
Parameters: |
|
---|
This method save the result of a 1D integration.
Parameters: |
|
---|
This method save the result of a 2D integration.
Define the filename while will be used
Minimalistic method to limit the overhead.
Parameters: | data – array with intensities or tuple (2th,I) or (I,2th,chi) :type data: Integrate1dResult, Integrate2dResult |
---|
Bases: pyFAI.io.Writer
Image file writer based on FabIO
TODO !!!
Creates the directory that will host the output file(s)
Bases: pyFAI.io.Writer
Class allowing to write HDF5 Files.
Constructor of an HDF5 writer:
Parameters: |
|
---|
Update some data like axis units and so on.
Parameters: |
|
---|
Initializes the HDF5 file for writing :param fai_cfg: the configuration of the worker as a dictionary
Minimalistic method to limit the overhead. :param data: array with intensities or tuple (2th,I) or (I,2th,chi)
Bases: object
Writer class to handle Nexus/HDF5 data
Manages:
entry
pyFAI-subentry
- detector
TODO: make it thread-safe !!!
Constructor
Parameters: |
|
---|
close the filename and update all entries
perform a deep copy: create a “name” entry in self containing a copy of the object
Parameters: |
|
---|
Tries to find a detector within a NeXus file, takes the first compatible detector
Parameters: | all – return all detectors found as a list |
---|
Return the attribute of the dataset
Handles the ascii -> unicode issue in python3 #275
Parameters: |
|
---|---|
Returns: | attribute value decoded in python3 or default |
return all sub-groups of the given type within a group
Parameters: |
|
---|
return all dataset of the the NeXus class NXdata
Parameters: |
|
---|
retrieves all entry sorted the latest first.
Returns: | list of HDF5 groups |
---|
Retrieves an entry from its name
Parameters: | name – name of the entry to retrieve |
---|---|
Returns: | HDF5 group of NXclass == NXentry |
create a new sub-group with type class_type :param grp: parent group :param name: name of the sub-group :param class_type: NeXus class name :return: subgroup created
Create a new entry/pyFAI/Detector
Parameters: |
|
---|
Create a new entry
Parameters: |
|
---|---|
Returns: | the corresponding HDF5 group |
Create an instrument in an entry or create both the entry and the instrument if
Bases: object
Abstract class for writers.
Constructor of the class
To be implemented
Creates the directory that will host the output file(s) :param fai_cfg: configuration for worker :param lima_cfg: configuration for acquisition
Sets the JSON configuration
To be implemented
Parameters: | text – string representing the time is iso format |
---|
Parameters: | forceTime (float) – enforce a given time (current by default) |
---|---|
Returns: | the current time as an ISO8601 string |
Return type: | string |
Check if a file is actually a HDF5 file
Parameters: | filename – this file has better to exist |
---|
pyFAI-calib
A tool for determining the geometry of a detector using a reference sample.
Bases: object
Everything that is common to Calibration and Recalibration
Constructor of AbstractCalibration
Parameters: |
|
---|
Analyzes options and arguments
Returns: | option,arguments |
---|
plot delta_2theta/2theta = f(chi) and fit the curve.
Parameters: | rings – list of rings to consider |
---|
Common configuration for parsers
Performs an automatic keypoint extraction: Can be used in recalib or in calib after a first calibration has been performed.
Parameters: |
|
---|
convert a comma separated sting into pixel size
Common part: shows the result of the azimuthal integration in 1D and 2D
Common part: do dark, flat correction thresholding, ... and read missing data from keyboard if needed
prompt for commands to guide the calibration process
Returns: | True when the user is happy with what he has, False to request another refinement |
---|
Read the name of the calibrant / file with d-spacing
Read the pixel size from prompt if not available
Read the wavelength
Contains the common geometry refinement part
Reset the geometry: no tilt in all cases
Parameters: |
|
---|
call-back function for the peak-picker
Validate the calibration and calculate the offset in the diffraction image
Validate the position of the center by cross-correlating two spectra 180 deg appart. Output values are in micron.
Designed for orthogonal setup with centered beam...
Parameters: | slices – number of slices on which perform |
---|
Bases: pyFAI.calibration.AbstractCalibration
class doing the calibration of frames
Constructor for calibration:
Parameters: |
|
---|
Tries to initialise the GeometryRefinement (dist, poni, rot) Returns a dictionary of key value pairs
parse options from command line
do dark, flat correction thresholding, ...
Contains the geometry refinement part specific to Calibration Sets up the initial guess when starting pyFAI-calib
Bases: object
Rebuild the diffraction image and measures the offset with the reference :return: offset
Show the image with the the errors
smooth out around the mask to avoid aligning on the mask
Bases: object
convert a comma separated sting into pixel size
parse options from command line :param exe: name of the program (MX-calibrate) :param description: Description of the program
Read the name of the calibrant or the file with d-spacing
Read the pixel size from prompt if not available
Read the wavelength
Bases: pyFAI.calibration.AbstractCalibration
class doing the re-calibration of frames
Constructor for Recalibration:
Parameters: |
|
---|
parse options from command line
do dark, flat correction thresholding, ...
Read the name of the file with d-spacing
Contains the geometry refinement part specific to Recalibration
Procedural interfact for calibration
Parameters: |
|
---|---|
Returns: | AzimuthalIntegrator instance |
Detector factory taking into account the binning knowing the datafiles
Parameters: |
|
---|
:return pyFAI.detector.Detector instance :raise RuntimeError: If no detector found
Bases: object
This class contains a set of control points with (optionally) their ring number hence d-spacing and diffraction 2Theta angle ...
Parameters: |
|
---|---|
Returns: | PointGroup instance |
Parameters: |
|
---|
check internal consistency of the class
retireves the last set of points for a given ring (by default the last)
Parameters: | ring – index of ring to search for |
---|
Retrieve the list of control points suitable for geometry refinement with ring number
Retrieve the list of control points suitable for geometry refinement
Retrieve the list of control points suitable for geometry refinement with ring number
Retrieve the list of control points suitable for geometry refinement with ring number and intensities :param image: :return: a (x,4) array with pos0, pos1, ring nr and intensity
#TODO: refine the value of the intensity using 2nd order polynomia
load all control points from a file
Remove the set of points, either from its code or from a given ring (by default the last)
Parameters: |
|
---|
Ask the ring number values for the given points
remove all stored values and resets them to default
Save a set of control points to a file :param filename: name of the file :return: None
This is probably not a good idea, but who knows !
Bases: object
This class is in charge of peak picking, i.e. find bragg spots in the image Two methods can be used : massif or blob
Parameters: |
|
---|
Overlay a contour-plot
Parameters: | data – 2darray with the 2theta values in radians... |
---|
display all points and their ring annotations :param minIndex: ring index to start with :param reset: remove all point before re-displaying them
Ask the ring number for the given points
Parameters: | filename – file with the point coordinates saved |
---|
Parameters: | log – show z in log scale |
---|
Unified initializer
load a filename and plot data on the screen (if GUI)
Overlays a mask over a diffraction image
Parameters: | data – mask to be overlaid |
---|
callback function
callback function
callback function
callback function
Called when a mouse is clicked
Return the list of peaks within an area
Parameters: |
|
---|---|
Returns: | list of peaks [y,x], [y,x], ...] |
remove a group of points
Parameters: | lbl – label of the group of points |
---|
Reset control point and graph (if needed)
Bases: object
Class contains a group of points ... They all belong to the same Debye-Scherrer ring
Constructor
Parameters: |
|
---|
Numerical value for the label: mainly for sorting
return the next label
reset intenal counter
update the internal counter if needed
Bases: object
A massif is defined as an area around a peak, it is used to find neighboring peaks
defines a map of the massif around x and returns the mask
All in one function that finds a maximum from the given seed (x) then calculates the region extension and extract position of the neighboring peaks. :param x: seed for the calculation, input coordinates :param nmax: maximum number of peak per region :param annotate: call back method taking number of points + coordinate as input. :param massif_contour: callback to show the contour of a massif with the given index. :param stdout: this is the file where output is written by default. :return: list of peaks
:return binned data
Returns: | a blurred image |
---|
Returns: | an image composed of int with a different value for each massif |
---|
Returns: | a spacial median filtered image |
---|
Parameters: | x – coordinates of the peak |
---|---|
Returns: | the coordinates of the nearest peak |
Return the list of peaks within an area
Parameters: |
|
---|---|
Returns: | list of peaks [y,x], [y,x], ...] |
Defines the minimum distance between two massifs
Bases: object
Performs a blob detection: http://en.wikipedia.org/wiki/Blob_detection using a Difference of Gaussian + Pyramid of Gaussians
Performs a blob detection: http://en.wikipedia.org/wiki/Blob_detection using a Difference of Gaussian + Pyramid of Gaussians
Parameters: |
|
---|
Perform and plot the two main directions of the peaks, considering their previously calculated scale ,by calculating the Hessian at different sizes as the combination of gaussians and their first and second derivatives
Return the nearest peak from a position
Parameters: |
|
---|
Return the list of peaks within an area
Parameters: |
|
---|---|
Returns: | list of peaks [y,x], [y,x], ...] |
Perform the keypoint extraction for max_octave cycles or until all octaves have been processed. :param max_octave: number of octave to process
Refine the keypoint location based on a 3 point derivative, and delete non-coherent keypoints.
Parameters: |
|
---|---|
Returns: | arrays of corrected coordinates of keypoints, values and locations of keypoints |
Savitzky Golay algorithm to check if a point is really the maximum :param kpx: x_pos of keypoint :param kpy: y_pos of keypoint :param kps: s_pos of keypoint :return array of corrected keypoints
Shows a window with the repartition of keypoint in function of scale/intensity
Parameters: |
|
---|
Calibrant
A module containing classical calibrant and also tools to generate d-spacing.
Interesting formula: http://geoweb3.princeton.edu/research/MineralPhy/xtalgeometry.pdf
Bases: object
A calibrant is a reference compound where the d-spacing (interplanar distances) are known. They are expressed in Angstrom (in the file)
Generates a fake calibration image from an azimuthal integrator
Parameters: |
|
---|
return the index in the 2theta angle index
save the d-spacing to a file
This is probably not a good idea, but who knows !
Bases: object
This is a cell object, able to calculate the volume and d-spacing according to formula from:
http://geoweb3.princeton.edu/research/MineralPhy/xtalgeometry.pdf
Constructor of the Cell class:
Crystalographic units are Angstrom for distances and degrees for angles !
Parameters: |
|
---|
Factory for cubic lattices
Parameters: | a – unit cell length |
---|
Calculate the actual d-spacing for a 3-tuple of integer representing a family of Miller plans
Parameters: | hkl – 3-tuple of integers |
---|---|
Returns: | the inter-planar distance |
Calculate all d-spacing down to dmin
applies selection rules
Parameters: | dmin – minimum value of spacing requested |
---|---|
Returns: | dict d-spacing as string, list of tuple with Miller indices preceded with the numerical value |
Factory for Diamond type FCC like Si and Ge
Parameters: | a – unit cell length |
---|
Factory for hexagonal lattices
Parameters: |
|
---|
Factory for hexagonal lattices
Parameters: |
|
---|
Factory for orthorhombic lattices
Parameters: |
|
---|
Factory for hexagonal lattices
Parameters: |
|
---|
Save informations about the cell in a d-spacing file, usable as Calibrant
Parameters: |
|
---|
contains a list of functions returning True(allowed)/False(forbiden)/None(unknown)
Factory for tetragonal lattices
Parameters: |
|
---|
Bases: object
Behaves like a dict but is actually a factory:
Each time one retrieves an object it is a new geniune new calibrant (unmodified)
Constructor
Parameters: | basedir – directory name where to search for the calibrants |
---|
Bases: object
This class applies a distortion correction on an image.
New version compatible both with CSR and LUT...
Parameters: |
|
---|
Calculate the Look-up table
Returns: | look up table either in CSR or LUT format depending on serl.method |
---|
Initialize all arrays
Calculate the pixel boundary position on the regular grid
Returns: | pixel corner positions (in pixel units) on the regular grid |
---|---|
Return type: | ndarray of shape (nrow, ncol, 4, 2) |
Calculate the number of pixels falling into every single bin and
Returns: | max of pixel falling into a single bin |
---|
Considering the “half-CCD” spline from ID11 which describes a (1025,2048) detector, the physical location of pixels should go from: [-17.48634 : 1027.0543, -22.768829 : 2028.3689] We chose to discard pixels falling outside the [0:1025,0:2048] range with a lose of intensity
Correct an image based on the look-up table calculated ...
Parameters: |
|
---|---|
Returns: | corrected 2D image |
reset the distortion correction and re-calculate the look-up table
Parameters: |
|
---|
Calculate/cache the output shape
:return output shape
Take an image which has been corrected and transform it into it’s raw (with loss of information)
Parameters: | image – 2D-array with the image |
---|---|
Returns: | uncorrected 2D image |
Nota: to retrieve the input mask on can do:
>>> msk = dis.uncorrect(numpy.ones(dis._shape_out)) <= 0
Bases: object
Quad modelisation.
This module contains the Worker class:
A tool able to perform azimuthal integration with: additional saving capabilities like
Aims at being integrated into a plugin like LImA or as model for the GUI
The configuration of this class is mainly done via a dictionary transmitted as a JSON string: Here are the valid keys:
Bases: object
Simple worker doing dark, flat, solid angle and polarization correction
Constructor of the worker :param dark: array :param flat: array :param solidangle: solid-angle array :param polarization: numpy array with 2D polarization corrections :param device: Used to influance OpenCL behavour: can be “cpu”, “GPU”, “Acc” or even an OpenCL context
Process the data and apply a normalization factor :param data: input data :param normalization: normalization factor :return processed data
Bases: object
Simple worker doing dark, flat, solid angle and polarization correction
Constructor of the worker
Parameters: |
|
---|
Process the data and apply a normalization factor :param data: input data :param normalization: normalization factor :return processed data
Bases: object
Parameters: |
|
---|
return configuration as a dictionary
return configuration as a JSON string
Process a frame #TODO: dark, flat, sa are missing
Parameters: |
|
---|
This is just to force the integrator to initialize with a given input image shape
Parameters: |
|
---|
this is just to force the integrator to initialize
enforce the extension of the processed data file written
Set the relative or absolute path for processed data
Process a dummy image to ensure everything is initialized
Parameters: | sync – wait for processing to be finished |
---|
Create an Azimuthal integrator from the configuration stand alone function !
Parameters: | config – dict with all parameters |
---|---|
Returns: | configured (but uninitialized) AzimuthalIntgrator |
Manages the different units
Nota for developers: this module is used a singleton to store all units in a unique manner. This explains the number of top-level variables on the one hand and their CAPITALIZATION on the other.
Bases: object
Represents a unit.
It has at least a name and a scale (in SI-unit)
Constructor of a unit.
Parameters: |
|
---|
Mimic the dictionary interface
Parameters: | key ((str)) – key wanted |
---|---|
Returns: | self.key |
Calculates the 2theta aperture of the cone
Parameters: |
|
---|
Calculates the modulus of the scattering vector
Parameters: |
|
---|
Calculates the radius
Parameters: |
|
---|
Utilities, mainly for image treatment
Bases: set
Like a set, made for FixedParameters in geometry refinement
Add a value to a set if value, else discard it :param key: element to added or discared from set :type value: boolean. If None do nothing ! :return: None
Parameters: |
|
---|---|
Returns: | binned input ndarray |
Calculate the checksum by default (or returns its buffer location if unsafe)
Calculate the center of mass of of the array. Like scipy.ndimage.measurements.center_of_mass :param img: 2-D array :return: 2-tuple of float with the center of mass
Parameters: | filenames (list of str which can be filename of kernel as a string.) – filenames containing the kernels |
---|
this method concatenates all the kernel from the list
convert a function name in CamelCase into camel_case
Convert degrees to radian in the range -pi->pi
Parameters: | dd – angle in degrees |
---|
Nota: depending on the platform it could be 0<2pi A branch is cheaper than a trigo operation
2D difference of gaussian typically 1 to 10 parameters
2-dimensional Difference of Gaussian filter implemented with FFT
Parameters: |
|
---|
Expand array a with its reflection on boundaries
Parameters: |
|
---|
Nota: sigma is the half-width of the kernel. For gaussian convolution it is adviced that it is 4*sigma_of_gaussian
This expands a vector to a 2d-array.
The result is the same as:
if vertical:
numpy.outer(numpy.ones(size2), vect)
else:
numpy.outer(vect, numpy.ones(size2))
This is a ninja optimization: replace *1 with a memcopy, saves 50% of time at the ms level.
Parameters: |
|
---|
Takes an argv and expand it (under Windows, cmd does not convert *.tif into a list of files. Keeps only valid files (thanks to glob)
Parameters: | args – list of files or wilcards |
---|---|
Returns: | list of actual args |
Convert anything to a float ... or None if not applicable
Return a Gaussian window of length M with standard-deviation std.
This differs from the scipy.signal.gaussian implementation as: - The default for sym=False (needed for gaussian filtering without shift) - This implementation is normalized
Parameters: |
|
---|
The FWHM is 2*numpy.sqrt(2 * numpy.pi)*std
2-dimensional Gaussian filter implemented with FFT
Parameters: |
|
---|
get the full path of a calibration directory
Returns: | the full path of the calibrant file |
---|
get the full path of a openCL file
Returns: | the full path of the openCL source file |
---|
get the full path of a user-interface file
Returns: | the full path of the ui |
---|
Convert anything to an int ... or None if not applicable
Tells if a point is far from a group of points, distance greater than d2 (distance squared)
Parameters: |
|
---|---|
Returns: | True If the point is far from all others. |
Bases: object
meant to be used for lazy evaluation of an object attribute. property should represent non-mutable data, as it replaces itself.
Same as scipy.ndimage.measurements.maximum_position: Find the position of the maximum of the values of the array.
Parameters: | img – 2-D image |
---|---|
Returns: | 2-tuple of int with the position of the maximum |
Measure the actual offset between 2 images :param img1: ndarray, first image :param img2: ndarray, second image, same shape as img1 :param withLog: shall we return logs as well ? boolean :return: tuple of floats with the offsets
Read float from the keyboard ....
Parameters: |
|
---|
Parameters: | filename – read an OpenCL file and apply a preprocessor |
---|---|
Returns: | preprocessed source code |
Relabel limits the number of region in the label array. They are ranked relatively to their max(I0)-max(blur(I0)
Parameters: |
|
---|---|
Returns: | array like label |
This function returns the integer >=N for which size the Fourier analysis is faster (fron the FFT point of view) Credit: Alessandro Mirone, ESRF, 2012
Parameters: | N – interger on which one would like to do a Fourier transform |
---|---|
Returns: | integer with a better choice |
Shift an array like scipy.ndimage.interpolation.shift(input_img, shift_val, mode=”wrap”, order=0) but faster :param input_img: 2d numpy array :param shift_val: 2-tuple of integers :return: shifted image
Do shift using FFTs
Shift an array like scipy.ndimage.interpolation.shift(input, shift, mode=”wrap”, order=”infinity”) but faster :param input_img: 2d numpy array :param shift_val: 2-tuple of float :return: shifted image
Convert anything to a string ... but None -> “”
Parameters: |
|
---|---|
Returns: | unBinned input ndarray |
Module providing gui util tools
Bases: object
Dummy class for dummy things
Try to set the figure fullscreen
Update a matplotlib figure with a Qt4 backend
Parameters: | fig – pylab figure |
---|
This extension makes a discrete 2D-array appear like a continuous function thanks to bilinear interpolations.
Bases: object
Bilinear interpolator for finding max.
Instance attribute defined in pxd file
Function f((y,x)) where f is a continuous function (y,x) are pixel coordinates @param x: 2-tuple of float @return: Interpolated signal from the image (negative for minimizer)
Return the local maximum ... with sub-pixel refinement
@param x: 2-tuple of integers @param w: half with of the window: 1 or 2 are advised @return: 2-tuple of float with the nearest local maximum
Sub-pixel refinement: Second order Taylor expansion of the function; first derivative is null delta = x-i = -Inverse[Hessian].gradient
if Hessian is singular or |delta|>1: use a center of mass.
calc_cartesian_positions(signatures, args, kwargs, defaults)
Calculate the Cartesian position for array of position (d1, d2) with pixel coordinated stored in array pos This is bilinear interpolation
Parameters: |
|
---|
:return 3-tuple of position.
convert_corner_2D_to_4D(signatures, args, kwargs, defaults)
Convert 2 (or 3) arrays of corner position into a 4D array of pixel corner coordinates
Parameters: |
|
---|---|
Returns: | pos 4D array with position of pixels corners |
This extension is a re-implementation of bi-cubic spline evaluation from scipy
Spline evaluation function
Created on Nov 4, 2013
@author: zubair, Jerome Kieffer
Evaluate a bivariate B-spline and its derivatives.
Return a rank-2 array of spline function values (or spline derivative values) at points given by the cross-product of the rank-1 arrays x and y. In special cases, return an array or just a float if either x or y or both are floats. Based on BISPEV from FITPACK.
splprep, splrep, splint, sproot, splev UnivariateSpline, BivariateSpline
See bisplrep to generate the tck representation.
[1] | Dierckx P. : An algorithm for surface fitting with spline functions Ima J. Numer. Anal. 1 (1981) 267-283. |
[2] | Dierckx P. : An algorithm for surface fitting with spline functions report tw50, Dept. Computer Science,K.U.Leuven, 1980. |
[3] | Dierckx P. : Curve and surface fitting with splines, Monographs on Numerical Analysis, Oxford University Press, 1993. |
Blob detection is used to find peaks in images by performing subsequent blurs
Some Cythonized function for blob detection function
Calculate if a point is a maximum in a 3D space: (scale, y, x)
Parameters: |
|
---|---|
Returns: | 3d_array with 1 where is_max |
Container are a new uniform storage, optimized for the creation of both LUT and CSR. It has nothing to do with Docker.
Convolutions in real space are used to blurs images, used in blob-detection algorithm
Implementation of a separable 2D convolution
Return a Gaussian window of length “width” with standard-deviation “sigma”.
Parameters: |
|
---|
Width should be odd.
The FWHM is 2*sqrt(2 * pi)*sigma
Performs a gaussian bluring using a gaussian kernel.
Parameters: |
|
---|
Implements a 1D horizontal convolution with a filter. The only implemented mode is “reflect” (default in scipy.ndimage.filter)
Parameters: |
|
---|---|
Returns: | array of the same shape as image with |
Implements a 1D vertical convolution with a filter. The only implemented mode is “reflect” (default in scipy.ndimage.filter)
Parameters: |
|
---|---|
Returns: | array of the same shape as image with |
Distortion correction are correction are applied by Look-up table (or CSR)
Common Look-Up table datatypes
Bases: object
This class applies a distortion correction on an image.
It is also able to apply an inversion of the correction.
Parameters: | detector – detector instance or detector name |
---|
Considering the “half-CCD” spline from ID11 which describes a (1025,2048) detector, the physical location of pixels should go from: [-17.48634 : 1027.0543, -22.768829 : 2028.3689] We chose to discard pixels falling outside the [0:1025,0:2048] range with a lose of intensity
We keep self.pos: pos_corners will not be compatible with systems showing non adjacent pixels (like some xpads)
Correct an image based on the look-up table calculated ...
Parameters: | image – 2D-array with the image |
---|---|
Returns: | corrected 2D image |
Take an image which has been corrected and transform it into it’s raw (with loss of information)
Parameters: | image – 2D-array with the image |
---|---|
Returns: | uncorrected 2D image and a mask (pixels in raw image |
Calculate the Look-up table as CSR format
Parameters: |
|
---|---|
Returns: | look-up table in CSR format: 3-tuple of array |
Parameters: |
|
---|---|
Returns: | look-up table |
Calculate the area between I1 and I2 of a line with a given slope & intercept
Calculate the look-up table (or CSR) using OpenMP
Parameters: |
|
---|---|
Returns: | look-up table in CSR/LUT format |
calc_pos(signatures, args, kwargs, defaults) Calculate the pixel boundary position on the regular grid
param pixel_corners: pixel corner coordinate as detector.get_pixel_corner() param shape: requested output shape. If None, it is calculated param pixel1, pixel2: pixel size along row and column coordinates return: pos, delta1, delta2, shape_out, offset
calc_size(signatures, args, kwargs, defaults) Calculate the number of items per output pixel
param pos: 4D array with position in space param shape: shape of the output array param mask: input data mask param offset: 2-tuple of float with the minimal index of return: number of input element per output elements
Limits the value to bounds
Correct an image based on the look-up table calculated ...
Parameters: |
|
---|---|
Returns: | corrected 2D image |
Correct an image based on the look-up table calculated ...
Parameters: |
|
---|---|
Returns: | corrected 2D image |
Take an image which has been corrected and transform it into it’s raw (with loss of information)
Parameters: |
|
---|---|
Returns: | uncorrected 2D image and a mask (pixels in raw image not existing) |
Take an image which has been corrected and transform it into it’s raw (with loss of information)
Parameters: |
|
---|---|
Returns: | uncorrected 2D image and a mask (pixels in raw image not existing) |
This extension is a fast-implementation for calculating the geometry, i.e. where every pixel of an array stays in space (x,y,z) or its (r, chi) coordinates.
Calculate the chi array (azimuthal angles) using OpenMP
X1 = p1*cos(rot2)*cos(rot3) + p2*(cos(rot3)*sin(rot1)*sin(rot2) - cos(rot1)*sin(rot3)) - L*(cos(rot1)*cos(rot3)*sin(rot2) + sin(rot1)*sin(rot3)) X2 = p1*cos(rot2)*sin(rot3) - L*(-(cos(rot3)*sin(rot1)) + cos(rot1)*sin(rot2)*sin(rot3)) + p2*(cos(rot1)*cos(rot3) + sin(rot1)*sin(rot2)*sin(rot3)) X3 = -(L*cos(rot1)*cos(rot2)) + p2*cos(rot2)*sin(rot1) - p1*sin(rot2) tan(Chi) = X2 / X1
Parameters: |
|
---|---|
Returns: | ndarray of double with same shape and size as pos1 |
Calculate the cosine of the incidence angle using OpenMP. Used for sensors thickness effect corrections
Parameters: |
|
---|---|
Returns: | ndarray of double with same shape and size as pos1 |
Calculate the 3D coordinates in the sample’s referential
Parameters: |
|
---|---|
Returns: | 3-tuple of ndarray of double with same shape and size as pos1 |
Calculate the q (scattering vector) array using OpenMP
X1 = p1*cos(rot2)*cos(rot3) + p2*(cos(rot3)*sin(rot1)*sin(rot2) - cos(rot1)*sin(rot3)) - L*(cos(rot1)*cos(rot3)*sin(rot2) + sin(rot1)*sin(rot3)) X2 = p1*cos(rot2)*sin(rot3) - L*(-(cos(rot3)*sin(rot1)) + cos(rot1)*sin(rot2)*sin(rot3)) + p2*(cos(rot1)*cos(rot3) + sin(rot1)*sin(rot2)*sin(rot3)) X3 = -(L*cos(rot1)*cos(rot2)) + p2*cos(rot2)*sin(rot1) - p1*sin(rot2) tan(Chi) = X2 / X1
Parameters: |
|
---|---|
Returns: | ndarray of double with same shape and size as pos1 |
Calculate the radius array (radial direction) in parallel
Parameters: |
|
---|---|
Returns: | ndarray of double with same shape and size as pos1 |
Calculate the radial & azimutal position for each pixel from pos1, pos2, pos3.
Parameters: |
|
---|---|
Returns: | ndarray of double with same shape and size as pos1 + (2,), |
Raise: | KeyError when space is bad ! ValueError when wavelength is missing |
Calculate the 2theta array (radial angle) in parallel
Parameters: |
|
---|---|
Returns: | ndarray of double with same shape and size as pos1 |
Re-implementation of the numpy.histogram, optimized for azimuthal integration. Deprecated, will be replaced by silx.math.histogramnd
Re-implementation of numpy histograms using OpenMP
Calculates histogram of pos weighted by weights
@param pos: 2Theta array @param weights: array with intensities @param bins: number of output bins @param pixelSize_in_Pos: size of a pixels in 2theta: DESACTIVATED @param nthread: OpenMP is disabled. unused @param empty: value given to empty bins @param normalization_factor: divide the result by this value
@return 2theta, I, weighted histogram, raw histogram
Calculate 2D histogram of pos0,pos1 weighted by weights
@param pos0: 2Theta array @param pos1: Chi array @param weights: array with intensities @param bins: number of output bins int or 2-tuple of int @param split: pixel splitting is disabled in histogram @param nthread: maximum number of thread to use. By default: maximum available. @param empty: value given to empty bins @param normalization_factor: divide the result by this value
@return I, edges0, edges1, weighted histogram(2D), unweighted histogram (2D)
One can also limit this with OMP_NUM_THREADS environment variable
The marchingsquares algorithm is used for calculating an iso-contour curve (displayed on the screen while calibrating) but also to seed the points for the “massif” algoritm during recalib.
Cythonized version of the marching square function for “isocontour” plot
isocontour(img, isovalue=None)
Calculate the iso contours for the given 2D image. If isovalue is not given or None, a value between the min and max of the image is used.
@param img: 2D array representing the image @param isovalue: the value for which the iso_contour shall be calculated @param sorted: perform a sorting of the points to have them contiguous ?
Returns a pointset in which each two subsequent points form a line piece. This van be best visualized using “vv.plot(result, ls=’+’)”.
Reorder edges in such a way they become contiguous
The morphology extension provides a couple of binary morphology operations on images. They are also implemented in scipy.ndimage in the general case, but not as fast.
A few binary morphology operation
Return fast binary morphological dilation of an image.
Morphological dilation sets a pixel at (i,j) to the maximum over all pixels in the neighborhood centered at (i,j). Dilation enlarges bright regions and shrinks dark regions.
:param image : ndarray :param radius: float :return: ndiamge
Return fast binary morphological erosion of an image.
Morphological erosion sets a pixel at (i,j) to the minimum over all pixels in the neighborhood centered at (i,j). Erosion shrinks bright regions and enlarges dark regions.
:param image : ndarray :param radius: float :return: ndiamge
Very simple inpainting module for reconstructing the missing part of an image (masked) to be able to use more common algorithms.
Cython module to reconstruct the masked values of an image
reconstruct missing part of an image (tries to be continuous)
Parameters: |
|
---|---|
Returns: | reconstructed image. |
Relabel regions, used to flag from largest regions to the smallest
A module to relabel regions
Count :param label: 2D array containing labeled zones :param data: 2D array containing the raw data :param blured: 2D array containing the blured data :return: 2D arrays containing:
- count pixels in labelled zone: label == index).sum()
- max of data in that zone: data[label == index].max()
- max of blured in that zone: blured[label == index].max()
- data-blured where data is max.
Contains a preprocessing function in charge of the dark-current subtraction, flat-field normalization, ... taking care of masked values and normalization.
Common preprocessing step for all
Parameters: |
|
---|
All calculation are performed in single precision floating point.
NaN are always considered as invalid
if neither empty nor dummy is provided, empty pixels are 0
The tree is used in file hierarchy tree for the diff_map graphical user interface.
Bases: object
TreeItem(str label=None, TreeItem parent=None)
Node of a tree ...
Each node contains:
- children: list
- parent: TreeItem parent
- label: str
- order: int
- type: str can be “dir”, “file”, “group” or “dataset”
- extra: any object
x.__init__(...) initializes x; see help(type(x)) for signature
children: list
extra: object
label: str
order: ‘int’
parent: pyFAI.ext._tree.TreeItem
type: str
Add new children in tree
Peak peaking via inverse watershed for connecting region of high intensity
Inverse watershed for connecting region of high intensity
Bases: object
Bilinear interpolator for finding max.
Instance attribute defined in pxd file
Function f((y,x)) where f is a continuous function (y,x) are pixel coordinates @param x: 2-tuple of float @return: Interpolated signal from the image (negative for minimizer)
Return the local maximum ... with sub-pixel refinement
@param x: 2-tuple of integers @param w: half with of the window: 1 or 2 are advised @return: 2-tuple of float with the nearest local maximum
Sub-pixel refinement: Second order Taylor expansion of the function; first derivative is null delta = x-i = -Inverse[Hessian].gradient
if Hessian is singular or |delta|>1: use a center of mass.
Bases: object
Idea:
Parameters: | data – 2d image as numpy array |
---|
Load data from a HDF5 file
Merge groups then (pass-mini)/(maxi-mini) >=thres
merge single pixel region
Twins are two peak region which are best linked together: A -> B and B -> A
Parameters: |
|
---|
Save all regions into a HDF5 file
Bases: object
Initialize the values : maxi, mini and pass both height and so on :param flat: flat view on the data (intensity) :return: True if there is a problem and the region should be removed
merge 2 regions