Plotting - Time spectrum

[1]:
import nexus as nx
import numpy as np
import matplotlib.pyplot as plt

iron = nx.Material.Template(nx.lib.material.Fe)

layer_Fe = nx.Layer(id = "Fe layer",
                    material = iron,
                    thickness = 3000)

site = nx.Hyperfine(magnetic_field = 33,
                    magnetic_theta = 90,
                    magnetic_phi = 0,
                    isotropic = False)

iron.hyperfine_sites = [site]

sample = nx.Sample(layers = [layer_Fe])

beam = nx.Beam()
beam.LinearSigma()

exp = nx.Experiment(beam = beam,
                    objects = [sample],
                    isotope = nx.lib.moessbauer.Fe57)

time_spectrum = nx.TimeSpectrum(experiment = exp,
                                time_length = 200,
                                time_step = 0.5,
                                bunch_spacing = 192.2, # PETRA III bunch spacing
                                id = "my time spectrum")

time, intensity = time_spectrum.Calculate()
[2]:
time_spectrum.Plot()
../../_images/tutorial_plotting_nb_plot_time_spectrum_2_0.png
[3]:
intensity = np.round(1e5* intensity)
[4]:
time_spectrum_2 = nx.TimeSpectrum(experiment = exp,
                                time_data = time,
                                intensity_data = intensity,
                                time_length = 200,
                                time_step = 0.2,
                                bunch_spacing = 192.2, # PETRA III bunch spacing
                                id = "my time spectrum")

t, i = time_spectrum_2.Calculate()
[5]:
time_spectrum_2.Plot(errors=True, datalinestyle="solid")
../../_images/tutorial_plotting_nb_plot_time_spectrum_5_0.png
[6]:
fit = nx.Fit([time_spectrum_2])

fit.options.method = "Subplex"

fit()

Run Fit instance with id:

Starting fit with 1 measurement data set(s) and 1 fit parameter(s):

  no. |                           id |       initial value |              min |              max
    0 |                   TS scaling |               29900 |                0 |         2.99e+08

Using 0 equality constraint(s) on parameter(s):

Using 0 inequality constraint(s).


Calling NLopt solver with fit method Subplex

Termination: parameter tolerance reached.

  cost = 1.104842e+01
  iterations: 47

Gradient error analysis.


Fit performed with algorithm:
Subplex
Error analysis:
Gradient

Using 1 fit parameter(s):

  no. |                           id |          fit value |   +/- std dev | initial value |          min |          max
    0 |                   TS scaling |            97864.7 |       311.945 |         29900 |            0 |     2.99e+08

Correlation matrix:

  no. |        0
 -----|---------
    0 |    1.000

Using 0 equality constraint(s) on parameter(s):

and 0 inequality constraint(s).

Total cost = 1.105e+01

cost for each FitMeasurement is:

  no. |                           id |                cost |                   %
    0 |             my time spectrum |           1.105e+01 |             100.000

Fit instance with id "" finished.

[7]:
time_spectrum_2.Plot(errors=True, datalinestyle="solid")
../../_images/tutorial_plotting_nb_plot_time_spectrum_7_0.png