The BornAgain I/O module supports only a few file formats: ascii
, tiff
and our own internal format. This might be not enough when it comes to the fitting of data obtained from some particular instrument.
However, we fully support fitting of the data presented in the form of numpy
arrays.
The fitting workflow is as follows:
In the code snippet below we show how to create a numpy array from a file in edf
format using the fabio library.
import fabio
img = fabio.open("experimental_data.edf")
print(img.header)
data = img.data.astype("float64")
Later in the code this data array can be used to setup a fitting job.
import bornagain as ba
fit_objective = FitObjective()
fit_objective.addSimulationAndData(simulation_builder, data)
The BornAgain I/O module supports a limited amount of file formats: ascii
, 32-bits tiff
and an internal text format int
.
If the file name contains .gz
or .bzip2
extensions, the module considers them as compressed and performs uncompressing on-the-flight.
import bornagain as ba
data = ba.IOFactory.readDatafield("experimental_data.int.gz")