From 97f319f8cc4a751b361ae6220ecc8dbee217014a Mon Sep 17 00:00:00 2001
From: Olivier Sauter <Olivier.Sauter@epfl.ch>
Date: Mon, 28 Jun 2021 16:44:36 +0200
Subject: [PATCH] fix when Lpf bad in AUG, usually IDE assuming 10'000 refs
 instead of 100'000

---
 matlab/AUG/gdat_aug.m | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/matlab/AUG/gdat_aug.m b/matlab/AUG/gdat_aug.m
index 3ae36d18..3cc7d982 100644
--- a/matlab/AUG/gdat_aug.m
+++ b/matlab/AUG/gdat_aug.m
@@ -2849,9 +2849,17 @@ elseif ischar(NTIME) || ischar(NTIME_Lpf) || (NTIME > NTIME_Lpf)
   end
   return
 end
-Lpf_tot = Lpf_par.value(1:NTIME); % nb of points: 100000*nb_SOL points + nb_core
-Lpf_SOL = fix(Lpf_tot/100000);
-Lpf1_t = mod(Lpf_tot,100000)+1; % nb of Lpf points
+i_ref = 100000;
+Lpf_tot = Lpf_par.value(1:NTIME); % nb of points: i_ref*nb_SOL points + nb_core
+Lpf_SOL = fix(Lpf_tot/i_ref);
+Lpf1_t = mod(Lpf_tot,i_ref)+1; % nb of Lpf points
+if max(Lpf1_t) > 3000
+  % most probably i_ref wrong
+  i_ref = 10^fix(log10(max(Lpf1_t)));
+  Lpf_tot = Lpf_par.value(1:NTIME); % nb of points: i_ref*nb_SOL points + nb_core
+  Lpf_SOL = fix(Lpf_tot/i_ref);
+  Lpf1_t = mod(Lpf_tot,i_ref)+1; % nb of Lpf points
+end
 
 [equil_time,e]=rdaAUG_eff(shot,DIAG,'time',exp_name_eff,[],gdat_data.gdat_params.extra_arg_sf2sig);
 gdat_data.t = equil_time.value(1:NTIME);
-- 
GitLab