NuclearReflectivity
- class nexus.NuclearReflectivity(experiment, sample, angles, time_start, time_stop, time_step, max_detuning=400.0, intensity_data=[], scaling='auto', background=0.0, offset=0.0, resolution=0.001, fit_weight=1.0, bunch_spacing=inf, residual=<nexus.clib.cnexus.Sqrt; proxy of <Swig Object of type 'Residual *'> >, coherence=False, print_progress=False, id='')
Bases:
FitMeasurement
Constructor for the
NuclearReflectivityEnergy
class. Class to calculate the angular dependent and time-integrated resonant scattering intensity of the experiment while for one sample the gracing-incidence angle is changed.- Parameters:
id (string) – User identifier.
experiment (
Experiment
) – Experiment.sample (
GrazingSample
) –Sample of the
Experiment
for the calculation.Changed in version 2.0.0: changed from old
Sample
class toGrazingSample
.angles (list) – List of the angles.
time_start (float) – Start time for the integration (ns).
time_stop (float) – Stop time for the integration (ns).
time_step (float) – Step size for the time axis (ns).
max_detuning (float) – Maximum value of the energy detuning in units of the resonant linewidth. Set this value to speed up the calculation. If zero no maximum is applied. The FFT window is always
auto
.intensity_data (list or ndarray) – Intensity data for fitting.
scaling (float or
Var
or string) – Intensity scaling factor for fitting. Default isauto
.background (float or
Var
or string) – Background for fitting. Default is0
.offset (float or
Var
) –Angular offset of the model. Defualt is
0
.Added in version 1.1.0.
resolution (float or
Var
) – Resolution value for convolution.fit_weight (float) – Relative weight for the cost function in multi measurement fitting.
bunch_spacing (float) – Spacing of subsequent X-ray bunches in time (nanoseconds).
residual (
Residual
) – Implementation of the residual calculation used for fitting.coherence (bool) –
Determines if the summation over the thickness and divergence distributions is performed coherently (
True
) or incoherently (False
). Default isFalse
.Added in version 1.0.3.
print_progrees (bool) –
Determines if the progress bar is printed. Default is
False
.Added in version 1.2.0.
- id
User identifier.
- Type:
string
- experiment
Experiment.
- Type:
- sample
Sample of the
Experiment
for the calculation.Changed in version 2.0.0: changed from old
Sample
class toGrazingSample
.- Type:
- angles
List of the angles.
- Type:
list
- time_start
Start time for the integration (ns).
- Type:
float
- time_stop
Stop time for the integration (ns).
- Type:
float
- time_step
Step size for the time axis (ns).
- Type:
float
- max_detuning
Maximum value of the energy detuning in units of the resonant linewidth. Set this value to speed up the calculation. If zero no maximum is applied. The FFT window is always
auto
.- Type:
float
- result
List of angle-dependent time-integrated intensity values in units of (\(\Gamma\)).
- Type:
list
- intensity_data
Intensity data for fitting.
- Type:
list
- data_size
Number of data points of experimental data.
- Type:
int
- resolution_kernel
weight of the Gaussian resolution same step size as detuning.
- Type:
list
- fit_weight
Relative weight for the cost function in multi measurement fitting.
- Type:
float
- bunch_spacing
Spacing of subsequent X-ray bunches in time (nanoseconds).
- Type:
float
- coherence
Determines if the summation over the thickness and divergence distributions is performed coherently (
True
) or incoherently (False
). Default isFalse
.Added in version 1.0.3.
- Type:
bool
- print_progrees
Determines if the progress bar is printed. Default is
False
.Added in version 1.2.0.
- Type:
bool
- Calculate()
Calculates the class method. Also callable via operator
()
.- Returns:
Array of intensity values.
- Return type:
ndarray
- Cost()
Get the cost function of the measurement
\[cost = \frac{1}{n} \sum_i r(y_i, \hat{y}_i)\]Added in version 2.0.0.
- Returns:
cost function value.
- Return type:
float
- MeanSquaredError()
Get the mean squared error (MSE) of the measurement
\[cost = \frac{1}{n} \sum_i (y_i - \hat{y}_i)^2\]Added in version 2.0.0.
- Returns:
MSE value.
- Return type:
float
- Plot(data=True, residuals=True, datacolor='black', theorycolor='r', theorywidth=2, datalinestyle='none', datamarker='+', datamarkersize=2, datafillstyle='full', legend=True, errors=False, errorcap=2, name=None)
Plot the
NuclearReflectivity
.Added in version 1.0.3.
Changed in version 1.2.0.
- Parameters:
data (bool) – Select if
intensity_data
should be plot.residuals (bool) – Select if
residuals
from fit should be plot.datacolor (string) – See matplotlib documentation.
theorycolor (string) – See matplotlib documentation.
theorywidth (float) – See matplotlib documentation.
datalinestyle (string) – See matplotlib documentation.
datamarker (string) – See matplotlib documentation.
datamarkersize (float) – See matplotlib documentation.
datafillstyle (string) – See matplotlib documentation.
legend (bool) – Select if legend should be plot when model and data are plot.
errors (bool) – Select if error bars should be plot.
errorcap (float) – See matplotlib documentation (
capsize
).name (string) –
If given, the plot is saved under this name.
Added in version 1.1.0.
- Velocity()
Returns the velocity detuning of the measurement in units of mm/s.
- Returns:
Velocity detuning (mm/s).
- Return type:
ndarray