diff --git a/tracking/rf.py b/tracking/rf.py index 9fb475540a4109006afb565ae032be8ef2a18a84..8b553c5b223ff5abae612c83b1ad37cae5ba6a8c 100644 --- a/tracking/rf.py +++ b/tracking/rf.py @@ -299,8 +299,18 @@ class CavityResonator(): bin_length = center[1]-center[0] charge_per_mp = beam.mpi.charge_per_mp_all[j] else: - # get bunch profile for current bunch - (bins, sorted_index, profile, center) = bunch.binning() + if i == 0: + # get bunch profile for current bunch + (bins, sorted_index, profile, center) = bunch.binning() + if j == 0: + self.profile_save = np.zeros((len(beam),len(profile),)) + self.center_save = np.zeros((len(beam),len(center),)) + self.profile_save[j,:] = profile + self.center_save[j,:] = center + else: + profile = self.profile_save[j,:] + center = self.center_save[j,:] + bin_length = center[1]-center[0] charge_per_mp = bunch.charge_per_mp