Skip to content
Snippets Groups Projects
Commit 101f2bcb authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

1

parent 40be68d6
No related branches found
No related tags found
1 merge request!1678Load GISAS data from REFSANS csv-table format (#580)
...@@ -13,12 +13,13 @@ ...@@ -13,12 +13,13 @@
// ************************************************************************************************ // ************************************************************************************************
#include "Device/IO/ReadRefsans.h" #include "Device/IO/ReadRefsans.h"
//#include "Base/Axis/Scale.h" #include "Base/Axis/MakeScale.h"
#include "Base/Util/Assert.h" #include "Base/Util/Assert.h"
#include "Base/Util/StringUtil.h" #include "Base/Util/StringUtil.h"
#include "Device/Data/ArrayUtil.h" #include "Device/Data/ArrayUtil.h"
#include "Device/Data/Datafield.h" #include "Device/Data/Datafield.h"
#include "Device/IO/ParseUtil.h" #include "Device/IO/ParseUtil.h"
#include <algorithm>
#include <vector> #include <vector>
namespace { namespace {
...@@ -44,8 +45,6 @@ bool getNextLine(std::istream& input_stream, std::string& line) ...@@ -44,8 +45,6 @@ bool getNextLine(std::istream& input_stream, std::string& line)
// 4. q-units are A^-1 // 4. q-units are A^-1
Datafield *Util::RW::readRefsans(std::istream &input_stream) Datafield *Util::RW::readRefsans(std::istream &input_stream)
{ {
std::cout << "readRefsans is not implemented yet\n";
// read qx coords from first line // read qx coords from first line
std::string line; std::string line;
getNextLine(input_stream, line); getNextLine(input_stream, line);
...@@ -61,5 +60,46 @@ Datafield *Util::RW::readRefsans(std::istream &input_stream) ...@@ -61,5 +60,46 @@ Datafield *Util::RW::readRefsans(std::istream &input_stream)
qz.push_back(dataInRow.front()); qz.push_back(dataInRow.front());
matrix.emplace_back(dataInRow.begin() + 1, dataInRow.end()); matrix.emplace_back(dataInRow.begin() + 1, dataInRow.end());
} }
return DataUtil::Array::createPField2D(matrix).release();
// sort data
if(qz.front() > qz.back()) {
std::reverse(qz.begin(), qz.end());
std::reverse(matrix.begin(), matrix.end());
}
if(qx.front() > qx.back()) {
std::reverse(qx.begin(), qx.end());
// for(auto& row : matrix)
// std::reverse(row.begin(), row.end());
}
// flatten values
std::vector<double> values;
for(const auto& row : matrix)
values.insert(values.end(), row.begin(), row.end());
// create datafield
std::vector<const Scale*> axes;
axes.push_back(newListScan("qx_axis", qx));
axes.push_back(newListScan("qz_axis", qz));
return new Datafield(std::move(axes), values);
return nullptr;//new Datafield(std::vector<const Scale*>{newListScan("Qx", qx), newListScan("Qz", qz)}/*, RVec, sRVec*/);
// return DataUtil::Array::createPField2D(values).release();
// while (std::getline(input_stream, line)) {
// line = Base::String::trim(line);
// if (line.find("axis") != std::string::npos)
// axes.emplace_back(Util::Parse::parseScale(input_stream));
// if (line.find("data") != std::string::npos)
// break;
// }
// // std::cout << "Read " << axes.size() << " axes" << std::endl;
// auto* result = new Datafield(std::move(axes));
// Util::Parse::fillDatafield(result, input_stream);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment