Skip to content
Snippets Groups Projects
Commit 7d134302 authored by Yngve Levinsen's avatar Yngve Levinsen
Browse files

added option to add and remove particles from the dst object

parent fc44035f
No related branches found
No related tags found
No related merge requests found
......@@ -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!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment