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
7d134302
Commit
7d134302
authored
8 years ago
by
Yngve Levinsen
Browse files
Options
Downloads
Patches
Plain Diff
added option to add and remove particles from the dst object
parent
fc44035f
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
ess/TraceWin.py
+29
-1
29 additions, 1 deletion
ess/TraceWin.py
with
29 additions
and
1 deletion
ess/TraceWin.py
+
29
−
1
View file @
7d134302
...
...
@@ -12,7 +12,7 @@ class dst:
- y [m]
- yp [rad]
- phi [rad]
- E [MeV]
- E [MeV]
(kinetic energy)
'''
def
__init__
(
self
,
filename
):
# easy storage..
...
...
@@ -22,6 +22,34 @@ class dst:
# read in the file..
self
.
_readBinaryFile
()
def
append
(
self
,
x
=
0.0
,
xp
=
0.0
,
y
=
0.0
,
yp
=
0.0
,
E
=
0.0
,
phi
=
0.0
):
'''
Append one particle to the distribution
- Kinetic Energy in MeV
- x,y in m
- xp,yp in rad
- phi in rad
'''
import
numpy
self
.
_data
=
numpy
.
append
(
self
.
_data
,
[[
x
,
xp
,
y
,
yp
,
phi
,
E
]],
0
)
self
.
Np
+=
1
def
remove
(
self
,
i
=
None
):
'''
Removes all particles from the distribution, or the line specified by i
'''
import
numpy
if
i
==
None
:
self
.
_data
=
numpy
.
delete
(
self
.
_data
,
numpy
.
s_
[:],
0
)
self
.
Np
=
0
else
:
self
.
_data
=
numpy
.
delete
(
self
.
_data
,
i
,
0
)
self
.
Np
-=
1
def
_readBinaryFile
(
self
):
# Thanks Emma!
...
...
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