diff --git a/matlab/TCV/CXRS_get_profiles.m b/matlab/TCV/CXRS_get_profiles.m
index 28d637c1900b638f435c101798e37a965b179e35..a527043d09e0c1e0b86cb161c2626f3c129be92a 100644
--- a/matlab/TCV/CXRS_get_profiles.m
+++ b/matlab/TCV/CXRS_get_profiles.m
@@ -8,14 +8,14 @@ function cxrs_profiles = CXRS_get_profiles(varargin)
 % Inputs:   {1} shot  - TCV shot number
 %           or  data  - structure from CXRS data analysis
 %           {2} sys   - cxrs system(s) LFS, HFS, ALL or 1,2,0 (default ALL)
-%           {3} time  - time, {a} [tmin tmax], 
+%           {3} time  - time, {a} [tmin tmax],
 %                             {b} [tmin:dt:tmax],   [Tmin(i) Tmax(i)]=[t(i) t(i+1)];
-%                             {c} -[tmin(1) tmax(1) ... tmin(end) tmax(end)]) - direct specification of [Tmin(i) Tmax(i)]=abs([t(i*2-1) t(i*2)]);  
+%                             {c} -[tmin(1) tmax(1) ... tmin(end) tmax(end)]) - direct specification of [Tmin(i) Tmax(i)]=abs([t(i*2-1) t(i*2)]);
 %                                  default [] - all times for first system in sys
 %           {4} param - parameters strucrure, useful fields:
 %                      param.k_plot - 1 (default) plot results, 0 disable graphics, -1 plot in new figures, <=-2 plot on the top of existing figure (hold on)
 %                      param.prof.all - structire with parameters for interpos (see help interpos) used if corresponding filelds in param.prof.(Ti,vi,nc,zeff) are empty
-%                      param.prof.all.xout - rho for proffit, if empty variable on time according to rho_min rho_max of CXRS measurement 
+%                      param.prof.all.xout - rho for proffit, if empty variable on time according to rho_min rho_max of CXRS measurement
 % Output:
 %         OK:  1 -OK, or error index
 %      argin:  cell of input arguments
@@ -26,25 +26,25 @@ function cxrs_profiles = CXRS_get_profiles(varargin)
 %       data:  cxrs data from CXRS_load_MDS(shot,isys,'result',[],...)
 %        exp:  experimental data for Ti, vTor, vPol, nC, Zeff structures with x,dx,y,dy,t,dt,sys
 %         Ti, vTor, vPol, nC, Zeff - cells with proffit data from CXRS_fit_profies.m function
-%    proffit: proffit data Ti(eV), vTor(km/sec), vPol(km/sec), nC(m^{-3}), Zeff all (time x rho) with rho(time x rho) - (normalized poloidal flux)^0.5, 
+%    proffit: proffit data Ti(eV), vTor(km/sec), vPol(km/sec), nC(m^{-3}), Zeff all (time x rho) with rho(time x rho) - (normalized poloidal flux)^0.5,
 %
 %
 %   See also: CXRS_save_profiles  - save cxrs_profiles in MDS
 %             CXRS_calc_automatic - automatic CXRS data analysis
 %             CXRS_save_MDS       - save CXRS data
 % Examples: shot=42422; cxrs_profiles = CXRS_get_profiles(shot);                                                      % standard run
-%           cxrs_profiles = CXRS_get_profiles; param=cxrs_profiles.param; param.prof.all.xout=linspace(0,1.1,101); 
+%           cxrs_profiles = CXRS_get_profiles; param=cxrs_profiles.param; param.prof.all.xout=linspace(0,1.1,101);
 %                                              cxrs_profiles = CXRS_get_profiles(shot,[],[],param);                   % define rho grid
 %           mdsopen(shot); tdiTS=tdi('\results::thomson.profiles.auto:te'); mdsclose;                                 % get TS times
-%                                              dTimes=0.05;                                                           % max TS/CXRS time difference (50/2 ms) 
+%                                              dTimes=0.05;                                                           % max TS/CXRS time difference (50/2 ms)
 %                                              Times(1:2:length(tdiTS.dim{1})*2)=tdiTS.dim{1}'-dTimes/2;
-%                                              Times(2:2:length(tdiTS.dim{1})*2)=tdiTS.dim{1}'+dTimes/2; 
-%                                              cxrs_profiles = CXRS_get_profiles; param=cxrs_profiles.param; param.prof.all.xout=linspace(0,1.1,101); 
+%                                              Times(2:2:length(tdiTS.dim{1})*2)=tdiTS.dim{1}'+dTimes/2;
+%                                              cxrs_profiles = CXRS_get_profiles; param=cxrs_profiles.param; param.prof.all.xout=linspace(0,1.1,101);
 %                                              cxrs_profiles = CXRS_get_profiles(shot,[],-Times,param);               % gives CXRS profiles at TS times 101 rho points in [0 1.1]
 %                                              cxrs_profiles = CXRS_get_profiles; param=cxrs_profiles.param; param.prof.all.xout=tdiTS.dim{2}';
 %                                              param.k_plot=0;                                                        % without plot for profiles
 %                                              cxrs_profiles = CXRS_get_profiles(shot,[],-Times,param);               % gives CXRS profiles at TS times and rho
-%           param.prof.all.xout=[]; param.prof.Ti.taus=1.e-5; param.prof.vi.taus=5.e-5; 
+%           param.prof.all.xout=[]; param.prof.Ti.taus=1.e-5; param.prof.vi.taus=5.e-5;
 %                                              cxrs_profiles = CXRS_get_profiles(shot,[],[],param);                   % define taus for interpos for Ti and vi
 %           plot profiles from LFS,VER&HFS systems on the same plots by different colors
 %           cxrs_profiles = CXRS_get_profiles; param=cxrs_profiles.param; param.prof.all.xout=linspace(0,1.1,101);
@@ -69,12 +69,12 @@ elseif isa(inparg{1},'struct'), % data structure from CXRS data analysis
     data=inparg{1};
     if ~isfield(data,'shot'), data_OK=0; elseif ~isfield(data,'calc'), data_OK=0; elseif ~isfield(data.calc,'Ti'), data_OK=0; else data_OK=1; end
     if data_OK, k_load=0; shot=data.shot; inparg{2}=data.system; else, cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=0; return; end
-else, 
-    cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=-9998; return; 
+else,
+    cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=-9998; return;
 end
-if isempty(inparg{2}), 
+if isempty(inparg{2}),
    sys=0;
-elseif isa(inparg{2},'char'), 
+elseif isa(inparg{2},'char'),
    switch upper(inparg{2});
    case ('ALL'),
       sys=0;
@@ -89,27 +89,27 @@ elseif isa(inparg{2},'char'),
    otherwise,
       cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=-9999; return;
    end
-elseif isa(inparg{2},'numeric'), 
-   if ((inparg{2} >= -1)&(inparg{2} <= 4)), 
+elseif isa(inparg{2},'numeric'),
+   if ((inparg{2} >= -1)&(inparg{2} <= 4)),
       sys=inparg{2};
    else
-      cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=0; return; 
-   end  
-else, 
-   cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=0; return; 
+      cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=0; return;
+   end
+else,
+   cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=0; return;
 end
 if (sys(1)==0), sys=[1 2]; end % LFS & VER systems
 if (sys(1)==-1), sys=[1 2 3]; end % LFS & VER & HFS systems
 
-if ~isempty(inparg{3}), 
-  if (max(inparg{3}(1))<=0)&(length(inparg{3})>=2), 
+if ~isempty(inparg{3}),
+  if (max(inparg{3}(1))<=0)&(length(inparg{3})>=2),
      Time_min=abs(inparg{3}(1:2:end)); Time_max=abs(inparg{3}(2:2:end)); % [tmin(1) tmax(1) tmin(2) tmax(2) ... tmin(end) tmax(end)]
-  elseif (length(inparg{3})==1), 
+  elseif (length(inparg{3})==1),
      Time_min=abs(inparg{3})-0.05; Time_max=abs(inparg{3})+0.05;         % single time point
   else
      Time_min=abs(inparg{3}(1:end-1)); Time_max=abs(inparg{3}(2:end));   % tmax(i)=tmin(i-1)
   end
-else, 
+else,
   Time_min=[]; Time_max=[];
 end
 
@@ -123,8 +123,8 @@ param.plot.lnstyle = lnstyle;
 param.plot.typemk  = typemk;
 a.kopt = 23;                   % option for interpolation and extrapolation method, 23 - cubic spline interpolation, with tension=taus
 %a.xout = linspace(0,1.10,101); % output grid for interpos
-a.xout = []; 
-%a.taus = [];               
+a.xout = [];
+%a.taus = [];
 a.taus = 2.e-3 ;                % tension value for cubic spline interpolation
 %a.nbc  = [1  2 ];              % 0/1/2 - VALUE OF SECOND DERIVATIVE; 1-ST; FUNCTION AT XBCLFT
 a.nbc  = [1  0 ];               % 0/1/2 - VALUE OF SECOND DERIVATIVE; 1-ST; FUNCTION AT XBCLFT
@@ -156,7 +156,7 @@ if ~isempty(param.prof.all.xout),
   param.prof.vi.xout    = param.prof.all.xout;
   param.prof.nc.xout    = param.prof.all.xout;
   param.prof.zeff.xout  = param.prof.all.xout;
-end 
+end
 
 cxrs_profiles.argin=inparg;
 cxrs_profiles.shot   = shot;
@@ -165,9 +165,9 @@ cxrs_profiles.param  = param;
 cxrs_profiles.Times=(Time_min+Time_max)/2.;
 if nargin==0, cxrs_profiles.OK=0; return; end
 
-V.y = []; V.dy = []; V.x=[]; V.dx=[]; V.t=[]; V.dt=[]; V.sys=[]; 
+V.y = []; V.dy = []; V.x=[]; V.dx=[]; V.t=[]; V.dt=[]; V.sys=[];
 Ti=V; vTor=V; vPol=V; nC=V; Zeff=V;
-jsis=0; 
+jsis=0;
 for isys=sys
   %data=CXRS_load_MDS(shot,isys,'result',[],param.k_debug,param.k_plot);
   if k_load, data=CXRS_load_MDS(shot,isys,'result',[],param.k_debug,0); end
@@ -175,44 +175,44 @@ for isys=sys
   if (data.OK==1)
      jsis=jsis+1; cxrs_profiles.data{jsis}=data;
      nr=size(data.calc.Ti,1); nt=length(data.calc.time);
-     for it=1:nt, 
-        time(1:nr,it)=data.calc.time(it); 
+     for it=1:nt,
+        time(1:nr,it)=data.calc.time(it);
 	if (length(data.calc.dtime)==1), dtime(1:nr,it)=data.calc.dtime; else, dtime(1:nr,it)=data.calc.dtime(it); end
      end
      if isempty(Time_min), Time_min=time(1,:)-dtime(1,:)/2; Time_max=time(1,:)+dtime(1,:)/2; end
      Times=(Time_min+Time_max)/2.;
      if isfield(data.calc,'Ti'),
-        Vold=Ti; V.y=data.calc.Ti; V.dy=data.calc.err_Ti; 
+        Vold=Ti; V.y=data.calc.Ti; V.dy=data.calc.err_Ti;
 	sel=find(~isnan(V.y)&~isnan(V.dy));
         V.y=data.calc.Ti(sel); V.dy=data.calc.err_Ti(sel); V.x=data.calc.rho(sel); V.dx=data.calc.rho_err(sel); V.t=time(sel); V.dt=dtime(sel); V.sys=ones(size(V.y))*data.system;
-	V.y   =  [Vold.y; V.y]; V.dy   =  [Vold.dy; V.dy]; V.x   =  [Vold.x; V.x]; V.dx   =  [Vold.dx; V.dx]; V.t   =  [Vold.t; V.t]; V.dt   =  [Vold.dt; V.dt]; V.sys   =  [Vold.sys; V.sys]; 
+	V.y   =  [Vold.y; V.y]; V.dy   =  [Vold.dy; V.dy]; V.x   =  [Vold.x; V.x]; V.dx   =  [Vold.dx; V.dx]; V.t   =  [Vold.t; V.t]; V.dt   =  [Vold.dt; V.dt]; V.sys   =  [Vold.sys; V.sys];
 	Ti=V;
      end
      if isfield(data.calc,'vi')&((((data.system==2)&(data.shot<47823))||((data.system==3)&(data.shot>=47823)))||(data.system==4)), % VER CXRS system
-        Vold=vPol; V.y=data.calc.vi; V.dy=data.calc.err_vi; 
+        Vold=vPol; V.y=data.calc.vi; V.dy=data.calc.err_vi;
 	    sel=find(~isnan(V.y)&~isnan(V.dy));
         V.y=data.calc.vi(sel); V.dy=data.calc.err_vi(sel); V.x=data.calc.rho(sel); V.dx=data.calc.rho_err(sel); V.t=time(sel); V.dt=dtime(sel); V.sys=ones(size(V.y))*data.system;
