8. Data layout and plotting routines¶
sasmodels.data
¶
SAS data representations.
Plotting functions for data sets:
plot_data()
plots the data file.
plot_theory()
plots a calculated result from the model.
Wrappers for the sasview data loader and data manipulations:
load_data()
loads a sasview data file.
set_beam_stop()
masks the beam stop from the data.
set_half()
selects the right or left half of the data, which can be useful for shear measurements which have not been properly corrected for path length and reflections.
set_top()
cuts the top part off the data.
Empty data sets for evaluating models without data:
empty_data1D()
creates an empty dataset, which is useful for plotting a theory function before the data is measured.
empty_data2D()
creates an empty 2D dataset.
Note that the empty datasets use a minimal representation of the SasView objects so that models can be run without SasView on the path. You could also use these for your own data loader.
-
class
sasmodels.data.
Data1D
(x=None, y=None, dx=None, dy=None)¶ Bases:
object
1D data object.
Note that this definition matches the attributes from sasview, with some generic 1D data vectors and some SAS specific definitions. Some refactoring to allow consistent naming conventions between 1D, 2D and SESANS data would be helpful.
Attributes
x, dx: \(q\) vector and gaussian resolution
y, dy: \(I(q)\) vector and measurement uncertainty
mask: values to include in plotting/analysis
dxl: slit widths for slit smeared data, with dx ignored
qmin, qmax: range of \(q\) values in x
filename: label for the data line
_xaxis, _xunit: label and units for the x axis
_yaxis, _yunit: label and units for the y axis
-
xaxis
(label, unit)¶ set the x axis label and unit
-
yaxis
(label, unit)¶ set the y axis label and unit
-
-
class
sasmodels.data.
Data2D
(x=None, y=None, z=None, dx=None, dy=None, dz=None)¶ Bases:
object
2D data object.
Note that this definition matches the attributes from sasview. Some refactoring to allow consistent naming conventions between 1D, 2D and SESANS data would be helpful.
Attributes
qx_data, dqx_data: \(q_x\) matrix and gaussian resolution
qy_data, dqy_data: \(q_y\) matrix and gaussian resolution
data, err_data: \(I(q)\) matrix and measurement uncertainty
mask: values to exclude from plotting/analysis
qmin, qmax: range of \(q\) values in x
filename: label for the data line
_xaxis, _xunit: label and units for the x axis
_yaxis, _yunit: label and units for the y axis
_zaxis, _zunit: label and units for the y axis
Q_unit, I_unit: units for Q and intensity
x_bins, y_bins: grid steps in x and y directions
-
xaxis
(label, unit)¶ set the x axis label and unit
-
yaxis
(label, unit)¶ set the y axis label and unit
-
zaxis
(label, unit)¶ set the y axis label and unit
-
-
class
sasmodels.data.
Detector
(pixel_size=(None, None), distance=None)¶ Bases:
object
Detector attributes.
-
class
sasmodels.data.
Sample
¶ Bases:
object
Sample attributes.
-
class
sasmodels.data.
SesansData
(**kw)¶ Bases:
sasmodels.data.Data1D
SESANS data object.
This is just
Data1D
with a wavelength parameter.x is spin echo length and y is polarization (P/P0).
-
xaxis
(label, unit)¶ set the x axis label and unit
-
yaxis
(label, unit)¶ set the y axis label and unit
-
isSesans
= True¶
-
-
class
sasmodels.data.
Source
¶ Bases:
object
Beam attributes.
-
class
sasmodels.data.
Vector
(x=None, y=None, z=None)¶ Bases:
object
3-space vector of x, y, z
-
sasmodels.data.
demo
()¶ Load and plot a SAS dataset.
-
sasmodels.data.
empty_data1D
(q, resolution=0.0, L=0.0, dL=0.0)¶ Create empty 1D data using the given q as the x value.
rms resolution \(\Delta q/q\) defaults to 0%. If wavelength L and rms wavelength divergence dL are defined, then resolution defines rms \(\Delta \theta/\theta\) for the lowest q, with \(\theta\) derived from \(q = 4\pi/\lambda \sin(\theta)\).
-
sasmodels.data.
empty_data2D
(qx, qy=None, resolution=0.0)¶ Create empty 2D data using the given mesh.
If qy is missing, create a square mesh with qy=qx.
resolution dq/q defaults to 5%.
-
sasmodels.data.
load_data
(filename, index=0)¶ Load data using a sasview loader.
-
sasmodels.data.
plot_data
(data, view='log', limits=None)¶ Plot data loaded by the sasview loader.
data is a sasview data object, either 1D, 2D or SESANS.
view is log or linear.
limits sets the intensity limits on the plot; if None then the limits are inferred from the data.
-
sasmodels.data.
plot_theory
(data, theory, resid=None, view='log', use_data=True, limits=None, Iq_calc=None)¶ Plot theory calculation.
data is needed to define the graph properties such as labels and units, and to define the data mask.
theory is a matrix of the same shape as the data.
view is log or linear
use_data is True if the data should be plotted as well as the theory.
limits sets the intensity limits on the plot; if None then the limits are inferred from the data.
Iq_calc is the raw theory values without resolution smearing
-
sasmodels.data.
protect
(func)¶ Decorator to wrap calls in an exception trapper which prints the exception and continues. Keyboard interrupts are ignored.
-
sasmodels.data.
set_beam_stop
(data, radius, outer=None)¶ Add a beam stop of the given radius. If outer, make an annulus.
-
sasmodels.data.
set_half
(data, half)¶ Select half of the data, either “right” or “left”.
-
sasmodels.data.
set_top
(data, cutoff)¶ Chop the top off the data, above cutoff.