Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Pawian
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PWA
Pawian
Commits
ccb184ea
Commit
ccb184ea
authored
6 years ago
by
Bertram Kopf
Browse files
Options
Downloads
Patches
Plain Diff
added new function in script dir
parent
85a3aecf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Scripts/IOTools.C
+49
-0
49 additions, 0 deletions
Scripts/IOTools.C
with
49 additions
and
0 deletions
Scripts/IOTools.C
+
49
−
0
View file @
ccb184ea
...
...
@@ -28,6 +28,9 @@
#include
<fstream>
#include
<sstream>
#include
<string>
#include
<iomanip>
#include
"TMath.h"
class
IOTools
{
...
...
@@ -80,4 +83,50 @@ class IOTools
inputStream
.
close
();
oStream
.
close
();
}
static
void
moduloPhaseParams
(
std
::
string
iFileName
,
std
::
string
oFileName
){
std
::
ifstream
inputStream
(
iFileName
.
c_str
());
if
(
!
inputStream
.
is_open
()){
std
::
cout
<<
"Could not open input file: "
<<
iFileName
<<
std
::
endl
;
exit
(
0
);
}
std
::
ofstream
oStream
(
oFileName
.
c_str
());
while
(
!
inputStream
.
eof
()){
std
::
string
currentLine
;
getline
(
inputStream
,
currentLine
);
std
::
size_t
pos
=
currentLine
.
find
(
"Phi
\t
"
);
if
(
pos
!=
string
::
npos
){
std
::
string
parname
=
currentLine
.
substr
(
0
,
pos
+
3
);
std
::
string
lineRemain
=
currentLine
.
substr
(
pos
+
3
,
string
::
npos
);
// find the first digit:
std
::
size_t
startPos
=
0
;
for
(;
startPos
<
lineRemain
.
size
();
++
startPos
)
if
(
std
::
isdigit
(
lineRemain
[
startPos
]))
break
;
std
::
string
lineRemain1stDigit
=
lineRemain
.
substr
(
startPos
-
1
,
string
::
npos
);
istringstream
lineRemain1stDigitiString
(
lineRemain1stDigit
);
double
d
;
lineRemain1stDigitiString
>>
d
;
std
::
cout
<<
"d: "
<<
std
::
setprecision
(
16
)
<<
d
<<
std
::
endl
;
int
factor
=
std
::
round
(
d
/
(
2
.
*
TMath
::
Pi
()));
double
newPhase
=
d
-
factor
*
(
2
.
*
TMath
::
Pi
());
std
::
string
remainingDigits
;
lineRemain1stDigitiString
>>
remainingDigits
;
std
::
cout
<<
"
\n
"
<<
currentLine
<<
std
::
endl
;
std
::
cout
<<
"is replaced by: "
<<
std
::
endl
;
std
::
cout
<<
parname
<<
"
\t
"
<<
std
::
setprecision
(
16
)
<<
newPhase
<<
"
\t
"
<<
remainingDigits
<<
std
::
endl
;
oStream
<<
parname
<<
"
\t
"
<<
std
::
setprecision
(
16
)
<<
newPhase
<<
"
\t
"
<<
remainingDigits
<<
std
::
endl
;
}
else
{
oStream
<<
currentLine
<<
std
::
endl
;
}
}
}
};
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