-	    V.y   =  [Vold.y; V.y]; V.dy   =  [Vold.dy; V.dy]; V.x   =  [Vold.x; V.x]; V.dx   =  [Vold.dx; V.dx]; V.t   =  [Vold.t; V.t]; V.dt   =  [Vold.dt; V.dt]; V.sys   =  [Vold.sys; V.sys]; 
+	    V.y   =  [Vold.y; V.y]; V.dy   =  [Vold.dy; V.dy]; V.x   =  [Vold.x; V.x]; V.dx   =  [Vold.dx; V.dx]; V.t   =  [Vold.t; V.t]; V.dt   =  [Vold.dt; V.dt]; V.sys   =  [Vold.sys; V.sys];
 	    vPol=V;
      else                                         % LFS CXRS system
-        Vold=vTor; V.y=data.calc.vi; V.dy=data.calc.err_vi; 
+        Vold=vTor; V.y=data.calc.vi; V.dy=data.calc.err_vi;
 	    sel=find(~isnan(V.y)&~isnan(V.dy));
         V.y=data.calc.vi(sel); V.dy=data.calc.err_vi(sel); V.x=data.calc.rho(sel); V.dx=data.calc.rho_err(sel); V.t=time(sel); V.dt=dtime(sel); V.sys=ones(size(V.y))*data.system;
-	V.y   =  [Vold.y; V.y]; V.dy   =  [Vold.dy; V.dy]; V.x   =  [Vold.x; V.x]; V.dx   =  [Vold.dx; V.dx]; V.t   =  [Vold.t; V.t]; V.dt   =  [Vold.dt; V.dt]; V.sys   =  [Vold.sys; V.sys]; 
+	V.y   =  [Vold.y; V.y]; V.dy   =  [Vold.dy; V.dy]; V.x   =  [Vold.x; V.x]; V.dx   =  [Vold.dx; V.dx]; V.t   =  [Vold.t; V.t]; V.dt   =  [Vold.dt; V.dt]; V.sys   =  [Vold.sys; V.sys];
 	vTor=V;
      end
      if isfield(data.calc,'ni'),
-        Vold=nC; V.y=data.calc.ni; V.dy=data.calc.err_ni; 
+        Vold=nC; V.y=data.calc.ni; V.dy=data.calc.err_ni;
 	sel=find(~isnan(V.y)&~isnan(V.dy));
         V.y=data.calc.ni(sel); V.dy=data.calc.err_ni(sel); V.x=data.calc.rho(sel); V.dx=data.calc.rho_err(sel); V.t=time(sel); V.dt=dtime(sel); V.sys=ones(size(V.y))*data.system;
-	V.y   =  [Vold.y; V.y]; V.dy   =  [Vold.dy; V.dy]; V.x   =  [Vold.x; V.x]; V.dx   =  [Vold.dx; V.dx]; V.t   =  [Vold.t; V.t]; V.dt   =  [Vold.dt; V.dt]; V.sys   =  [Vold.sys; V.sys]; 
+	V.y   =  [Vold.y; V.y]; V.dy   =  [Vold.dy; V.dy]; V.x   =  [Vold.x; V.x]; V.dx   =  [Vold.dx; V.dx]; V.t   =  [Vold.t; V.t]; V.dt   =  [Vold.dt; V.dt]; V.sys   =  [Vold.sys; V.sys];
 	nC=V;
      end
      if isfield(data.calc,'zeff'),
-        Vold=Zeff; V.y=data.calc.zeff; V.dy=data.calc.err_zeff; 
+        Vold=Zeff; V.y=data.calc.zeff; V.dy=data.calc.err_zeff;
 	sel=find(~isnan(V.y)&~isnan(V.dy));
         V.y=data.calc.zeff(sel); V.dy=data.calc.err_zeff(sel); V.x=data.calc.rho(sel); V.dx=data.calc.rho_err(sel); V.t=time(sel); V.dt=dtime(sel); V.sys=ones(size(V.y))*data.system;
-	V.y   =  [Vold.y; V.y]; V.dy   =  [Vold.dy; V.dy]; V.x   =  [Vold.x; V.x]; V.dx   =  [Vold.dx; V.dx]; V.t   =  [Vold.t; V.t]; V.dt   =  [Vold.dt; V.dt]; V.sys   =  [Vold.sys; V.sys]; 
+	V.y   =  [Vold.y; V.y]; V.dy   =  [Vold.dy; V.dy]; V.x   =  [Vold.x; V.x]; V.dx   =  [Vold.dx; V.dx]; V.t   =  [Vold.t; V.t]; V.dt   =  [Vold.dt; V.dt]; V.sys   =  [Vold.sys; V.sys];
 	Zeff=V;
      end
   end
@@ -230,9 +230,9 @@ cxrs_profiles.exp.nC=nC;
 cxrs_profiles.exp.Zeff=Zeff;
 
 figures=[1:5]+9900;
