From 820e901f0b29ef9d6d756718b27da206404e6a1f Mon Sep 17 00:00:00 2001 From: Alexis Gamelin <alexis.gamelin@synchrotron-soleil.fr> Date: Fri, 20 Oct 2023 12:22:14 +0200 Subject: [PATCH] [Fix] plot_cavitydata Get back to previous behaviour with plot_type="bunch" as default. --- mbtrack2/tracking/monitors/plotting.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mbtrack2/tracking/monitors/plotting.py b/mbtrack2/tracking/monitors/plotting.py index d59d359..5f256b9 100644 --- a/mbtrack2/tracking/monitors/plotting.py +++ b/mbtrack2/tracking/monitors/plotting.py @@ -1076,7 +1076,7 @@ def streak_beamspectrum(filename, dim="tau", f0=None, log_scale=True, fmin=None, return fig def plot_cavitydata(filename, cavity_name, phasor="cavity", - plot_type="mean", bunch_number=0, turn=None, cm_lim=None, + plot_type="bunch", bunch_number=0, turn=None, cm_lim=None, show_objective=False): """ Plot data recorded by CavityMonitor. @@ -1092,8 +1092,6 @@ def plot_cavitydata(filename, cavity_name, phasor="cavity", "ig". plot_type : str, optional Type of plot: - - "mean" plots the mean phasor voltage and angle versus time for - non empty bunches. - "bunch" plots the phasor voltage and angle versus time for a given bunch. - "turn" plots the phasor voltage and ange versus bunch index for @@ -1104,7 +1102,11 @@ def plot_cavitydata(filename, cavity_name, phasor="cavity", time. - "detune" or "psi" plots the detuning or tuning angle versus time. - "power" plots the generator, cavity, beam and reflected power - versus time. + versus time. Needs BeamMonitor data with same save_every as + CavityMonitor. + - "mean" plots the mean phasor voltage and angle versus time for + non empty bunches. Needs BeamMonitor data with same save_every as + CavityMonitor. bunch_number : int, optional Bunch number to select. The default is 0. turn : int, optional @@ -1143,7 +1145,7 @@ def plot_cavitydata(filename, cavity_name, phasor="cavity", try: bunch_index = (file["Beam"]["current"][:,0] != 0).nonzero()[0] except: - print("Beam monitor is needed to show mean voltage.") + ValueError("Beam monitor is needed to show mean voltage.") data = [np.mean(cavity_data["cavity_phasor_record"][bunch_index,:],0), np.mean(cavity_data["beam_phasor_record"][bunch_index,:],0), np.mean(cavity_data["generator_phasor_record"][bunch_index,:],0), -- GitLab