BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
OutputDataWriteNumpyTXTStrategy Class Reference
Inheritance diagram for OutputDataWriteNumpyTXTStrategy:
Collaboration diagram for OutputDataWriteNumpyTXTStrategy:

Public Member Functions

virtual void writeOutputData (const OutputData< double > &data, std::ostream &output_stream)
 

Detailed Description

Strategy to write OutputData to simple ASCII file with the layout as in numpy.savetxt.

Definition at line 46 of file OutputDataWriteStrategy.h.

Member Function Documentation

◆ writeOutputData()

void OutputDataWriteNumpyTXTStrategy::writeOutputData ( const OutputData< double > &  data,
std::ostream &  output_stream 
)
virtual

Implements IOutputDataWriteStrategy.

Definition at line 113 of file OutputDataWriteStrategy.cpp.

115 {
116  output_stream << "# BornAgain Intensity Data" << std::endl;
117  output_stream << "# Simple array suitable for numpy, matlab etc." << std::endl;
118 
119  const size_t dim = data.getRank();
120  switch (dim) {
121  case 1:
122  Write1DRepresentation(data, output_stream);
123  break;
124  case 2:
125  Write2DRepresentation(data, output_stream);
126  break;
127  default:
128  throw std::runtime_error("Error in OutputDataWriteNumpyTXTStrategy::writeOutputData: data "
129  "of unsupported dimensions");
130  }
131 }
size_t getRank() const
Returns number of dimensions.
Definition: OutputData.h:59
void Write2DRepresentation(const OutputData< double > &data, std::ostream &output_stream)
void Write1DRepresentation(const OutputData< double > &data, std::ostream &output_stream)

References OutputData< T >::getRank(), anonymous_namespace{OutputDataWriteStrategy.cpp}::Write1DRepresentation(), and anonymous_namespace{OutputDataWriteStrategy.cpp}::Write2DRepresentation().

Here is the call graph for this function:

The documentation for this class was generated from the following files: