BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
|
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:
Definition at line 46 of file IOFactory.h.
Public Types | |
enum | LoaderSelector { automatic , bornagain , tiff , nicos } |
Static Public Member Functions | |
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 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 Datafield * | readReflectometryData (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... | |
Static Private Member Functions | |
static bool | fileTypeMatchesLoaderSelector (const std::string &fileName, LoaderSelector selector) |
static Datafield * | readDatafield (const std::string &file_name, std::function< Datafield *(std::istream &)> readData) |
static void | writeDatafield (const std::string &file_name, std::function< void(std::ostream &)> writeData) |
|
staticprivate |
Definition at line 130 of file IOFactory.cpp.
References automatic, bornagain, DataUtils::Format::isIntFile(), DataUtils::Format::isNicosFile(), DataUtils::Format::isTiffFile(), nicos, and tiff.
Referenced by readDatafield().
|
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.
Definition at line 41 of file IOFactory.cpp.
References ASSERT, automatic, bornagain, fileTypeMatchesLoaderSelector(), nicos, ReadWriteINT::readDatafield(), ReadWriteNumpyTXT::readDatafield(), IO::readNicosData(), and tiff.
Referenced by IOUtil::filesAgree(), and readReflectometryData().
|
staticprivate |
Definition at line 152 of file IOFactory.cpp.
References BaseUtils::Filesystem::convert_utf8_to_utf16(), DataUtils::Format::isBZipped(), DataUtils::Format::isCompressed(), BaseUtils::Filesystem::IsFileExists(), DataUtils::Format::isGZipped(), and DataUtils::Format::isTiffFile().
|
static |
Definition at line 75 of file IOFactory.cpp.
References readDatafield(), and ReadReflectometry::readDatafield().
|
static |
Writes Datafield in file.
Definition at line 81 of file IOFactory.cpp.
References DataUtils::Format::isIntFile(), DataUtils::Format::isTiffFile(), ReadWriteINT::writeDatafield(), and ReadWriteNumpyTXT::writeDatafield().
Referenced by writeSimulationResult().
|
staticprivate |
Definition at line 95 of file IOFactory.cpp.
References BaseUtils::Filesystem::convert_utf8_to_utf16(), DataUtils::Format::isBZipped(), DataUtils::Format::isCompressed(), DataUtils::Format::isGZipped(), and DataUtils::Format::isTiffFile().
|
static |
Writes Datafield contained in the given SimulationResult object.
Definition at line 146 of file IOFactory.cpp.
References SimulationResult::datafield(), and writeDatafield().