Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ess-python-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
ESS Beam Physics
ess-python-tools
Commits
e352efa8
Commit
e352efa8
authored
6 years ago
by
Yngve Levinsen
Browse files
Options
Downloads
Patches
Plain Diff
moved ibsimu2tw to scripts folder
added command line arguments
parent
94f1dcba
No related branches found
No related tags found
No related merge requests found
Pipeline
#2805
passed
6 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/ibsimu2tw
+45
-14
45 additions, 14 deletions
scripts/ibsimu2tw
setup.py
+2
-2
2 additions, 2 deletions
setup.py
with
47 additions
and
16 deletions
e
ss/ibsimu2tw
.py
→
s
cript
s/ibsimu2tw
+
45
−
14
View file @
e352efa8
#!/usr/bin/env python
'''
- Convert an IBSimu
'
s output (export_path_manager_data) to a TraceWin
'
s binary.
...
...
@@ -16,16 +17,46 @@
R. Miyamoto (2018.06.25)
'''
import
argparse
import
os
import
subprocess
parser
=
argparse
.
ArgumentParser
(
description
=
"
Converts IBSimu output to TraceWin dst format
"
)
parser
.
add_argument
(
'
-i
'
,
'
--inp
'
,
dest
=
'
infile
'
,
help
=
"
Input file
"
,
required
=
True
)
parser
.
add_argument
(
'
-o
'
,
'
--out
'
,
dest
=
'
outfile
'
,
help
=
"
Output file
"
,
required
=
True
)
parser
.
add_argument
(
'
--h2
'
,
dest
=
'
h2
'
,
action
=
'
store_const
'
,
help
=
"
Include H2
"
,
const
=
True
,
default
=
False
)
parser
.
add_argument
(
'
--h3
'
,
dest
=
'
h3
'
,
action
=
'
store_const
'
,
help
=
"
Include H3
"
,
const
=
True
,
default
=
False
)
parser
.
add_argument
(
"
-m
"
,
dest
=
"
mc2_H1
"
,
default
=
938.272
,
type
=
float
,
help
=
"
H1 mass [MeV/c2]
"
)
parser
.
add_argument
(
"
-f
"
,
dest
=
"
freq
"
,
default
=
352.21
,
type
=
float
,
help
=
"
Frequency
"
)
args
=
parser
.
parse_args
()
#-- Constants and inputs
mc2_H1
=
938.272
freq
=
352.21
mc2_H1
=
args
.
mc2_H1
freq
=
args
.
freq
file_name_in
=
'
tracewin_path_format_2d_10M.txt
'
file_name_out_H1
=
'
ISRC.H1_ibsimu.2d_10M.83mA.dst
'
file_name_out_H2
=
'
ISRC.H2_ibsimu.2d_10M.83mA.dst
'
# Comment out if H2 file isn't needed
file_name_out_H3
=
'
ISRC.H3_ibsimu.2d_10M.83mA.dst
'
# Comment out if H3 file isn't needed
file_name_in
=
args
.
infile
file_name_out_H1
=
args
.
outfile
if
args
.
h2
:
if
args
.
outfile
[
-
4
:]
!=
'
.dst
'
:
raise
ValueError
(
'
Do not accept file ending of output file
'
)
file_name_out_H2
=
args
.
outfile
[:
-
4
]
+
'
_H2.dst
'
if
args
.
h3
:
if
args
.
outfile
[
-
4
:]
!=
'
.dst
'
:
raise
ValueError
(
'
Do not accept file ending of output file
'
)
file_name_out_H3
=
args
.
outfile
[:
-
4
]
+
'
_H3.dst
'
#W_cut = 0.01 # Filter for W [MeV]. Only for experts.
...
...
@@ -50,14 +81,14 @@ def save_dst(file_name, x6, Ibeam, mc2=938.272, freq=352.21):
x6
=
numpy
.
reshape
(
x6
,
(
numpy
.
size
(
x6
)))
with
open
(
file_name
,
'
wb
'
)
as
file
:
out
=
struct
.
pack
(
'
b
'
,
125
)
out
+=
struct
.
pack
(
'
b
'
,
100
)
out
+=
struct
.
pack
(
'
i
'
,
len
(
x6
))
out
+=
struct
.
pack
(
'
d
'
,
Ibeam
)
out
+=
struct
.
pack
(
'
d
'
,
freq
)
out
+=
struct
.
pack
(
'
b
'
,
125
)
# Typo in the manual !!!!
out
+=
struct
.
pack
(
'
%s
'
%
len
(
x6
)
+
'
d
'
,
*
x6
)
out
+=
struct
.
pack
(
'
d
'
,
mc2
)
out
=
struct
.
pack
(
'
b
'
,
125
)
out
+=
struct
.
pack
(
'
b
'
,
100
)
out
+=
struct
.
pack
(
'
i
'
,
len
(
x6
)
)
out
+=
struct
.
pack
(
'
d
'
,
Ibeam
)
out
+=
struct
.
pack
(
'
d
'
,
freq
)
out
+=
struct
.
pack
(
'
b
'
,
125
)
# Typo in the manual !!!!
out
+=
struct
.
pack
(
'
%s
'
%
len
(
x6
)
+
'
d
'
,
*
x6
)
out
+=
struct
.
pack
(
'
d
'
,
mc2
)
file
.
write
(
out
)
#-- Parameters from the header
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
2
−
2
View file @
e352efa8
from
distutils.core
import
setup
setup
(
name
=
'
ESS Python Tools
'
,
version
=
'
1.
7
'
,
version
=
'
1.
8
'
,
description
=
'
ESS Related Tools
'
,
url
=
'
https://gitlab01.esss.lu.se/ess-bp/ess-python-tools
'
,
author
=
'
Yngve Inntjore Levinsen
'
,
...
...
@@ -29,6 +29,6 @@ setup(name='ESS Python Tools',
'
Programming Language :: Python :: 3.6
'
,
],
packages
=
[
'
ess
'
],
scripts
=
[
'
scripts/tracewin
'
,
'
scripts/tracewin_errorstudy
'
],
scripts
=
[
'
scripts/tracewin
'
,
'
scripts/tracewin_errorstudy
'
,
'
scripts/ibsimu2tw
'
],
)
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