diff --git a/crpptbx_new/AUG/aug_requests_mapping.m b/crpptbx_new/AUG/aug_requests_mapping.m
new file mode 100644
index 0000000000000000000000000000000000000000..15b98dd61e0063c58bb5c8662cd6c503e6a8b8d0
--- /dev/null
+++ b/crpptbx_new/AUG/aug_requests_mapping.m
@@ -0,0 +1,169 @@
+function mapping = aug_requests_mapping(data_request)
+
+% Defaults
+mapping = struct(...
+    'label', '', ...
+    'method', '', ...
+    'expression','', ...
+    'timedim', -1, ...     % dim which is the time, to copy in .t, the other dims are in .x (-1 means last dimension)
+    'new_timedim',0, ...  % if need to reshape data and dim orders to have timedim as new_timedim (shifting time to new_timedim)
+    'min', -inf, ...
+    'max', inf);
+
+if ~exist('data_request') || isempty(data_request)
+  return
+end
+
+% default label: data_request keyword itself
+mapping.label = data_request;
+
+% for AUG, following choices are set so far:
+% method = 'tdi' and then expression is the string within tdi (usual case when there is a direct link to an existing signal)
+%                with tdi, if expression cell array, call tdi(cell{1},cell{2},...)
+% method = 'function', then expression is the funtion to call which should return the correct structure
+% method = 'switchcase', then there will be a specific case within gdat_aug (usual case when not directly a signal)
+%
+% label is used for plotting
+switch lower(data_request)
+ case 'b0'
+  mapping.label = 'B_0';
+  mapping.method = 'switchcase';
+  mapping.expression = '';
+ case 'betan'
+  mapping.label = '\beta_N';
+  mapping.method = 'switchcase';
+  mapping.expression = '';
+ case 'betap'
+  mapping.label = '\beta_p';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::beta_pol';
+ case 'cxrs'
+  mapping.label = 'cxrs';
+  mapping.method = 'switchcase';
+  mapping.expression = '';
+ case 'delta'
+  mapping.method = 'tdi';
+  mapping.expression = '\results::delta_edge';
+  mapping.method = 'function';
+  mapping.expression = ['tdi(''\results::q_psi'');'];
+ case 'delta_top'
+  mapping.label = 'delta\_top';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::delta_ed_top';
+ case 'delta_bottom'
+  mapping.label = 'delta\_bottom';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::delta_ed_bot';
+ case 'ece'
+  mapping.method = 'switchcase';
+  mapping.expression = '';
+ case 'eqdsk'
+  mapping.method = 'switchcase'; % could use function make_eqdsk directly?
+  mapping.expression = '';
+ case 'halpha'
+  mapping.label = 'Halpha';
+  mapping.method = 'tdi';
+  mapping.expression = '\base::pd:pd_011';
+ case 'ioh'
+  mapping.label = 'I ohmic transformer';
+  mapping.method = 'tdi';
+  mapping.expression = [{'\magnetics::ipol[*,$1]'} {'OH_001'}];
+ case 'ip'
+  mapping.label = 'Plasma current';
+  mapping.method = 'tdi';
+  mapping.expression = '\magnetics::iplasma:trapeze';
+ case 'kappa'
+  mapping.method = 'tdi';
+  mapping.expression = '\results::kappa_edge';
+ case 'mhd'
+  mapping.label = 'n=1,2, etc';
+  mapping.method = 'switchcase';
+  mapping.expression = '';
+ case 'ne'
+  mapping.method = 'switchcase';
+ case 'neint'
+  mapping.label = 'line integrated el. density';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::fir:lin_int_dens';
+ case 'nel'
+  mapping.label = 'line-averaged el. density';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::fir:n_average';
+ case 'nerho'
+  mapping.label = 'ne';
+  mapping.method = 'switchcase';
+ case 'neterho'
+  mapping.label = 'ne and Te';
+  mapping.method = 'switchcase';
+ case 'ni'
+  mapping.method = 'switchcase'; % especially since might have option fit, etc
+ case 'powers'
+  mapping.label = 'various powers';
+  mapping.method = 'switchcase';
+ case 'q0'
+  mapping.method = 'tdi';
+  mapping.expression = '\results::q_zero';
+ case 'q95'
+  mapping.method = 'tdi';
+  mapping.expression = '\results::q_95';
+ case 'qedge'
+  mapping.method = 'tdi';
+  mapping.expression = '\results::q_edge';
+ case 'qrho'
+  mapping.label = 'q';
+  mapping.method = 'switchcase';
+ case 'rgeom'
+  mapping.label = 'Rgeom';
+  mapping.method = 'switchcase';
+ case 'rhovol'
+  mapping.label = 'rhovol\_norm';
+  mapping.method = 'switchcase'; % from conf if exist otherwise computes it
+ case 'rmag'
+  mapping.label = 'R\_magaxis';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::r_axis';
+ case 'sxr'
+  mapping.method = 'switchcase';
+ case 'te'
+  mapping.label = 'Te';
+  mapping.method = 'switchcase';
+ case 'terho'
+  mapping.label = 'Te';
+  mapping.method = 'switchcase';
+ case 'ti'
+  mapping.label = 'Ti';
+  mapping.method = 'switchcase';
+ case 'transp'
+  mapping.label = 'transp output';
+  mapping.method = 'switchcase';
+ case 'vloop'
+  mapping.label = '';
+  mapping.method = 'tdi';
+  mapping.expression = '';
+ case 'vol'
+  mapping.label = 'Volume';
+  mapping.method = 'switchcase';
+  % mapping.expression = '\results::psitbx:vol'; (if exists for liuqe2 and 3 as well)
+ case 'zeff'
+  mapping.label = 'zeff from Ip-Ibs';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::ibs:z_eff';
+ case 'zgeom'
+  mapping.label = 'Zgeom';
+  mapping.method = 'switchcase';
+ case 'zmag'
+  mapping.label = 'Zmagaxis';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::z_axis';
+% $$$  case ''
+% $$$   mapping.label = '';
+% $$$   mapping.method = 'tdi';
+% $$$   mapping.expression = '';
+ otherwise
+  mapping.label = data_request;
+  mapping.method = 'tdi'; % assume a full tracename is given, so just try with tdi (could check there are some ":", etc...)
+  mapping.expression = data_request;
+  
+end
+
+
diff --git a/crpptbx_new/AUG/gdat_aug.m b/crpptbx_new/AUG/gdat_aug.m
new file mode 100644
index 0000000000000000000000000000000000000000..228b8fd9294fed7da6f058c694eaac1048ecf27a
--- /dev/null
+++ b/crpptbx_new/AUG/gdat_aug.m
@@ -0,0 +1,420 @@
+function [gdat_data,gdat_params,error_status,varargout] = gdat_aug(shot,data_request,varargin)
+%
+% function [gdat_data,gdat_params,error_status,varargout] = gdat(shot,data_request,varargin)
+%
+% Aim: get data from a given machine using full path or keywords. 
+%      data_request are and should be case independent (transformed in lower case in the function and outputs)
+%
+% If no inputs are provided, return the list of available pre-defined data_request in gdat_data and default parameters gdat_params
+%
+% Inputs:
+%
+%    no inputs: return default parameters in a structure form in gdat_params
+%    shot: shot number
+%    data_request: keyword (like 'ip') or trace name or structure containing all parameters but shot number
+%    varargin{i},varargin{i+1},i=1:nargin-2: additional optional parameters given in pairs: param_name, param_value
+%                                            The optional parameters list might depend on the data_request
+%              examples of optional parameters:
+%                               'plot',1 (plot is set by default to 0)
+%                               'machine','AUG' (the default machine is the local machine)
+%
+%
+% Outputs:
+%
+% gdat_data: structure containing the data, the time trace if known and other useful information
+% gdat_data.t : time trace
+% gdat_data.data: requested data values
+% gdat_data.dim : values of the various coordinates related to the dimensions of .data(:,:,...)
+%                     note that one of the dim is the time, replicated in .t for clarity
+% gdat_data.dimunits : units of the various dimensions, 'dimensionless' if dimensionless
+% gdat_data.error_bar : if provided
+% gdat_data.gdat_call : list of parameters provided in the gdat call (so can be reproduced)
+% gdat_data.shot: shot number
+% gdat_data.machine: machine providing the data
+% gdat_data.gdat_request: keyword for gdat if relevant
+% gdat_data.data_fullpath: full path to the data node if known and relevant, or expression, or relevant function called if relevant
+% gdat_data.gdat_params: copy gdat_params for completeness
+% gdat_data.xxx: any other relevant information
+%
+%
+% Examples:
+% (should add working examples for various machines (provides working shot numbers for each machine...))
+% 
+%    [a1,a2]=gdat;
+%    a2.data_request = 'Ip';
+%    a3=gdat(48836,a2);  % gives input parameters as a structure, allows to call the same for many shots
+%    a4=gdat('opt1',123,'opt2',[1 2 3],'shot',48832,'data_request','Ip','opt3','aAdB'); % all in pairs
+%    a5=gdat(48836,'ip'); % standard call
+%    a6=gdat(48836,'ip','Opt1',123,'Doplot',1,'opt2','Abc'); % standard call with a few options (note all lowercase in output)
+
+%
+% Comments for local developer:
+% This gdat is just a "header routine" calling the gdat for the specific machine gdat_`machine`.m which can be called
+% directly, thus which should be able to treat the same type of input arguments
+%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Prepare some variables, etc
+
+varargout{1}=cell(1,1);
+error_status=1;
+
+% construct default parameters structure
+gdat_params.data_request = '';
+default_machine = 'aug';
+
+gdat_params.machine=default_machine;
+gdat_params.doplot = 0;
+
+% construct list of keywords from global set of keywords and specific AUG set
+% get data_request names from centralized function
+data_request_names = get_data_request_names;
+
+% add AUG specific to all:
+if ~isempty(data_request_names.aug)
+  aug_names = fieldnames(data_request_names.aug);
+  for i=1:length(aug_names)
+    data_request_names.all.(aug_names{i}) = data_request_names.aug.(aug_names{i});
+  end
+end
+data_request_names_all = fieldnames(data_request_names.all);
+
+% $$$ data_request_names_all= [{'ip'} {'b0'} {'zmag'} {'rmag'} {'rcont'} {'zcont'} {'vol'} {'rhovol'} {'qrho'} {'q95'} {'kappa'} ...
+% $$$       {'delta'} {'deltatop'} {'deltabot'} {'neint'} {'nel'} ...
+% $$$       {'ne'} {'te'} {'nerho'} {'terho'}  {'ne_edge'} {'te_edge'} {'nerho_edge'} {'terho_edge'} {'nerhozshift'} {'terhozshift'} {'profnerho'} {'profterho'} ...
+% $$$       {'neft'} {'teft'} {'neftav'} {'teftav'} {'neft:trial'} {'teft:trial'} {'neftav:trial'} {'teftav:trial'}  ...
+% $$$       {'sxr'} {'sxr'} {'ece'} {'mpx'} {'ioh'} {'vloop'} {'pgyro'} {'jtor'} {'vi_tor'} {'vi_torfit'} {'vi_pol'} {'vi_polfit'} {'ti'} {'tifit'} {'ni'} {'nifit'} {'zeffcxrs'} {'zeffcxrsfit'}];
+
+% construct default output structure
+gdat_data.data = [];
+gdat_data.units = [];
+gdat_data.dim = [];
+gdat_data.dimunits = [];
+gdat_data.t = [];
+gdat_data.x = [];
+gdat_data.shot = [];
+gdat_data.gdat_request = [];
+gdat_data.gdat_params = gdat_params;
+gdat_data.data_fullpath = [];
+
+
+% Treat inputs:
+ivarargin_first_char = 3;
+data_request_eff = '';
+if nargin>=2 && ischar(data_request); data_request = lower(data_request); end
+
+gdat_data.gdat_request = data_request_names_all; % so if return early gives list of possible request names
+% no inputs
+if nargin==0
+  % return defaults and list of keywords
+  return
+end
+
+do_mdsopen_mdsclose = 1;
+% treat 1st arg
+if nargin>=1
+  if isempty(shot)
+    % means mdsopen(shot) already performed
+    shot = mdsipmex(2,'$SHOT');
+    gdat_data.shot = shot;
+    do_mdsopen_mdsclose = 0;
+  elseif isnumeric(shot)
+    gdat_data.shot = shot;
+  elseif ischar(shot)
+    ivarargin_first_char = 1;
+  else
+    warning('type of 1st argument unexpected, should be numeric or char')
+    error_status=2;
+    return
+  end
+  if nargin==1
+    % Only shot number given. If there is a default data_request set it and continue, otherwise return
+    return
+  end
+end
+% 2nd input argument if not part of pairs
+if nargin>=2 && ivarargin_first_char~=1
+  if isempty(data_request)
+    return
+  end
+  % 2nd arg can be a structure with all options except shot_number, or a string for the pathname or keyword, or the start of pairs string/value for the parameters
+  if isstruct(data_request)
+    if ~isfield(data_request,'data_request')
+      warning('expects field data_request in input parameters structure')
+      error_status=3;
+      return
+    end
+    data_request.data_request = lower(data_request.data_request);
+    data_request_eff = data_request.data_request;
+    gdat_params = data_request;
+  else
+    % since data_request is char check from nb of args if it is data_request or a start of pairs
+    if mod(nargin-1,2)==0
+      ivarargin_first_char = 2;
+    else
+      ivarargin_first_char = 3;
+      data_request_eff = data_request;
+    end
+  end
+end
+
+if ~isstruct(data_request)
+  gdat_params.data_request = data_request_eff;
+end
+
+% if start pairs from shot or data_request, shift varargin
+if ivarargin_first_char==1
+  varargin_eff{1} = shot;
+  varargin_eff{2} = data_request;
+  varargin_eff(3:nargin) = varargin(:);
+elseif ivarargin_first_char==2
+  varargin_eff{1} = data_request;
+  varargin_eff(2:nargin-1) = varargin(:);
+else
+  varargin_eff(1:nargin-2) = varargin(:);
+end
+
+% extract parameters from pairs of varargin:
+if (nargin>=ivarargin_first_char)
+  if mod(nargin-ivarargin_first_char+1,2)==0
+    for i=1:2:nargin-ivarargin_first_char+1
+      if ischar(varargin_eff{i})
+        % enforce lower case for any character driven input
+        if ischar(varargin_eff{i+1})
+          gdat_params.(lower(varargin_eff{i})) = lower(varargin_eff{i+1});
+        else
+          gdat_params.(lower(varargin_eff{i})) = varargin_eff{i+1};
+        end
+      else
+        warning(['input argument nb: ' num2str(i) ' is incorrect, expects a character string'])
+        error_status=401;
+        return
+      end
+    end
+  else
+    warning('number of input arguments incorrect, cannot make pairs of parameters')
+    error_status=402;
+    return
+  end
+end
+data_request_eff = gdat_params.data_request; % in case was defined in pairs
+
+% if it is a request_keyword copy it:
+ij=strmatch(data_request_eff,data_request_names_all,'exact');
+if ~isempty(ij); gdat_data.gdat_request = data_request_names_all{ij}; end
+
+% special treatment if shot and data_request given within pairs
+if isfield(gdat_params,'shot')
+  shot = gdat_params.shot; % should use only gdat_params.shot but change shot to make sure
+  gdat_data.shot = gdat_params.shot;
+  gdat_params=rmfield(gdat_params,'shot');
+end
+if ~isfield(gdat_params,'data_request') || isempty(gdat_params.data_request)
+  % warning('input for ''data_request'' missing from input arguments') % might be correct, asking for list of requests
+  error_status=5;
+  return
+end
+gdat_data.gdat_params = gdat_params;
+
+% re-assign main variables to make sure use the one in gdat_data structure
+shot = gdat_data.shot;
+data_request_eff = gdat_data.gdat_params.data_request;
+error_status = 6; % at least reached this level
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Specifications on how to get the data provided in aug_requests_mapping
+mapping_for_aug = aug_requests_mapping(data_request_eff);
+gdat_data.label = mapping_for_aug.label;
+
+ishot=NaN;
+if do_mdsopen_mdsclose
+  mdsdefaultserver aug1.epfl.ch; % should be in aug general path, but set-it in the meantime...
+  ishot = mdsopen(shot); % if ishot equal to shot, then mdsclose at the end
+  if ishot~=shot
+    warning(['cannot open shot= ' num2str(shot)])
+    return
+  end
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% 1st treat the simplest method: "tdi"
+if strcmp(mapping_for_aug.method,'tdi')
+  % need to treat liuqe2, model, etc from options....
+  if iscell(mapping_for_aug.expression)
+    if length(mapping_for_aug.expression)>0
+      % series of arguments for tdi given in each cell
+      eval_expr = ['aatmp=tdi(''' mapping_for_aug.expression{1} ''''];
+      for i=2:length(mapping_for_aug.expression)
+        eval_expr = [eval_expr ',''' mapping_for_aug.expression{i} ''''];
+      end
+      eval_expr = [eval_expr ');'];
+      eval(eval_expr);
+    else
+      % empty or wrong expression
+      error_status=701;
+      return
+    end
+  else
+    eval_expr = ['aatmp=tdi(''' mapping_for_aug.expression ''');'];
+    eval(eval_expr);
+  end
+  gdat_data.data = aatmp.data;
+  gdat_data.dim = aatmp.dim;
+  nbdims = length(gdat_data.dim);
+  if mapping_for_aug.timedim==-1; 
+    mapping_for_aug.timedim = nbdims;
+    if (size(gdat_data.data,nbdims)==1 && nbdims>1); mapping_for_aug.timedim = nbdims-1; end
+  end
+  dim_nontim = setdiff([1:nbdims],mapping_for_aug.timedim);
+  if ~isempty(dim_nontim)
+    % since most cases have at most 2d, copy as array if data is 2D and as cell if 3D or more
+    if length(dim_nontim)==1
+      gdat_data.x = gdat_data.dim{dim_nontim(1)};
+    else
+      gdat_data.x = gdat_data.dim(dim_nontim);
+    end
+  end
+  gdat_data.t = gdat_data.dim{mapping_for_aug.timedim};
+  gdat_data.units = aatmp.units;
+  gdat_data.dimunits = aatmp.dimunits;
+  if mapping_for_aug.new_timedim>0 && mapping_for_aug.new_timedim ~= mapping_for_aug.timedim
+    % shift timedim to new_timedim data(i,j,...itime,k,...) -> data(i,inewtime,j,...,k,...)
+    % note that this means that gdat_data.x and gdat_data.t are same and correct, 
+    % only .data, .dim and .dimunits need to be changed
+    iprev=[1:nbdims];
+    ij=find(dim_nontim>mapping_for_aug.new_timedim-1);
+    inew=[1:mapping_for_aug.new_timedim-1 mapping_for_aug.timedim dim_nontim(ij)];
+    data_sizes = size(aatmp.data);
+    gdat_data.data = NaN*ones(data_sizes(inew));
+    abcol=ones(1,nbdims)*double(':'); abcomma=ones(1,nbdims)*double(',');
+    dimstr_prev=['(' repmat(':,',1,mapping_for_aug.timedim-1) 'it,' ...
+                 repmat(':,',1,nbdims-mapping_for_aug.timedim-1) ':)'];
+    dimstr_new=['(' repmat(':,',1,mapping_for_aug.new_timedim-1) 'it,' ...
+                repmat(':,',1,nbdims-mapping_for_aug.new_timedim-1) ':)'];
+    % eval gdat_data.data(;,:,...,it,...) = aatmp.data(:,:,:,it,...);
+    for it=1:size(aatmp.data,mapping_for_aug.timedim)
+      shift_eval = ['gdat_data.data' dimstr_new ' = aatmp.data'  dimstr_prev ';'];
+      eval(shift_eval);
+    end
+    gdat_data.dim = aatmp.dim(inew);
+    gdat_data.dimunits = aatmp.dimunits(inew);
+  end
+  gdat_data.data_fullpath=mapping_for_aug.expression;
+  % end of method "tdi"
+
+  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+elseif strcmp(mapping_for_aug.method,'function')
+  % 2nd: method="function"
+  % assume expression contains function to call and which returns a structure
+  % we copy the structure, to make sure default nodes are defined and to avoid if return is an closed object like tdi
+  eval_expr = ['aatmp=' mapping_for_aug.expression ';'];
+  eval(eval_expr);
+  if isempty(aatmp) || (~isstruct(aatmp) & ~isobject(aatmp))
+    warning(['function expression does not return a structure: ' eval_expr])
+    error_status=801;
+    return
+  end
+  tmp_fieldnames = fieldnames(aatmp);
+  if sum(strcmp(tmp_fieldnames,'data'))==0 % note: cannot do isfield since aatmp might be an object
+    warning(['function does not return a child name ''data'' for ' data_request_eff])
+  end
+  for i=1:length(tmp_fieldnames)
+    gdat_data.(tmp_fieldnames{i}) = aatmp.(tmp_fieldnames{i});
+  end
+  % add .t and .x in case only dim is provided
+  % do not allow shifting of timedim since should be treated in the relevant function
+  ijdim=find(strcmp(tmp_fieldnames,'dim')==1);
+  if ~isempty(ijdim)
+    nbdims = length(gdat_data.dim);
+    if mapping_for_aug.timedim==-1; 
+      mapping_for_aug.timedim = nbdims;
+      if (size(gdat_data.data,nbdims)==1 && nbdims>1); mapping_for_aug.timedim = nbdims-1; end
+    end
+    dim_nontim = setdiff([1:nbdims],mapping_for_aug.timedim);
+    ijt=find(strcmp(tmp_fieldnames,'t')==1);
+    if isempty(ijt)
+      gdat_data.t = gdat_data.dim{mapping_for_aug.timedim};
+    end
+    ijx=find(strcmp(tmp_fieldnames,'x')==1);
+    if isempty(ijx)
+      if ~isempty(dim_nontim)
+        % since most cases have at most 2d, copy as array if data is 2D and as cell if 3D or more
+        if length(dim_nontim)==1
+          gdat_data.x = gdat_data.dim{dim_nontim(1)};
+        else
+          gdat_data.x = gdat_data.dim(dim_nontim);
+        end
+      end
+    end
+    gdat_data.data_fullpath=mapping_for_aug.expression;
+  end
+  % end of method "function"
+
+  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+elseif strcmp(mapping_for_aug.method,'switchcase')
+  switch data_request_eff % not lower(...) since data_request_eff should be lower case already at this stage
+   case {'ne','te'}
+    % ne or Te from Thomson data on raw z mesh vs (z,t)
+    mdsopen(shot);
+    nodenameeff=['\results::thomson:' data_request_eff];
+    tracetdi=tdi(nodenameeff);
+    tracestd=tdi(['\results::thomson:' data_request_eff ':error_bar']);
+    trace_fir_rat=tdi('\results::thomson:fir_thom_rat');
+    gdat_data.data=tracetdi.data'; % Thomson data as (t,z)
+    gdat_data.error_bar=tracestd.data';
+    gdat_data.data_fullpath=[nodenameeff];
+    % add correct dimensions
+    try
+      time=mdsdata('\results::thomson:times');
+    catch
+      warning('Problems with \results::thomson:times')
+      disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' data_request_eff])
+      return
+    end
+    if isempty(time) || ischar(time)
+      thomsontimes=time
+      warning('!!!!!!!!!!!!!!!!!!!!!!!!!\results::thomson:times  is empty? Check')
+      disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' data_request_eff])
+      return
+    end
+    if strcmp(data_request_eff(1:2),'ne')
+      tracefirrat_data = get_fir_thom_rat_data('thomson',time);
+      gdat_data.data_abs = gdat_data.data * diag(tracefirrat_data);
+      gdat_data.error_bar_abs = gdat_data.error_bar * diag(tracefirrat_data);
+      gdat_data.firrat=tracefirrat_data;
+      gdat_data.data_fullpath=[gdat_data.data_fullpath ' ; _abs includes *firrat'];
+    end
+    z=mdsdata('\diagz::thomson_set_up:vertical_pos');
+    gdat_data.dim=[{z};{time}];
+    gdat_data.dimunits=[{'Z [m]'} ; {'time [s]'}];
+    gdat_data.x=z;
+    gdat_data.t=time;
+    % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus use fieldnames
+    if any(strcmp(fieldnames(tracetdi),'units'))
+      gdat_data.units=tracetdi.units;
+    end
+
+    
+   case 'nerho'
+    
+    
+   otherwise
+    warning(['switchcase= ' data_request_eff ' not known in gdat_aug'])
+    error_status=901;
+    return
+  end
+  
+else
+  warning(['AUG method=' mapping_for_aug.method ' not known yet, contact Olivier.Sauter@epfl.ch'])
+  error_status=602;
+  return
+end
+
+if ishot==shot; mdsclose; end
+
+gdat_data.mapping_for_aug = mapping_for_aug;
+error_status=0;
+
+return
+
diff --git a/crpptbx_new/TCV/gdat_tcv.m b/crpptbx_new/TCV/gdat_tcv.m
new file mode 100644
index 0000000000000000000000000000000000000000..fdec0bcea92e492b2e13219f9312fa2f416eb905
--- /dev/null
+++ b/crpptbx_new/TCV/gdat_tcv.m
@@ -0,0 +1,472 @@
+function [gdat_data,gdat_params,error_status,varargout] = gdat_tcv(shot,data_request,varargin)
+%
+% function [gdat_data,gdat_params,error_status,varargout] = gdat(shot,data_request,varargin)
+%
+% Aim: get data from a given machine using full path or keywords. 
+%      data_request are and should be case independent (transformed in lower case in the function and outputs)
+%
+% If no inputs are provided, return the list of available pre-defined data_request in gdat_data and default parameters gdat_params
+%
+% Inputs:
+%
+%    no inputs: return default parameters in a structure form in gdat_params
+%    shot: shot number
+%    data_request: keyword (like 'ip') or trace name or structure containing all parameters but shot number
+%    varargin{i},varargin{i+1},i=1:nargin-2: additional optional parameters given in pairs: param_name, param_value
+%                                            The optional parameters list might depend on the data_request
+%              examples of optional parameters:
+%                               'plot',1 (plot is set by default to 0)
+%                               'machine','TCV' (the default machine is the local machine)
+%
+%
+% Outputs:
+%
+% gdat_data: structure containing the data, the time trace if known and other useful information
+% gdat_data.t : time trace
+% gdat_data.data: requested data values
+% gdat_data.dim : values of the various coordinates related to the dimensions of .data(:,:,...)
+%                     note that one of the dim is the time, replicated in .t for clarity
+% gdat_data.dimunits : units of the various dimensions, 'dimensionless' if dimensionless
+% gdat_data.error_bar : if provided
+% gdat_data.gdat_call : list of parameters provided in the gdat call (so can be reproduced)
+% gdat_data.shot: shot number
+% gdat_data.machine: machine providing the data
+% gdat_data.gdat_request: keyword for gdat if relevant
+% gdat_data.data_fullpath: full path to the data node if known and relevant, or expression, or relevant function called if relevant
+% gdat_data.gdat_params: copy gdat_params for completeness
+% gdat_data.xxx: any other relevant information
+%
+%
+% Examples:
+% (should add working examples for various machines (provides working shot numbers for each machine...))
+% 
+%    [a1,a2]=gdat;
+%    a2.data_request = 'Ip';
+%    a3=gdat(48836,a2);  % gives input parameters as a structure, allows to call the same for many shots
+%    a4=gdat('opt1',123,'opt2',[1 2 3],'shot',48832,'data_request','Ip','opt3','aAdB'); % all in pairs
+%    a5=gdat(48836,'ip'); % standard call
+%    a6=gdat(48836,'ip','Opt1',123,'Doplot',1,'opt2','Abc'); % standard call with a few options (note all lowercase in output)
+
+%
+% Comments for local developer:
+% This gdat is just a "header routine" calling the gdat for the specific machine gdat_`machine`.m which can be called
+% directly, thus which should be able to treat the same type of input arguments
+%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Prepare some variables, etc
+
+varargout{1}=cell(1,1);
+error_status=1;
+
+% construct default parameters structure
+gdat_params.data_request = '';
+default_machine = 'tcv';
+
+gdat_params.machine=default_machine;
+gdat_params.doplot = 0;
+
+% construct list of keywords from global set of keywords and specific TCV set
+% get data_request names from centralized function
+data_request_names = get_data_request_names;
+% add TCV specific to all:
+if ~isempty(data_request_names.tcv)
+  tcv_names = fieldnames(data_request_names.tcv);
+  for i=1:length(tcv_names)
+    data_request_names.all.(tcv_names{i}) = data_request_names.tcv.(tcv_names{i});
+  end
+end
+data_request_names_all = fieldnames(data_request_names.all);
+
+% $$$ data_request_names_all= [{'ip'} {'b0'} {'zmag'} {'rmag'} {'rcont'} {'zcont'} {'vol'} {'rhovol'} {'qrho'} {'q95'} {'kappa'} ...
+% $$$       {'delta'} {'deltatop'} {'deltabot'} {'neint'} {'nel'} ...
+% $$$       {'ne'} {'te'} {'nerho'} {'terho'}  {'ne_edge'} {'te_edge'} {'nerho_edge'} {'terho_edge'} {'nerhozshift'} {'terhozshift'} {'profnerho'} {'profterho'} ...
+% $$$       {'neft'} {'teft'} {'neftav'} {'teftav'} {'neft:trial'} {'teft:trial'} {'neftav:trial'} {'teftav:trial'}  ...
+% $$$       {'sxr'} {'sxr'} {'ece'} {'mpx'} {'ioh'} {'vloop'} {'pgyro'} {'jtor'} {'vi_tor'} {'vi_torfit'} {'vi_pol'} {'vi_polfit'} {'ti'} {'tifit'} {'ni'} {'nifit'} {'zeffcxrs'} {'zeffcxrsfit'}];
+
+% construct default output structure
+gdat_data.data = [];
+gdat_data.units = [];
+gdat_data.dim = [];
+gdat_data.dimunits = [];
+gdat_data.t = [];
+gdat_data.x = [];
+gdat_data.shot = [];
+gdat_data.gdat_request = [];
+gdat_data.gdat_params = gdat_params;
+gdat_data.data_fullpath = [];
+
+
+% Treat inputs:
+ivarargin_first_char = 3;
+data_request_eff = '';
+if nargin>=2 && ischar(data_request); data_request = lower(data_request); end
+
+gdat_data.gdat_request = data_request_names_all; % so if return early gives list of possible request names
+% no inputs
+if nargin==0
+  % return defaults and list of keywords
+  return
+end
+
+do_mdsopen_mdsclose = 1;
+% treat 1st arg
+if nargin>=1
+  if isempty(shot)
+    % means mdsopen(shot) already performed
+    shot = mdsipmex(2,'$SHOT');
+    gdat_data.shot = shot;
+    do_mdsopen_mdsclose = 0;
+  elseif isnumeric(shot)
+    gdat_data.shot = shot;
+  elseif ischar(shot)
+    ivarargin_first_char = 1;
+  else
+    warning('type of 1st argument unexpected, should be numeric or char')
+    error_status=2;
+    return
+  end
+  if nargin==1
+    % Only shot number given. If there is a default data_request set it and continue, otherwise return
+    return
+  end
+end
+% 2nd input argument if not part of pairs
+if nargin>=2 && ivarargin_first_char~=1
+  if isempty(data_request)
+    return
+  end
+  % 2nd arg can be a structure with all options except shot_number, or a string for the pathname or keyword, or the start of pairs string/value for the parameters
+  if isstruct(data_request)
+    if ~isfield(data_request,'data_request')
+      warning('expects field data_request in input parameters structure')
+      error_status=3;
+      return
+    end
+    data_request.data_request = lower(data_request.data_request);
+    data_request_eff = data_request.data_request;
+    gdat_params = data_request;
+  else
+    % since data_request is char check from nb of args if it is data_request or a start of pairs
+    if mod(nargin-1,2)==0
+      ivarargin_first_char = 2;
+    else
+      ivarargin_first_char = 3;
+      data_request_eff = data_request;
+    end
+  end
+end
+
+if ~isstruct(data_request)
+  gdat_params.data_request = data_request_eff;
+end
+
+% if start pairs from shot or data_request, shift varargin
+if ivarargin_first_char==1
+  varargin_eff{1} = shot;
+  varargin_eff{2} = data_request;
+  varargin_eff(3:nargin) = varargin(:);
+elseif ivarargin_first_char==2
+  varargin_eff{1} = data_request;
+  varargin_eff(2:nargin-1) = varargin(:);
+else
+  varargin_eff(1:nargin-2) = varargin(:);
+end
+
+% extract parameters from pairs of varargin:
+if (nargin>=ivarargin_first_char)
+  if mod(nargin-ivarargin_first_char+1,2)==0
+    for i=1:2:nargin-ivarargin_first_char+1
+      if ischar(varargin_eff{i})
+        % enforce lower case for any character driven input
+        if ischar(varargin_eff{i+1})
+          gdat_params.(lower(varargin_eff{i})) = lower(varargin_eff{i+1});
+        else
+          gdat_params.(lower(varargin_eff{i})) = varargin_eff{i+1};
+        end
+      else
+        warning(['input argument nb: ' num2str(i) ' is incorrect, expects a character string'])
+        error_status=401;
+        return
+      end
+    end
+  else
+    warning('number of input arguments incorrect, cannot make pairs of parameters')
+    error_status=402;
+    return
+  end
+end
+data_request_eff = gdat_params.data_request; % in case was defined in pairs
+
+% if it is a request_keyword copy it:
+ij=strmatch(data_request_eff,data_request_names_all,'exact');
+if ~isempty(ij); gdat_data.gdat_request = data_request_names_all{ij}; end
+
+% special treatment if shot and data_request given within pairs
+if isfield(gdat_params,'shot')
+  shot = gdat_params.shot; % should use only gdat_params.shot but change shot to make sure
+  gdat_data.shot = gdat_params.shot;
+  gdat_params=rmfield(gdat_params,'shot');
+end
+if ~isfield(gdat_params,'data_request') || isempty(gdat_params.data_request)
+  % warning('input for ''data_request'' missing from input arguments') % might be correct, asking for list of requests
+  error_status=5;
+  return
+end
+gdat_data.gdat_params = gdat_params;
+
+% re-assign main variables to make sure use the one in gdat_data structure
+shot = gdat_data.shot;
+data_request_eff = gdat_data.gdat_params.data_request;
+error_status = 6; % at least reached this level
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Specifications on how to get the data provided in tcv_requests_mapping
+mapping_for_tcv = tcv_requests_mapping(data_request_eff);
+gdat_data.label = mapping_for_tcv.label;
+
+ishot=NaN;
+if do_mdsopen_mdsclose
+  mdsdefaultserver tcv1.epfl.ch; % should be in tcv general path, but set-it in the meantime...
+  ishot = mdsopen(shot); % if ishot equal to shot, then mdsclose at the end
+  if ishot~=shot
+    warning(['cannot open shot= ' num2str(shot)])
+    return
+  end
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% 1st treat the simplest method: "tdi"
+if strcmp(mapping_for_tcv.method,'tdi')
+  % need to treat liuqe2, model, etc from options....
+  if iscell(mapping_for_tcv.expression)
+    if length(mapping_for_tcv.expression)>0
+      % series of arguments for tdi given in each cell
+      eval_expr = ['aatmp=tdi(''' mapping_for_tcv.expression{1} ''''];
+      for i=2:length(mapping_for_tcv.expression)
+        eval_expr = [eval_expr ',''' mapping_for_tcv.expression{i} ''''];
+      end
+      eval_expr = [eval_expr ');'];
+      eval(eval_expr);
+    else
+      % empty or wrong expression
+      error_status=701;
+      return
+    end
+  else
+    eval_expr = ['aatmp=tdi(''' mapping_for_tcv.expression ''');'];
+    eval(eval_expr);
+  end
+  gdat_data.data = aatmp.data;
+  gdat_data.dim = aatmp.dim;
+  nbdims = length(gdat_data.dim);
+  if mapping_for_tcv.timedim==-1; 
+    mapping_for_tcv.timedim = nbdims;
+    if (size(gdat_data.data,nbdims)==1 && nbdims>1); mapping_for_tcv.timedim = nbdims-1; end
+  end
+  dim_nontim = setdiff([1:nbdims],mapping_for_tcv.timedim);
+  if ~isempty(dim_nontim)
+    % since most cases have at most 2d, copy as array if data is 2D and as cell if 3D or more
+    if length(dim_nontim)==1
+      gdat_data.x = gdat_data.dim{dim_nontim(1)};
+    else
+      gdat_data.x = gdat_data.dim(dim_nontim);
+    end
+  end
+  gdat_data.t = gdat_data.dim{mapping_for_tcv.timedim};
+  gdat_data.units = aatmp.units;
+  gdat_data.dimunits = aatmp.dimunits;
+  if mapping_for_tcv.new_timedim>0 && mapping_for_tcv.new_timedim ~= mapping_for_tcv.timedim
+    % shift timedim to new_timedim data(i,j,...itime,k,...) -> data(i,inewtime,j,...,k,...)
+    % note that this means that gdat_data.x and gdat_data.t are same and correct, 
+    % only .data, .dim and .dimunits need to be changed
+    iprev=[1:nbdims];
+    ij=find(dim_nontim>mapping_for_tcv.new_timedim-1);
+    inew=[1:mapping_for_tcv.new_timedim-1 mapping_for_tcv.timedim dim_nontim(ij)];
+    data_sizes = size(aatmp.data);
+    gdat_data.data = NaN*ones(data_sizes(inew));
+    abcol=ones(1,nbdims)*double(':'); abcomma=ones(1,nbdims)*double(',');
+    dimstr_prev=['(' repmat(':,',1,mapping_for_tcv.timedim-1) 'it,' ...
+                 repmat(':,',1,nbdims-mapping_for_tcv.timedim-1) ':)'];
+    dimstr_new=['(' repmat(':,',1,mapping_for_tcv.new_timedim-1) 'it,' ...
+                repmat(':,',1,nbdims-mapping_for_tcv.new_timedim-1) ':)'];
+    % eval gdat_data.data(;,:,...,it,...) = aatmp.data(:,:,:,it,...);
+    for it=1:size(aatmp.data,mapping_for_tcv.timedim)
+      shift_eval = ['gdat_data.data' dimstr_new ' = aatmp.data'  dimstr_prev ';'];
+      eval(shift_eval);
+    end
+    gdat_data.dim = aatmp.dim(inew);
+    gdat_data.dimunits = aatmp.dimunits(inew);
+  end
+  gdat_data.data_fullpath=mapping_for_tcv.expression;
+  % end of method "tdi"
+
+  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+elseif strcmp(mapping_for_tcv.method,'function')
+  % 2nd: method="function"
+  % assume expression contains function to call and which returns a structure
+  % we copy the structure, to make sure default nodes are defined and to avoid if return is an closed object like tdi
+  eval_expr = ['aatmp=' mapping_for_tcv.expression ';'];
+  eval(eval_expr);
+  if isempty(aatmp) || (~isstruct(aatmp) & ~isobject(aatmp))
+    warning(['function expression does not return a structure: ' eval_expr])
+    error_status=801;
+    return
+  end
+  tmp_fieldnames = fieldnames(aatmp);
+  if sum(strcmp(tmp_fieldnames,'data'))==0 % note: cannot do isfield since aatmp might be an object
+    warning(['function does not return a child name ''data'' for ' data_request_eff])
+  end
+  for i=1:length(tmp_fieldnames)
+    gdat_data.(tmp_fieldnames{i}) = aatmp.(tmp_fieldnames{i});
+  end
+  % add .t and .x in case only dim is provided
+  % do not allow shifting of timedim since should be treated in the relevant function
+  ijdim=find(strcmp(tmp_fieldnames,'dim')==1);
+  if ~isempty(ijdim)
+    nbdims = length(gdat_data.dim);
+    if mapping_for_tcv.timedim==-1; 
+      mapping_for_tcv.timedim = nbdims;
+      if (size(gdat_data.data,nbdims)==1 && nbdims>1); mapping_for_tcv.timedim = nbdims-1; end
+    end
+    dim_nontim = setdiff([1:nbdims],mapping_for_tcv.timedim);
+    ijt=find(strcmp(tmp_fieldnames,'t')==1);
+    if isempty(ijt)
+      gdat_data.t = gdat_data.dim{mapping_for_tcv.timedim};
+    end
+    ijx=find(strcmp(tmp_fieldnames,'x')==1);
+    if isempty(ijx)
+      if ~isempty(dim_nontim)
+        % since most cases have at most 2d, copy as array if data is 2D and as cell if 3D or more
+        if length(dim_nontim)==1
+          gdat_data.x = gdat_data.dim{dim_nontim(1)};
+        else
+          gdat_data.x = gdat_data.dim(dim_nontim);
+        end
+      end
+    end
+    gdat_data.data_fullpath=mapping_for_tcv.expression;
+  end
+  % end of method "function"
+
+  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+elseif strcmp(mapping_for_tcv.method,'switchcase')
+  switch data_request_eff % not lower(...) since data_request_eff should be lower case already at this stage
+   case {'ne','te'}
+    % ne or Te from Thomson data on raw z mesh vs (z,t)
+    mdsopen(shot);
+    nodenameeff=['\results::thomson:' data_request_eff];
+    tracetdi=tdi(nodenameeff);
+    tracestd=tdi(['\results::thomson:' data_request_eff ':error_bar']);
+    trace_fir_rat=tdi('\results::thomson:fir_thom_rat');
+    gdat_data.data=tracetdi.data'; % Thomson data as (t,z)
+    gdat_data.error_bar=tracestd.data';
+    gdat_data.data_fullpath=[nodenameeff];
+    % add correct dimensions
+    try
+      time=mdsdata('\results::thomson:times');
+    catch
+      warning('Problems with \results::thomson:times')
+      disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' data_request_eff])
+      return
+    end
+    if isempty(time) || ischar(time)
+      thomsontimes=time
+      warning('!!!!!!!!!!!!!!!!!!!!!!!!!\results::thomson:times  is empty? Check')
+      disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' data_request_eff])
+      return
+    end
+    if strcmp(data_request_eff(1:2),'ne')
+      tracefirrat_data = get_fir_thom_rat_data('thomson',time);
+      gdat_data.data_abs = gdat_data.data * diag(tracefirrat_data);
+      gdat_data.error_bar_abs = gdat_data.error_bar * diag(tracefirrat_data);
+      gdat_data.firrat=tracefirrat_data;
+      gdat_data.data_fullpath=[gdat_data.data_fullpath ' ; _abs includes *firrat'];
+    end
+    z=mdsdata('\diagz::thomson_set_up:vertical_pos');
+    gdat_data.dim=[{z};{time}];
+    gdat_data.dimunits=[{'Z [m]'} ; {'time [s]'}];
+    gdat_data.x=z;
+    gdat_data.t=time;
+    % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus use fieldnames
+    if any(strcmp(fieldnames(tracetdi),'units'))
+      gdat_data.units=tracetdi.units;
+    end
+
+    
+   case 'nerho'
+    
+    
+   otherwise
+    warning(['switchcase= ' data_request_eff ' not known in gdat_tcv'])
+    error_status=901;
+    return
+  end
+  
+else
+  warning(['TCV method=' mapping_for_tcv.method ' not known yet, contact Olivier.Sauter@epfl.ch'])
+  error_status=602;
+  return
+end
+
+if ishot==shot; mdsclose; end
+
+gdat_data.mapping_for_tcv = mapping_for_tcv;
+error_status=0;
+
+return
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function [firthomratio] = get_fir_thom_rat_data(maintracename,timebase);
+%
+% since depends on shot number for using auto fit and thomson or thomson edge, use tracename and function here
+%
+% maintracename = 'thomson' or 'thomson_edge
+%
+% return fir_to_thomson ratio on time=timebase
+%
+% normally should use "main" thomson one built from auto fit if possible
+% take edge one if need be
+%
+% default: maintracename = "thomson"
+%
+maintracename_eff = 'thomson';
+if exist('maintracename') && ~isempty(maintracename)
+  maintracename_eff = maintracename;
+end
+
+firthomratio = NaN;
+if ~exist('timebase') || isempty(timebase)
+  disp('need a timebase in get_fir_thom_rat_data')
+  return
+end
+firthomratio = NaN*ones(size(timebase));
+
+if strcmp(maintracename_eff,'thomson')
+  if shot>=23801
+    tracefirrat=tdi('\results::thomson.profiles.auto:fir_thom_rat'); %time base not same!!
+    if isempty(tracefirrat.data) || ischar(tracefirrat.data)
+      disp('problem with \results::thomson.profiles.auto:fir_thom_rat: empty, use thomson:fir_thom_rat')
+      tracefirrat=tdi('\results::thomson:fir_thom_rat');
+    end
+  else
+    tracefirrat=tdi('\results::thomson:fir_thom_rat');
+    if isempty(tracefirrat.data) || ischar(tracefirrat.data)
+      disp('problem with \results::thomson:fir_thom_rat: empty')
+    end
+  end
+elseif strcmp(maintracename_eff,'thomson_edge')
+  tracefirrat=tdi('\results::thomson_edge:fir_thom_rat');
+  if isempty(tracefirrat.data) || ischar(tracefirrat.data)
+    disp('problem with \results::thomson_edge:fir_thom_rat: empty')
+  end
+else
+  disp('bad input in get_fir_thom_rat_data')
+  return
+end  
+  
+if ~isempty(tracefirrat.data) || ischar(tracefirrat.data)
+  firthomratio = interp1(tracefirrat.dim{1},tracefirrat.data,timebase);
+end
+
diff --git a/crpptbx_new/TCV/loadTCVdata.m b/crpptbx_new/TCV/loadTCVdata.m
index e912325d2532073226a91a53b48c1f9be4b48c6f..cc7ef6baf950a7b9e23ceaef0f051e80fd654d43 100644
--- a/crpptbx_new/TCV/loadTCVdata.m
+++ b/crpptbx_new/TCV/loadTCVdata.m
@@ -1,9 +1,9 @@
- function [trace,error,varargout]=loadTCVdata(shot,data_request,varargin)
+ function [trace,error_status,varargout]=loadTCVdata(shot,data_type,varargin)
 %
 % Added option to load shot=-1 or >=100000
 % Added option shot=-9 to list keywords
 %
-% list of data_request currently available (when [_2,_3] is added, means can add _i to get Liuqe i):
+% list of data_type currently available (when [_2,_3] is added, means can add _i to get Liuqe i):
 % if -1 is added, can also get it from FBTE with shot=-1, >=100000 or liuqe_version='_-1' (to get model file)
 %
 % 'Ip'[_2,_3]   =  current
@@ -54,18 +54,18 @@
 %
 % INPUT:
 % shot: shot number
-% data_request: type of the required data
+% data_type: type of the required data
 %
-% Definition of varargin depends on data_request:
+% Definition of varargin depends on data_type:
 %
-% data_request=sxr or ece:
+% data_type=sxr or ece:
 %                  varargin{1}:  [i1 i2] : if not empty, assumes need many chords from i1 to i2
 %                  varargin{2}:  channel status 1= unread yet, 0= read
 %                                (for traces with many channel, enables to load additional channels,
 %                                 like SXR, ECE, etc.)
 %                  varargin{3}:  zmag for varargout{1} computation
 %                       (can have more inputs for AUG, but not used here)
-% data_request=nerhozshift or terhozshift:
+% data_type=nerhozshift or terhozshift:
 %                  varargin{1}:  zshift [m] constant or (t) : positive, moves equil up (that is thomson effective z down)
 %                                                time dependent: needs same time base as psitbx:psi
 %
@@ -78,41 +78,41 @@
 % trace.dimunits: units of dimensions
 % trace.units:  units of data
 %
-% Additional Output arguments depending on data_request
+% Additional Output arguments depending on data_type
 %
-% data_request=sxR, ece:
+% data_type=sxR, ece:
 %                varargout{1}: major radius: intersection/projection of the view lines with z=zmag
-% data_request=MPX:
+% data_type=MPX:
 %                varargout{1}: te be determined
 %
 %
 % function needed: mds functions-xtomo_geometry-get_xtomo_data (Furno's routines)
 %                  VsxrTCVradius
 % Example:
-%         [ip,error]=loadTCVdata(shot,'Ip',1);
-%         [sxr,error,R]=loadTCVdata(shot,'sxR',1);
+%         [ip,error_status]=loadTCVdata(shot,'Ip',1);
+%         [sxr,error_status,R]=loadTCVdata(shot,'sxR',1);
 %
 
 varargout{1}=cell(1,1);
-error=1;
+error_status=1;
 
-% To allow multiple ways of writing a specific keyword, use data_request_eff within this routine
-if exist('data_request') && ~isempty(data_request)
-  data_request_eff=data_request;
+% To allow multiple ways of writing a specific keyword, use data_type_eff within this routine
+if exist('data_type') && ~isempty(data_type)
+  data_type_eff=data_type;
 else
-  data_request_eff=' ';
+  data_type_eff=' ';
 end
 i_23=0;
 % LIUQE tree
 begstr = '\results::';
 endstr = '';
 liuqe_version = 1;
-if length(data_request_eff)>2
-  if strcmp(data_request_eff(end-1:end),'_2') | strcmp(data_request_eff(end-1:end),'_3')
+if length(data_type_eff)>2
+  if strcmp(data_type_eff(end-1:end),'_2') | strcmp(data_type_eff(end-1:end),'_3')
     i_23=2;
-    endstr=data_request_eff(end-1:end);
-    liuqe_version = str2num(data_request_eff(end:end));
-  elseif strcmp(upper(data_request_eff(end-2:end)),'_-1')
+    endstr=data_type_eff(end-1:end);
+    liuqe_version = str2num(data_type_eff(end:end));
+  elseif strcmp(upper(data_type_eff(end-2:end)),'_-1')
     i_23=3;
     begstr = 'tcv_eq( "';
     endstr = '", "FBTE" )';
@@ -128,122 +128,122 @@ end
 
 % use keyword without eventual _2 or _3 extension to check for multiple possibilities
 % Also remove ":4" for trial_indx specification
-jj=strfind(data_request_eff,':');
+jj=strfind(data_type_eff,':');
 trialindx=[];
 if ~isempty(jj)
-  ii=strmatch(data_request_eff(1:jj-1),[{'teft'},{'neft'},{'teftav'},{'neftav'}]);
+  ii=strmatch(data_type_eff(1:jj-1),[{'teft'},{'neft'},{'teftav'},{'neftav'}]);
   if ~isempty(ii)
-    trialindx=str2num(data_request_eff(jj+1:end));
-    data_request_eff_noext=[data_request_eff(1:jj-1) ':trial'];
+    trialindx=str2num(data_type_eff(jj+1:end));
+    data_type_eff_noext=[data_type_eff(1:jj-1) ':trial'];
   else
-    data_request_eff_noext=data_request_eff(1:end-i_23);
+    data_type_eff_noext=data_type_eff(1:end-i_23);
   end
 else
-  data_request_eff_noext=data_request_eff(1:end-i_23);
+  data_type_eff_noext=data_type_eff(1:end-i_23);
 end
 
-if ~isempty(strmatch(data_request_eff_noext,[{'ip'} {'i_p'} {'xip'}],'exact'))
-  data_request_eff_noext='Ip';
+if ~isempty(strmatch(data_type_eff_noext,[{'ip'} {'i_p'} {'xip'}],'exact'))
+  data_type_eff_noext='Ip';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'b0'} {'B_0'} {'Bgeom'} {'BGEOM'}],'exact'))
-  data_request_eff_noext='B0';
+if ~isempty(strmatch(data_type_eff_noext,[{'b0'} {'B_0'} {'Bgeom'} {'BGEOM'}],'exact'))
+  data_type_eff_noext='B0';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Te'} {'t_e'} {'TE'} {'T_e'}],'exact'))
-  data_request_eff_noext='te';
+if ~isempty(strmatch(data_type_eff_noext,[{'Te'} {'t_e'} {'TE'} {'T_e'}],'exact'))
+  data_type_eff_noext='te';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Te_edge'} {'TE_edge'}],'exact'))
-  data_request_eff_noext='te_edge';
+if ~isempty(strmatch(data_type_eff_noext,[{'Te_edge'} {'TE_edge'}],'exact'))
+  data_type_eff_noext='te_edge';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Ne_edge'} {'NE_edge'}],'exact'))
-  data_request_eff_noext='ne';
+if ~isempty(strmatch(data_type_eff_noext,[{'Ne_edge'} {'NE_edge'}],'exact'))
+  data_type_eff_noext='ne';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Rcont'}],'exact'))
-  data_request_eff_noext='rcont';
+if ~isempty(strmatch(data_type_eff_noext,[{'Rcont'}],'exact'))
+  data_type_eff_noext='rcont';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Zcont'}],'exact'))
-  data_request_eff_noext='zcont';
+if ~isempty(strmatch(data_type_eff_noext,[{'Zcont'}],'exact'))
+  data_type_eff_noext='zcont';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Terho'}],'exact'))
-  data_request_eff_noext='terho';
+if ~isempty(strmatch(data_type_eff_noext,[{'Terho'}],'exact'))
+  data_type_eff_noext='terho';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Terhozshift'}],'exact'))
-  data_request_eff_noext='terhozshift';
+if ~isempty(strmatch(data_type_eff_noext,[{'Terhozshift'}],'exact'))
+  data_type_eff_noext='terhozshift';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'SXR'}],'exact'))
-  data_request_eff_noext='sxr';
+if ~isempty(strmatch(data_type_eff_noext,[{'SXR'}],'exact'))
+  data_type_eff_noext='sxr';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'ECE'}],'exact'))
-  data_request_eff_noext='ece';
+if ~isempty(strmatch(data_type_eff_noext,[{'ECE'}],'exact'))
+  data_type_eff_noext='ece';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'VOL'} {'volume'}],'exact'))
-  data_request_eff_noext='vol';
+if ~isempty(strmatch(data_type_eff_noext,[{'VOL'} {'volume'}],'exact'))
+  data_type_eff_noext='vol';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'RHOVOL'}],'exact'))
-  data_request_eff_noext='rhovol';
+if ~isempty(strmatch(data_type_eff_noext,[{'RHOVOL'}],'exact'))
+  data_type_eff_noext='rhovol';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'q_95'} {'Q95'}],'exact'))
-  data_request_eff_noext='q95';
+if ~isempty(strmatch(data_type_eff_noext,[{'q_95'} {'Q95'}],'exact'))
+  data_type_eff_noext='q95';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'elongation'} {'elon'}],'exact'))
-  data_request_eff_noext='kappa';
+if ~isempty(strmatch(data_type_eff_noext,[{'elongation'} {'elon'}],'exact'))
+  data_type_eff_noext='kappa';
 end
-if ~isempty(strmatch(lower(data_request_eff_noext),[{'j_tor'} {'jtor'} {'\results::j_tor'}],'exact'))
-  data_request_eff_noext='jtor';
-  data_request_eff = ['jtor' endstr];
+if ~isempty(strmatch(lower(data_type_eff_noext),[{'j_tor'} {'jtor'} {'\results::j_tor'}],'exact'))
+  data_type_eff_noext='jtor';
+  data_type_eff = ['jtor' endstr];
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'triangularity'} {'triang'}],'exact'))
-  data_request_eff_noext='delta';
+if ~isempty(strmatch(data_type_eff_noext,[{'triangularity'} {'triang'}],'exact'))
+  data_type_eff_noext='delta';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'deltaup'} {'deltau'} {'triangtop'} {'triangu'} {'triangup'}],'exact'))
-  data_request_eff_noext='deltatop';
+if ~isempty(strmatch(data_type_eff_noext,[{'deltaup'} {'deltau'} {'triangtop'} {'triangu'} {'triangup'}],'exact'))
+  data_type_eff_noext='deltatop';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'deltalow'} {'deltal'} {'triangbot'} {'triangl'} {'trianglow'}],'exact'))
-  data_request_eff_noext='deltabot';
+if ~isempty(strmatch(data_type_eff_noext,[{'deltalow'} {'deltal'} {'triangbot'} {'triangl'} {'trianglow'}],'exact'))
+  data_type_eff_noext='deltabot';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Rmag'}],'exact'))
-  data_request_eff_noext='rmag';
+if ~isempty(strmatch(data_type_eff_noext,[{'Rmag'}],'exact'))
+  data_type_eff_noext='rmag';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Zmag'}],'exact'))
-  data_request_eff_noext='zmag';
+if ~isempty(strmatch(data_type_eff_noext,[{'Zmag'}],'exact'))
+  data_type_eff_noext='zmag';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'MPX'}],'exact'))
-  data_request_eff_noext='MPX';
+if ~isempty(strmatch(data_type_eff_noext,[{'MPX'}],'exact'))
+  data_type_eff_noext='MPX';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'ioh'} {'Ioh'} {'iot'} {'IOT'}],'exact'))
-  data_request_eff_noext='IOH';
+if ~isempty(strmatch(data_type_eff_noext,[{'ioh'} {'Ioh'} {'iot'} {'IOT'}],'exact'))
+  data_type_eff_noext='IOH';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Vloop'} {'Vsurf'} {'vsurf'}],'exact'))
-  data_request_eff_noext='vloop';
+if ~isempty(strmatch(data_type_eff_noext,[{'Vloop'} {'Vsurf'} {'vsurf'}],'exact'))
+  data_type_eff_noext='vloop';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'vtor'} {'v_tor'} {'vi'} {'vc'} {'v_i'} {'v_c'} {'VTOR'} {'V_TOR'} {'VI'} {'VC'} {'V_I'} {'V_C'}],'exact'))
-  data_request_eff_noext='vi_tor';
+if ~isempty(strmatch(data_type_eff_noext,[{'vtor'} {'v_tor'} {'vi'} {'vc'} {'v_i'} {'v_c'} {'VTOR'} {'V_TOR'} {'VI'} {'VC'} {'V_I'} {'V_C'}],'exact'))
+  data_type_eff_noext='vi_tor';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'vtorfit'} {'vtorft'} {'v_torfit'} {'vifit'} {'vcfit'} {'v_ifit'} {'v_cfit'} {'VTORfit'} {'V_TORfit'} {'VIfit'} {'VCfit'} {'V_Ifit'} {'V_Cfit'}],'exact'))
-  data_request_eff_noext='vi_torfit';
+if ~isempty(strmatch(data_type_eff_noext,[{'vtorfit'} {'vtorft'} {'v_torfit'} {'vifit'} {'vcfit'} {'v_ifit'} {'v_cfit'} {'VTORfit'} {'V_TORfit'} {'VIfit'} {'VCfit'} {'V_Ifit'} {'V_Cfit'}],'exact'))
+  data_type_eff_noext='vi_torfit';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'vpol'} {'v_pol'} {'VPOL'} {'V_POL'}],'exact'))
-  data_request_eff_noext='vi_pol';
+if ~isempty(strmatch(data_type_eff_noext,[{'vpol'} {'v_pol'} {'VPOL'} {'V_POL'}],'exact'))
+  data_type_eff_noext='vi_pol';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'vpolfit'} {'vpolft'} {'v_polfit'} {'VPOLfit'} {'V_POLfit'}],'exact'))
-  data_request_eff_noext='vi_polfit';
+if ~isempty(strmatch(data_type_eff_noext,[{'vpolfit'} {'vpolft'} {'v_polfit'} {'VPOLfit'} {'V_POLfit'}],'exact'))
+  data_type_eff_noext='vi_polfit';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Ti'} {'ti'} {'TC'} {'tc'} {'T_C'} {'t_c'}],'exact'))
-  data_request_eff_noext='Ti';
+if ~isempty(strmatch(data_type_eff_noext,[{'Ti'} {'ti'} {'TC'} {'tc'} {'T_C'} {'t_c'}],'exact'))
+  data_type_eff_noext='Ti';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Tifit'} {'tifit'} {'TCfit'} {'tcfit'} {'T_Cfit'} {'t_cfit'}],'exact'))
-  data_request_eff_noext='Tifit';
+if ~isempty(strmatch(data_type_eff_noext,[{'Tifit'} {'tifit'} {'TCfit'} {'tcfit'} {'T_Cfit'} {'t_cfit'}],'exact'))
+  data_type_eff_noext='Tifit';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Ni'} {'ni'} {'NC'} {'nc'} {'N_C'} {'n_c'}],'exact'))
-  data_request_eff_noext='ni';
+if ~isempty(strmatch(data_type_eff_noext,[{'Ni'} {'ni'} {'NC'} {'nc'} {'N_C'} {'n_c'}],'exact'))
+  data_type_eff_noext='ni';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Nifit'} {'nifit'} {'NCfit'} {'ncfit'} {'N_Cfit'} {'n_cfit'}],'exact'))
-  data_request_eff_noext='nifit';
+if ~isempty(strmatch(data_type_eff_noext,[{'Nifit'} {'nifit'} {'NCfit'} {'ncfit'} {'N_Cfit'} {'n_cfit'}],'exact'))
+  data_type_eff_noext='nifit';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Zeffcxrs'} {'zeffcxrs'} {'Z_effcxrs'} {'z_effcxrs'} {'Zeff_cxrs'} {'zeff_cxrs'} {'Z_eff_cxrs'} {'z_eff_cxrs'}],'exact'))
-  data_request_eff_noext='zeffcxrs';
+if ~isempty(strmatch(data_type_eff_noext,[{'Zeffcxrs'} {'zeffcxrs'} {'Z_effcxrs'} {'z_effcxrs'} {'Zeff_cxrs'} {'zeff_cxrs'} {'Z_eff_cxrs'} {'z_eff_cxrs'}],'exact'))
+  data_type_eff_noext='zeffcxrs';
 end
-if ~isempty(strmatch(data_request_eff_noext,[{'Zeffcxrsfit'} {'zeffcxrsfit'} {'Z_effcxrsfit'} {'z_effcxrsfit'} {'Zeff_cxrsfit'} {'zeff_cxrsfit'} {'Z_eff_cxrsfit'} {'z_eff_cxrsfit'}],'exact'))
-  data_request_eff_noext='zeffcxrsfit';
+if ~isempty(strmatch(data_type_eff_noext,[{'Zeffcxrsfit'} {'zeffcxrsfit'} {'Z_effcxrsfit'} {'z_effcxrsfit'} {'Zeff_cxrsfit'} {'zeff_cxrsfit'} {'Z_eff_cxrsfit'} {'z_eff_cxrsfit'}],'exact'))
+  data_type_eff_noext='zeffcxrsfit';
 end
 
 % some defaults
@@ -434,33 +434,33 @@ trace.dimunits=[];
 trace.units=[];
 iprintwarn=0;
 % find index of signal called upon
-if strcmp(data_request_eff(1:1),'\')
+if strcmp(data_type_eff(1:1),'\')
   % in case full node name was given
-  index=strmatch(data_request_eff(1:end-i_23),TCVsiglocation,'exact');
+  index=strmatch(data_type_eff(1:end-i_23),TCVsiglocation,'exact');
   if iprintwarn & isempty(index)
     disp('********************')
     disp('trace not yet registered.')
     disp('If standard data, ask olivier.sauter@epfl.ch to create a keyqord entry for this data')
-%    eval(['!mail -s ''' data_request_eff ' ' num2str(shot) ' ' getenv('USER') ' TCV'' olivier.sauter@epfl.ch < /dev/null'])
+%    eval(['!mail -s ''' data_type_eff ' ' num2str(shot) ' ' getenv('USER') ' TCV'' olivier.sauter@epfl.ch < /dev/null'])
     disp('********************')
   elseif isempty(index)
     % temporarily add entry in arrays, so can work below
     index=length(TCVkeywrdall)+1;
     TCVkeywrdall(end+1)={'new'};
     TCVkeywrdcase(end+1)={'simpletdi'};
