diff --git a/ess/TraceWin.py b/ess/TraceWin.py index dd8b89da5615338fb4c17d813764b04ce0967ddc..d0b6501f5dbb293b0b0d0e949defd10032c31dc5 100644 --- a/ess/TraceWin.py +++ b/ess/TraceWin.py @@ -51,7 +51,7 @@ class dst: def append_many(self, array): ''' - Append a matrix of particle vectors + 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] @@ -62,6 +62,20 @@ class dst: self._data = numpy.append(self._data, array, 0) self.Np += len(array) + def combine_dst(self, other): + ''' + Appends the particles from another dst object to this one + + ''' + + if self.mass != other.mass: + raise ValueError("You are trying to add two distributions with differing mass: {} and {}".format( self.mass, other.mass)) + if self.freq != other.freq: + raise ValueError("You are trying to add two distributions with differing freq: {} and {}".format( self.freq, other.freq)) + + self.append_many(other._data) + self.Ib = ( self.Ib*self.Np + other.Ib*other.Np ) / ( self.Np + other.Np) + def remove(self, i=None): ''' Removes all particles from the distribution, or the line specified by i @@ -551,6 +565,10 @@ class density_file: ''' Simple class to read a TraceWin density file into a pythonized object + + Class afterwards hold the same items as + found in the TraceWin documentation: + z, nelp, ib, Np, Xouv, Youv, dXouv, .. ''' def __init__(self, filename, envelope=None):