-names_exp{1} = 'Ti'; names_exp{2} = 'vTor'; names_exp{3} = 'vPol'; names_exp{4} = 'nC'; names_exp{5} = 'Zeff'; 
-names_par{1} = 'Ti'; names_par{2} = 'vi';   names_par{3} = 'vi';   names_par{4} = 'nc'; names_par{5} = 'zeff'; 
-names_uni{1} = 'eV'; names_uni{2} = 'km/sec';   names_uni{3} = 'km/sec';   names_uni{4} = 'm^{-3}'; names_uni{5} = ' '; 
+names_exp{1} = 'Ti'; names_exp{2} = 'vTor'; names_exp{3} = 'vPol'; names_exp{4} = 'nC'; names_exp{5} = 'Zeff';
+names_par{1} = 'Ti'; names_par{2} = 'vi';   names_par{3} = 'vi';   names_par{4} = 'nc'; names_par{5} = 'zeff';
+names_uni{1} = 'eV'; names_uni{2} = 'km/sec';   names_uni{3} = 'km/sec';   names_uni{4} = 'm^{-3}'; names_uni{5} = ' ';
 %if cxrs_profiles.param.k_plot==1 || cxrs_profiles.param.k_plot==-1 || cxrs_profiles.param.k_plot<=-2
 if cxrs_profiles.param.k_plot~=0
    param_plot.ON      = 1; param_plot.lnwidth = 2.0; param_plot.sizemk  = 6.0;
@@ -267,13 +267,13 @@ for iexp=1:length(names_exp),
       profiles{it}=CXRS_fit_profies(exp_data,[cxrs_profiles.Time_min(it) cxrs_profiles.Time_max(it)],param_prof,param_plot);
     end
     cmd=sprintf('cxrs_profiles.%s=profiles;',names_exp{iexp}); eval(cmd);
-    %if (cxrs_profiles.param.k_plot>0), 
-    if (cxrs_profiles.param.k_plot~=0), 
+    %if (cxrs_profiles.param.k_plot>0),
+    if (cxrs_profiles.param.k_plot~=0),
       title(sprintf('CXRS %s for TCV shot: %5.5d sys.No.:[%s]',names_exp{iexp},cxrs_profiles.shot,num2str(cxrs_profiles.system)));
       xlabel('\rho_{TCV}')
       ylabel(sprintf('%s, %s',names_exp{iexp},names_uni{iexp}));
       clear hh leg
-      for it=1:length(profiles), 
+      for it=1:length(profiles),
          hh(it)=profiles{it}.plot_handle;
          if isempty(profiles{it}.y_prof),
              leg{it}=sprintf('%3.3f-%3.3fs - No Data',profiles{it}.t_lim);
@@ -287,15 +287,15 @@ for iexp=1:length(names_exp),
              end
              leg{it}=sprintf('#%d@%3.3f-%3.3fs%s',shot,profiles{it}.t_lim,SysP);
              set(hh(it),'Tag','CXRS data','DisplayName',leg{it});
-         end 
+         end
       end
       hE = findobj(gcf,'-regexp','Tag','CXRS data');
       if(length(hE)>0),
           hE=hE(end:-1:1);
           leg=get(hE,'DisplayName');
-          legend(hE,leg,0);
+          legend(hE,leg,'location','best');
       end
-      %legend(hh,leg,0); grid on
+      %legend(hh,leg,'location','best'); grid on
     end
    else
     if (cxrs_profiles.param.k_plot~=0), clf; tit=sprintf('No CXRS %s for TCV shot:%d sys.No.:[%s]',names_exp{iexp},shot,num2str(sys)); title(tit); text(0.5,0.5,tit,'HorizontalAlignment','center'); end
@@ -312,41 +312,41 @@ for it=1:length(cxrs_profiles.Ti)
    cxrs_profiles.proffit.dtime(1,it) = (D.t_lim(2)-D.t_lim(1))/2.;
    if ~isempty(D.y_prof), rho=D.x_prof; else rho=cxrs_profiles.param.prof.Ti.xout'; end
    if isempty(rho); rho=NaN(1,101); end
-   if isempty(D.y_prof),   V=rho*NaN;    D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0),   V=rho*NaN;  else,  V=D.y_prof'; end 
-   if isempty(D.dy_prof), dV=rho*NaN;  elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN;  else, dV=D.dy_prof'; end 
-   V(find(V<0))=0; 
+   if isempty(D.y_prof),   V=rho*NaN;    D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0),   V=rho*NaN;  else,  V=D.y_prof'; end
+   if isempty(D.dy_prof), dV=rho*NaN;  elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN;  else, dV=D.dy_prof'; end
+   V(find(V<0))=0;
    cxrs_profiles.proffit.Ti(:,it)   =V'; cxrs_profiles.proffit.dTi(:,it)   =dV'; cxrs_profiles.proffit.Ti_rho(:,it)  = rho';
    cxrs_profiles.proffit.rho(:,it)  = rho';
    if isfield(cxrs_profiles,'vTor')
       D=cxrs_profiles.vTor{it};
       if ~isempty(D.y_prof), rho=D.x_prof; else, rho=cxrs_profiles.proffit.rho(:,it); end
-      if isempty(D.y_prof),  V=rho*NaN;    D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN;  else, V=D.y_prof'; end  
-      if isempty(D.dy_prof), dV=rho*NaN;  elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN;  else, dV=D.dy_prof'; end 
+      if isempty(D.y_prof),  V=rho*NaN;    D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN;  else, V=D.y_prof'; end
+      if isempty(D.dy_prof), dV=rho*NaN;  elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN;  else, dV=D.dy_prof'; end
       cxrs_profiles.proffit.vTor(:,it)   =V'; cxrs_profiles.proffit.dvTor(:,it)   =dV'; cxrs_profiles.proffit.vTor_rho(:,it)  = rho';
-   end  
+   end
    if isfield(cxrs_profiles,'vPol')
       D=cxrs_profiles.vPol{it};
       if ~isempty(D.y_prof), rho=D.x_prof; else, rho=cxrs_profiles.proffit.rho(:,it); end
-      if isempty(D.y_prof),  V=rho*NaN;    D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN;  else, V=D.y_prof'; end  
-      if isempty(D.dy_prof), dV=rho*NaN;  elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN;  else, dV=D.dy_prof'; end 
+      if isempty(D.y_prof),  V=rho*NaN;    D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN;  else, V=D.y_prof'; end
+      if isempty(D.dy_prof), dV=rho*NaN;  elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN;  else, dV=D.dy_prof'; end
       cxrs_profiles.proffit.vPol(:,it)   =V'; cxrs_profiles.proffit.dvPol(:,it)   =dV'; cxrs_profiles.proffit.vPol_rho(:,it)  = rho';
-   end  
+   end
    if isfield(cxrs_profiles,'nC')
       D=cxrs_profiles.nC{it};
       if ~isempty(D.y_prof), rho=D.x_prof; else, rho=cxrs_profiles.proffit.rho(:,it); end
-      if isempty(D.y_prof),  V=rho*NaN;  D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN;  else, V=D.y_prof'; end  
-      if isempty(D.dy_prof), dV=rho*NaN;  elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN;  else, dV=D.dy_prof'; end 
-      V(find(V<0))=0; 
+      if isempty(D.y_prof),  V=rho*NaN;  D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN;  else, V=D.y_prof'; end
+      if isempty(D.dy_prof), dV=rho*NaN;  elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN;  else, dV=D.dy_prof'; end
+      V(find(V<0))=0;
       cxrs_profiles.proffit.nC(:,it)   =V'; cxrs_profiles.proffit.dnC(:,it)   =dV'; cxrs_profiles.proffit.nC_rho(:,it)  = rho';
-   end  
+   end
    if isfield(cxrs_profiles,'Zeff')
       D=cxrs_profiles.Zeff{it};
       if ~isempty(D.y_prof), rho=D.x_prof; else, rho=cxrs_profiles.proffit.rho(:,it); end
-      if isempty(D.y_prof),  V=rho*NaN;    D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN;  else, V=D.y_prof'; end  
-      if isempty(D.dy_prof), dV=rho*NaN;  elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN;  else, dV=D.dy_prof'; end 
-      V(find(V<1))=1; 
+      if isempty(D.y_prof),  V=rho*NaN;    D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN;  else, V=D.y_prof'; end
+      if isempty(D.dy_prof), dV=rho*NaN;  elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN;  else, dV=D.dy_prof'; end
+      V(find(V<1))=1;
       cxrs_profiles.proffit.Zeff(:,it)   =V'; cxrs_profiles.proffit.dZeff(:,it)   =dV'; cxrs_profiles.proffit.Zeff_rho(:,it)  = rho';
-   end  
+   end
 
 end
 
diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m
index 16014647adbc3c95ef8938bd335a7042902a3363..d716210ccd3c8e529bfa4057f52d80f64dd9c6a0 100644
--- a/matlab/TCV/gdat_tcv.m
+++ b/matlab/TCV/gdat_tcv.m
@@ -88,6 +88,7 @@ gdat_params.machine=default_machine;
 gdat_params.doplot = 0;
 gdat_params.liuqe = 1;
 gdat_params.nverbose = 1;
+gdat_params.trialindx = [];
 
 % construct list of keywords from global set of keywords and specific TCV set
 % get data_request names from centralized table
@@ -356,6 +357,17 @@ if strcmp(mapping_for_tcv.method(1:3),'tdi')
   if liuqe_matlab==0 && strcmp(mapping_for_tcv.method,'tdiliuqe'); substr_tdi = substr_liuqe; end
   if iscell(mapping_for_tcv.expression)
     if length(mapping_for_tcv.expression)>0
+      if ~isempty(gdat_data.gdat_params.trialindx) && gdat_data.gdat_params.trialindx >= 0 ...
+            && contains(mapping_for_tcv.expression{1},{'toray','conf','ibs','proffit','astra'})
+        ij = findstr(mapping_for_tcv.expression{1},':trial');
+        if isempty(ij)
+          aa = [mapping_for_tcv.expression{1} ':trial'];
+          if mdsdata(['node_exists("' aa '")']) > 0
+            mapping_for_tcv.expression_orig = mapping_for_tcv.expression;
+            mapping_for_tcv.expression{1} = aa;
+          end
+        end
+      end
       % series of arguments for tdi given in each cell
       if liuqe_matlab==1
         ij = findstr(mapping_for_tcv.expression{1},'equil_');
@@ -377,6 +389,7 @@ if strcmp(mapping_for_tcv.method(1:3),'tdi')
   else
     do_liuqem2liuqef = 0;
     if liuqe_version_eff==-1
+      % trialindx not relevant for fbte
       mapping_for_tcv_expression_eff = mapping_for_tcv.expression;
       if length(mapping_for_tcv.expression)>8 && strcmp(lower(mapping_for_tcv.expression(1:8)),'\results')
         mapping_for_tcv_expression_eff = mapping_for_tcv.expression(11:end);