-    TCVsiglocation(end+1)={data_request_eff(1:end-i_23)};
+    TCVsiglocation(end+1)={data_type_eff(1:end-i_23)};
     TCVsigtimeindx(end+1)=0;
   elseif ~strcmp(TCVkeywrdcase{index},'simpletdi')
-    msgbox(['Problem in loadTCVdata with data_request_eff = ' data_request_eff ...
+    msgbox(['Problem in loadTCVdata with data_type_eff = ' data_type_eff ...
           '. Full paths of nodes should only be for case simpletdi'],'in loadTCVdata','error')
     error('in loadTCVdata')
   end
 else
-  index=strmatch(data_request_eff_noext,TCVkeywrdall,'exact');
+  index=strmatch(data_type_eff_noext,TCVkeywrdall,'exact');
   if isempty(index)
     disp(' ')
     disp('********************')
-    disp(['no such keyword: ' data_request_eff(1:end-i_23)])
+    disp(['no such keyword: ' data_type_eff(1:end-i_23)])
     disp(' ')
     disp('Available keywords:')
     TCVkeywrdall(:)
@@ -473,13 +473,13 @@ else
   end
 end
 if iprintwarn
-  disp(['loading' ' ' data_request_eff_noext ' from TCV shot #' num2str(shot)]);
+  disp(['loading' ' ' data_type_eff_noext ' from TCV shot #' num2str(shot)]);
   disp(['case ' TCVkeywrdcase{index}])
 end
 if i_23==2 & isempty(strmatch(TCVsiglocation(index),liuqe23,'exact')) & strcmp(TCVkeywrdcase{index},'simpletdi')
   disp('********')
   disp('Warning asks for liuqe 2 or 3 of a signal, but not in liuqe23 list in loadTCVdata')
-%  eval(['!mail -s ''' data_request_eff ' ' num2str(shot) ' ' getenv('USER') ' TCV: not in liuqe23 list'' olivier.sauter@epfl.ch < /dev/null'])
+%  eval(['!mail -s ''' data_type_eff ' ' num2str(shot) ' ' getenv('USER') ' TCV: not in liuqe23 list'' olivier.sauter@epfl.ch < /dev/null'])
   disp('********')
 end
 
@@ -502,7 +502,7 @@ switch TCVkeywrdcase{index}
     else
       mdsopen(shot);
       % test if node exists
-      error=1;
+      error_status=1;
       ij=findstr(TCVsiglocation{index},'[');
       if isempty(ij); ij=length(TCVsiglocation{index})+1; end
       if eval(['~mdsdata(''node_exists("\' TCVsiglocation{index}(1:ij-1) '")'')'])
@@ -527,7 +527,7 @@ switch TCVkeywrdcase{index}
     end
     tracetdi=tdi(nodenameeff);
     mdsclose;
-    if isempty(tracetdi.data) | isnan(tracetdi.data)
+    if isempty(tracetdi.data) || (~iscell(tracetdi.data) && isnan(tracetdi.data))
       disp(['node ' nodenameeff ' is empty for shot = ' num2str(shot)])
       return
     end
@@ -589,7 +589,7 @@ switch TCVkeywrdcase{index}
         trace.data=trace.data';
       end
     elseif length(tracetdi.dim)>2
-      msgbox(['data more than 2D (data_request_eff=' data_request_eff ...
+      msgbox(['data more than 2D (data_type_eff=' data_type_eff ...
             '), check how to save it, contact andrea.scarabosio@epfl.ch or olivier.sauter@epfl.ch'],...
           'in simpletdi','warn')
       warning('in simpletdi of loadTCVdata')
@@ -614,7 +614,7 @@ switch TCVkeywrdcase{index}
     end
     
     trace.name=[num2str(shot) ';' nodenameeff];
-    error=0;
+    error_status=0;
 
   %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   case {'ne','te'}
@@ -628,7 +628,6 @@ switch TCVkeywrdcase{index}
       nodenameeff='\results::thomson:te';
       tracetdi=tdi(nodenameeff);
       tracestd=tdi('\results::thomson:te:error_bar');
-      trace_abs=tdi('\results::thomson:fir_thom_rat');
     end
     trace.data=tracetdi.data'; % Thomson data as (t,z)
     trace.std=tracestd.data';
@@ -666,11 +665,11 @@ switch TCVkeywrdcase{index}
       nodenameeff='\results::thomson.edge:ne';
       tracetdi=tdi(nodenameeff);
       tracestd=tdi('\results::thomson.edge:ne:error_bar');
+      % trace_abs=tdi('\results::thomson.edge:fir_thom_rat');
     else
       nodenameeff='\results::thomson.edge:te';
       tracetdi=tdi(nodenameeff);
       tracestd=tdi('\results::thomson.edge:te:error_bar');
-      trace_abs=tdi('\results::thomson.edge:fir_thom_rat');
     end
     trace.data=tracetdi.data'; % Thomson.Edge data as (t,z)
     trace.std=tracestd.data';
@@ -874,9 +873,7 @@ switch TCVkeywrdcase{index}
     else
       zshift=0.;
     end
-%    mdsdisconnect; mdsconnect tcv1;
     mdsopen(shot);
-    keyboard
     try
       time=mdsdata('\results::thomson:times');
     catch
@@ -982,7 +979,7 @@ switch TCVkeywrdcase{index}
   case {'profnerho','profterho'}
     % vol from psitbx
     mdsopen(shot);
-    error=1;
+    error_status=1;
     if strcmp(TCVkeywrdcase{index},'profnerho')
       nodenameeff=['\results::THOMSON.PROFILES.AUTO:ne'];
       avers=tdi('\results::THOMSON.PROFILES.AUTO:ne:version_num');
@@ -1003,9 +1000,9 @@ switch TCVkeywrdcase{index}
         if ~isempty(tracetdi.dim) && ~ischar(tracetdi.data)
           trace.x=tracetdi.dim{1};
           trace.t=tracetdi.dim{2};
-          error=0;
+          error_status=0;
         else
-         error=2;
+         error_status=2;
           trace.x=[];
           trace.t=[];
         end
@@ -1015,11 +1012,11 @@ switch TCVkeywrdcase{index}
           disp('assumes dim{2} for x in THOMSON.PROFILES.AUTO')
           trace.x=tracetdi.dim{2};
           trace.t=tracetdi.dim{1};
-          error=0;
+          error_status=0;
         else
           trace.x=[];
           trace.t=[];
-         error=2;
+         error_status=2;
         end
       end
     else
@@ -1186,7 +1183,7 @@ switch TCVkeywrdcase{index}
     if ~isempty(find(status(1:20*icamera*ones(10,1)) == 1))
       [fans,vangle,xchord,ychord,aomega,angfact]=xtomo_geometry(1,icamera);
       % calculating intersection of the view lines with magnetic axis
-      if strcmp(data_request_eff,'sxR')
+      if strcmp(data_type_eff,'sxR')
         if nargin>=5 & ~isempty(varargin{3})
           zmag=varargin{3};
         else
@@ -1213,7 +1210,7 @@ switch TCVkeywrdcase{index}
     trace.dim=[{trace.x} ; {trace.t}];
     trace.dimunits=[{'channel #'} ; {'time [s]'}];
     trace.name=[num2str(shot) ';' 'get_xtomo_data'];
-    error=0;
+    error_status=0;
 
   %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   case 'ece'
@@ -1244,7 +1241,7 @@ switch TCVkeywrdcase{index}
     radius.data=trace.R;
     radius.t=trace.t;
     varargout{1}={radius};
-    error=0;
+    error_status=0;
     % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work
     if any(strcmp(fieldnames(tracetdi),'units'))
       trace.units=tracetdi.units;
@@ -1275,7 +1272,7 @@ switch TCVkeywrdcase{index}
     trace.name=[num2str(shot) ';' 'get_mds_mio(MPX)'];
     [xchord,ychord]=mpx_geometry;
     varargout{1}={VsxrTCVradius(zmag.data,xchord,ychord)};
-    error=0;
+    error_status=0;
 
   %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   case 'IOH'
@@ -1294,7 +1291,7 @@ switch TCVkeywrdcase{index}
     end
     trace.name=[num2str(shot) ';' nodenameeff{1} ',' nodenameeff{2}];
     mdsclose;
-    error=0;
+    error_status=0;
     
   %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   case 'vloop'
@@ -1313,7 +1310,7 @@ switch TCVkeywrdcase{index}
     end
     trace.name=[num2str(shot) ';' nodenameeff{1} ',' nodenameeff{2}];
     mdsclose;
-    error=0;
+    error_status=0;
     
   %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   case 'pgyro'
@@ -1332,7 +1329,7 @@ switch TCVkeywrdcase{index}
     end
     trace.name=[num2str(shot) ';' nodenameeff];
     mdsclose;
-    error=0;
+    error_status=0;
     
   %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   case 'jtor'
@@ -1351,7 +1348,7 @@ switch TCVkeywrdcase{index}
     end
     trace.name=[num2str(shot) ';' nodenameeff];
     mdsclose;
-    error=0;
+    error_status=0;
     
   %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   case {'neft:trial','teft:trial','neftav:trial','teftav:trial'}
@@ -1373,7 +1370,7 @@ switch TCVkeywrdcase{index}
     end
     trace.name=[num2str(shot) ' ; ' nodenameeff{:} ' ; trialindx=' num2str(trialindx) ];
     mdsclose;
-    error=0;
+    error_status=0;
     
   %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  case {'vi_tor', 'vi_torfit', 'vi_pol', 'vi_polfit', 'Ti', 'Tifit', 'ni', 'nifit', 'zeffcxrs', 'zeffcxrsfit'}
@@ -1416,11 +1413,11 @@ switch TCVkeywrdcase{index}
       trace.std_t = [];
     end
     mdsclose;
-    error=0;
+    error_status=0;
     
   %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   otherwise
-    % eval(['!mailto_Andrea ''from loadTCVdata, data_request_eff= ' data_request_eff ''''])
-    disp(['this data_request_eff' ' ' data_request_eff ' ' 'not yet programmed in loadTCVdata, ask Andrea.Scarabosio@epfl.ch']);
+    % eval(['!mailto_Andrea ''from loadTCVdata, data_type_eff= ' data_type_eff ''''])
+    disp(['this data_type_eff' ' ' data_type_eff ' ' 'not yet programmed in loadTCVdata, ask Andrea.Scarabosio@epfl.ch']);
 
 end
diff --git a/crpptbx_new/TCV/tcv_requests_mapping.m b/crpptbx_new/TCV/tcv_requests_mapping.m
new file mode 100644
index 0000000000000000000000000000000000000000..f2e3c7e1d5ac05731bc1dac90dfd21e70bc7ecb1
--- /dev/null
+++ b/crpptbx_new/TCV/tcv_requests_mapping.m
@@ -0,0 +1,169 @@
+function mapping = tcv_requests_mapping(data_request)
+
+% Defaults
+mapping = struct(...
+    'label', '', ...
+    'method', '', ...
+    'expression','', ...
+    'timedim', -1, ...     % dim which is the time, to copy in .t, the other dims are in .x (-1 means last dimension)
+    'new_timedim',0, ...  % if need to reshape data and dim orders to have timedim as new_timedim (shifting time to new_timedim)
+    'min', -inf, ...
+    'max', inf);
+
+if ~exist('data_request') || isempty(data_request)
+  return
+end
+
+% default label: data_request keyword itself
+mapping.label = data_request;
+
+% for TCV, following choices are set so far:
+% method = 'tdi' and then expression is the string within tdi (usual case when there is a direct link to an existing signal)
+%                with tdi, if expression cell array, call tdi(cell{1},cell{2},...)
+% method = 'function', then expression is the funtion to call which should return the correct structure
+% method = 'switchcase', then there will be a specific case within gdat_tcv (usual case when not directly a signal)
+%
+% label is used for plotting
+switch lower(data_request)
+ case 'b0'
+  mapping.label = 'B_0';
+  mapping.method = 'switchcase';
+  mapping.expression = '';
+ case 'betan'
+  mapping.label = '\beta_N';
+  mapping.method = 'switchcase';
+  mapping.expression = '';
+ case 'betap'
+  mapping.label = '\beta_p';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::beta_pol';
+ case 'cxrs'
+  mapping.label = 'cxrs';
+  mapping.method = 'switchcase';
+  mapping.expression = '';
+ case 'delta'
+  mapping.method = 'tdi';
+  mapping.expression = '\results::delta_edge';
+  mapping.method = 'function';
+  mapping.expression = ['tdi(''\results::q_psi'');'];
+ case 'delta_top'
+  mapping.label = 'delta\_top';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::delta_ed_top';
+ case 'delta_bottom'
+  mapping.label = 'delta\_bottom';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::delta_ed_bot';
+ case 'ece'
+  mapping.method = 'switchcase';
+  mapping.expression = '';
+ case 'eqdsk'
+  mapping.method = 'switchcase'; % could use function make_eqdsk directly?
+  mapping.expression = '';
+ case 'halpha'
+  mapping.label = 'Halpha';
+  mapping.method = 'tdi';
+  mapping.expression = '\base::pd:pd_011';
+ case 'ioh'
+  mapping.label = 'I ohmic transformer';
+  mapping.method = 'tdi';
+  mapping.expression = [{'\magnetics::ipol[*,$1]'} {'OH_001'}];
+ case 'ip'
+  mapping.label = 'Plasma current';
+  mapping.method = 'tdi';
+  mapping.expression = '\magnetics::iplasma:trapeze';
+ case 'kappa'
+  mapping.method = 'tdi';
+  mapping.expression = '\results::kappa_edge';
+ case 'mhd'
+  mapping.label = 'n=1,2, etc';
+  mapping.method = 'switchcase';
+  mapping.expression = '';
+ case 'ne'
+  mapping.method = 'switchcase';
+ case 'neint'
+  mapping.label = 'line integrated el. density';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::fir:lin_int_dens';
+ case 'nel'
+  mapping.label = 'line-averaged el. density';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::fir:n_average';
+ case 'nerho'
+  mapping.label = 'ne';
+  mapping.method = 'switchcase';
+ case 'neterho'
+  mapping.label = 'ne and Te';
+  mapping.method = 'switchcase';
+ case 'ni'
+  mapping.method = 'switchcase'; % especially since might have option fit, etc
+ case 'powers'
+  mapping.label = 'various powers';
+  mapping.method = 'switchcase';
+ case 'q0'
+  mapping.method = 'tdi';
+  mapping.expression = '\results::q_zero';
+ case 'q95'
+  mapping.method = 'tdi';
+  mapping.expression = '\results::q_95';
+ case 'qedge'
+  mapping.method = 'tdi';
+  mapping.expression = '\results::q_edge';
+ case 'qrho'
+  mapping.label = 'q';
+  mapping.method = 'switchcase';
+ case 'rgeom'
+  mapping.label = 'Rgeom';
+  mapping.method = 'switchcase';
+ case 'rhovol'
+  mapping.label = 'rhovol\_norm';
+  mapping.method = 'switchcase'; % from conf if exist otherwise computes it
+ case 'rmag'
+  mapping.label = 'R\_magaxis';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::r_axis';
+ case 'sxr'
+  mapping.method = 'switchcase';
+ case 'te'
+  mapping.label = 'Te';
+  mapping.method = 'switchcase';
+ case 'terho'
+  mapping.label = 'Te';
+  mapping.method = 'switchcase';
+ case 'ti'
+  mapping.label = 'Ti';
+  mapping.method = 'switchcase';
+ case 'transp'
+  mapping.label = 'transp output';
+  mapping.method = 'switchcase';
+ case 'vloop'
+  mapping.label = '';
+  mapping.method = 'tdi';
+  mapping.expression = '';
+ case 'vol'
+  mapping.label = 'Volume';
+  mapping.method = 'switchcase';
+  % mapping.expression = '\results::psitbx:vol'; (if exists for liuqe2 and 3 as well)
+ case 'zeff'
+  mapping.label = 'zeff from Ip-Ibs';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::ibs:z_eff';
+ case 'zgeom'
+  mapping.label = 'Zgeom';
+  mapping.method = 'switchcase';
+ case 'zmag'
+  mapping.label = 'Zmagaxis';
+  mapping.method = 'tdi';
+  mapping.expression = '\results::z_axis';
+% $$$  case ''
+% $$$   mapping.label = '';
+% $$$   mapping.method = 'tdi';
+% $$$   mapping.expression = '';
+ otherwise
+  mapping.label = data_request;
+  mapping.method = 'tdi'; % assume a full tracename is given, so just try with tdi (could check there are some ":", etc...)
+  mapping.expression = data_request;
+  
+end
+
+
diff --git a/crpptbx_new/gdat.m b/crpptbx_new/gdat.m
index 60ff6b67cada715bd493653eff83e655dfec8f1a..5ec4e3634ed2d7212e326585e3d33a68d0cce7ba 100644
--- a/crpptbx_new/gdat.m
+++ b/crpptbx_new/gdat.m
@@ -1,6 +1,6 @@
-function [gdat_data,gdat_params,varargout] = gdat(shot,data_request,varargin)
+function [gdat_data,gdat_params,error_status,varargout] = gdat(shot,data_request,varargin)
 %
-% function [gdat_data,gdat_params,varargout] = gdat(shot,data_request,varargin)
+% function [gdat_data,gdat_params,error_status,varargout] = gdat(shot,data_request,varargin)
 %
 % Aim: get data from a given machine using full path or keywords. 
 %      Keywords should be the same for different machines, otherwise add "_machinname" to the keyword if specific
@@ -32,7 +32,7 @@ function [gdat_data,gdat_params,varargout] = gdat(shot,data_request,varargin)
 % gdat_data.gdat_call : list of parameters provided in the gdat call (so can be reproduced)
 % gdat_data.shot: shot number
 % gdat_data.machine: machine providing the data
-% gdat_data.gdat_keyword: keyword for gdat if relevant
+% gdat_data.gdat_request: keyword for gdat if relevant
 % gdat_data.data_fullpath: full path to the data node if known and relevant, or expression, or relevant function called if relevant
 % gdat_data.gdat_params: copy gdat_params for completeness
 % gdat_data.xxx: any other relevant information
@@ -46,18 +46,25 @@ function [gdat_data,gdat_params,varargout] = gdat(shot,data_request,varargin)
 %    a3=gdat(48836,a2);  % gives input parameters as a structure, allows to call the same for many shots
 %    a4=gdat('opt1',123,'opt2',[1 2 3],'shot',48832,'data_request','Ip','opt3','aAdB'); % all in pairs
 %    a5=gdat(48836,'ip'); % standard call
-%    a6=gdat(48836,'ip','Opt1',123,'Doplot',1,'opt2','Abc'); % standard call with a few options (note all lowercase in output)
+%    a6=gdat(48836,'ip','Opt1',123,'Doplot',1,'opt2','Abc'); % standard call with a few options (all lowercase in output)
+
+
+%
+% Comments for local developer:
+% This gdat is just a "header routine" calling the gdat for the specific machine gdat_`machine`.m which can be called
+% directly, thus which should be able to treat the same type of input arguments
+%
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Prepare some variables, etc
 
 % for backward compatibility (with most recent simple call ala: gdat(shot,'data_request',doplot,machine) )
 % if nargin<=4 and >2 and 1st and 3rd are numeric, assume this is an old call and transform it to:
-% gdat(shot,'data_request','doplot',doplot','machine',machine) by adding at end of varargin, so will be taken
+% gdat(shot,'data_request','doplot',doplot','machine',machine)
 % and a warning
-varargin_eff = varargin;
 if nargin>2
-  if nargin>=3 && nargin<=4  && isnumeric(shot) && isnumeric(varagin{1})
+  varargin_eff = varargin;
+  if nargin>=3 && nargin<=4  && isnumeric(shot) && isnumeric(varargin{1})
     % assume old call: gdat(shot,'data_request',doplot[,machine])
     varargin_eff{1} = 'doplot';
     varargin_eff{end+1} = varargin{1};
@@ -68,9 +75,6 @@ if nargin>2
   end
 end
 
-% add paths to each machine which are in subdirectory of gdat and working
-gdatpaths
-
 % construct default parameters structure
 gdat_params.data_request = '';
 fusion_machine_defaultname=getenv('FUSION_MACHINE_DEFAULTNAME');
@@ -85,24 +89,36 @@ else
     default_machine = 'aug';
   end
 end
+machine_eff = default_machine;
+
+% do not treat inputs here but in subsequent gdat_machine.m function, however, need to extract machine name if provided:
+if nargin>=2 % need at least 2 inputs to have 'machine','aug' as arguments (to ask specific list of requests)
+  % in case start directly with pairs of options
+  if ischar(shot) && ischar(data_request)
+    machine_eff = data_request;
+  elseif isstruct(shot) && isfield(shot,'machine')
+    machine_eff = shot.machine;
+  elseif isstruct(data_request) && isfield(data_request,'machine')
+    machine_eff = data_request.machine;
+  else
+    imachine=[];
+    for i=1:length(varargin_eff)
+      if ischar(varargin_eff{i})
+        ii = strmatch(varargin_eff{i},'machine','exact');
+        if ~isempty(ii); imachine = i; end
+      end
+    end
+    if ~isempty(imachine) && length(varargin_eff)>=imachine+1 && ~isempty(varargin_eff{imachine+1})
+      machine_eff = varargin_eff{imachine+1};
+    end
+  end
+end
 
-gdat_params.machine=default_machine;
-gdat_params.doplot = 0;
-
-% construct list of keywords
-gdat_keywords= [{'kwd1'}, {'kwd2'}];
+% add paths to each machine which are in subdirectory of gdat and working
+% add only given machine directory using machine_eff...
+gdat_path = mfilename('fullpath');
+eval(['addpath ' gdat_path(1:end-4) upper(machine_eff)]);
 
-% construct default output structure
-gdat_data.t = [];
-gdat_data.data = [];
-gdat_data.dim = [];
-gdat_data.dimunits = [];
-gdat_data.error_bar = [];
-gdat_data.shot = [];
-gdat_data.machine = [];
-gdat_data.gdat_keyword = [];
-gdat_data.gdat_params = gdat_params;
-gdat_data.data_fullpath = [];
 % copy gdat present call:
 if nargin==0
   subcall=['gdat;'];
@@ -131,174 +147,35 @@ elseif nargin>=1
   % ... to continue
   subcall = [subcall ');'];
 end
-gdat_data.gdat_call = subcall;
-
-% Treat inputs:
-ivarargin_first_char = 3;
-data_request_eff = '';
-if nargin>=2 && ischar(data_request); data_request = lower(data_request); end
-
-% no inputs
-if nargin==0
-  % return defaults and list of keywords
-  gdat_data.gdat_keyword = gdat_keywords;
-
-  % add window with scrollable list of keywords (and probably small GUI to add shot number and choose data_request)
-  return
-end
-
-% treat 1st arg
-if nargin>=1
-  if isempty(shot)
-    % same as no inputs (later might mean asks for defaults of given data_request)
-    gdat_data.gdat_keyword = gdat_keywords;
-    return
-  end
-  if isnumeric(shot)
-    gdat_data.shot = shot;
-  elseif ischar(shot)
-    ivarargin_first_char = 1;
-  else
-    warning('type of 1st argument unexpected, should be numeric or char')
-    return
-  end
-  if nargin==1
-    % Only shot number given. If there is a default data_request set it and continue, otherwise return
-    gdat_data.gdat_keyword = gdat_keywords;
-    return
-  end
-end
-% 2nd input argument if not part of pairs
-if nargin>=2 && ivarargin_first_char~=1
-  if isempty(data_request)
-    gdat_data.gdat_keyword = gdat_keywords;
-    return
-  end
-  % 2nd arg can be a structure with all options except shot_number, or a string for the pathname or keyword, or the start of pairs string/value for the parameters
-  if isstruct(data_request)
-    if ~isfield(data_request,'data_request')
-      warning('expects field data_request in input parameters structure')
-      return
-    end
-    data_request.data_request = lower(data_request.data_request);
-    data_request_eff = data_request.data_request;
-    gdat_params = data_request;
-  else
-    % since data_request is char check from nb of args if it is data_request or a start of pairs
-    if mod(nargin-1,2)==0
-      ivarargin_first_char = 2;
-    else
-      ivarargin_first_char = 3;
-      data_request_eff = data_request;
-    end
-  end
-end
-
-if ~isstruct(data_request); gdat_params.data_request = data_request_eff; end
 
-% if start pairs from shot or data_request, shift varargin
-if ivarargin_first_char==1
-  varargin_eff{1} = shot;
-  varargin_eff{2} = data_request;
-  varargin_eff(3:nargin) = varargin(:);
-elseif ivarargin_first_char==2
-  varargin_eff{1} = data_request;
-  varargin_eff(2:nargin-1) = varargin(:);
-else
-  varargin_eff(1:nargin-2) = varargin(:);
-end
-
-% extract parameters from pairs of varargin:
-if (nargin>=ivarargin_first_char)
-  if mod(nargin-ivarargin_first_char+1,2)==0
-    for i=1:2:nargin-ivarargin_first_char+1
-      if ischar(varargin_eff{i})
-        % enforce lower case for any character driven input
-        if ischar(varargin_eff{i+1})
-          gdat_params.(lower(varargin_eff{i})) = lower(varargin_eff{i+1});
-        else
-          gdat_params.(lower(varargin_eff{i})) = varargin_eff{i+1};
-        end
-      else
-        warning(['input argument nb: ' num2str(i) ' is incorrect, expects a character string'])
-        return
-      end
-    end
+% Note: would need to check nargout to make call consistent, but to avoid this, each gdat_xxx should return at least an empty varargout: varargout{1}=cell(1);
+try
+  if nargin==0
+    eval(['[gdat_data,gdat_params,error_status,varargout] = gdat_' lower(machine_eff) ';']);
+  elseif nargin==1
+    eval(['[gdat_data,gdat_params,error_status,varargout] = gdat_' lower(machine_eff) '(shot);']);
+  elseif nargin==2  
+    eval(['[gdat_data,gdat_params,error_status,varargout] = gdat_' lower(machine_eff) '(shot,data_request);']);
   else
-    warning('number of input arguments incorrect, cannot make pairs of parameters')
-    return
+    eval(['[gdat_data,gdat_params,error_status,varargout] = gdat_' lower(machine_eff) '(shot,data_request,varargin_eff{:});']);
   end
-end
-data_request_eff = gdat_params.data_request; % in case was defined in pairs
-
-% special treatment if shot and data_request given within pairs
-if isfield(gdat_params,'shot')
-  shot = gdat_params.shot; % should use only gdat_params.shot but change shot to make sure
-  gdat_data.shot = gdat_params.shot;
-  gdat_params=rmfield(gdat_params,'shot');
-end
-if ~isfield(gdat_params,'data_request') || isempty(gdat_params.data_request)
-  warning('input for ''data_request'' missing from input arguments')
+catch
+  warning(['problems calling gdat_' lower(machine_eff)]);
   return
 end
 
-gdat_data.gdat_params = gdat_params;
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function subcall_string = subcall_all2str(varargin)
-% create a string from varargin allowing following types:
-%
-% char: varargin is just copied
-% numeric: if scalar use num2str, if 1 or 2-D array add relevant '[' and ']', else mark a string multi-D
-% structure: explode structure as field,value
-%
-
-% to be taken from above and include this call in above
+% copy subcall here so is last subnode
+gdat_data.gdat_call = [subcall ' % nargout = ' num2str(nargout)];
 
-if nargin==0
-  subcall_string = '';
-  return
+if ~isfield(gdat_data.gdat_params,'doplot')
+  gdat_data.gdat_params.doplot = 0;
 end
 
-subcall = '';
-for i_in=1:length(varargin)
-  var_to_treat = varargin{i_in};
-  if isstruct(var_to_treat)
-    % explode structure into 'childname',childvalues
-    param_names = fieldnames(var_to_treat);
-    for i=1:length(param_names)
-      subcall = [subcall ',''' param_names{i} ''''];
-      if ischar(var_to_treat.(param_names{i}))
-        subcall = [subcall ',''' var_to_treat.(param_names{i}) ''''];
-      elseif isnumeric(var_to_treat.(param_names{i}))
-        aa_values = var_to_treat.(param_names{i});
-        if prod(size(aa_values))~= length(aa_values)
-          % multi-D input, do not treat it yet
-          subcall = [subcall ',''multi-D input'''];
-        elseif length(aa_values) > 1
-          % array
-          subcall = [subcall ',[' num2str(reshape(aa_values,1,length(aa_values))) ']'];
-        else
-          subcall = [subcall ',' num2str(aa_values) ''];
-        end
-      else
-        % to treat extra cases
-      end
-    end
-  elseif isnumeric(var_to_treat)
-    if prod(size(var_to_treat))~= length(var_to_treat)
-      % multi-D input, do not treat it yet
-      subcall = [subcall ',''multi-D input'''];
-    elseif length(var_to_treat) > 1
-      % array
-      subcall = [subcall ',[' num2str(var_to_treat) ']'];
-    else
-      subcall = [subcall ',' num2str(var_to_treat) ''];
-    end
-  elseif ischar(var_to_treat)
-    subcall = [subcall ',''' var_to_treat ''''];
+if gdat_data.gdat_params.doplot
+  % plot gdat_data versus 1st dim by default, if nb_dims<=2, otherwise do not plot
+  if length(varargout)==0 || isempty(varargout{1})
+    varargout{1} = gdat_plot(gdat_data); % return handle to figure
+  else
+    varargout{end+1} = gdat_plot(gdat_data); % return handle to figure
   end
 end
-
-subcall_string = subcall;
diff --git a/crpptbx_new/gdat2.m b/crpptbx_new/gdat2.m
deleted file mode 100644
index 799af109ccc353254fe4115453f044c21c2fa2fd..0000000000000000000000000000000000000000
--- a/crpptbx_new/gdat2.m
+++ /dev/null
@@ -1,274 +0,0 @@
-function [gdat_data,gdat_params,varargout] = gdat2(shot,data_request,varargin)
-%
-% function [gdat_data,gdat_params,varargout] = gdat(shot,data_request,varargin)
-%
-% Aim: get data from a given machine using full path or keywords. 
-%      Keywords should be the same for different machines, otherwise add "_machinname" to the keyword if specific
-%      Keywords are and should be case independent (transformed in lower case in the function and outputs)
-%
-% If no inputs are provided, return the list of available keywords in gdat_data and default parameters gdat_params
-%
-% Inputs:
-%
-%    no inputs: return default parameters in a structure form in gdat_params
-%    shot: shot number
-%    data_request: keyword (like 'ip') or trace name or structure containing all parameters but shot number
-%    varargin{i},varargin{i+1},i=1:nargin-2: additional optional parameters given in pairs: param_name, param_value
-%                                            The optional parameters list might depend on the data_request
-%              examples of optional parameters:
-%                               'plot',1 (plot is set by default to 0)
-%                               'machine','TCV' (the default machine is the local machine)
-%
-%
-% Outputs:
-%
-% gdat_data: structure containing the data, the time trace if known and other useful information
-% gdat_data.t : time trace
-% gdat_data.data: requested data values
-% gdat_data.dim : values of the various coordinates related to the dimensions of .data(:,:,...)
-%                     note that one of the dim is the time, replicated in .t for clarity
-% gdat_data.dimunits : units of the various dimensions, 'dimensionless' if dimensionless
-% gdat_data.error_bar : if provided
-% gdat_data.gdat_call : list of parameters provided in the gdat call (so can be reproduced)
-% gdat_data.shot: shot number
-% gdat_data.machine: machine providing the data
-% gdat_data.gdat_keyword: keyword for gdat if relevant
-% gdat_data.data_fullpath: full path to the data node if known and relevant, or expression, or relevant function called if relevant
-% gdat_data.gdat_params: copy gdat_params for completeness
-% gdat_data.xxx: any other relevant information
-%
-%
-% Examples:
-% (should add working examples for various machines (provides working shot numbers for each machine...))
-% 
-%    [a1,a2]=gdat;
-%    a2.data_request = 'Ip';
-%    a3=gdat(48836,a2);  % gives input parameters as a structure, allows to call the same for many shots
-%    a4=gdat('opt1',123,'opt2',[1 2 3],'shot',48832,'data_request','Ip','opt3','aAdB'); % all in pairs
-%    a5=gdat(48836,'ip'); % standard call
-%    a6=gdat(48836,'ip','Opt1',123,'Doplot',1,'opt2','Abc'); % standard call with a few options (note all lowercase in output)
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Prepare some variables, etc
-
-% add paths to each machine which are in subdirectory of gdat and working
-gdatpaths
-
-% construct default parameters structure
-gdat_params.data_request = '';
-gdat_params.machine=lower('TCV'); % to insert default machine
-gdat_params.doplot = 0;
-
-% construct list of keywords
-gdat_keywords= [{'kwd1'}, {'kwd2'}];
-
-% construct default output structure
-gdat_data.t = [];
-gdat_data.data = [];
-gdat_data.dim = [];
-gdat_data.dimunits = [];
-gdat_data.error_bar = [];
-gdat_data.shot = [];
-gdat_data.machine = [];
-gdat_data.gdat_keyword = [];
-gdat_data.gdat_params = gdat_params;
-gdat_data.data_fullpath = [];
-% copy gdat present call:
-if nargin==0
-  subcall=['gdat;'];
-elseif nargin>=1
-  if isnumeric(shot)
-    subcall=['gdat(' num2str(shot) ];
-  elseif ischar(shot)
-    subcall=['gdat(' shot ];
-  else
-    warning('type of 1st argument unexpected, should be numeric or char')
-    gdat_data.gdat_call = [];
-    return
-  end
-  if nargin>=2
-    if isempty(data_request)
-      subcall = [subcall ',[]'];
-    else
-      substring = subcall_all2str(data_request);
-      subcall = [subcall substring];
-    end
-    if nargin>=3
-      substring = subcall_all2str(varargin{:});
-      subcall = [subcall substring];
-    end
-  end
-  % ... to continue
-  subcall = [subcall ');'];
-end
-gdat_data.gdat_call = subcall;
-
-% Treat inputs:
-ivarargin_first_char = 3;
-data_request_eff = '';
-if nargin>=2 && ischar(data_request); data_request = lower(data_request); end
-
-% no inputs
-if nargin==0
-  % return defaults and list of keywords
-  gdat_data.gdat_keyword = gdat_keywords;
-
-  % add window with scrollable list of keywords (and probably small GUI to add shot number and choose data_request)
-  return
-end
-
-% treat 1st arg
-if nargin>=1
-  if isempty(shot)
-    % same as no inputs (later might mean asks for defaults of given data_request)
-    gdat_data.gdat_keyword = gdat_keywords;
-    return
-  end
-  if isnumeric(shot)
-    gdat_data.shot = shot;
-  elseif ischar(shot)
-    ivarargin_first_char = 1;
-  else
-    warning('type of 1st argument unexpected, should be numeric or char')
-    return
-  end
-  if nargin==1
-    % Only shot number given. If there is a default data_request set it and continue, otherwise return
-    gdat_data.gdat_keyword = gdat_keywords;
-    return
-  end
-end
-% 2nd input argument if not part of pairs
-if nargin>=2 && ivarargin_first_char~=1
-  if isempty(data_request)
-    gdat_data.gdat_keyword = gdat_keywords;
-    return
-  end
-  % 2nd arg can be a structure with all options except shot_number, or a string for the pathname or keyword, or the start of pairs string/value for the parameters
-  if isstruct(data_request)
-    if ~isfield(data_request,'data_request')
-      warning('expects field data_request in input parameters structure')
-      return
-    end
-    data_request.data_request = lower(data_request.data_request);
-    data_request_eff = data_request.data_request;
-    gdat_params = data_request;
-  else
-    % since data_request is char check from nb of args if it is data_request or a start of pairs
-    if mod(nargin-1,2)==0
-      ivarargin_first_char = 2;
-    else
-      ivarargin_first_char = 3;
-      data_request_eff = data_request;
-    end
-  end
-end
-
-if ~isstruct(data_request); gdat_params.data_request = data_request_eff; end
-
-% if start pairs from shot or data_request, shift varargin
-if ivarargin_first_char==1
-  varargin_eff{1} = shot;
-  varargin_eff{2} = data_request;
-  varargin_eff(3:nargin) = varargin(:);
-elseif ivarargin_first_char==2
-  varargin_eff{1} = data_request;
-  varargin_eff(2:nargin-1) = varargin(:);
-else
-  varargin_eff(1:nargin-2) = varargin(:);
-end
-
-% extract parameters from pairs of varargin:
-if (nargin>=ivarargin_first_char)
-  if mod(nargin-ivarargin_first_char+1,2)==0
-    for i=1:2:nargin-ivarargin_first_char+1
-      if ischar(varargin_eff{i})
-        % enforce lower case for any character driven input
-        if ischar(varargin_eff{i+1})
-          gdat_params.(lower(varargin_eff{i})) = lower(varargin_eff{i+1});
-        else
-          gdat_params.(lower(varargin_eff{i})) = varargin_eff{i+1};
-        end
-      else
-        warning(['input argument nb: ' num2str(i) ' is incorrect, expects a character string'])
-        return
-      end
-    end
-  else
-    warning('number of input arguments incorrect, cannot make pairs of parameters')
-    return
-  end
-end
-data_request_eff = gdat_params.data_request; % in case was defined in pairs
-
-% special treatment if shot and data_request given within pairs
-if isfield(gdat_params,'shot')
-  shot = gdat_params.shot; % should use only gdat_params.shot but change shot to make sure
-  gdat_data.shot = gdat_params.shot;
-  gdat_params=rmfield(gdat_params,'shot');
-end
-if ~isfield(gdat_params,'data_request') || isempty(gdat_params.data_request)
-  warning('input for ''data_request'' missing from input arguments')
-  return
-end
-
-gdat_data.gdat_params = gdat_params;
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function subcall_string = subcall_all2str(varargin)
-% create a string from varargin allowing following types:
-%
-% char: varargin is just copied
-% numeric: if scalar use num2str, if 1 or 2-D array add relevant '[' and ']', else mark a string multi-D
-% structure: explode structure as field,value
-%
-
-% to be taken from above and include this call in above
-
-if nargin==0
-  subcall_string = '';
-  return
-end
-
-subcall = '';
-for i_in=1:length(varargin)
-  var_to_treat = varargin{i_in};
-  if isstruct(var_to_treat)
-    % explode structure into 'childname',childvalues
-    param_names = fieldnames(var_to_treat);
-    for i=1:length(param_names)
-      subcall = [subcall ',''' param_names{i} ''''];
-      if ischar(var_to_treat.(param_names{i}))
-        subcall = [subcall ',''' var_to_treat.(param_names{i}) ''''];
-      elseif isnumeric(var_to_treat.(param_names{i}))
-        aa_values = var_to_treat.(param_names{i});
-        if prod(size(aa_values))~= length(aa_values)
-          % multi-D input, do not treat it yet
-          subcall = [subcall ',''multi-D input'''];
-        elseif length(aa_values) > 1
-          % array
-          subcall = [subcall ',[' num2str(aa_values) ']'];
-        else
-          subcall = [subcall ',' num2str(aa_values) ''];
-        end
-      else
-        % to treat extra cases
-      end
-    end
-  elseif isnumeric(var_to_treat)
-    if prod(size(var_to_treat))~= length(var_to_treat)
-      % multi-D input, do not treat it yet
-      subcall = [subcall ',''multi-D input'''];
-    elseif length(var_to_treat) > 1
-      % array
-      subcall = [subcall ',[' num2str(var_to_treat) ']'];
-    else
-      subcall = [subcall ',' num2str(var_to_treat) ''];
-    end
-  elseif ischar(var_to_treat)
-    subcall = [subcall ',''' var_to_treat ''''];
-  end
-end
-
-subcall_string = subcall;
diff --git a/crpptbx_new/gdat_data_request_names.xlsx b/crpptbx_new/gdat_data_request_names.xlsx
new file mode 100644
index 0000000000000000000000000000000000000000..419bf48dcfa4eec850ba8aefc48338caf2044112
Binary files /dev/null and b/crpptbx_new/gdat_data_request_names.xlsx differ
diff --git a/crpptbx_new/gdat_plot.m b/crpptbx_new/gdat_plot.m
new file mode 100644
index 0000000000000000000000000000000000000000..67e315b12f2e1d955883debe1b29483489b32abc
--- /dev/null
+++ b/crpptbx_new/gdat_plot.m
@@ -0,0 +1,12 @@
+function [fighandle]=gdat_plot(gdat_data);
+%
+%
+
+fighandle = figure;
+if prod(isfield(gdat_data,{'data','t'})) && ~isempty(gdat_data.data) && ~isempty(gdat_data.t)
+  plot(gdat_data.t,gdat_data.data);
+  title([gdat_data.gdat_params.machine ' #' num2str(gdat_data.shot)]);
+  ylabel(gdat_data.label);
+else
+  disp('cannot plot gdat_data, has empty data or t field')
+end
diff --git a/crpptbx_new/gdat_prev.m b/crpptbx_new/gdat_prev.m
deleted file mode 100644
index edafb8d16e00b06c8ea4d3cb050148329ed2193a..0000000000000000000000000000000000000000
--- a/crpptbx_new/gdat_prev.m
+++ /dev/null
@@ -1,279 +0,0 @@
-function [gdat_data,gdat_params,varargout] = gdat(shot,data_request,varargin)
-%
-% function [gdat_data,gdat_params,varargout] = gdat(shot,data_request,varargin)
-%
-% Aim: get data from a given machine using full path or keywords. 
-%      Keywords should be the same for different machines, otherwise add "_machinname" to the keyword if specific
-%      Keywords are and should be case independent (transformed in lower case in the function and outputs)
-%
-% If no inputs are provided, return the list of available keywords in gdat_data and default parameters gdat_params
-%
-% Inputs:
-%
-%    no inputs: return default parameters in a structure form in gdat_params
-%    shot: shot number
-%    data_request: keyword (like 'ip') or trace name or structure containing all parameters but shot number
-%    varargin{i},varargin{i+1},i=1:nargin-2: additional optional parameters given in pairs: param_name, param_value
-%                                            The optional parameters list might depend on the data_request
-%              examples of optional parameters:
-%                               'plot',1 (plot is set by default to 0)
-%                               'machine','TCV' (the default machine is the local machine)
-%
-%
-% Outputs:
-%
-% gdat_data: structure containing the data, the time trace if known and other useful information
-% gdat_data.t : time trace
-% gdat_data.data: requested data values
-% gdat_data.dim : values of the various coordinates related to the dimensions of .data(:,:,...)
-%                     note that one of the dim is the time, replicated in .t for clarity
-% gdat_data.dimunits : units of the various dimensions, 'dimensionless' if dimensionless
-% gdat_data.error_bar : if provided
-% gdat_data.gdat_call : list of parameters provided in the gdat call (so can be reproduced)
-% gdat_data.shot: shot number
-% gdat_data.machine: machine providing the data
-% gdat_data.gdat_keyword: keyword for gdat if relevant
-% gdat_data.data_fullpath: full path to the data node if known and relevant, or expression, or relevant function called if relevant
-% gdat_data.gdat_params: copy gdat_params for completeness
-% gdat_data.xxx: any other relevant information
-%
-%
-% Examples:
-% (should add working examples for various machines (provides working shot numbers for each machine...))
-% 
-%    [a1,a2]=gdat;
-%    a2.data_request = 'Ip';
-%    a3=gdat(48836,a2);  % gives input parameters as a structure, allows to call the same for many shots
-%    a4=gdat('opt1',123,'opt2',[1 2 3],'shot',48832,'data_request','Ip','opt3','aAdB'); % all in pairs
-%    a5=gdat(48836,'ip'); % standard call
-%    a6=gdat(48836,'ip','Opt1',123,'Doplot',1,'opt2','Abc'); % standard call with a few options (note all lowercase in output)
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Prepare some variables, etc
-
-% add paths to each machine which are in subdirectory of gdat and working
-gdatpaths
-
-% construct default parameters structure
-gdat_params.data_request = '';
-gdat_params.machine=lower('TCV'); % to insert default machine
-gdat_params.doplot = 0;
-
-% construct list of keywords
-gdat_keywords= [{'kwd1'}, {'kwd2'}];
-
-% construct default output structure
-gdat_data.t = [];
-gdat_data.data = [];
-gdat_data.dim = [];
-gdat_data.dimunits = [];
-gdat_data.error_bar = [];
-gdat_data.shot = [];
-gdat_data.machine = [];
-gdat_data.gdat_keyword = [];
-gdat_data.gdat_params = gdat_params;
-gdat_data.data_fullpath = [];
-% copy gdat present call:
-if nargin==0
-  subcall=['gdat;'];
-elseif nargin>=1
-  if isnumeric(shot)
-    subcall=['gdat(' num2str(shot) ];
-  elseif ischar(shot)
-    subcall=['gdat(' shot ];
-  else
-    warning('type of 1st argument unexpected, should be numeric or char')
-    gdat_data.gdat_call = [];
-    return
-  end
-  if nargin>=2
-    if isempty(data_request)
-      subcall = [subcall ',[]'];
-    else
-      substring = subcall_all2str(data_request);
-      subcall = [subcall ',' substring];
-      
-    end
-    if nargin>=3
-      for i=1:nargin-2
-        if ischar(varargin{i})
-          subcall = [subcall ',''' varargin{i} ''''];
-        elseif isnumeric(varargin{i})
-          aa_values = varargin{i};
-          if prod(size(aa_values))~= length(aa_values)
-            % multi-D input, do not treat it yet
-            subcall = [subcall ',''multi-D input'''];
-          elseif length(aa_values) > 1
-            % array
-            subcall = [subcall ',[' num2str(aa_values) ']'];
-          else
-            subcall = [subcall ',' num2str(aa_values) ''];
-          end
-        else
-          % treat extra cases
-        end
-      end
-    end
-  end
-  % ... to continue
-  subcall = [subcall ');'];
-end
-gdat_data.gdat_call = subcall;
-
-% Treat inputs:
-ivarargin_first_char = 3;
-data_request_eff = '';
-if nargin>=2 && ischar(data_request); data_request = lower(data_request); end
-
-% no inputs
-if nargin==0
-  % return defaults and list of keywords
-  gdat_data.gdat_keyword = gdat_keywords;
-
-  % add window with scrollable list of keywords (and probably small GUI to add shot number and choose data_request)
-  return
-end
-
-% treat 1st arg
-if nargin>=1
-  if isempty(shot)
-    % same as no inputs (later might mean asks for defaults of given data_request)
-    gdat_data.gdat_keyword = gdat_keywords;
-    return
-  end
-  if isnumeric(shot)
-    gdat_data.shot = shot;
-  elseif ischar(shot)
-    ivarargin_first_char = 1;
-  else
-    warning('type of 1st argument unexpected, should be numeric or char')
-    return
-  end
-  if nargin==1
-    % Only shot number given. If there is a default data_request set it and continue, otherwise return
-    gdat_data.gdat_keyword = gdat_keywords;
-    return
-  end
-end
-% 2nd input argument if not part of pairs
-if nargin>=2 && ivarargin_first_char~=1
-  if isempty(data_request)
-    gdat_data.gdat_keyword = gdat_keywords;
-    return
-  end
-  % 2nd arg can be a structure with all options except shot_number, or a string for the pathname or keyword, or the start of pairs string/value for the parameters
-  if isstruct(data_request)
-    if ~isfield(data_request,'data_request')
-      warning('expects field data_request in input parameters structure')
-      return
-    end
-    data_request.data_request = lower(data_request.data_request);
-    data_request_eff = data_request.data_request;
-    gdat_params = data_request;
-  else
-    % since data_request is char check from nb of args if it is data_request or a start of pairs
-    if mod(nargin-1,2)==0
-      ivarargin_first_char = 2;
-    else
-      ivarargin_first_char = 3;
-      data_request_eff = data_request;
-    end
-  end
-end
-
-if ~isstruct(data_request); gdat_params.data_request = data_request_eff; end
-
-% if start pairs from shot or data_request, shift varargin
-if ivarargin_first_char==1
-  varargin_eff{1} = shot;
-  varargin_eff{2} = data_request;
-  varargin_eff(3:nargin) = varargin(:);
-elseif ivarargin_first_char==2
-  varargin_eff{1} = data_request;
-  varargin_eff(2:nargin-1) = varargin(:);
-else
-  varargin_eff(1:nargin-2) = varargin(:);
-end
-
-% extract parameters from pairs of varargin:
-if (nargin>=ivarargin_first_char)
-  if mod(nargin-ivarargin_first_char+1,2)==0
-    for i=1:2:nargin-ivarargin_first_char+1
-      if ischar(varargin_eff{i})
-        % enforce lower case for any character driven input
-        if ischar(varargin_eff{i+1})
-          gdat_params.(lower(varargin_eff{i})) = lower(varargin_eff{i+1});
-        else
-          gdat_params.(lower(varargin_eff{i})) = varargin_eff{i+1};
-        end
-      else
-        warning(['input argument nb: ' num2str(i) ' is incorrect, expects a character string'])
-        return
-      end
-    end
-  else
-    warning('number of input arguments incorrect, cannot make pairs of parameters')
-    return
-  end
-end
-data_request_eff = gdat_params.data_request; % in case was defined in pairs
-
-% special treatment if shot and data_request given within pairs
-if isfield(gdat_params,'shot')
-  shot = gdat_params.shot; % should use only gdat_params.shot but change shot to make sure
-  gdat_data.shot = gdat_params.shot;
-  gdat_params=rmfield(gdat_params,'shot');
-end
-if ~isfield(gdat_params,'data_request') || isempty(gdat_params.data_request)
-  warning('input for ''data_request'' missing from input arguments')
-  return
-end
-
-gdat_data.gdat_params = gdat_params;
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function subcall_string = subcall_all2str(varargin)
-% create a string from varargin allowing following types:
-%
-% char: varargin is just copied
-% numeric: if scalar use num2str, if 1 or 2-D array add relevant '[' and ']', else mark a string multi-D
-% structure: explode structure as field,value
-%
-
-% to be taken from above and include this call in above
-
-if nargin==0
-  subcall_string = '';
-  return
-end
-
-subcall = '';
-for i_in=1:length(varargin)
-  var_to_treat = varargin{i_in};
-  if isstruct(var_to_treat)
-    % explode structure into 'childname',childvalues
-    param_names = fieldnames(var_to_treat);
-    for i=1:length(param_names)
-      subcall = [subcall ',''' param_names{i} ''''];
-      if ischar(var_to_treat.(param_names{i}))
-        subcall = [subcall ',''' var_to_treat.(param_names{i}) ''''];
-      elseif isnumeric(var_to_treat.(param_names{i}))
-        aa_values = var_to_treat.(param_names{i});
-        if prod(size(aa_values))~= length(aa_values)
-          % multi-D input, do not treat it yet
-          subcall = [subcall ',''multi-D input'''];
-        elseif length(aa_values) > 1
-          % array
-          subcall = [subcall ',[' num2str(aa_values) ']'];
-        else
-          subcall = [subcall ',' num2str(aa_values) ''];
-        end
-      else
-        % to treat extra cases
-      end
-    end
-  elseif ischar(var_to_treat)
-    subcall = [subcall ',''' var_to_treat ''''];
-  end
-end
diff --git a/crpptbx_new/gdatpaths.m b/crpptbx_new/gdatpaths.m
deleted file mode 100644
index ca08087fb9f60d66389e30f166323c97bf3d47d4..0000000000000000000000000000000000000000
--- a/crpptbx_new/gdatpaths.m
+++ /dev/null
@@ -1,16 +0,0 @@
-%
-% add paths for gdat directory
-%
-% assumes gdat already available
-%
-a=which('gdat');
-ii=findstr('/',a);
-a=a(1:ii(end));
-
-machines=[{'JET'} {'TCV'} {'AUG'} {'D3D'}];
-machines=[{'JET'} {'TCV'} {'AUG'} {'KSTAR'}];
-
-for i=1:length(machines)
-  addpath([a machines{i}])
-end
-
diff --git a/crpptbx_new/get_data_request_names.m b/crpptbx_new/get_data_request_names.m
new file mode 100644
index 0000000000000000000000000000000000000000..5aaf8099e7a2567e4f14a3d95874cd29bc1f6ee7
--- /dev/null
+++ b/crpptbx_new/get_data_request_names.m
@@ -0,0 +1,45 @@
+function [data_request_names] = get_data_request_names;
+%
+% get list of presently available data_request names grouped and with description
+%
+% at this stage using first 3 columns of file gdat_data_request_names.xlsx
+%
+
+expected_machines = [{'aug'}, {'jet'}, {'tcv'}]; % substrutures created for these at this stage (all means all of these)
+for j=1:length(expected_machines)
+  data_request_names.(expected_machines{j}) = [];
+end
+
+filename='gdat_data_request_names.xlsx';
+
+[numeric_struct,text_struct,raw_struct]=xlsread(filename);
+
+% use text structure
+[n1,n2]=size(text_struct);
+if prod(n1,n2)==0 || n2<3
+  disp(['problems with file ' filename])
+  return
+end
+
+% assume 1st column has data_request names with the headline "data_request"
+ij=find(strcmp('data_request',strtrim(lower(text_struct{1,1})))==1);
+if isempty(ij) || ij+1>=n1
+  disp(['problems with file ' filename '; ''data_request'' not found in 1st column or no extra lines'])
+  return
+end
+
+ij_1strow = ij+1;
+for iline=ij+1:n1
+  if isempty(text_struct{iline,1}); keyboard; end
+  % extra machine
+  validity = text_struct{iline,3};
+  if ~isempty(regexpi(validity,'all'))
+    data_request_names.all.(strtrim(lower(text_struct{iline,1}))).description = strtrim(text_struct{iline,2});
+  else
+    for j=1:length(expected_machines)
+      if ~isempty(regexpi(validity,expected_machines{j}))
+        data_request_names.(lower(expected_machines{j})).(strtrim(lower(text_struct{iline,1}))).description = strtrim(text_struct{iline,2});
+      end
+    end
+  end
+end
diff --git a/crpptbx_new/subcall_all2str.m b/crpptbx_new/subcall_all2str.m
new file mode 100644
index 0000000000000000000000000000000000000000..a87eff3a3767bb855d26d6f42cd6d92ff5524838
--- /dev/null
+++ b/crpptbx_new/subcall_all2str.m
@@ -0,0 +1,59 @@
+function subcall_string = subcall_all2str(varargin)
+%
+% subcall_string = subcall_all2str(varargin)
+%
+% create a string from varargin allowing following types:
+%
+% char: varargin is just copied
+% numeric: if scalar use num2str, if 1 or 2-D array add relevant '[' and ']', else mark a string multi-D
+% structure: explode structure as field,value
+%
+
+% to be taken from above and include this call in above
+
+if nargin==0
+  subcall_string = '';
+  return
+end
+
+subcall = '';
+for i_in=1:length(varargin)
+  var_to_treat = varargin{i_in};
+  if isstruct(var_to_treat)
+    % explode structure into 'childname',childvalues
+    param_names = fieldnames(var_to_treat);
+    for i=1:length(param_names)
+      subcall = [subcall ',''' param_names{i} ''''];
+      if ischar(var_to_treat.(param_names{i}))
+        subcall = [subcall ',''' var_to_treat.(param_names{i}) ''''];
+      elseif isnumeric(var_to_treat.(param_names{i}))
+        aa_values = var_to_treat.(param_names{i});
+        if prod(size(aa_values))~= length(aa_values)
+          % multi-D input, do not treat it yet
+          subcall = [subcall ',''multi-D input'''];
+        elseif length(aa_values) > 1
+          % array
+          subcall = [subcall ',[' num2str(reshape(aa_values,1,length(aa_values))) ']'];
+        else
+          subcall = [subcall ',' num2str(aa_values) ''];
+        end
+      else
+        % to treat extra cases
+      end
+    end
+  elseif isnumeric(var_to_treat)
+    if prod(size(var_to_treat))~= length(var_to_treat)
+      % multi-D input, do not treat it yet
+      subcall = [subcall ',''multi-D input'''];
+    elseif length(var_to_treat) > 1
+      % array
+      subcall = [subcall ',[' num2str(var_to_treat) ']'];
+    else
+      subcall = [subcall ',' num2str(var_to_treat) ''];
+    end
+  elseif ischar(var_to_treat)
+    subcall = [subcall ',''' var_to_treat ''''];
+  end
+end
+
+subcall_string = subcall;