From a9d1201f1c68b3b313bf8ca1ff53160d51f33815 Mon Sep 17 00:00:00 2001
From: Olivier Sauter <Olivier.Sauter@epfl.ch>
Date: Sun, 27 Oct 2019 06:08:04 +0100
Subject: [PATCH] add time_out to tcv2ids params and call gdat with automatic
 gdat_params

---
 matlab/TCV_IMAS/tcv2ids.m | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/matlab/TCV_IMAS/tcv2ids.m b/matlab/TCV_IMAS/tcv2ids.m
index 4adfb493..be9a48e2 100644
--- a/matlab/TCV_IMAS/tcv2ids.m
+++ b/matlab/TCV_IMAS/tcv2ids.m
@@ -35,7 +35,10 @@ p.addOptional('error_bar', 'delta', @(x) isempty(x) || ischar(x) ); % char or ce
 p.addOptional('cocos_out', 11, @(x) isempty(x) || isnumeric(x) ); % char
 p.addOptional('ipsign_out', 0, @(x) isempty(x) || (x==0 | x==-1 | x==+1) ); % char
 p.addOptional('b0sign_out', 0, @(x) isempty(x) || (x==0 | x==-1 | x==+1) ); % char
-p.addOptional('nverbose', 1, @(x) isempty(x) || isnumeric(x) ); 
+p.addOptional('nverbose', 1, @(x) isempty(x) || isnumeric(x) );
+p.addOptional('time_out', [], @(x) isempty(x) || isnumeric(x) );
+
+params_not_for_gdat_params = {'shot','ids_names'};
 
 p.parse;
 defaults_tcv2ids = p.Results; % to keep track of defaults
@@ -90,10 +93,21 @@ if isempty(params_tcv2ids.ids_names)
   disp('no ids names available')
   return
 end
+
+bb=gdat_tcv;
+gdat_params = bb.gdat_params; clear bb
+aa = rmfield(params_tcv2ids,params_not_for_gdat_params);
+gdat_params_fields = fieldnames(aa);
+for i=1:length(gdat_params_fields)
+  if ~isempty(aa.(gdat_params_fields{i})),
+    gdat_params.(gdat_params_fields{i}) = aa.(gdat_params_fields{i});
+  end
+end
+gdat_params.data_request = 'ids';
 for i=1:length(params_tcv2ids.ids_names)
   ids_to_get = params_tcv2ids.ids_names{i};
-  tmp = gdat(shot,'ids','source',ids_to_get,'machine','tcv','error_bar',params_tcv2ids.error_bar,'cocos_out',params_tcv2ids.cocos_out, ...
-          'b0sign_out',params_tcv2ids.b0sign_out,'ipsign_out',params_tcv2ids.ipsign_out,'nverbose',params_tcv2ids.nverbose);
+  gdat_params.source = ids_to_get;
+  tmp = gdat(shot,gdat_params);
   ids_from_tcv.(ids_to_get) = tmp.(ids_to_get);
   ids_from_tcv.([ids_to_get '_description']) = tmp.([ids_to_get '_description']);
 end
-- 
GitLab