From 83def7a7c041b2522b28b5633a26b1014f8f3823 Mon Sep 17 00:00:00 2001 From: Konstantinos Iliakis <konstantinos.iliakis@cern.ch> Date: Mon, 12 Jun 2023 10:48:31 +0300 Subject: [PATCH] fixes warning coming from calculate_phi_s in rf_params --- blond/input_parameters/rf_parameters.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/blond/input_parameters/rf_parameters.py b/blond/input_parameters/rf_parameters.py index 984645b6..8de9e841 100644 --- a/blond/input_parameters/rf_parameters.py +++ b/blond/input_parameters/rf_parameters.py @@ -505,14 +505,13 @@ def calculate_phi_s(RFStation, Particle=Proton(), denergy = np.append(RFStation.delta_E, RFStation.delta_E[-1]) acceleration_ratio = denergy / (Particle.charge * RFStation.voltage[0, :]) - acceleration_test = np.where((acceleration_ratio > -1) * - (acceleration_ratio < 1) is False)[0] - + acceleration_test = ((acceleration_ratio > -1) & (acceleration_ratio < 1)) == 0 + # Validity check on acceleration_ratio - if acceleration_test.size > 0: + if np.count_nonzero(acceleration_test) > 0: print("WARNING in calculate_phi_s(): acceleration is not " + "possible (momentum increment is too big or voltage too " + - "low) at index " + str(acceleration_test)) + "low) at index " + str(acceleration_test.nonzero()[0])) phi_s = np.arcsin(acceleration_ratio) -- GitLab