From 344cc4beead9beaffb561d2ef6e9f11e73a797cb Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Thu, 8 Dec 2022 14:41:33 +0100 Subject: [PATCH] ZH: only use Agg backend if no DISPLAY --- .../airshower_beacon_simulation/ba_beacon_phases.py | 4 +++- .../bb_beacon_true_phases.py | 4 +++- .../airshower_beacon_simulation/bc_phase_sigmas.py | 4 +++- .../ca_period_from_shower.py | 10 ++++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/simulations/airshower_beacon_simulation/ba_beacon_phases.py b/simulations/airshower_beacon_simulation/ba_beacon_phases.py index fa540f1..c56e4a8 100755 --- a/simulations/airshower_beacon_simulation/ba_beacon_phases.py +++ b/simulations/airshower_beacon_simulation/ba_beacon_phases.py @@ -17,7 +17,9 @@ if __name__ == "__main__": from os import path import sys import matplotlib - matplotlib.use('Agg') + import os + if os.name == 'posix' and "DISPLAY" not in os.environ: + matplotlib.use('Agg') f_beacon_band = (49e-3,55e-3) #GHz allow_frequency_fitting = False diff --git a/simulations/airshower_beacon_simulation/bb_beacon_true_phases.py b/simulations/airshower_beacon_simulation/bb_beacon_true_phases.py index 704ccb9..f95d172 100755 --- a/simulations/airshower_beacon_simulation/bb_beacon_true_phases.py +++ b/simulations/airshower_beacon_simulation/bb_beacon_true_phases.py @@ -37,8 +37,10 @@ if __name__ == "__main__": from os import path import sys + import os import matplotlib - matplotlib.use('Agg') + if os.name == 'posix' and "DISPLAY" not in os.environ: + matplotlib.use('Agg') fname = "ZH_airshower/mysim.sry" c_light = 3e8*1e-9 # m/ns diff --git a/simulations/airshower_beacon_simulation/bc_phase_sigmas.py b/simulations/airshower_beacon_simulation/bc_phase_sigmas.py index b567e1f..afe2f61 100755 --- a/simulations/airshower_beacon_simulation/bc_phase_sigmas.py +++ b/simulations/airshower_beacon_simulation/bc_phase_sigmas.py @@ -14,8 +14,10 @@ if __name__ == "__main__": from os import path import sys + import os import matplotlib - matplotlib.use('Agg') + if os.name == 'posix' and "DISPLAY" not in os.environ: + matplotlib.use('Agg') fname = "ZH_airshower/mysim.sry" c_light = 3e8*1e-9 diff --git a/simulations/airshower_beacon_simulation/ca_period_from_shower.py b/simulations/airshower_beacon_simulation/ca_period_from_shower.py index f167eef..40714b2 100755 --- a/simulations/airshower_beacon_simulation/ca_period_from_shower.py +++ b/simulations/airshower_beacon_simulation/ca_period_from_shower.py @@ -48,10 +48,10 @@ def find_best_sample_shifts_summing_at_location(test_loc, antennas, allowed_samp t_max = t__[-1] # Interpolate and find best sample shift - max_neg_shift = np.min(allowed_sample_shifts) * dt - max_pos_shift = np.max(allowed_sample_shifts) * dt + max_neg_shift = 0 #np.min(allowed_sample_shifts) * dt + max_pos_shift = 0 #np.max(allowed_sample_shifts) * dt - t_sum = np.arange(t_min+1+max_neg_shift, t_max-1+max_pos_shift, dt) + t_sum = np.arange(t_min+max_neg_shift, t_max+max_pos_shift, dt) a_sum = np.zeros(len(t_sum)) best_sample_shifts = np.zeros( (len(antennas)) ,dtype=int) @@ -97,8 +97,10 @@ def find_best_sample_shifts_summing_at_location(test_loc, antennas, allowed_samp if __name__ == "__main__": import sys + import os import matplotlib - matplotlib.use('Agg') + if os.name == 'posix' and "DISPLAY" not in os.environ: + matplotlib.use('Agg') atm = AtmoCal()