diff --git a/ess/TraceWin.py b/ess/TraceWin.py index 4a62fdf813f5bcec9ee331102c59e8409eca5343..9e14096d41ddfc3a7c17bfd11bdbc5fcb77f241a 100644 --- a/ess/TraceWin.py +++ b/ess/TraceWin.py @@ -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!