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
13e67b71
Commit
13e67b71
authored
6 years ago
by
Yngve Levinsen
Browse files
Options
Downloads
Patches
Plain Diff
improving of TraceWin.dst class
parent
5778b13f
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
ess/TraceWin.py
+22
-6
22 additions, 6 deletions
ess/TraceWin.py
with
22 additions
and
6 deletions
ess/TraceWin.py
+
22
−
6
View file @
13e67b71
...
@@ -15,7 +15,11 @@ class dst:
...
@@ -15,7 +15,11 @@ class dst:
- phi [rad]
- phi [rad]
- E [MeV] (kinetic energy)
- E [MeV] (kinetic energy)
'''
'''
def
__init__
(
self
,
filename
=
None
):
def
__init__
(
self
,
filename
=
None
,
freq
=
352.21
,
mass
=
938.272
,
Ib
=
0.0
):
# easy storage..
# easy storage..
self
.
filename
=
filename
self
.
filename
=
filename
# used to create dict behaviour..
# used to create dict behaviour..
...
@@ -26,10 +30,10 @@ class dst:
...
@@ -26,10 +30,10 @@ class dst:
else
:
else
:
import
numpy
import
numpy
self
.
Np
=
0
self
.
Np
=
0
self
.
Ib
=
0.0
self
.
Ib
=
Ib
self
.
freq
=
352.21
self
.
freq
=
freq
self
.
_data
=
numpy
.
zeros
((
self
.
Np
,
6
))
self
.
_data
=
numpy
.
zeros
((
self
.
Np
,
6
))
self
.
mass
=
0.0
self
.
mass
=
mass
def
append
(
self
,
x
=
0.0
,
xp
=
0.0
,
y
=
0.0
,
yp
=
0.0
,
E
=
0.0
,
phi
=
0.0
):
def
append
(
self
,
x
=
0.0
,
xp
=
0.0
,
y
=
0.0
,
yp
=
0.0
,
E
=
0.0
,
phi
=
0.0
):
'''
'''
...
@@ -45,6 +49,19 @@ class dst:
...
@@ -45,6 +49,19 @@ class dst:
self
.
_data
=
numpy
.
append
(
self
.
_data
,
[[
x
,
xp
,
y
,
yp
,
phi
,
E
]],
0
)
self
.
_data
=
numpy
.
append
(
self
.
_data
,
[[
x
,
xp
,
y
,
yp
,
phi
,
E
]],
0
)
self
.
Np
+=
1
self
.
Np
+=
1
def
append_many
(
self
,
array
):
'''
Append a matrix of particle vectors
Matrix on form 6xN, where N is number of particles.
Each row should hold [x,xp,y,yp,phi,E]
Units m,rad, MeV
'''
import
numpy
self
.
_data
=
numpy
.
append
(
self
.
_data
,
array
,
0
)
self
.
Np
+=
len
(
array
)
def
remove
(
self
,
i
=
None
):
def
remove
(
self
,
i
=
None
):
'''
'''
Removes all particles from the distribution, or the line specified by i
Removes all particles from the distribution, or the line specified by i
...
@@ -150,8 +167,7 @@ class dst:
...
@@ -150,8 +167,7 @@ class dst:
else
:
else
:
data
=
data
.
reshape
(
self
.
Np
*
6
,
1
)
data
=
data
.
reshape
(
self
.
Np
*
6
,
1
)
for
x
in
data
:
fout
.
write
(
pack
(
'
{}d
'
.
format
(
len
(
data
)),
*
data
))
fout
.
write
(
pack
(
'
d
'
,
x
))
fout
.
write
(
pack
(
'
d
'
,
self
.
mass
))
fout
.
write
(
pack
(
'
d
'
,
self
.
mass
))
fout
.
close
()
fout
.
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