NuclearReflectivityEnergy

class nexus.NuclearReflectivityEnergy(Measurement self, Experiment experiment, std::string const id="")
class nexus.NuclearReflectivityEnergy(Measurement self, Experiment experiment, DoubleVector detuning, std::string const id="") → Measurement

Bases: FitMeasurement

Constructor for the NuclearReflectivityEnergy class. Class to calculate the angular-dependent and energy-integrated total 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 whose angle is changed.

    Changed in version 2.0.0: changed from old Sample class to GrazingSample.

  • angles (list) – List of the angles.

  • detuning (list or ndarray) – Detuning values for the calculation.

  • intensity_data (list or ndarray) – Intensity data for fitting.

  • scaling (float or Var or string) – Intensity scaling factor for fitting. Default is auto.

  • background (float or Var or string) – Background for fitting. Default is 0.

  • offset (float or Var) –

    Angular offset of the model. Default is 0.

    Added in version 1.1.0.

  • resolution (float or Var) –

    Resolution value for convolution.

    Removed in version 2.0.0.

  • fit_weight (float) – Relative weight for the cost function in multi measurement fitting.

  • instrument (Instrument) –

    Instrument object with the implementation of a resolution function. Default is a Gaussian instrument function with 0.001 degree FWHM.

    Added in version 2.0.0.

  • residual (Residual) – Implementation of the residual calculation used for fitting.

  • time_gate (list) –

    An empty or two element list. If a two element list is passed these two values [start, stop] are taken as a time gating. The spectrum is Fourier transformed, the time gate is applied, and time response is transformed back to a spectrum. This does not give a time gated Moessbauer spectrum. Given in ns.

    Added in version 1.0.1.

  • coherence (bool) –

    Determines if the summation over the thickness and divergence distributions is performed coherently (True) or incoherently (False). Default is False.

    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:

Experiment

sample

Sample whose angle is changed.

Changed in version 2.0.0: changed from old Sample class to GrazingSample.

Type:

GrazingSample

angles

List of the angles.

Type:

list

detuning

Detuning values for the calculation.

Type:

list or ndarray

result

List of angle-dependent energy-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

scaling

Intensity scaling factor for fitting.

Type:

Var

background

Background for fitting.

Type:

Var

offset

Angular offset of the model. Default is 0.

Added in version 1.1.0.

Type:

float or Var

resolution

Resolution value for convolution.

Removed in version 2.0.0.

Type:

Var

resolution_kernel

Weight of the Gaussian resolution same step size as detuning.

Removed in version 2.0.0.

Type:

list

fit_weight

Relative weight for the cost function in multi measurement fitting.

Type:

float

instrument

Instrument object with the implementation of a resolution function. Default is a Gaussian instrument function with 0.001 degree FWHM.

Added in version 2.0.0.

Type:

Instrument

residual

Implementation of the residual calculation used for fitting.

Type:

Residual

time_gate

An empty or two element list. If a two element list is passed these two values [start, stop] are taken as a time gating. The spectrum is Fourier transformed, the time gate is applied, and time response is transformed back to a spectrum. This does not give a time gated Moessbauer spectrum. Given in ns.

Added in version 1.0.1.

Type:

list

coherence

Determines if the summation over the thickness and divergence distributions is performed coherently (True) or incoherently (False). Default is False.

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 NuclearReflectivityEnergy.

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.

PopulateFitHandler(FitMeasurement self, OptimizerHandler fit_handler)
PopulateOptimizerHandler(Measurement self, OptimizerHandler optimizer_handler)
Residuals(NuclearReflectivityEnergy self) → double
SetCeresFitParameterPointers(FitMeasurement self, double const *const * parameters)
SetFitEqualities(FitMeasurement self)
SetNLoptFitParameterPointers(FitMeasurement self)
SetPagmoFitParameterPointers(FitMeasurement self, DoubleVector inputs)
Update(Measurement self)
Velocity()

Returns the velocity detuning of the measurement in units of mm/s.

Returns:

Velocity detuning (mm/s).

Return type:

ndarray

property angles

std::vector<(double,std::allocator<(double)>)>

Type:

angles

property background

p.Var

Type:

background

property bare_residuals

std::vector<(double,std::allocator<(double)>)>

Type:

bare_residuals

property bootstrap_fit_result

std::vector<(double,std::allocator<(double)>)>

Type:

bootstrap_fit_result

property bootstrap_residuals

std::vector<(double,std::allocator<(double)>)>

Type:

bootstrap_residuals

property coherence

bool

Type:

coherence

property data_size

size_t

Type:

data_size

property detuning

std::vector<(double,std::allocator<(double)>)>

Type:

detuning

property distribution_points

unsigned int

Type:

distribution_points

property experiment

p.Experiment

Type:

experiment

property fit_equalities

std::vector<(p.Var,std::allocator<(p.Var)>)>

Type:

fit_equalities

property fit_parameter_pointers

std::vector<(p.double,std::allocator<(p.double)>)>

Type:

fit_parameter_pointers

property fit_residuals

std::vector<(double,std::allocator<(double)>)>

Type:

fit_residuals

property fit_weight

double

Type:

fit_weight

property id

std::string

Type:

id

property inequality

p.Inequality

Type:

inequality

property input_intensity_data

std::vector<(double,std::allocator<(double)>)>

Type:

input_intensity_data

property instrument

p.Instrument

Type:

instrument

property intensity_data

std::vector<(double,std::allocator<(double)>)>

Type:

intensity_data

property nlopt_fit_parameters_ptr

p.double

Type:

nlopt_fit_parameters_ptr

property offset

p.Var

Type:

offset

property print_progress

bool

Type:

print_progress

property residual

p.Residual

Type:

residual

property result

std::vector<(double,std::allocator<(double)>)>

Type:

result

property sample

p.GrazingSample

Type:

sample

property scaling

p.Var

Type:

scaling

property sum_user_residuals

double

Type:

sum_user_residuals

property time

std::vector<(double,std::allocator<(double)>)>

Type:

time

property time_gate

std::vector<(double,std::allocator<(double)>)>

Type:

time_gate