BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IntensityDataIOFactory Class Reference

Provides users with possibility to read and write IntensityData from/to files in different format. More...

Static Public Member Functions

static IHistogram * readIntensityData (const std::string &file_name)
 Reads file and returns newly created Histogram object.
 
static OutputData< double > * readOutputData (const std::string &file_name)
 Reads file and returns newly created OutputData object.
 
static OutputData< double > * readReflectometryData (const std::string &file_name)
 
static void writeIntensityData (const IHistogram &histogram, const std::string &file_name)
 Writes histogram in file.
 
static void writeOutputData (const OutputData< double > &data, const std::string &file_name)
 Writes OutputData in file.
 
static void writeSimulationResult (const SimulationResult &result, const std::string &file_name)
 Writes OutputData contained in the given SimulationResult object.
 

Detailed 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 = IntensityDataIOFactory.readIntensityData("filename.txt")
histogram = IntensityDataIOFactory.readIntensityData("filename.txt.gz")
# writing to 32-bits tiff file or b-zipped tiff file
IntensityDataIOFactory.writeIntensityData(histogram, "filename.tif.bz2")
static IHistogram * readIntensityData(const std::string &file_name)
Reads file and returns newly created Histogram object.
Definition: IntensityDataIOFactory.cpp:61
static void writeIntensityData(const IHistogram &histogram, const std::string &file_name)
Writes histogram in file.
Definition: IntensityDataIOFactory.cpp:125