@@ -391,6 +404,17 @@ if strcmp(mapping_for_tcv.method(1:3),'tdi')
       end
       eval_expr = ['tdi(''' begstr mapping_for_tcv_expression_eff substr_liuqe ''');']
     else
+      if ~isempty(gdat_data.gdat_params.trialindx) && gdat_data.gdat_params.trialindx >= 0 ...
+            && contains(mapping_for_tcv.expression,{'toray','conf','ibs','proffit','astra'})
+        ij = findstr(mapping_for_tcv.expression,':trial');
+        if isempty(ij)
+          aa = [mapping_for_tcv.expression ':trial'];
+          if mdsdata(['node_exists("' aa '")']) > 0 || mdsdata(['node_exists("\' aa '")']) > 0
+            mapping_for_tcv.expression_orig = mapping_for_tcv.expression;
+            mapping_for_tcv.expression = aa;
+          end
+        end
+      end
       if liuqe_matlab==1
         ij = findstr(mapping_for_tcv.expression,'equil_');
         if ~isempty(ij)
@@ -459,6 +483,21 @@ if strcmp(mapping_for_tcv.method(1:3),'tdi')
       end
     end
     aatmp=eval(eval_expr);
+    if ~isempty(gdat_data.gdat_params.trialindx) && gdat_data.gdat_params.trialindx >= 0
+      if isfield(mapping_for_tcv,'expression_orig')
+        mapping_for_tcv.expression = mapping_for_tcv.expression_orig;
+        mapping_for_tcv = rmfield(mapping_for_tcv,'expression_orig');
+        % reduce data to only desired trialindx
+        nbdims = length(aatmp.dim);
+        bbtmp = aatmp;
+        aatmp.dim = bbtmp.dim(1:nbdims-1);
+        aatmp.dimunits = bbtmp.dimunits(1:nbdims-1);
+        abc(1:nbdims-1)={':,'};
+        strdata=sprintf('%s',abc{:});
+        eval(['aatmp.data = bbtmp.data(' strdata num2str(gdat_data.gdat_params.trialindx+1) ');']);
+        aatmp.help = [bbtmp.help ' :trial(...,trialindx='  num2str(gdat_data.gdat_params.trialindx) ')'];
+      end
+    end
   end
   if isempty(aatmp.data) || (isempty(aatmp.dim) && ischar(aatmp.data) && ~isempty(strfind(lower(aatmp.data),'no data')))% || ischar(aatmp.data) (to add?)
     if (gdat_params.nverbose>=1); warning(['problems loading data for ' eval_expr ' for data_request= ' data_request_eff]); end
@@ -1327,7 +1366,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
       gdat_data.(sources_avail{i}).data_fullpath=[];
       gdat_data.(sources_avail{i}).label=[];
     end
-    if ~isfield(gdat_data.gdat_params,'trialindx') || gdat_data.gdat_params.trialindx < 0
+    if ~isempty(gdat_data.gdat_params.trialindx) && gdat_data.gdat_params.trialindx < 0
       gdat_data.gdat_params.trialindx = [];
     end
 
diff --git a/matlab/TCV_IMAS/tcv2ids.m b/matlab/TCV_IMAS/tcv2ids.m
index 69786d1f7f23fcb95640e611c2d1f1fd3d9b49a3..920948939d219aef3ffa9835a4a9e63e4ac3eb1b 100644
--- a/matlab/TCV_IMAS/tcv2ids.m
+++ b/matlab/TCV_IMAS/tcv2ids.m
@@ -22,6 +22,7 @@ function [ids_from_tcv,varargout] = tcv2ids(shot,varargin);
 %           'nverbose': (default 1), set it to 3 to have more messages, for example about not fully valid nodes when doing transformation (empty or Nans)
 %           'time_out': if 2 values provided: get all time data within that time interval
 %                       otherwise get values at these times provided in time_out (with linear interpolation and cst extrapolation)
+%           'trialindx': trial_indx for relevant nodes, in particular CONF kinetic profiles nodes
 %
 % Outputs
 % varargout{1}: return also the ids in array of structure with the names, to allow easy use of plotallids
@@ -39,6 +40,7 @@ p.addOptional('ipsign_out', 0, @(x) isempty(x) || (x==0 | x==-1 | x==+1) ); % ch
 p.addOptional('b0sign_out', 0, @(x) isempty(x) || (x==0 | x==-1 | x==+1) ); % char
 p.addOptional('nverbose', 1, @(x) isempty(x) || isnumeric(x) );
 p.addOptional('time_out', [], @(x) isempty(x) || isnumeric(x) );
+p.addOptional('trialindx', [], @(x) isempty(x) || isnumeric(x) );
 
 params_not_for_gdat_params = {'shot','ids_names'};
 
diff --git a/matlab/TCV_IMAS/tcv2ids2database.m b/matlab/TCV_IMAS/tcv2ids2database.m
index 52bc6058fd1ed8b7e0387bbc81842daf49139996..99b52f127177026d2f61ad94c9485fb1fd1c66d4 100644
--- a/matlab/TCV_IMAS/tcv2ids2database.m
+++ b/matlab/TCV_IMAS/tcv2ids2database.m
@@ -22,6 +22,7 @@ function [ids_from_tcv,varargout] = tcv2ids2database(shot,run_out,varargin);
 %           'b0sign_out': if a specific sign fo B0 is desired in output within the cocos_out system (default 0=no specific sign)
 %           'time_out': if 2 values provided: get all time data within that time interval
 %                       otherwise get values at these times provided in time_out (with linear interpolation and cst extrapolation)
+%           'trialindx': trial_indx for relevant nodes, in particular CONF kinetic profiles nodes
 %
 % example:
 %   ids_from_tcv = tcv2ids2database(62745,9999,'ids_names',{'pf_active'},'error_bar','added'); % to test only one ids
@@ -57,6 +58,7 @@ p.addOptional('ipsign_out', 0, @(x) isempty(x) || (x==0 | x==-1 | x==+1) ); % ch
 p.addOptional('b0sign_out', 0, @(x) isempty(x) || (x==0 | x==-1 | x==+1) ); % char
 p.addOptional('nverbose', 1, @(x) isempty(x) || isnumeric(x) );
 p.addOptional('time_out', [], @(x) isempty(x) || isnumeric(x) );
+p.addOptional('trialindx', [], @(x) isempty(x) || isnumeric(x) );
 
 p.parse;
 defaults_tcv2ids2database = p.Results; % to keep track of defaults
@@ -113,7 +115,7 @@ if isfield(ids_from_tcv,'core_profiles')
   end
 end
 
-  
+
 %% can plot with: [plotids_H] = plotids([],idsok.ids{1},idsok.ids{2});
 if isfield(ids_from_tcv,'tf')
   % avoid present problem of not saving data if ids_from_tcv.tf.field_map{1}.time is not set