From ebb39e8d74e97ae0cc4fec2e53084fb931cd19a6 Mon Sep 17 00:00:00 2001
From: Olivier Sauter <Olivier.Sauter@epfl.ch>
Date: Tue, 27 Apr 2021 13:07:40 +0200
Subject: [PATCH] make basis ids_summary 100 points, ready for database

---
 matlab/TCV/gdat_tcv.m                 |  6 ++++++
 matlab/TCV_IMAS/tcv_get_ids_summary.m | 10 +++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m
index 06b3bf04..8cbfda73 100644
--- a/matlab/TCV/gdat_tcv.m
+++ b/matlab/TCV/gdat_tcv.m
@@ -1474,6 +1474,12 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
         gdat_data.gdat_params.b0sign_in = 0;
       end
     end
+    if strcmp(ids_top_name,'summary')
+      if isfield(gdat_data.gdat_params,'time_out') && ~isempty(gdat_data.gdat_params.time_out)
+        warning(['For summary ids, the present convention is to have time defined within get_ids_summary, but since time_out is provided,', ...
+                 ' it is not modified but there might be extra points']);
+      end
+    end
     try
       if ~isempty(shot)
         [ids_top,ids_top_description] = feval(['tcv_get_ids_' ids_top_name],shot,ids_empty,gdat_data.gdat_params);
diff --git a/matlab/TCV_IMAS/tcv_get_ids_summary.m b/matlab/TCV_IMAS/tcv_get_ids_summary.m
index 03c1852a..de3c2da3 100644
--- a/matlab/TCV_IMAS/tcv_get_ids_summary.m
+++ b/matlab/TCV_IMAS/tcv_get_ids_summary.m
@@ -50,11 +50,15 @@ params_eff = params_eff_ref;
 params_eff.data_request='kappa';
 kappa = gdat(params_summary.shot,params_eff);
 % to get liuqe time array for main time, but add points before and after according to ip_trapeze, to have other data when available
-dt_caract = 1e-3;
-ids_summary.time = unique([[0:dt_caract:kappa.t(1)]'; kappa.t; [kappa.t(end):dt_caract:t_end]']);
+% aim for 100 points
+dt_min = 1e-3;
+t_before = [0:max(3*dt_min,(kappa.t(1)-0)/10.):kappa.t(1)]';
+t_after = [t_end:min(-2*dt_min,(kappa.t(end)-t_end)/10.):kappa.t(end)]'; t_after = t_after(end:-1:1); % to make sure to have lst point
+nb_points_remaining = 100 - numel(t_before) - numel(t_after);
+ids_summary.time = unique([t_before; [kappa.t(1):max((kappa.t(end)-kappa.t(1))/(nb_points_remaining-1),dt_min):kappa.t(end)]'; t_after]);
 ids_summary_description.time = 'time from gdat(shot,''kappa'') and adding from 0 up to t(ip_trapeze(end))';
-
 params_eff = params_eff_ref;
+
 % boundary:
 boundary.elongation = kappa;
 boundary_desc.elongation = kappa.gdat_params.data_request;
-- 
GitLab