Class Datafield

Class Datafield holds experimental or simulated scattering data.

Most important, the function simulation.simulate() returns an object of class Datafield.

A Datafield object contains

  • an array with radiation intensities,
  • optionally, an array with error estimates,
  • coordinate axes, and
  • optionally, a title.

Modify

To set the title of Datafield df:

df.setTitle("text")

This is particularly useful for disambiguating datafields that are put together in a list. The plotting functions use datafield titles to generate a legend.

For coordinate systems and axis transformations, see Axis coordinates and transformations.

Export

For detailed reference, see Export.

To save Datafield values from Python, extract NumPy arrays and use NumPy or another file-format package:

import numpy as np

np.savetxt(file_name, df.intensities())

To extract NumPy arrays from a Datafield df:

df.xCenters()     # centers of x bins
df.yCenters()     # centers of y bins (2D data)
df.intensities()  # intensities
df.errors()       # error estimates thereof

Plot

For detailed reference, see Plotting.

To plot a Datafield df:

import bornagain as ba

ba.plot_datafield(df)
ba.plt.show()

Analyze

To analyze a 2D Datafield, see