BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
IOFactory Class Reference

Description

Provides users with possibility to read and write IntensityData from/to files in different format. Type of the file will be deduced from file name. *.txt - ASCII file with 2D array [nrow][ncol], layout as in numpy. *.int - BornAgain internal ASCII format. *.tif - 32-bits tiff file. If file name ends with "*.gz" or "*.bz2" the file will be zipped on the fly using appropriate algorithm.

Usage:

# reading from ASCII file or g-zipped ASCII file
histogram = IOFactory.readDatafield("filename.txt")
histogram = IOFactory.readDatafield("filename.txt.gz")
# writing to 32-bits tiff file or b-zipped tiff file
IOFactory.writeIntensityData(histogram, "filename.tif")
IOFactory.writeIntensityData(histogram, "filename.tif.bz2")
static Datafield * readDatafield(const std::string &file_name, LoaderSelector selector=automatic)
Reads file and returns newly created Datafield object. If selector is automatic, then the file extens...

Public Types

enum  LoaderSelector { automatic , bornagain , tiff , nicos }
 

Static Public Member Functions

static DatafieldreadDatafield (const std::string &file_name, LoaderSelector selector=automatic)
 Reads file and returns newly created Datafield object. If selector is automatic, then the file extension will be used to determine which file type to load. If selector is not automatic, then this selector will define which type of file to load (no matter which file extension or content). May throw, but will never return nullptr. More...
 
static DatafieldreadReflectometryData (const std::string &file_name)
 
static void writeDatafield (const Datafield &data, const std::string &file_name)
 Writes Datafield in file. More...
 
static void writeSimulationResult (const SimulationResult &result, const std::string &file_name)
 Writes Datafield contained in the given SimulationResult object. More...
 

Member Enumeration Documentation

◆ LoaderSelector

Enumerator
automatic 
bornagain 
tiff 
nicos 

Member Function Documentation

◆ readDatafield()

static Datafield* IOFactory::readDatafield ( const std::string &  file_name,
LoaderSelector  selector = automatic 
)
static

Reads file and returns newly created Datafield object. If selector is automatic, then the file extension will be used to determine which file type to load. If selector is not automatic, then this selector will define which type of file to load (no matter which file extension or content). May throw, but will never return nullptr.

◆ readReflectometryData()

static Datafield* IOFactory::readReflectometryData ( const std::string &  file_name)
static

◆ writeDatafield()

static void IOFactory::writeDatafield ( const Datafield data,
const std::string &  file_name 
)
static

Writes Datafield in file.

◆ writeSimulationResult()

static void IOFactory::writeSimulationResult ( const SimulationResult result,
const std::string &  file_name 
)
static

Writes Datafield contained in the given SimulationResult object.