Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
40be68d6
Commit
40be68d6
authored
1 year ago
by
Mikhail Svechnikov
Browse files
Options
Downloads
Patches
Plain Diff
read data
parent
efd7b262
No related branches found
No related tags found
1 merge request
!1678
Load GISAS data from REFSANS csv-table format (#580)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Device/IO/ReadRefsans.cpp
+43
-7
43 additions, 7 deletions
Device/IO/ReadRefsans.cpp
with
43 additions
and
7 deletions
Device/IO/ReadRefsans.cpp
+
43
−
7
View file @
40be68d6
...
@@ -15,15 +15,51 @@
...
@@ -15,15 +15,51 @@
#include
"Device/IO/ReadRefsans.h"
#include
"Device/IO/ReadRefsans.h"
//#include "Base/Axis/Scale.h"
//#include "Base/Axis/Scale.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 <string>
#include
<vector>
//#include <vector>
namespace
{
const
std
::
vector
<
std
::
string
>
to_replace
=
{
","
,
"
\"
"
,
"("
,
")"
,
"["
,
"]"
};
bool
getNextLine
(
std
::
istream
&
input_stream
,
std
::
string
&
line
)
{
while
(
std
::
getline
(
input_stream
,
line
))
{
line
=
Base
::
String
::
trim
(
line
);
Base
::
String
::
replaceItemsFromString
(
line
,
to_replace
,
" "
);
if
(
!
line
.
empty
())
return
true
;
}
return
false
;
}
}
// From issue #580:
// 1. There is no header or metadata in any csv-file.
// 2. Each csv-matrix has 257 rows and 257 columns of comma-separated floating-point values with a period as the decimal separator.
// 3. The first row and the first column are Q-values for each matrix element.
// 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
"
;
std
::
cout
<<
"readRefsans is not implemented yet
\n
"
;
return
nullptr
;
// read qx coords from first line
std
::
string
line
;
getNextLine
(
input_stream
,
line
);
std
::
vector
<
double
>
dataInRow
=
Util
::
Parse
::
parse_doubles
(
line
);
std
::
vector
<
double
>
qx
(
dataInRow
.
begin
()
+
1
,
dataInRow
.
end
());
// first point is unused
// read qz coords from first column and all values
std
::
vector
<
double
>
qz
;
std
::
vector
<
std
::
vector
<
double
>>
matrix
;
while
(
getNextLine
(
input_stream
,
line
))
{
dataInRow
=
Util
::
Parse
::
parse_doubles
(
line
);
ASSERT
(
dataInRow
.
size
()
==
(
qx
.
size
()
+
1
));
qz
.
push_back
(
dataInRow
.
front
());
matrix
.
emplace_back
(
dataInRow
.
begin
()
+
1
,
dataInRow
.
end
());
}
return
DataUtil
::
Array
::
createPField2D
(
matrix
).
release
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment