Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hallc_replay
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Melanie Cardona
hallc_replay
Commits
09319354
Commit
09319354
authored
7 years ago
by
Edward Brash
Browse files
Options
Downloads
Patches
Plain Diff
Add scaler_parse script
parent
585c63d1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scaler_parse.py
+79
-0
79 additions, 0 deletions
scaler_parse.py
with
79 additions
and
0 deletions
scaler_parse.py
0 → 100755
+
79
−
0
View file @
09319354
#!/usr/bin/python
import
argparse
def
get_args
():
'''
This function parses and returns arguments passed in
'''
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
-r
'
,
'
--runs
'
,
type
=
str
,
help
=
'
Run list
'
,
required
=
True
,
nargs
=
"
+
"
)
parser
.
add_argument
(
'
-f
'
,
'
--infile
'
,
type
=
str
,
help
=
'
Scaler list file
'
,
required
=
True
)
parser
.
add_argument
(
'
-o
'
,
'
--outfile
'
,
type
=
str
,
help
=
'
Output file
'
,
required
=
True
)
args
=
parser
.
parse_args
()
infilename
=
args
.
infile
outfilename
=
args
.
outfile
runlist
=
args
.
runs
[
0
].
split
(
"
,
"
)
return
runlist
,
infilename
,
outfilename
runlist
,
infilename
,
outfilename
=
get_args
()
print
"
\n
Scaler File Name: [ %s ]
\n
"
%
infilename
print
"
\n
Output File Name: [ %s ]
\n
"
%
outfilename
final_runlist
=
[]
for
r
in
runlist
:
minirunlist
=
r
.
split
(
"
-
"
)
nruns
=
len
(
minirunlist
)
if
nruns
==
1
:
#print "Run: [%s]" % r
scaler_filename
=
"
replay_coin_scalers_
"
+
r
+
"
.report
"
final_runlist
.
append
(
scaler_filename
)
else
:
startrun
=
int
(
minirunlist
[
0
])
endrun
=
int
(
minirunlist
[
1
])
while
startrun
<=
endrun
:
#print "MiniRun: [%s]" % startrun
scaler_filename
=
"
replay_coin_scalers_
"
+
str
(
startrun
)
+
"
.report
"
final_runlist
.
append
(
scaler_filename
)
startrun
=
startrun
+
1
#print final_runlist
basic_name_array
=
[
"
Run Number
"
]
scaler_name_array
=
[]
with
open
(
infilename
)
as
fp
:
scaler_name_array
=
fp
.
read
().
splitlines
()
fp
.
close
()
of
=
open
(
outfilename
,
'
w
'
)
scaler_name_array_run_number
=
basic_name_array
+
scaler_name_array
mx
=
len
(
max
(
scaler_name_array_run_number
))
print
(
"
"
.
join
([
"
{:<{mx}}
"
.
format
(
ele
,
mx
=
mx
)
for
ele
in
scaler_name_array_run_number
]))
of
.
write
(
"
"
.
join
([
"
{:<{mx}}
"
.
format
(
ele
,
mx
=
mx
)
for
ele
in
scaler_name_array_run_number
]))
of
.
write
(
"
\n
"
)
for
runfile
in
final_runlist
:
with
open
(
runfile
)
as
fp
:
runfile_linelist
=
fp
.
read
().
splitlines
()
runnumbersplit
=
runfile
.
split
(
"
_
"
)
runnumbersplit2
=
runnumbersplit
[
3
].
split
(
"
.
"
)
run_number_array
=
[]
run_number_array
.
append
(
runnumbersplit2
[
0
])
scaler_value_array
=
[]
for
line
in
runfile_linelist
:
parsed_line
=
line
.
split
(
"
:
"
)
for
scaler
in
scaler_name_array
:
if
parsed_line
[
0
].
rstrip
(
"
"
)
==
scaler
:
full_value
=
parsed_line
[
1
].
lstrip
()
numerical_value
=
full_value
.
split
(
"
"
)
scaler_value_array
.
append
(
numerical_value
[
0
])
scaler_value_array_run_number
=
run_number_array
+
scaler_value_array
print
(
"
"
.
join
([
"
{:<{mx}}
"
.
format
(
ele
,
mx
=
mx
)
for
ele
in
scaler_value_array_run_number
]))
of
.
write
(
"
"
.
join
([
"
{:<{mx}}
"
.
format
(
ele
,
mx
=
mx
)
for
ele
in
scaler_value_array_run_number
]))
of
.
write
(
"
\n
"
)
fp
.
close
()
of
.
close
()
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