Data Set¶
The DataSet object is the interface between the data files and the data treatment and visualziation. It is both responsible for the conversion of raw ‘.h5’-files into ‘.nxs’-files as well as plotting these. Extracting values from this object results in a list of values where the first dimension is determined from the number of data files provided.
DataSet object to hold all informations about data. |
|
Conversion method for converting scan file(s) to hkl file. |
|
Wrapper for 1D cut through constant energy plane from q1 to q2 function returning binned intensity, monitor, normalization and normcount. |
|
plot new or already performed cut. |
|
Wrapper for cut data into maps of q and intensity between two q points and given energies. |
|
plot of intensity as function of Q between Q1 and Q2 and Energy. |
|
Cut data powder map with intensity as function of the length of q and energy. |
|
Plotting wrapper for the cutPowder method. |
|
Wrapper for plotting tool to show binned intensities in the Q plane between provided energies. |
|
Method to perform Q-energy cuts from a variable number of points. |
|
Plotting wrapper for the cutQELine method. |
This is the data module inteded to be used as a stand-alone data reduction and visualization.
DataSet Object and Methods¶
Object to take care of all data conversion and treatment taking it from raw hdf5 files obtained at the instrument into re-binned data sets converted to S(q,omega).
- DataSet.OxfordList(list)[source]¶
Create a comma separated string from the strings provided with last comma trailed by ‘and’.
- DataSet.binData3D(dx, dy, dz, pos, data, norm=None, mon=None, bins=None)[source]¶
3D binning of data.
- Parameters
dx (-) – Step size in x (required).
dy (-) – Step size in x (required).
dz (-) – Step size in x (required).
pos (-) – Position of data points as flattened lists (X,Y,Z) (required).
data (-) – Flattened data array (required).
Kwargs:
norm (array): Flattened normalization array.
mon (array): Flattened monitor array.
bins (list of arrays): Bins locating edges in the x, y, and z directions.
- Returns
Re-binned intensity (and if provided Normalization, Monitor, and Normalization Count) and X, Y, and Z bins in 3 3D arrays.
Example:
>>> pos = [Qx,Qy,E] >>> Data,bins = DataSet.binData3D(0.05,0.05,0.2,pos,I,norm=Norm,mon=Monitor)
- DataSet.boundaryQ(file, plane, A4Extend=0.0, A3Extend=0.0)[source]¶
Calculate the boundary of a given scan in Q space A4Extend: in degrees A3Extend: in degrees
- DataSet.calculateGrid3D(X, Y, Z)[source]¶
- Generate 3D grid with centers given by X,Y, and Z.
Args:
X (3D array): 3D array of x values generated by np.meshgrid.
Y (3D array): 3D array of y values generated by np.meshgrid.
Z (3D array): 3D array of z values generated by np.meshgrid.
Example:
>>> x = np.linspace(-1.5,1.5,20) >>> y = np.linspace(0,1.5,10) >>> z = np.linspace(-1.0,5.5,66) >>> X,Y,Z = np.meshgrid(x,y,z,indexing='ij') >>> XX,YY,ZZ = calculateGrid3D(X,Y,Z)
Now XX is a 21x11x67 array containing all x coordinates of the edges exactly midway between the points. Same goes for YY and ZZ with y and z coordinates respectively.
- DataSet.convertToHKL(sample, QxQy)[source]¶
Convert a given list og QPoints to QxQy from UB matrix of sample
- Parameters
sample (-) – Sample from which the UB matrix is to be used
QxQy (-) – List of HKL points to be converted
- Returns
List of QxQy points in same shape as provided
- Return type
HKL (list)
- DataSet.convertToQxQy(sample, QPoints)[source]¶
Convert a given list og QPoints to QxQy from UB matrix of sample
- Parameters
sample (-) – Sample from which the UB matrix is to be used
QPoints (-) – List of HKL points to be converted
- Returns
List of QxQy points in same shape as provided
- Return type
Q (list)
- DataSet.convexHullPoints(A3, A4)[source]¶
Calculate the convex hull of rectangularly spaced A3 and A4 values
- DataSet.cut1D(positions, I, Norm, Monitor, q1, q2, width, minPixel, Emin, Emax, plotCoverage=False, extend=False, constantBins=False)[source]¶
Perform 1D cut through constant energy plane from q1 to q2 returning binned intensity, monitor, normalization and normcount. The full width of the line is width while height is given by Emin and Emax. the minimum step sizes is given by minPixel.
Note
Can only perform cuts for a constant energy plane of definable width.
- Parameters
positions (-) – position in Qx, Qy, and E in flattend arrays.
I (-) – Flatten intensity array
Norm (-) – Flatten normalization array
Monitor (-) – Flatten monitor array
q1 (-) – Start position of cut in format (qx,qy).
q2 (-) – End position of cut in format (qx,qy).
width (-) – Full width of cut in q-plane.
minPixel (-) – Minimal size of binning along the cutting direction. Points will be binned if they are closer than minPixel.
Emin (-) – Minimal energy to include in cut.
Emax (-) – Maximal energy to include in cut
Kwargs:
plotCoverage (bool): If True, generates plot of all points in the cutting plane and adds bounding box of cut in new figure, if axis, plots on top (default False).
extend (bool): Whether or not the cut from q1 to q2 is to be extended throughout the data (default true)
constantBins (bool): If True only bins of size minPixel is used (default False)
- Returns
Intensity, monitor count, normalization and normalization counts binned in the 1D cut.
Bin list (3 arrays): Bin edge positions in plane of size (n+1,3), orthogonal positions of bin edges in plane of size (2,2), and energy edges of size (2).
- Return type
Data list (4 arrays)
- DataSet.cut1DE(positions, I, Norm, Monitor, E1, E2, q, width, minPixel, constantBins=False, background=None)[source]¶
Perform 1D cut through constant Q point returning binned intensity, monitor, normalization and normcount. The width of the cut is given by the width attribute.
Note
Can only perform cuts for a constant energy plane of definable width.
- Parameters
positions (-) – position in Qx, Qy, and E in flattend arrays.
I (-) – Flatten intensity array
Norm (-) – Flatten normalization array
Monitor (-) – Flatten monitor array
E1 (-) – Start energy.
E2 (-) – End energy.
q (-) – Q point in (qx,qy)
width (-) – Full width of cut in q-plane.
minPixel (-) – Minimal size of binning along the cutting direction. Points will be binned if they are closer than minPixel.
Emin (-) – Minimal energy to include in cut.
Emax (-) – Maximal energy to include in cut
Kwargs:
constantBins (bool): If True only bins of size minPixel is used (default False)
background (list): If provided perform background subtraction as well
- Returns
Intensity, monitor count, normalization and normalization counts binned in the 1D cut.
Bin list (1 array): Bin edge positions in energy
- Return type
Data list (4 arrays)
- DataSet.cutPowder(positions, I, Norm, Monitor, EBins, QBins, background=None)[source]¶
Cut data powder map with intensity as function of the length of q and energy.
- Parameters
positions (-) – position in Qx, Qy, and E in flattend arrays.
I (-) – Flatten intensity array
Norm (-) – Flatten normalization array
Monitor (-) – Flatten monitor array
EBins (-) – Energy bin edges.
QBins (-) – Q length bin edges.
Kwargs:
background (list): List of background values (default None)
- Returns
DataFrame containing qx,qy,H,K,L,Intensity,Normalization,Monitor,BinCount,Int,binDistance for powder cut.
- Return type
Data list (pandas DataFrame)
- DataSet.func(self, function)¶
Symmetrize data by providing a custom function
- Parameters
function (function) – Function to symmetrize
The signature of the function must be func(H,K,L) and must return (H,K,L). An example is
>>> def symmetrize(H,K,L): >>> return np.abs(H),np.abs(K),np.abs(L)
- DataSet.load(filename)[source]¶
Function to load an object from a pickled file.
Note
It is not possible to un-pickle an object created in python 3 in python 2 or vice versa.
- DataSet.plotA3A4(files, ax=None, planes=[], binningDecimals=3, log=False, returnPatches=False, singleFigure=False, plotTessellation=False, Ei_err=0.05, temperature_err=0.2, magneticField_err=0.2, electricField_err=0.2)[source]¶
Plot data files together with pixels created around each point in A3-A4 space. Data is binned in the specified planes through their A3 and A4 values. This can result in distorted binning when binning across large energy regions. Data is plotted using the pixels calculated for average plane value, i.e. binning 7,8,9,10, and 11 patches for plane 9 are used for plotting.
- Parameters
files (-) – single file or list of files to be binned together
Kwargs:
ax (matplotlib axis): Axis into which the planes are to be plotted (Default None, i.e. new)
planes (list (of lists)): Planes to be plotted and binned (default [])
binningDecimals (int): Number of decimal places A3-A4 positions are rounded before binning (default 3)
log (bool): Whether or not to plot intensities as logarithm (default False)
returnPatches (bool): If true the method returns the patches otherwise plotted in the given axis (default False)
singleFigure (bool): If true, all planes are plotted in same figure (default False)
plotTessellation (bool): Plot Tessellation of points (default False)
Ei_err (float): Tolerance of E_i for which the values are equal (default = 0.05)
temperature_err (float): Tolerance of temperature for which the values are equal (default = 0.2)
magneticField_err (float): Tolerance of magnetic field for which the values are equal (default = 0.2)
electricField_err (float): Tolerance of electric field for which the values are equal (default = 0.2)
- Returns
axis (list of) containing figures for plotted planes.
- Return type
ax (matplotlib axis or list of)
- Raises
- AttributeError –
Examples:
The following example will combine the two files and plot all of the available planes in different figures.
>>> DS = DataSet.DataSet(convertedFiles=[--.nxs,---.nxs]) >>> plt.figure() >>> ax = plt.gca() >>> >>> DataSet.plotA3A4(DS.convertedFiles,ax=ax)
If only a subset of planes or different planes are to be combined the following will achieve this:
>>> DataSet.plotA3A4(DS.convertedFiles,ax=ax,planes=[0,1,2,3,[4,5,6],[8,9]])
Here planes 0 through 3 are plotted separately while 4,5, and 6 as well as 8 and 9 are binned.
Note
Binning planes from different analysers might result in nonsensible binnings.
- class DataSet.DataSet(dataFiles=None, normalizationfiles=None, calibrationfiles=None, convertedFiles=None, **kwargs)[source]¶
DataSet object to hold all informations about data.
Kwargs:
dataFiles (string, DataFile or list of strings or DataFiles): List of datafiles or DataFile objects to be used in conversion (default None).
normalizationfiles (string or list of strings): Location of Vanadium normalization file(s) (default None).
calibrationfiles (string or list of strings): Location of calibration normalization file(s) (default None).
convertedFiles (string, DataFile or list of strings): Location of converted data files (default None).
- Raises
- ValueError –
- NotImplementedError –
- View3D(dQx, dQy, dE, rlu=True, log=False, grid=False, axis=2, counts=False, adjustable=True, customSlicer=False, instrumentAngles=False, outputFunction=<built-in function print>, backgroundSubtraction=False, cmap=None, CurratAxeBraggList=None, plotCurratAxe=False, cut1DFunctionRectangle=None, cut1DFunctionCircle=None, cut1DFunctionRectanglePerp=None, cut1DFunctionRectangleHorizontal=None, cut1DFunctionRectangleVertical=None, **kwargs)[source]¶
View data in the Viewer3D object.
- Parameters
dQx (-) – step size in qx
dQy (-) – step size in qy
dE (-) – step size in E
Kwargs:
rlu (Bool): If true a rlu axis is used for plotting otherwise qx,qy (Default True).
log (Bool): If true logarithm of intensity is plotted
grid (Bool): If true, grid is plotted. If float or integer, value is used as zorder of grid (Default False)
axis (int): Axis shown initially (default 2)
counts (bool): If set true, data shown is number of neutrons/pixel
adjustable (bool): If set true, 2 sliders will be present allowing to fine tune the c-axis (Default True)
customSlicer (bool): If true, utilize the interactive viewer based on PyQtGraph (Default False)
instrumenAngles (bool): If true show also A3 and A4 calculations for HKL axis when hovering (Default False)
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform backgorund subtraction (default False)
outputFunction (func): Function to print the format_coord when the user clicks the axis (default print)
CurratAxeBraggList (list): List of Bragg reflections used to calulcate Currat-Axe spurions (default None)
plotCurratAxe (bool): Flag to determine whether or not to plot the Currat-Axe spurions
cut1DFunctionRectangle (function): Function to be called when generating interactive rectangle cut (default None)
cut1DFunctionCircle (function): Function to be called when generating interactive circle cut (default None)
kwargs: The remaining kwargs are given to the createQAxis method, intended for tick mark positioning (see createQAxis)
If one plots not using RLU, everything is plotted in real units (1/AA), and the Qx and QY is not rotated. That is, the x axis in energy is not along the projection vector. The cuts of constant Qx and Qy does not represent any symmetry directions in the sample. However, if one utilizes the RLU flag, first Qx and Qy are rotated with first HKL vector along the x-axis. This thus means that cuts of constant Qx (or more correctly along the principal HKL vector) represents a symmetry direction. However, as the data is binned in equal sized voxels, constant Qy does not necessarily correspond to HKL vector 2 (it will in systems with 90 degrees between the two vectors).
- absoluteNormalize(sampleMass=None, sampleMolarMass=None, sampleChemicalFormula=None, formulaUnitsPerUnitCell=1.0, sampleGFactor=2.0, correctVanadium=False, vanadiumMass=15.25, vanadiumMonitor=100000, vanadiumSigmaIncoherent=5.08, vanadiumChemicalFormula='V', vanadiumGFactor=2.0, vanadiumUnitsPerUnitCell=1.0, vanadiumMolarMass=None)[source]¶
Normaliza dataset to absolute units () by
Kwargs:
sampleMass (float): Mass of sample in gram
sampleChemicalFormula (string): Chemical formula of sample
formulaUnitsPerUnitCell (float): Number of formula units per unit cell (default 1.0)
sampleDebyeWaller (float): Debye Waller factor (default 1.0)
sampleGFactor (float): Magnetic G factor for sample (defalt 2.0)
sampleFormFactor (float): Formfactor of sample (default 1.0)
correctVanadium (bool): If normalization files have not been updated set this to True (default False)
vanadiumMass (float): Mass of vanadium used in normalization in gram (default 15.25)
vanadiumMonitor (int): Monitor count used in normalization scan (default 100000)
vanadiumSigmaIncoherent (float): Incoherent scattering strength of Vanadium (default 5.08)
- autoSort(sortFunction=None)[source]¶
Sort datafiles according to lowest energy, then abs(2Theta), then scan direction in A3, then A3 start position.
Kwargs:
sortFunction (function): Takes enumerate and data file (Default as described above)
Sorting function takes in (index, dataFile) and should return a tuple of sorting values in descending priority.
Default sorting function is:
>>> def sortFunction(IdxDf): >>> df = IdxDf[1] >>> return (np.round(df.Ei[0],1), np.abs(np.round(df.twotheta[0],1)), -np.sign(np.diff(df.A3[:2]))[0], np.round(df.A3[0],2))
- binData3D(dx, dy, dz, rlu=True, dataFiles=None, backgroundSubtraction=False, noApproximation=False)[source]¶
Bin a converted data file into voxels with sizes dx*dy*dz. Wrapper for the binData3D functionality.
- Parameters
dx (-) – step sizes along the x direction (required).
dy (-) – step sizes along the y direction (required).
dz (-) – step sizes along the z direction (required).
Kwargs:
rlu (bool): If True, the rotate QX,QY is used for binning (default True)
datafile (string or list of strings): Location(s) of data file to be binned (default converted file in DataSet).
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
- Raises
- AttributeError –
- Returns
List of converted data files having 4 sub arrays: Intensity(counts), Monitor, Normalization, Normalization count
bins: 3 arrays containing edge positions in x, y, and z directions.
- Return type
Datalist
- calculateCurratAxeMask(BraggPeaks, dqx=None, dqy=None, dH=None, dK=None, dL=None, spurionType='both', maskInside=True)[source]¶
Generate an elliptical mask centered on the Currat-Axe spurion.
- Parameters
BraggPeaks (-) – List of Bragg peaks to be used for mask. Shape is given by [[H1,K1,L1], [H2,K2,L2], … [HN,KN,LN]]
Kwargs:
dqx (float): Radius used for masking along qx (default None)
dqy (float): Radius used for masking along qy (default None)
dH (float): Radius used for masking along H (default None)
dK (float): Radius used for masking along K (default None)
dL (float): Radius used for masking along L (default None)
spurionType (str): Either monochromator, analyser or both (default ‘both’)
maskInside (bool): If true, points inside is masked otherwise outside (default True)
- Returns
List of boolean numpy arrays with shapes equal to df.I.shape
- Return type
mask (list)
Note
If either dqx or dqy is None, utilizes the dH, dK, dL instead.
- calculateResolutionMatrix(position, Ei, Ef, rlu=True)[source]¶
Calculate the resolution ellipsoid matrix at a specific point in reciprocal space
- Parameters
position (-) – Position in either HKL or Qx,Qy
Ei (-) – Incoming energy in meV
Ef (-) – Outgoing energy in meV
Kwargs:
rlu (bool): If true, position is calculated in reciprocal lattice units, otherwise in QxQy (default True)
Method is based on thew updated calculation from “Analytiucal approach to the 4D-resolution functiuon of three axes neutron spectrometers with focussing monochromators ananalysers” - C. Eckold, O. Sobolev doi: 10.1016/j.nima.2014.03.019
- calculateResolutionMatrixAndVectors(position, projectionVector1, projectionVector2, Ei, Ef, rlu=True, rluAxis=False)[source]¶
Calculate the resolution ellipsoid matrix at a specific point in reciprocal space and project to plane
- Parameters
position (-) – Position in either HKL or Qx,Qy
projectionVector1 (-) – Projection vector in 4D of unit length
Ei (-) – Incoming energy in meV
Ef (-) – Outgoing energy in meV
Kwargs:
rlu (bool): If true, position is calculated in reciprocal lattice units, otherwise in QxQy (default True)
rluAxis (bool): If plotting on rluAxis counter rotate eigen vectors with RotMat (default False)
Projection matrix is given by two projections vectors with unit length.
- checkSecondOrderElastic(EPeaks, atol=0.2, printing=True)[source]¶
Check if peaks at certain energies corresponds with second order elastic scattering in data set
- Parameters
EPeaks (-) – List of peaks to check
Kwargs:
atol (float): Tolerance of Ei calculation (default 0.2 meV)
printing (bool): Boolean flag to control printing (default True)
- Returns
List of Ei’s corresponding to second order elastic for all peaks. If no Ei is found nan is returned
- Return type
Eis (list)
- convertDataFile(dataFiles=None, binning=None, saveLocation=None, saveFile=False, printFunction=None, deleteOnConvert=True)[source]¶
Conversion method for converting scan file(s) to hkl file. Converts the given hdf file into NXsqom format and saves in a file with same name, but of type .nxs. Copies all of the old data file into the new to ensure complete redundancy. Determines the binning wanted from the file name of normalization file.
Kwargs:
dataFiles (DataFile, string or list of): File path(s), file must be of hdf format (default self.dataFiles).
binning (int): Binning to be used when converting files (default 8).
saveLocation (string): File path to save location of data file(s) (defaults to same as raw file).
saveFile (bool): If true, the file(s) will be saved as nxs-files. Otherwise they will only persis in memory.
printFunction (function): Function called if a message is to be printed (default None, uses warning)
deleteOnConvert (bool): If true, delete raw data files when a conversion has been done (default False)
- Raises
- IOError –
- AttributeError –
- convertToHKL(QxQy)[source]¶
Convert array or vector of QxQy point(s) to corresponding HKL
- Parameters
QxQy (-) – array or vector of QxQy point(s)
Returns
HKL (array): Converted QxQy points in HKL
- convertToQxQy(HKL)[source]¶
Convert array or vector of HKL point(s) to corresponding Qx and QY
- Parameters
HKL (-) – array or vector of HKL point(s)
Returns
Q (array): Converted HKL points in Qx QY of un-rotated coordinate system.
- createQAxis(rlu=True, withoutOnClick=False, figure=None, ids=[1, 1, 1], basex=None, basey=None)¶
Create a reciprocal lattice plot for a given DataSet object.
- Parameters
Dataset (-) – DataSet object for which the RLU plot is to be made.
Kwargs:
rlu (bool): If true, plot in reciprocal lattice units, else in Qx, Qy (default True)
withoutOnClick (bool): If False, utilize the updated onClick method (default False)
figure: Matplotlib figure in which the axis is to be put (default None)
ids (array): List of integer numbers provided to the SubplotHost ids attribute (default [1,1,1])
basex (float): Ticks are positioned at multiples of this value along x (default None)
basey (float): Ticks are positioned at multiples of this value along y (default None)
- Returns
Axes containing the RLU plot.
- Return type
ax (Matplotlib axes)
Note
When rlu axis is created, the orientation of Qx and Qy is assumed to be rotated as well. This is to be done in the self.View3D method call!
Note
When using python 2 the changing of tick marks is not supported due to limitations in matplotlib. However, if python 3 is used, the number of ticks and their location can be change after the initialization using the set_xticks_number, set_yticks_number chaning the wanted number of tick marks, or the set_xticks_base or set_yticks_base to change the base number, see RLU tutorial under Tools. As default a sufficient base number is found and will update when zooming.
- createQEAxes(axis=0, figure=None, projectionVector1=None, projectionVector2=None, rlu=True, figurePos=[1, 1, 1])¶
Function to create Q E plot
Kwargs:
DataSet (DataSet): If provided and no projections vectors creates QE axis for main direction (default None)
axis (int): Whether to create axis 0 or 1 (projection vector 0 or orthogonal to this, default 0)
figure (figure): If provided, this is used to create the axis within (default None)
projectionVector1 (vec): Projection vector along which data is plotted. If not provided sample vector is used (default None)
projectionVector2 (vec): Projection vector orthogonal to data. If not provided sample vector is used (default None)
rlu (Bool): Boolean to control if rlu or qxqy (default True)
- cut1D(q1, q2, width, minPixel, Emin, Emax, rlu=True, plotCoverage=False, extend=False, dataFiles=None, constantBins=False, positions=None, I=None, Norm=None, Monitor=None, backgroundSubtraction=False, ufit=False)[source]¶
Wrapper for 1D cut through constant energy plane from q1 to q2 function returning binned intensity, monitor, normalization and normcount. The full width of the line is width while height is given by Emin and Emax. the minimum step sizes is given by minPixel.
Note
Can only perform cuts for a constant energy plane of definable width.
- Parameters
q1 (-) – Start position of cut in format (h,k,l) or (qx,qy) depending on rlu flag.
q2 (-) – End position of cut in format (h,k,l) or (qx,qy) depending on rlu flag.
width (-) – Full width of cut in q-plane in 1/AA.
minPixel (-) – Minimal size of binning along the cutting direction. Points will be binned if they are closer than minPixel.
Emin (-) – Minimal energy to include in cut.
Emax (-) – Maximal energy to include in cut
Kwargs:
rlu (bool): If True, coordinates given are interpreted as (h,k,l) otherwise as (qx,qy)
plotCoverage (bool): If True, generates plot of all points in the cutting plane and adds bounding box of cut (default False).
extend (bool): Whether or not the cut from q1 to q2 is to be extended throughout the data (default true)
dataFiles (list): List of dataFiles to cut (default None). If none, the ones in the object will be used.
constantBins (bool): If True only bins of size minPixel is used (default False)
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
ufit (bool): If True a uFit Dataset object is returned in stead of pandas data frame
- Returns
See below
Bin list (3 arrays): Bin edge positions in plane of size (n+1,3), orthogonal positions of bin edges in plane of size (2,2), and energy edges of size (2).
A Pandas data frame returns is returned with the following columns:
Qx: X component of scattering vector in instrument frame of reference
Qy: Y component of scattering vector in instrument frame of reference
H: H component of scattering vector in sample frame of reference
K: H component of scattering vector in sample frame of reference
L: H component of scattering vector in sample frame of reference
Int: Normalized intensity proportional to S(Q,Omega)
Int_err: Error of normalized intensity
intensity: Accumulated neutron number - either background subtracted or true neutron count
Monitor: Accumulated monitor in bin
Normalization: Accumulated normalization in bin
BinCount: Number of insertions into bin
BinDistance: If present, describes plotting position in axis
- Return type
Data list (pandas DataFrame)
If a background subtraction is performed, the following columns are also present:
Int_Fg: Normalized foreground intensity
Int_Bg: Normalized background intensity
Int_Fg_err: Normalized foreground error
Int_Bg_err: Normalized background error
intensity_Fg: Accumulated foreground neutron number
intensity_Bg: Accumulated background neutron number
- cut1DE(E1, E2, q, rlu=True, width=0.02, minPixel=0.1, dataFiles=None, constantBins=False, ufit=False, backgroundSubtraction=False)[source]¶
Perform 1D cut through constant Q point returning binned intensity, monitor, normalization and normcount. The width of the cut is given by the width attribute.
- Parameters
E1 (-) – Start energy.
E2 (-) – End energy.
q (-) – Q point
Kwargs:
rlu (bool): If True, provided Q point is interpreted as (h,k,l) otherwise as (qx,qy), (Default true)
width (float): Full width of cut in q-plane (default 0.02).
minPixel (float): Minimal size of binning along the cutting direction. Points will be binned if they are closer than minPixel (default 0.1).
dataFiles (list): Data files to be used. If none provided use the ones in self (default None)
constantBins (bool): If True only bins of size minPixel is used (default False)
ufit (bool): If True a uFit Dataset object is returned in stead of pandas data frame
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
- Returns
See below.
Bin list (1 array): Bin edge positions in energy
A Pandas data frame returns is returned with the following columns:
Qx: X component of scattering vector in instrument frame of reference
Qy: Y component of scattering vector in instrument frame of reference
H: H component of scattering vector in sample frame of reference
K: H component of scattering vector in sample frame of reference
L: H component of scattering vector in sample frame of reference
Int: Normalized intensity proportional to S(Q,Omega)
Int_err: Error of normalized intensity
intensity: Accumulated neutron number - either background subtracted or true neutron count
Monitor: Accumulated monitor in bin
Normalization: Accumulated normalization in bin
BinCount: Number of insertions into bin
BinDistance: If present, describes plotting position in axis
- Return type
Data list (pandas DataFrame)
If a background subtraction is performed, the following columns are also present:
Int_Fg: Normalized foreground intensity
Int_Bg: Normalized background intensity
Int_Fg_err: Normalized foreground error
Int_Bg_err: Normalized background error
intensity_Fg: Accumulated foreground neutron number
intensity_Bg: Accumulated background neutron number
- cutELine(Q1, Q2, Emin=None, Emax=None, energyWidth=0.05, minPixel=0.02, width=0.02, rlu=True, dataFiles=None, constantBins=False, backgroundSubtraction=False)[source]¶
Perform cut along energy in steps between two Q Point
- Parameters
Q1 (-) – Starting point for energy cut.
Q2 (-) – End of energy cut
Kwargs:
Emin (float): Start energy (default is self.Energy.min() for data in cut).
Emax (float): End energy (default is self.Energy.max() for data in cut).
energyWidth (float): Height of energy bins (default 0.05 meV)
minPixel (float): Minimal size of binning along the cutting direction. Points will be binned if they are closer than minPixel (default 0.1).
width (float): Full width of cut in q-plane (default 0.02).
rlu (bool): If True, provided Q point is interpreted as (h,k,l) otherwise as (qx,qy), (Default true)
dataFiles (list): Data files to be used. If none provided use the ones in self (default None)
constantBins (bool): If True only bins of size minPixel is used (default False)
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
- Returns
DataFrame containing qx,qy,H,K,L,Intensity,Normalization,Monitor,BinCount,Int,binDistance for 1D cut.
Bin (1 array): Bin edge positions in energy
- Return type
Data (pandas DataFrame)
- cutPowder(EBins, QBins, dataFiles=None, constantBins=False, backgroundSubtraction=False)[source]¶
Cut data powder map with intensity as function of the length of q and energy.
- Parameters
EBins (-) – Energy bin edges.
QBins (-) – Q length bin edges.
Kwargs:
dataFiles (list): List of dataFiles to cut (default None). If none, the ones in the object will be used.
constantBins (bool): If True only bins of size minPixel is used (default False)
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
- Returns
DataFrame containing qx,qy,H,K,L,Intensity,Normalization,Monitor,BinCount,Int,binDistance for powder cut.
qbins (n arrays): n arrays holding the bin edges along the length of q
- Return type
Data list (pandas DataFrame)
- cutQE(q1, q2, width, minPixel, EMin=None, EMax=None, dE=None, EnergyBins=None, rlu=True, extend=True, dataFiles=None, constantBins=False, smoothing=None, backgroundSubtraction=False, scaledEnergy=False, scaleFunction=<function scale>, rescaleFunction=<function rescale>)[source]¶
Wrapper for cut data into maps of q and intensity between two q points and given energies. This is performed by doing consecutive constant energy planes.
- Parameters
q1 (-) – Start position of cut in format (h,k,l) or (qx,qy) depending on rlu flag.
q2 (-) – End position of cut in format (h,k,l) or (qx,qy) depending on rlu flag.
width (-) – Full width of cut in q-plane.
minPixel (-) – Minimal size of binning along the cutting direction. Points will be binned if they are closer than minPixel.
EnergyBins (-) – Bin edges between which the 1D constant energy cuts are performed.
Kwargs:
rlu (bool): If True, coordinates given are interpreted as (h,k,l) otherwise as (qx,qy)
extend (bool): If True, cut is extended to edge of measured area instead of only between provided points.
dataFiles (list): List of dataFiles to cut (default None). If none, the ones in the object will be used.
constantBins (bool): If True only bins of size minPixel is used (default False)
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
- Returns
See below
Bin list (n * 3 arrays): n instances of bin edge positions in plane of size (m+1,3), orthogonal positions of bin edges in plane of size (2,2), and energy edges of size (2).
center position (n * 3D arrays): n instances of center positions for the bins.
binDistance (n arrays): n instances of arrays holding the distance in q to q1.
A Pandas data frame returns is returned with the following columns:
Qx: X component of scattering vector in instrument frame of reference
Qy: Y component of scattering vector in instrument frame of reference
H: H component of scattering vector in sample frame of reference
K: H component of scattering vector in sample frame of reference
L: H component of scattering vector in sample frame of reference
Int: Normalized intensity proportional to S(Q,Omega)
Int_err: Error of normalized intensity
intensity: Accumulated neutron number - either background subtracted or true neutron count
Monitor: Accumulated monitor in bin
Normalization: Accumulated normalization in bin
BinCount: Number of insertions into bin
BinDistance: If present, describes plotting position in axis
- Return type
Data list (pandas DataFrame)
If a background subtraction is performed, the following columns are also present:
Int_Fg: Normalized foreground intensity
Int_Bg: Normalized background intensity
Int_Fg_err: Normalized foreground error
Int_Bg_err: Normalized background error
intensity_Fg: Accumulated foreground neutron number
intensity_Bg: Accumulated background neutron number
- cutQELine(QPoints, EnergyBins, width=0.1, minPixel=0.01, rlu=True, dataFiles=None, constantBins=False, backgroundSubtraction=False)[source]¶
Method to perform Q-energy cuts from a variable number of points. The function takes both qx/qy or hkl positions. In the case of using only two Q points, the method is equivalent to cutQE.
- Parameters
QPoints (-) – Q positions between which cuts are performed. Can be specified with both qx, qy or hkl positions dependent on the choice of format.
EnergyBins (-) – Energy bins for which the cuts are performed
Kwargs:
width (float): Width of the cut in 1/AA (default 0.1).
minPixel (float): Minimal size of binning along the cutting directions. Points will be binned if they arecloser than minPixel (default=0.01)
rlu (bool): If True, provided QPoints are interpreted as (h,k,l) otherwise as (qx,qy), (default True).
dataFiles (list): List of dataFiles to cut. If none, the ones in the object will be used (default None).
constantBins (bool): If True only bins of size minPixel is used (default False)
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
Warning
The way the binning works is by extending the end points with 0.5*minPixel, but the method sorts away points not between the two Q points given and thus the start and end bins are only half filled. This might result in discrepancies between a single cut and the same cut split into different steps. Further, splitting lines into sub-cuts forces a new binning to be done and the bin positions can then differ from the case where only one cut is performed.
Returns: m = Q points, n = energy bins
Data list (pandas DataFrame): See below
Bin list (m * n * 3 arrays): n instances of bin edge positions in plane of size (m+1,3), orthogonal positions of bin edges in plane of size (2,2), and energy edges of size (2).
Note
If an HKL point outside of the scattering plane is given, the program will just take the projection onto the scattering plane.
A Pandas data frame returns is returned with the following columns:
Qx: X component of scattering vector in instrument frame of reference
Qy: Y component of scattering vector in instrument frame of reference
H: H component of scattering vector in sample frame of reference
K: H component of scattering vector in sample frame of reference
L: H component of scattering vector in sample frame of reference
Int: Normalized intensity proportional to S(Q,Omega)
Int_err: Error of normalized intensity
intensity: Accumulated neutron number - either background subtracted or true neutron count
Monitor: Accumulated monitor in bin
Normalization: Accumulated normalization in bin
BinCount: Number of insertions into bin
BinDistance: If present, describes plotting position in axis
If a background subtraction is performed, the following columns are also present:
Int_Fg: Normalized foreground intensity
Int_Bg: Normalized background intensity
Int_Fg_err: Normalized foreground error
Int_Bg_err: Normalized background error
intensity_Fg: Accumulated foreground neutron number
intensity_Bg: Accumulated background neutron number
- cutRaw1D(detectorSelection=None, analyzerSelection=None)[source]¶
cut 1D data to be used for 1D raw plot using specified DASEL.
- kwargs:
detectorSelection (int): Detector to be used (default from file)
analyzerSelection (int): Analyzer segment to be used (default from file)
returns:
- extractData(A4=None, A4Id=None, Ef=None, EfId=None, raw=False, A4Tolerance=0.1, EfTolerance=0.1)[source]¶
Extract data given A4 value and Ef (or the corresponding indices).
Kwargs:
A4 (float): Wanted A4 value in degrees (default None)
A4Id (int): Id of wedge which is a number between 0 and 103 (default None)
Ef (float): Wanted Ef value in meV (default None)
EfId (int): Wanted Id of analyser energy, number between 0-7 (default None)
raw (bool): If true method returns Intensity,Normalization,Monitor, else returns Intensity/(Norm*Monitor) (default False)
A4Tolerance (float): Tolerance between found and wanted A4 value in degrees (default 0.1)
EfTolerance (float): Tolerance between found and wanted Ef value in meV (default 0.1)
Note
If A4 or Ef is provided, then these will be used instead of A4Id or EfId.
- generateBackgroundModel(backgroundMask=None, dQ=0.025, dE=0.05, combineForegroundMask=False)[source]¶
Generate a background model using powder average
Kwargs:
dQ (float): Step size along the q direction in the powder average bin in 1/AA (default 0.02)
dE (float): Step size along the energy direction in the powder average bin in meV (default 0.1)
backgroundMask (Mask): Masking object to utilize for background generation. If none use DataSet mask (default None)
combineForegroundMask (bool): If true, combine background mask with foreground (default False)
- generateUFitDataset(pdData, q1, q2, rlu, width, minPixel, Emin, Emax, QDirection=True)[source]¶
Generate uFitDataset from cut.
- Parameters
pdData (-) – Data generated from 1D cut
q1 (-) – Start point for cut
q2 (-) – End point for cut
rlu (-) – If in reciprocal lattice unites or not
width (-) – Width size (used for rounding of labels)
minPixel (-) – Minimum pixel size (used for rounding of labels)
Emin (-) – Minimum energy
Emax (-) – Maximum energy
Kwargs:
QDirection (bool): If true ufitdata is created along Q, otherwise energy (default True)
- plotA3A4(dataFiles=None, ax=None, planes=[], log=False, returnPatches=False, binningDecimals=3, singleFigure=False, plotTessellation=False, Ei_err=0.05, temperature_err=0.2, magneticField_err=0.2, electricField_err=0.2)[source]¶
Plot data files together with pixels created around each point in A3-A4 space. Data is binned in the specified planes through their A3 and A4 values. This can result in distorted binning when binning across large energy regions. Data is plotted using the pixels calculated for average plane value, i.e. binning 7,8,9,10, and 11 patches for plane 9 are used for plotting.
- Kwargs:
dataFiles (DataFiles): single file or list of files to be binned together (Default self.convertedFiles)
ax (matplotlib axis): Axis into which the planes are to be plotted (Default None, i.e. new)
planes (list (of lists)): Planes to be plotted and binned (default [])
log (bool): Whether or not to plot intensities as logarithm (default False)
returnPatches (bool): If true the method returns the patches otherwise plotted in the given axis (default False)
binningDecimals (int): Number of decimal places Q positions are rounded before binning (default 3)
singleFigure (bool): If true, all planes are plotted in same figure (default False)
plotTessellation (bool): Plot Tessellation of points (default False)
Ei_err (float): Tolerance of E_i for which the values are equal (default = 0.05)
temperature_err (float): Tolerance of temperature for which the values are equal (default = 0.2)
magneticField_err (float): Tolerance of magnetic field for which the values are equal (default = 0.2)
electricField_err (float): Tolerance of electric field for which the values are equal (default = 0.2)
- Returns
axis (list of) containing figures for plotted planes.
- Return type
ax (matplotlib axis or list of)
- Raises
- NotImplimentedError –
Examples:
The following example will combine the two files and plot all of the available planes in different figures.
>>> DS = DataSet.DataSet(convertedFiles=[--.nxs,---.nxs]) >>> plt.figure() >>> ax = plt.gca() >>> >>> DataSet.plotA3A4(DS.convertedFiles,ax=ax)
If only a subset of planes or different planes are to be combined the following will achieve this:
>>> DataSet.plotA3A4(DS.convertedFiles,ax=ax,planes=[0,1,2,3,[4,5,6],[8,9]])
Here planes 0 through 3 are plotted separately while 4,5, and 6 as well as 8 and 9 are binned.
Note
Binning planes from different analysers might result in nonsensible binnings.
- plotCut1D(q1, q2, width, minPixel, Emin, Emax, rlu=True, ax=None, plotCoverage=False, showEnergy=True, counts=False, extend=False, data=None, dataFiles=None, constantBins=False, backgroundSubtraction=False, ufit=False, plotForeground=False, plotBackground=False, outputFunction=<built-in function print>, **kwargs)[source]¶
plot new or already performed cut.
- Parameters
q1 (-) – Start position of cut in format (h,k,l) or (qx,qy) depending on rlu flag.
q2 (-) – End position of cut in format (h,k,l) or (qx,qy) depending on rlu flag.
width (-) – Full width of cut in q-plane in 1/AA, only needed for new cut (default None)
minPixel (-) – Minimal size of binning along the cutting direction. Points will be binned if they are closer than minPixel.
Emin (-) – Minimal energy to include in cut.
Emax (-) – Maximal energy to include in cut.
If a background subtraction is performed, the following columns are also present:
Int_Fg: Normalized foreground intensity
Int_Bg: Normalized background intensity
Int_Fg_err: Normalized foreground error
Int_Bg_err: Normalized background error
intensity_Fg: Accumulated foreground neutron number
intensity_Bg: Accumulated background neutron number
- plotCut1DE(E1, E2, q, rlu=True, width=0.02, minPixel=0.1, showQ=True, counts=False, dataFiles=None, constantBins=False, ax=None, ufit=False, data=None, backgroundSubtraction=False, plotForeground=False, plotBackground=False, outputFunction=<built-in function print>, **kwargs)[source]¶
Perform 1D cut through constant Q point returning binned intensity, monitor, normalization and normcount. The width of the cut is given by the width attribute.
- Parameters
E1 (-) – Start energy.
E2 (-) – End energy.
q (-) – Q point
Kwargs:
rlu (bool): If True, provided Q point is interpreted as (h,k,l) otherwise as (qx,qy), (Default true)
width (float): Full width of cut in q-plane (default 0.02).
minPixel (float): Minimal size of binning along the cutting direction. Points will be binned if they are closer than minPixel (default 0.1).
showQ (bool): If True show the current Q point on the x-axus (default True)
counts (bool): If True, plot raw counts, if False plot intensity, if ‘sensitivity’ plot mean sensitivity (Default False)
dataFiles (list): Data files to be used. If none provided use the ones in self (default None)
constantBins (bool): If True only bins of size minPixel is used (default False)
ufit (bool): If True a uFit Dataset object is returned in stead of pandas data frame
ax (matplotlib.axes): If None, new axis is created in which to plot (default None)
data ([data Pandas Dataframe, bins]): Data and bins from previously created cut (default None)
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
plotForeground (bool): If true, and background subtraction is true, plot the unsubtracted foreground data (default False)
plotBackground (bool): If true, and background subtraction is true, plot the corresponding background data (default False)
kwargs: Pass on to the ax.errorbar method used to plot
- Returns
See below
Bin list (1 array): Bin edge positions in energy
A Pandas data frame returns is returned with the following columns:
Qx: X component of scattering vector in instrument frame of reference
Qy: Y component of scattering vector in instrument frame of reference
H: H component of scattering vector in sample frame of reference
K: H component of scattering vector in sample frame of reference
L: H component of scattering vector in sample frame of reference
Int: Normalized intensity proportional to S(Q,Omega)
Int_err: Error of normalized intensity
intensity: Accumulated neutron number - either background subtracted or true neutron count
Monitor: Accumulated monitor in bin
Normalization: Accumulated normalization in bin
BinCount: Number of insertions into bin
BinDistance: If present, describes plotting position in axis
- Return type
Data list (pandas DataFrame)
If a background subtraction is performed, the following columns are also present:
Int_Fg: Normalized foreground intensity
Int_Bg: Normalized background intensity
Int_Fg_err: Normalized foreground error
Int_Bg_err: Normalized background error
intensity_Fg: Accumulated foreground neutron number
intensity_Bg: Accumulated background neutron number
- plotCutELine(Q1, Q2, ax=None, Emin=None, Emax=None, energyWidth=0.05, minPixel=0.02, width=0.02, rlu=True, counts=False, dataFiles=None, constantBins=False, Vmin=None, Vmax=None, backgroundSubtraction=False, **kwargs)[source]¶
Perform cut along energy in steps between two Q Point
- Parameters
Q1 (-) – Starting point for energy cut.
Q2 (-) – End of energy cut
Kwargs:
ax (matplotlib axis): Axis into which the plot is to go (default None, new created)
Emin (float): Start energy (default is self.Energy.min() for data in cut).
Emax (float): End energy (default is self.Energy.max() for data in cut).
energyWidth (float): Height of energy bins (default 0.05 meV)
minPixel (float): Minimal size of binning along the cutting direction. Points will be binned if they are closer than minPixel (default 0.1).
width (float): Full width of cut in q-plane (default 0.02).
rlu (bool): If True, provided Q point is interpreted as (h,k,l) otherwise as (qx,qy), (Default true)
counts (bool): If True, plot raw counts, if False plot intensity, if ‘sensitivity’ plot mean sensitivity (Default False)
dataFiles (list): Data files to be used. If none provided use the ones in self (default None)
constantBins (bool): If True only bins of size minPixel is used (default False)
Vmin (float): Lower limit for colorbar (default min(Intensity)).
Vmax (float): Upper limit for colorbar (default max(Intensity)).
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
- Returns
DataFrame containing qx,qy,H,K,L,Intensity,Normalization,Monitor,BinCount,Int,binDistance for 1D cut.
Bin list (1 array): Bin edge positions in energy
- Return type
Data list (pandas DataFrame)
- plotCutPowder(EBins, QBins, ax=None, dataFiles=None, log=False, colorbar=True, backgroundSubtraction=False, vmin=None, vmax=None, outputFunction=<built-in function print>, **kwargs)[source]¶
Plotting wrapper for the cutPowder method. Generates a 2D plot of powder map with intensity as function of the length of q and energy.
Note
Can only perform cuts for a constant energy plane of definable width.
- Parameters
EBins (-) – Energy bin edges.
QBins (-) – Q length bin edges.
Kwargs:
ax (matplotlib axis): Figure axis into which the plots should be done (default None). If not provided, a new figure will be generated.
dataFiles (list): List of dataFiles to cut (default None). If none, the ones in the object will be used.
log (bool): If true, logarithm to intensity is plotted (default False)
colorbar (bool): If True a colorbar is added to the figure (default True)
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
vmin (float): Minimum value for color scale
vmax (float): Maximum value for color scale
outputFunction (function): Function called on output strung (default print)
kwargs: All other keywords will be passed on to the ax.pcolormesh method.
- Returns
Matplotlib axis into which the plot was put.
Data list (pandas DataFrame): DataFrame containing qx,qy,H,K,L,Intensity,Normalization,Monitor,BinCount,Int,binDistance for poweder cut.
- Return type
ax (matplotlib axis)
- plotCutQE(q1, q2, EMin=None, EMax=None, dE=None, EnergyBins=None, minPixel=0.05, width=0.1, rlu=True, counts=False, smoothing=None, ax=None, grid=False, cmap=None, colorbar=False, outputFunction=<built-in function print>, dataFiles=None, backgroundSubtraction=False, scaledEnergy=False, scaleFunction=<function scale>, rescaleFunction=<function rescale>, cut1DFunctionRectanglePerpendicular=None, cut1DFunctionRectangleHorizontal=None, cut1DFunctionRectangleVertical=None, **kwargs)[source]¶
plot of intensity as function of Q between Q1 and Q2 and Energy.
- Parameters
q1 (-) – List of HKL or QxQy position of start of cut
q2 (-) – List of HKL or QxQy position of end of cut
Kwargs:
EMin (float): Minimal energy of cut (default None, see note below)
EMax (float): Maximal energy of cut (default None, see note below)
dE (float): Energy step of cut (default None, see note below)
EnergyBins (list): List of energy bin edges (default None, see note below)
scaledEnergy (bool/float): If true or float, rescale energy axis by E*f (default False)
scaleFunction (function): Function used to scale energy bins (default _tools.scale)
rescaleFunction (function): Function used to reverse energy bins (default _tools.rescale)
minPixel (float): Step size in 1/A along cut (default 0.05)
width (float): Integration width in 1/A perpendicular to cut (default 0.1)
rlu (bool): If True, plot as function of HKL otherwise QxQy (default True)
counts (bool): If True, plot raw counts, if False plot intensity, if ‘sensitivity’ plot mean sensitivity (Default False)
smoothing (float): Gaussian smoothing applied to data after cut (default None, see scipy.ndimage.gaussian_filter)
ax (plt axes): Axis into which data is plotted (default None, creates new, if False no plotting)
grid (float): If True, plot grid. If number provided plot grid with this z value (default False)
cmap (str): Color map used for plotting (default viridis)
vmin (float): Lower value of color scale (default None, minimum of intensity)
vmax (float): Upper value of color scale (default None, maxmimum of intensity)
log (bool): If true the plotted intensity is the logarithm of the intensity (default False)
colorbar (bool): If True, plot colorbar (default False)
outputFunction (function): Function called when onclick on axis is triggered (default print)
cut1DFunctionRectanglePerpendicular (function): Function called when performing a perpendicular cut
cut1DFunctionRectangleHorizontal (function): Function called when performing horizontal cut in the curren view
cut1DFunctionRectangleVertical (function): Function called when performing horizontal cut in the curren view
dataFiles (list): List of dataFiles to cut (default None). If none, the ones in the object will be used.
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
- Returns
Matplotlib axis in which data is plotted
Data (pandas DataFrame): See below
Bins
- Return type
ax (plt axes)
- Raises
- AttributeError –
Note
When EnergyBins is provided, this overwrites EMin, EMax, and dE. Otherwise bins are created linearly between EMin and EMax in steps of dE, np.arange(EMin,EMax+dE,dE) with length n.
A Pandas data frame returns is returned with the following columns:
Qx: X component of scattering vector in instrument frame of reference
Qy: Y component of scattering vector in instrument frame of reference
H: H component of scattering vector in sample frame of reference
K: H component of scattering vector in sample frame of reference
L: H component of scattering vector in sample frame of reference
Int: Normalized intensity proportional to S(Q,Omega)
Int_err: Error of normalized intensity
intensity: Accumulated neutron number - either background subtracted or true neutron count
Monitor: Accumulated monitor in bin
Normalization: Accumulated normalization in bin
BinCount: Number of insertions into bin
BinDistance: If present, describes plotting position in axis
If a background subtraction is performed, the following columns are also present:
Int_Fg: Normalized foreground intensity
Int_Bg: Normalized background intensity
Int_Fg_err: Normalized foreground error
Int_Bg_err: Normalized background error
intensity_Fg: Accumulated foreground neutron number
intensity_Bg: Accumulated background neutron number
- plotCutQELine(QPoints, EnergyBins, width=0.1, minPixel=0.01, rlu=True, ax=None, dataFiles=None, constantBins=True, outputFunction=<built-in function print>, backgroundSubtraction=False, **kwargs)[source]¶
Plotting wrapper for the cutQELine method. Plots the scattering intensity as a function of Q and E for cuts between specified Q-points.
- Parameters
QPoints (-) – List of Q points in either RLU (3D) or QxQy (2D).
EnergyBins (-) – List of bin edges in the energy direction.
Kwargs:
width (float): Width perpendicular to Q-direction for cuts (default 0.1)
minPixel (float): Minimum size of pixel for cut (default 0.01)
rlu (bool): If True, provided points are interpreted as (h,k,l) otherwise (qx,qy), (default RLU)
ax (matplotlib axis): Axis into whiht the data is plotted. If None a new will be created (default None).
dataFiles (DataFile(s)): DataFile or list of, from which data is to be taken. If None all datafiles in self is taken (default None).
vmin (float): Lower limit for colorbar (default min(Intensity)).
vmax (float): Upper limit for colorbar (default max(Intensity)).
ticks (int): Number of ticks in plot, minimum equal to number of Q points (default None - adaptive).
plotSeperator (bool): If true, vertical lines are plotted at Q points (default True).
seperatorWidth (float): Width of seperator line (default 2).
seperatorColor (str or list): Color of the seperator line (default k)
log (bool): If true the plotted intensity is the logarithm of the intensity (default False)
constantBins (bool): If True only bins of size minPixel is used (default True)
outputFunction (function): Function called on output string (default print)
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
Return: m = Q points, n = energy bins
ax: matplotlib axis in which the data is plotted
Data list (pandas DataFrame): DataFrame containing qx,qy,H,K,L,Intensity,Normalization,Monitor,BinCount,Int,binDistance for all 2D cuts.
Bin list (m * n * 3 arrays): n instances of bin edge positions in plane of size (m+1,3), orthogonal positions of bin edges in plane of size (2,2), and energy edges of size (2).
Note
The ax.set_clim function is created to change the colour scale. It takes inputs vmin,vmax. This function does however not work in 3D….
- plotQPlane(EMin=None, EMax=None, EBins=None, binning='xy', xBinTolerance=0.05, yBinTolerance=0.05, enlargen=False, log=False, ax=None, rlu=True, dataFiles=None, xScale=1.0, yScale=1.0, backgroundSubtraction=False, outputFunction=<built-in function print>, cut1DFunctionRectangle=None, cut1DFunctionCircle=None, scaleFunction=None, **kwargs)[source]¶
Wrapper for plotting tool to show binned intensities in the Q plane between provided energies.
Kwargs:
EMin (float): Lower energy limit (Default None).
EMax (float): Upper energy limit (Default None).
EBins (list): List of energy bins (Default None).
binning (str): Binning scheme, either ‘xy’ or ‘polar’ (default ‘xy’).
xBinTolerance (float): bin sizes along x direction (default 0.05). If enlargen is true, this is the minimum bin size.
yBinTolerance (float): bin sizes along y direction (default 0.05). If enlargen is true, this is the minimum bin size.
enlargen (bool): If the bin sizes should be adaptive (default False). If set true, bin tolerances are used as minimum bin sizes.
log (bool): Plot intensities as the logarithm (default False).
ax (matplotlib axes): Axes in which the data is plotted (default None). If None, the function creates a new axes object.
rlu (bool): If true and axis is None, a new reciprocal lattice axis is created and used for plotting (default True).
dataFiles (DataFile): If set, method uses these converted data files instead of the ones in self (default None)
vmin (float): Lower limit for colorbar (default min(Intensity)).
vmax (float): Upper limit for colorbar (default max(Intensity)).
colorbar (bool): If True, a colorbar is created in figure (default False)
zorder (int): If provided decides the z ordering of plot (default 10)
outputFunction (function): Function called on output string (default print)
cut1DFunctionRectangle (function): Function to be called when a 1D rectangular cut is created (default None)
cut1DFunctionCircle (function): Function to be called when a circuar cut is created (default None)
backgroundSubtraction (bool): If true, utilize the Background object on the data set to perform background subtraction (default False)
scaleFunction (function): Function to rescale the plotted intensity (default None)
other: Other key word arguments are passed to the pcolormesh plotting algorithm.
- Returns
See below
ax (matplotlib axes): Returns provided matplotlib axis
- Return type
data (Pandas datafrane)
Note
The axes object has a new method denoted ‘set_clim’ taking two parameters (VMin and VMax) used to change axes colouring.
Note
If a 3D matplotlib axis is provided, the planes are plotted in 3D with the provided energy bins. As the method contourf is used and it needs X,Y, and Z to have same shape, x and y are found as middle of bins.
A Pandas data frame returns is returned with the following columns:
Qx: X component of scattering vector in instrument frame of reference
Qy: Y component of scattering vector in instrument frame of reference
H: H component of scattering vector in sample frame of reference
K: H component of scattering vector in sample frame of reference
L: H component of scattering vector in sample frame of reference
Int: Normalized intensity proportional to S(Q,Omega)
Int_err: Error of normalized intensity
intensity: Accumulated neutron number - either background subtracted or true neutron count
Monitor: Accumulated monitor in bin
Normalization: Accumulated normalization in bin
BinCount: Number of insertions into bin
BinDistance: If present, describes plotting position in axis
If a background subtraction is performed, the following columns are also present:
Int_Fg: Normalized foreground intensity
Int_Bg: Normalized background intensity
Int_Fg_err: Normalized foreground error
Int_Bg_err: Normalized background error
intensity_Fg: Accumulated foreground neutron number
intensity_Bg: Accumulated background neutron number
- plotRaw1D(detectorSelection=None, analyzerSelection=None, legend=True, grid=-10, outputFunction=<built-in function print>)[source]¶
plot 1D figures of data in the specified DASEL.
- kwargs:
detectorSelection (int): Detector to be used (default from file)
analyzerSelection (int): Analyzer segment to be used (default from file)
legend (bool list): Insert legend with provided names or file names (default True)
grid (bool, Int): If true plot at grid on figure. If integer set zorder of grid (default -10)
- Returns
List of axes in which data are plotted.
- Return type
Ax (list)
- symmetrize(function)[source]¶
Symmetrize data by providing a custom function
- Parameters
function (function) – Function to symmetrize
The signature of the function must be func(H,K,L) and must return (H,K,L). An example is
>>> def symmetrize(H,K,L): >>> return np.abs(H),np.abs(K),np.abs(L)
- updateCalibration(calibFiles, overwrite=False)[source]¶
Update calibrations for all data files in data set. Does not save the changes.
Args:
calibrationFile (string or list): calibration file, as generated from MJOLNIR.Geometry.Instrument or list of these.
Kwargs:
overwrite (bool): If true, previous binnings will be overwritten if new files contain same binning (default False)
Note
Changes performed by this method is not saved to disk.