diff --git a/TCV/loadTCVdata.m b/TCV/loadTCVdata.m
index 02d630ba57b05b15e1207f4ffb97d85dc84b263a..9c4e6fcc9c2039da0da18b00454f195093753972 100644
--- a/TCV/loadTCVdata.m
+++ b/TCV/loadTCVdata.m
@@ -75,27 +75,24 @@ end
 disp(['loading' ' ' data_type ' from TCV shot #' num2str(shot)]); 
 disp(['case ' TCVkeywrdcase{index}])
 status=ones(1,100);
+zmag=cell(0,0);
 nargineff=nargin;
+i1=1;
+i2=20;
 if nargineff>=3
-  if isstruct(varargin{1})
-     zmag=varargin{1};
-  elseif size(varargin{1},2)>2
-     status=varargin{1};
-     if nargineff>=4  
-       if isstruct(varargin{2})
-         zmag=varargin{2};
-       else
-          i1 =varargin{2}(1);
-	  i2 =varargin{2}(2);
-	  if nargineff==5, zmag=varargin{3}; end
-       end
-     end  	   	  
-  else 
-     i1 =varargin{1}(1);
-     i2 =varargin{1}(2);
-     if nargineff>=4, zmag=varargin{2}; end   
+  for i=1:length(varargin)
+    if ~isempty(varargin{i})
+      if isstruct(varargin{i})
+         zmag=varargin{1};
+      elseif size(varargin{i},2)>2
+         status=varargin{i};
+      else
+         i1 =varargin{2}(1);
+    	 i2 =varargin{2}(2);
+      end
+    end 
   end
-end 
+end
 
 switch TCVkeywrdcase{index}
 
@@ -132,6 +129,10 @@ switch TCVkeywrdcase{index}
    
   case {'sxr','sxR'}
     %  load TCV soft x-ray data  
+    if isempty(zmag)
+      zmag=loadTCVdata(shot,'zmag');
+    end
+
     % camera selection: 1-10. each camera has 20 channels
     icamera=[0 1 0 0 0 0 0 0 0 0];  %index of the camera to use
     if ~isempty(find(status(1:20*icamera*ones(10,1)) == 1))
@@ -156,6 +157,9 @@ switch TCVkeywrdcase{index}
 
   case 'ece'
     %  load TCV ECE data
+    if isempty(zmag)
+      zmag=loadTCVdata(shot,'zmag');
+    end
     % Status=1 => Not Read Yet  
     if ~isempty(find(status == 1))
       [TE_ECE,TE_ECE_ERR,RHO,R,T,TE_THOM,TE_THOM_ERR,Fcentral,CAL]=ece_te ...
diff --git a/TCV/private/common_ece.m b/TCV/private/common_ece.m
new file mode 100755
index 0000000000000000000000000000000000000000..941fbb1cd8bfb84ea8845f3f285b8d193b1d5d5b
--- /dev/null
+++ b/TCV/private/common_ece.m
@@ -0,0 +1,41 @@
+function [t,i1,i2,i12,t1no,t2no,i1no,i2no]=common_ece(t1,t2,tol,mode,bounds)
+% [t,i1,i2,i12,t1no,t2no,i1no,i2no]=common(t1,t2,[tol,mode,bounds])
+% extract elements that are common to t1 and t2 within tolerance tol
+% t:  elements of t1 which are within tol of an element of t2
+% i1: index to elements of t1 which are within tol of an element of t2
+% i2: index to elements of t2 which are within tol of (and closest to if 'n') an element of t1
+% i12:index in t2 for elements from t1 corresponding to (first) match in t2
+% t1(2)no: elements of t1(2) which are not matched in t2(1)
+% i1(2)no: index to elements in t1(2) which are not matched in t2(1)
+% mode: 'a' all or 'n' nearest matches
+% bounds: [bmin,bmax] limits search interval for t1
+
+if exist('tol')==0,tol=eps;end
+if exist('bounds')==0,bounds=[min([min(t1),min(t2)])-tol;max([max(t2),max(t1)])+tol];end
+if exist('mode')==0,mode='n';end
+i1=zeros(size(t1));i2=zeros(size(t2));t=[];i12=zeros(size(t1));
+t1no=[];t2no=[];i1no=[];i2no=[];match=0;
+for j=1:length(t1);
+ if t1(j)>=bounds(1) & t1(j)<=bounds(2)
+  tt1=t1(j)*ones(size(t2));
+  ii2=find(abs(t2-tt1)<=tol);
+  if (mode=='n') & length(ii2)>0
+   if (length(ii2)>1),[x,ii2]=min(abs(t2-tt1));end
+   match=match+1;i2(ii2)=ii2;i1(j)=ii2;i12(j)=ii2;
+  end
+  if (mode=='a' & ii2~=[]),match=match+1;i1(j)=j;i12=ii2(1);i2(ii2)=ii2;end	
+ end
+end
+%disp(['matches found: ',int2str(match)])
+%keyboard
+
+  i1no=find(i1==0);
+  i2no=find(i2==0);
+  i1=find(i1~=0);
+  i2=find(i2~=0);
+  if length(i1)>0,t=t1(i1);end
+if length(i1no)>0,t1no=t1(i1no);end
+if length(i2no)>0,t2no=t2(i2no);end
+
+%keyboard
+
diff --git a/TCV/private/ece_bad_channels.m b/TCV/private/ece_bad_channels.m
new file mode 100755
index 0000000000000000000000000000000000000000..d7db31440ef336183908443eeecaa0ab7e4894a6
--- /dev/null
+++ b/TCV/private/ece_bad_channels.m
@@ -0,0 +1,19 @@
+function [N]=ece_bad_channels(shot)
+%	function [N]=ece_bad_channels(shot)
+%
+%	Fonction donnant la liste des cannaux  ne fonctionnant pas
+%	La numerotation est celle de la notice de l'ECE => comme dans MDS
+
+load bad_channels;
+if isempty(find(A(:,1)==shot))==1
+  if shot <=18628 
+    N=[1 23];
+  elseif shot > 18628 & shot<20000
+    N=[1 15 21 23];
+   elseif shot>20000
+    N=[15 21 23];
+  end
+else
+  N=A(find(A(:,1)==shot),2:20);
+  N=N(find(N>0));
+end
diff --git a/TCV/private/ece_calib.m b/TCV/private/ece_calib.m
new file mode 100755
index 0000000000000000000000000000000000000000..171fe18bf369850765cd553f3f57b0b332200e0b
--- /dev/null
+++ b/TCV/private/ece_calib.m
@@ -0,0 +1,155 @@
+function [CALIBRATION,Fcentral]=ece_calib(shot,Tc)
+
+%	function [CALIBRATION,Fcentral]=ece_calib(shot,Tc)
+%	[CALIBRATION,Fcentral]=ece_calib(shot,[0.1 0.29])
+%
+%	Calculate the CALIBRATION matrix of ECE signals on Thomson temperature
+%	on times bounded by Tc=[a b] for the specified shot#.
+%	Fcentral is the central Frequency of the ECE channels
+%	
+%	Blanchard  09.06.2001
+
+%-----------------------------------------------------------------------
+%	Recherche de la configuration de l'ECE
+%-----------------------------------------------------------------------
+[W]=writeece;
+
+warning off
+mdsopen('tcv_shot',shot)
+L=mdsdata('GETNCI("\\results::ece:calibration","length")');
+LL=mdsdata('GETNCI("\\results::psi_axis:foo","length")');
+mdsclose
+if LL==0
+ disp('----------------------------------')
+ disp('\results::psi_axis not calculated')
+ disp('----------------------------------')
+ return 
+end
+
+if L==0 | L==28 |W==1
+  disp(' La trace \results::ece:calibration est vide ');
+  mdsopen('tcv_shot',shot)
+  Cntrl1= mdsdata('\vsystem::tcv_publicdb_b["ECE:PIO_D0"]');
+  Cntrl2= mdsdata('\vsystem::tcv_publicdb_b["ECE:PIO_D1"]');
+  Sw1= mdsdata('\vsystem::tcv_publicdb_b["ECE:PIO_D2"]');
+  Sw2= mdsdata('\vsystem::tcv_publicdb_b["ECE:PIO_D3"]');
+  mdsclose
+  i=[1,2];
+  if strcmp(Cntrl1(i),'ON')
+     L=2;
+  else
+     if strcmp(Cntrl2(i),'ON')
+	L=1;
+     else
+	L=0;
+     end
+  end
+
+  if strcmp(Sw1(i),'ON') 
+   if strcmp(Sw2(i),'ON') 
+    K=2;
+   else
+    K=3;
+   end
+  else
+   if strcmp(Sw2(i),'ON') 
+    K=4;
+   else
+    K=1;
+   end
+  end
+  clear Cntrl1 Cntrl2 Sw1 Sw2
+
+  %-----------------------------------------------------------------------
+  %	Appel des principales donnees
+  %-----------------------------------------------------------------------
+  [RHOece,Rece,Zece,Tece, Fcentralrho]=ece_rho(shot,Tc);Tece=Tece';
+  [TEthom,NEthom,TEerr,NEerr,Tthom,RHOthom]=thom_rho(shot,5); %(Tthom,Nbre de pts selon rho)
+  [A,B]=size(TEthom);
+  KK=0;
+  if exist('TEthom')==0|length(TEthom) ==0
+	KK=1;
+	disp('Le profil Thomson proffit n''existe pas. On essaye le profil direct') %(Tthom,Nbre de pts selon rho)
+	[TEthom,NEthom,TEerr,NEerr,Tthom,RHOthom]=thom_rho(shot,3);
+	[A,B]=size(TEthom);
+	if mean(TEthom)==-1| isstr(TEthom)==1
+	 	return
+	end
+  end
+  if A==0|B==0|B==10
+	disp('--------------------------')
+	disp('No Thomson acquisition')
+	disp('--------------------------')
+	TEthom
+	return
+  end
+  [t,i1,i2]=common(Tece,Tthom(:,1),0.005);
+  [ECE,TECE,Fcentral]=ece_raw_signals(shot,Tc,1);Fcentral=Fcentral';
+  [t2,i3,i4]=common(Fcentralrho,Fcentral);
+  Rece=Rece(i3,i1);Zece=Zece(i3,i1);RHOece=RHOece(i3,i1);
+  TEthom=TEthom(i2,:);TEerr=TEerr(i2,:);RHOthom=RHOthom(i2,:);
+  T1=Tece(i1);
+  clear NEthom Tthom Tece Zece Fcentralrho
+  disp(['Pour la calibration, nous allons considerer ', num2str(length(t)),' profils Thomson '])
+  disp(['Tcal = ',num2str(t')])              
+  %-----------------------------------------------------------------------
+  %	Mise a jour des signaux sur les memes bases temporelles
+  %	et RHO
+  %-----------------------------------------------------------------------
+  [T1,Fcentral]=meshgrid(T1,Fcentral);[T2,Fcentral2]=meshgrid(TECE,Fcentral(:,1));
+  RHOcalib=interp2(T1,Fcentral,RHOece,T2',Fcentral2');
+  TEthom=griddata(RHOthom,repmat(T1(1,:)',1,B),TEthom,RHOcalib,T2'); 
+  TEerr=griddata(RHOthom,repmat(T1(1,:)',1,B),TEerr,RHOcalib,T2');
+  %-----------------------------------------------------------------------
+  %	Calibration sur mesure Thomson
+  %-----------------------------------------------------------------------
+  if isempty(find(isnan(TEthom)))==0
+    NN=find(isnan(mean(TEthom))==1);   
+    for j=1:length(NN)
+      nj=find(isnan(TEthom(:,NN(j)))==1);
+      nNN=find(isnan(TEthom(:,NN(j)))==0); 
+      disp(['On a remplace ',num2str(length(nj)),' NaN dans la colonne ',num2str(NN(j))]); 
+      if min(nNN)<min(nj)
+        TEthom(nj,NN(j))=TEthom(min(nj)-1,NN(j));
+      else
+        disp(['probleme avec NaN : toute la colonne ',num2str(NN(j)),' vaut 0']);
+        TEthom(nj,NN(j))=0;
+      end
+    end
+  end  
+ 
+  CAL(1,:)=Fcentral(:,1)';
+  c=TEthom./ECE;
+  if  max(size(find(c==0)))>1
+	  disp('On corrige les points valant 0')
+	  jj=min(find(mean(TEthom)>0));
+	  mm=min(find(c(:,3)>0));
+	  MM= max(find(c(:,3)>0));
+	  CAL(2,:)=mean(TEthom([mm:MM],:)./ECE([mm:MM],:));
+	  CAL(3,:)=std(TEthom([mm:MM],:)./ECE([mm:MM],:));CAL(4,:)=mean(TEerr([mm:MM],:)./ECE([mm:MM],:));
+	  CALIBRATION=CAL;CALIBRATION(5,[1:length(T1(1,:))])=T1(1,:);  
+  else
+	  CAL(2,:)=mean(TEthom./ECE);
+	  CAL(3,:)=std(TEthom./ECE);CAL(4,:)=mean(TEerr./ECE);
+	  CALIBRATION=CAL;CALIBRATION(5,[1:length(T1(1,:))])=T1(1,:);   
+  end
+  if W==2
+
+  else 
+	  mdsopen(shot) 
+	  mdsput('\results::ece:calibration',CALIBRATION,'f');
+	  mdsput('\results::ece:f_central',Fcentral(:,1),'f');
+	  mdsclose
+	  disp('On a enregistre la matrice de calibration et Fcentral dans MDS')
+	  clear RHOcalib TEthom T2 ECE Fcentral2 TECE 
+  end
+ 
+else
+	disp('On va chercher la matrice \results::ece:CALIBRATION dans MDS!')
+	mdsopen('tcv_shot',shot)
+	CALIBRATION=mdsdata('\results::ece:calibration');
+	Fcentral=mdsdata('\results::ece:f_central');
+	mdsclose
+end
+
+warning on
diff --git a/TCV/private/ece_conf.m b/TCV/private/ece_conf.m
new file mode 100755
index 0000000000000000000000000000000000000000..9c71c4c913d3d13319c54b69a9fdb5fbd27cac20
--- /dev/null
+++ b/TCV/private/ece_conf.m
@@ -0,0 +1,85 @@
+function [K,L]=ece_conf(shot,mode)
+
+%	function [K,L]=ece_conf(shot,mode)
+%	[K,L]=ece_conf(shot,0);
+%	if mode=0 => display some informations
+%	
+%	Give the configuration of the ECE radiometer for the specified shot.
+%	K=1 => high edge resolution (A)
+%	K=2 => high center resolution (B)
+%	K=3 => low resolution Lo1->IF2; Lo2->IF1 (C)
+% 	K=4 => low resolution Lo1->IF1; Lo2->IF2 (D)
+%
+%	L=0  	=> calibration
+%	L=1	=> Z=0
+%	L=2	=> Z=0.21 cm
+
+mdsopen('tcv_shot',shot)
+Cntrl1= mdsdata('\vsystem::tcv_publicdb_b["ECE:PIO_D0"]');
+Cntrl2= mdsdata('\vsystem::tcv_publicdb_b["ECE:PIO_D1"]');
+Sw1= mdsdata('\vsystem::tcv_publicdb_b["ECE:PIO_D2"]');
+Sw2= mdsdata('\vsystem::tcv_publicdb_b["ECE:PIO_D3"]');
+Att= mdsdata('\vsystem::tcv_publicdb_i["ECE:PIO_GAIN_2_IN"]');
+mdsclose
+
+if mode==0
+i=[1,2];
+
+if strcmp(Cntrl1(i),'ON')
+L=2;
+disp('ligne de visee Z = 21.3 cm')
+else
+if strcmp(Cntrl2(i),'ON')
+L=1;
+disp('ligne de visee Z=0')
+else
+L=0;
+disp('Calibration')
+end
+end
+
+if strcmp(Sw1(i),'ON') 
+ if strcmp(Sw2(i),'ON') 
+  K=2;
+  disp('Configuration B')
+ else
+  K=3;
+  disp('Configuration C')
+ end
+else
+ if strcmp(Sw2(i),'ON') 
+  K=4;
+  disp('Configuration D')
+ else
+  K=1;
+  disp('Configuration A')
+ end
+end
+disp(['Attenuation level = ',num2str(Att),' '])
+else
+i=[1,2];
+if strcmp(Cntrl1(i),'ON')
+L=2;
+else
+if strcmp(Cntrl2(i),'ON')
+L=1;
+else
+L=0;
+end
+end
+
+if strcmp(Sw1(i),'ON') 
+ if strcmp(Sw2(i),'ON') 
+  K=2;
+ else
+  K=3;
+ end
+else
+ if strcmp(Sw2(i),'ON') 
+  K=4;
+ else
+  K=1;
+ end
+end
+
+end
diff --git a/TCV/private/ece_mode.m b/TCV/private/ece_mode.m
new file mode 100755
index 0000000000000000000000000000000000000000..fd8a20f24d131bc87e8a9da52789cf2dc64004f6
--- /dev/null
+++ b/TCV/private/ece_mode.m
@@ -0,0 +1,99 @@
+function [Fcentral, Rcentral,No]=ece_mode(K,B)
+
+%	function [Fcentral, Rcentral,No]=ece_mode(K,B)
+%
+%	Programme calculant les frequences centrales, et la disposition 
+%	spatiale relative a ces frequences pour chaques cannaux dans les quatres 
+%	configurations possibles du radiometre ECE
+%
+%	K=1 => haute resol bord (8a)
+%	K=2 => haute resol centre (8b)
+%	K=3 => basse resolution Lo1->IF2; Lo2->IF1 (8c)
+%	K=4 => basse resolution Lo1->IF1; Lo2->IF2 (8d)
+%	B=champs magnetique
+%
+%	Fcentral = frequence centrale de chaque cannaux
+%	Rcentral = position selon R de l'emission a la frequence Fcentral
+%	No	 = correspondance Fcentral -> cannaux de l'ECE
+%
+%	Voir ece_conf.m
+
+%[Lo1,Lo2,cann1,cann2,cann,del,No1,No2]=ece_lo;
+Lo1=76.475;
+Lo2=94.475;
+cann1=[2.375:1.5:18.875]';
+No1=fliplr([1:12])';
+cann2=[3.125:1.5:19.625]';
+No2=([13:24]');
+cann=[2.375:0.75:19.625]'; 
+del=0.75;
+% introduce const constants from /mac/blanchard/matlab5/ece/public/const.m
+
+%	CONST.M
+%
+%	Constante physique						
+%									
+%	q, e, k, me, mp, h, hbar, c, epsilon0, mu0, G, Na
+%
+%	Unites SI
+%	Blanchard 07.97
+q=1.6022e-19;				% [C]
+e=1.6022e-19;				% [C]
+k=1.3807e-23;				% [J/K]
+me=9.1094e-31;				% [kg]
+mp=1.6726e-27;				% [kg]
+h=6.6261e-34;				% [Js]
+hbar=h/2/pi;				% [Js]
+c=2.9979e8;				% [m/s]
+epsilon0=8.8542e-12;			% [F/m]
+mu0=4e-7*pi;				% [H/m]
+G=6.6726e-11;				% [m^3/kg/s^2]
+Na=6.0221e23;				% [1/mol]
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%
+%       Programme donnant les parametres importants de TCV
+%       R0=Grand rayon
+%       eptuile = distance paroi-bord tuile cote chambre
+%       a=distance centre-bord tuile
+R0=0.88;
+eptuile=0.024;
+a=0.56/2-eptuile;
+
+if K == 1
+	F=cann;
+	Fcentral=cann+Lo2;
+	Rcentral=2*e*R0/me*(1./Fcentral)*B/1e9/2/pi;
+	%Wce_central=2*e*R0*(1./Rcentral)*B/me;
+	No=[cann2+Lo2,No2];
+	No(13:24,:)=[cann1+Lo2,No1];
+	[No]=sortrows(No,1); 
+elseif K == 2
+	F=cann;
+	Fcentral=cann+Lo1;
+	Rcentral=2*e*R0/me*(1./Fcentral)*B/1e9/2/pi;
+	%Wce_central=2*e*R0.*(1./Rcentral)*B/me;
+	No=[cann2+Lo1,No2];
+	No(13:24,:)=[cann1+Lo1,No1];
+	[No]=sortrows(No,1); 
+elseif K == 3
+	F=cann1;
+	F(length(cann1)+1:length(cann1)+length(cann2))=cann2;
+	Fcentral=cann2+Lo1;
+	Fcentral(length(cann1)+1:length(cann1)+length(cann2))=cann1+Lo2;
+	Rcentral=2*e*R0/me*(1./Fcentral)*B/1e9/2/pi;
+	%Wce_central=2*e*R0.*(1./Rcentral)*B/me;
+	No=[cann1+Lo2,No1];
+	No(13:24,:)=[cann2+Lo1,No2];
+	[No]=sortrows(No,1); 
+elseif K == 4
+	F=cann1;
+	F(length(cann1)+1:length(cann1)+length(cann2))=cann2;
+	Fcentral=cann1+Lo1;
+	Fcentral(length(cann1)+1:length(cann1)+length(cann2))=cann2+Lo2;
+	Rcentral=2*e*R0/me*(1./Fcentral)*B/1e9/2/pi;
+	%Wce_central=2*e*R0.*(1./Rcentral)*B/me;
+	No=[cann1+Lo1,No1];
+	No(13:24,:)=[cann2+Lo2,No2];
+	[No]=sortrows(No,1); 
+end
diff --git a/TCV/private/ece_raw_signals.m b/TCV/private/ece_raw_signals.m
new file mode 100755
index 0000000000000000000000000000000000000000..663ee5222045f6ee550dc4208dc86c89f14a782e
--- /dev/null
+++ b/TCV/private/ece_raw_signals.m
@@ -0,0 +1,408 @@
+function [ECE,Tece,Fcentral]=ece_raw_signals(shot,T,SS);
+
+%	function [ECE,Tece,Fcentral]=ece_raw_signals(shot,T,SS);
+%	
+%	Programme donnant les signaux ECE [V] non corriges par les 
+%	calibrations, pour le vecteur temporel T ou pour un sous 
+%	echantillonage SS
+%
+%	shot 	= no de tir a analyser
+%	T	= soit 
+%		-vecteur temporel croissant
+%		-si T=10 => tout les temps seront cherches
+%		-si T=[a b];=> a et b sont les bornes temporelles
+%	SS > 1 	=> sous echantillonage de facteur SS si T=10 ou T=[a b]
+%	Les 24 lignes de ECE correspondent aux frequences d'emissions
+%	classees par ordre croissant de frequence d'emission.
+%
+%	Blanchard  10.02.2000
+
+%------------------------------------------------------------------------------
+%	INFORMATION
+%
+%	Pour toutes les matrices, on aura la convention suivante:
+%	Les signaux temporels des 24 cannaux seront les 24 lignes,
+%------------------------------------------------------------------------------
+if shot>=20055
+
+	[K,L]=ece_conf(shot,1);
+	ece_d;
+	[Fcentral, Rcentral,No]=ece_mode(K,1.5);
+	[t,i1,i2]=common_ece(No(:,1),D(:,1));
+	D=D(i2,:);[D]=sortrows(D,1);
+	E=D(:,2);E(:,2)=[1:24]';[E]=sortrows(E,1);
+
+	%------------------------------------------------------------------------------
+	%	Appel des valeurs dans MDS
+	%	La matrice ECE a 24 lignes correspondant aux 24 cannaux
+	%	
+	%	La matrice est classee par ordre croissant des frequences cesntrales
+	%	des divers cannaux
+	%------------------------------------------------------------------------------
+	if length(T)==2
+	   mdsopen('tcv_shot',shot)
+	   Tece=mdsdata('dim_of(\atlas::dt100_northwest_001:channel_012)');   
+
+	   X=[1:SS:length(Tece)]';
+	   Tece=Tece(X);clear X
+
+	   del=Tece(2)-Tece(1);
+	   NN=Tece(1:max(find(Tece<0))); 
+	   N=find(Tece>=T(1) & Tece<=T(2));
+	   Tece=Tece(N); 
+	   ECE=zeros(length(Tece),24);
+	   ECE(:,E(1,2))=mdsdata('\atlas::dt100_northwest_001:channel_012[$]',Tece);
+	   ECE(:,E(2,2))=mdsdata('\atlas::dt100_northwest_001:channel_011[$]',Tece);
+	   ECE(:,E(3,2))=mdsdata('\atlas::dt100_northwest_001:channel_010[$]',Tece);
+	   ECE(:,E(4,2))=mdsdata('\atlas::dt100_northwest_001:channel_009[$]',Tece);
+	   ECE(:,E(5,2))=mdsdata('\atlas::dt100_northwest_001:channel_008[$]',Tece);
+	   ECE(:,E(6,2))=mdsdata('\atlas::dt100_northwest_001:channel_007[$]',Tece);
+	   ECE(:,E(7,2))=mdsdata('\atlas::dt100_northwest_001:channel_006[$]',Tece);
+	   ECE(:,E(8,2))=mdsdata('\atlas::dt100_northwest_001:channel_005[$]',Tece);
+	   ECE(:,E(9,2))=mdsdata('\atlas::dt100_northwest_001:channel_004[$]',Tece);
+	   ECE(:,E(10,2))=mdsdata('\atlas::dt100_northwest_001:channel_003[$]',Tece);
+	   ECE(:,E(11,2))=mdsdata('\atlas::dt100_northwest_001:channel_002[$]',Tece);
+	   ECE(:,E(12,2))=mdsdata('\atlas::dt100_northwest_001:channel_001[$]',Tece);
+	   ECE(:,E(13,2))=mdsdata('\atlas::dt100_northwest_001:channel_017[$]',Tece);
+	   ECE(:,E(14,2))=mdsdata('\atlas::dt100_northwest_001:channel_018[$]',Tece);
+	   ECE(:,E(15,2))=mdsdata('\atlas::dt100_northwest_001:channel_019[$]',Tece);
+	   ECE(:,E(16,2))=mdsdata('\atlas::dt100_northwest_001:channel_020[$]',Tece);
+	   ECE(:,E(17,2))=mdsdata('\atlas::dt100_northwest_001:channel_021[$]',Tece);
+	   ECE(:,E(18,2))=mdsdata('\atlas::dt100_northwest_001:channel_022[$]',Tece);
+	   ECE(:,E(19,2))=mdsdata('\atlas::dt100_northwest_001:channel_023[$]',Tece);
+	   ECE(:,E(20,2))=mdsdata('\atlas::dt100_northwest_001:channel_024[$]',Tece);
+	   ECE(:,E(21,2))=mdsdata('\atlas::dt100_northwest_001:channel_025[$]',Tece);
+	   ECE(:,E(22,2))=mdsdata('\atlas::dt100_northwest_001:channel_026[$]',Tece);
+	   ECE(:,E(23,2))=mdsdata('\atlas::dt100_northwest_001:channel_027[$]',Tece);
+	   ECE(:,E(24,2))=mdsdata('\atlas::dt100_northwest_001:channel_028[$]',Tece);
+	   M=zeros(length(NN),24);
+	   M(:,E(1,2))=mdsdata('\atlas::dt100_northwest_001:channel_012[$]',NN);
+	   M(:,E(2,2))=mdsdata('\atlas::dt100_northwest_001:channel_011[$]',NN);
+	   M(:,E(3,2))=mdsdata('\atlas::dt100_northwest_001:channel_010[$]',NN);
+	   M(:,E(4,2))=mdsdata('\atlas::dt100_northwest_001:channel_009[$]',NN);
+	   M(:,E(5,2))=mdsdata('\atlas::dt100_northwest_001:channel_008[$]',NN);
+	   M(:,E(6,2))=mdsdata('\atlas::dt100_northwest_001:channel_007[$]',NN);
+	   M(:,E(7,2))=mdsdata('\atlas::dt100_northwest_001:channel_006[$]',NN);
+	   M(:,E(8,2))=mdsdata('\atlas::dt100_northwest_001:channel_005[$]',NN);
+	   M(:,E(9,2))=mdsdata('\atlas::dt100_northwest_001:channel_004[$]',NN);
+	   M(:,E(10,2))=mdsdata('\atlas::dt100_northwest_001:channel_003[$]',NN);
+	   M(:,E(11,2))=mdsdata('\atlas::dt100_northwest_001:channel_002[$]',NN);
+	   M(:,E(12,2))=mdsdata('\atlas::dt100_northwest_001:channel_001[$]',NN);
+	   M(:,E(13,2))=mdsdata('\atlas::dt100_northwest_001:channel_017[$]',NN);
+	   M(:,E(14,2))=mdsdata('\atlas::dt100_northwest_001:channel_018[$]',NN);
+	   M(:,E(15,2))=mdsdata('\atlas::dt100_northwest_001:channel_019[$]',NN);
+	   M(:,E(16,2))=mdsdata('\atlas::dt100_northwest_001:channel_020[$]',NN);
+	   M(:,E(17,2))=mdsdata('\atlas::dt100_northwest_001:channel_021[$]',NN);
+	   M(:,E(18,2))=mdsdata('\atlas::dt100_northwest_001:channel_022[$]',NN);
+	   M(:,E(19,2))=mdsdata('\atlas::dt100_northwest_001:channel_023[$]',NN);
+	   M(:,E(20,2))=mdsdata('\atlas::dt100_northwest_001:channel_024[$]',NN);
+	   M(:,E(21,2))=mdsdata('\atlas::dt100_northwest_001:channel_025[$]',NN);
+	   M(:,E(22,2))=mdsdata('\atlas::dt100_northwest_001:channel_026[$]',NN);
+	   M(:,E(23,2))=mdsdata('\atlas::dt100_northwest_001:channel_027[$]',NN);
+	   M(:,E(24,2))=mdsdata('\atlas::dt100_northwest_001:channel_028[$]',NN);
+	   mdsclose
+	   N=min(find(Tece>0-del&Tece<0+del));
+	   M=mean(M);
+	   ECE=ECE-repmat(M,length(Tece),1);
+
+	elseif T==10
+	   mdsopen('tcv_shot',shot)
+	   Tece=mdsdata('dim_of(\atlas::dt100_northwest_001:channel_012)');   
+
+	   X=[1:SS:length(Tece)]';
+	   Tece=Tece(X);clear X
+
+	   ECE=zeros(length(Tece),24);
+	   ECE(:,E(1,2))=mdsdata('\atlas::dt100_northwest_001:channel_012[$]',Tece);
+	   ECE(:,E(2,2))=mdsdata('\atlas::dt100_northwest_001:channel_011[$]',Tece);
+	   ECE(:,E(3,2))=mdsdata('\atlas::dt100_northwest_001:channel_010[$]',Tece);
+	   ECE(:,E(4,2))=mdsdata('\atlas::dt100_northwest_001:channel_009[$]',Tece);
+	   ECE(:,E(5,2))=mdsdata('\atlas::dt100_northwest_001:channel_008[$]',Tece);
+	   ECE(:,E(6,2))=mdsdata('\atlas::dt100_northwest_001:channel_007[$]',Tece);
+	   ECE(:,E(7,2))=mdsdata('\atlas::dt100_northwest_001:channel_006[$]',Tece);
+	   ECE(:,E(8,2))=mdsdata('\atlas::dt100_northwest_001:channel_005[$]',Tece);
+	   ECE(:,E(9,2))=mdsdata('\atlas::dt100_northwest_001:channel_004[$]',Tece);
+	   ECE(:,E(10,2))=mdsdata('\atlas::dt100_northwest_001:channel_003[$]',Tece);
+	   ECE(:,E(11,2))=mdsdata('\atlas::dt100_northwest_001:channel_002[$]',Tece);
+	   ECE(:,E(12,2))=mdsdata('\atlas::dt100_northwest_001:channel_001[$]',Tece);
+	   ECE(:,E(13,2))=mdsdata('\atlas::dt100_northwest_001:channel_017[$]',Tece);
+	   ECE(:,E(14,2))=mdsdata('\atlas::dt100_northwest_001:channel_018[$]',Tece);
+	   ECE(:,E(15,2))=mdsdata('\atlas::dt100_northwest_001:channel_019[$]',Tece);
+	   ECE(:,E(16,2))=mdsdata('\atlas::dt100_northwest_001:channel_020[$]',Tece);
+	   ECE(:,E(17,2))=mdsdata('\atlas::dt100_northwest_001:channel_021[$]',Tece);
+	   ECE(:,E(18,2))=mdsdata('\atlas::dt100_northwest_001:channel_022[$]',Tece);
+	   ECE(:,E(19,2))=mdsdata('\atlas::dt100_northwest_001:channel_023[$]',Tece);
+	   ECE(:,E(20,2))=mdsdata('\atlas::dt100_northwest_001:channel_024[$]',Tece);
+	   ECE(:,E(21,2))=mdsdata('\atlas::dt100_northwest_001:channel_025[$]',Tece);
+	   ECE(:,E(22,2))=mdsdata('\atlas::dt100_northwest_001:channel_026[$]',Tece);
+	   ECE(:,E(23,2))=mdsdata('\atlas::dt100_northwest_001:channel_027[$]',Tece);
+	   ECE(:,E(24,2))=mdsdata('\atlas::dt100_northwest_001:channel_028[$]',Tece);
+	   mdsclose
+	   del=Tece(2)-Tece(1);
+	   N=min(find(Tece>0-del&Tece<0+del));
+	   M=mean(ECE([1:N],:));
+	   ECE=ECE-repmat(M,length(Tece),1);
+
+	elseif T~=10 | length(T)>2
+	   mdsopen('tcv_shot',shot)
+	   Tece=mdsdata('dim_of(\atlas::dt100_northwest_001:channel_012)');   
+	   
+	   NN=Tece(1:max(find(Tece<0))); 
+	   Tece=mdsdata('dim_of(\atlas::dt100_northwest_001:channel_012[$])',T);
+	   ECE=zeros(length(Tece),24);
+	   ECE(:,E(1,2))=mdsdata('\atlas::dt100_northwest_001:channel_012[$]',T);
+	   ECE(:,E(2,2))=mdsdata('\atlas::dt100_northwest_001:channel_011[$]',T);
+	   ECE(:,E(3,2))=mdsdata('\atlas::dt100_northwest_001:channel_010[$]',T);
+	   ECE(:,E(4,2))=mdsdata('\atlas::dt100_northwest_001:channel_009[$]',T);
+	   ECE(:,E(5,2))=mdsdata('\atlas::dt100_northwest_001:channel_008[$]',T);
+	   ECE(:,E(6,2))=mdsdata('\atlas::dt100_northwest_001:channel_007[$]',T);
+	   ECE(:,E(7,2))=mdsdata('\atlas::dt100_northwest_001:channel_006[$]',T);
+	   ECE(:,E(8,2))=mdsdata('\atlas::dt100_northwest_001:channel_005[$]',T);
+	   ECE(:,E(9,2))=mdsdata('\atlas::dt100_northwest_001:channel_004[$]',T);
+	   ECE(:,E(10,2))=mdsdata('\atlas::dt100_northwest_001:channel_003[$]',T);
+	   ECE(:,E(11,2))=mdsdata('\atlas::dt100_northwest_001:channel_002[$]',T);
+	   ECE(:,E(12,2))=mdsdata('\atlas::dt100_northwest_001:channel_001[$]',T);
+	   ECE(:,E(13,2))=mdsdata('\atlas::dt100_northwest_001:channel_017[$]',T);
+	   ECE(:,E(14,2))=mdsdata('\atlas::dt100_northwest_001:channel_018[$]',T);
+	   ECE(:,E(15,2))=mdsdata('\atlas::dt100_northwest_001:channel_019[$]',T);
+	   ECE(:,E(16,2))=mdsdata('\atlas::dt100_northwest_001:channel_020[$]',T);
+	   ECE(:,E(17,2))=mdsdata('\atlas::dt100_northwest_001:channel_021[$]',T);
+	   ECE(:,E(18,2))=mdsdata('\atlas::dt100_northwest_001:channel_022[$]',T);
+	   ECE(:,E(19,2))=mdsdata('\atlas::dt100_northwest_001:channel_023[$]',T);
+	   ECE(:,E(20,2))=mdsdata('\atlas::dt100_northwest_001:channel_024[$]',T);
+	   ECE(:,E(21,2))=mdsdata('\atlas::dt100_northwest_001:channel_025[$]',T);
+	   ECE(:,E(22,2))=mdsdata('\atlas::dt100_northwest_001:channel_026[$]',T);
+	   ECE(:,E(23,2))=mdsdata('\atlas::dt100_northwest_001:channel_027[$]',T);
+	   ECE(:,E(24,2))=mdsdata('\atlas::dt100_northwest_001:channel_028[$]',T);
+	   M=zeros(length(NN),24);
+	   M(:,E(1,2))=mdsdata('\atlas::dt100_northwest_001:channel_012[$]',NN);
+	   M(:,E(2,2))=mdsdata('\atlas::dt100_northwest_001:channel_011[$]',NN);
+	   M(:,E(3,2))=mdsdata('\atlas::dt100_northwest_001:channel_010[$]',NN);
+	   M(:,E(4,2))=mdsdata('\atlas::dt100_northwest_001:channel_009[$]',NN);
+	   M(:,E(5,2))=mdsdata('\atlas::dt100_northwest_001:channel_008[$]',NN);
+	   M(:,E(6,2))=mdsdata('\atlas::dt100_northwest_001:channel_007[$]',NN);
+	   M(:,E(7,2))=mdsdata('\atlas::dt100_northwest_001:channel_006[$]',NN);
+	   M(:,E(8,2))=mdsdata('\atlas::dt100_northwest_001:channel_005[$]',NN);
+	   M(:,E(9,2))=mdsdata('\atlas::dt100_northwest_001:channel_004[$]',NN);
+	   M(:,E(10,2))=mdsdata('\atlas::dt100_northwest_001:channel_003[$]',NN);
+	   M(:,E(11,2))=mdsdata('\atlas::dt100_northwest_001:channel_002[$]',NN);
+	   M(:,E(12,2))=mdsdata('\atlas::dt100_northwest_001:channel_001[$]',NN);
+	   M(:,E(13,2))=mdsdata('\atlas::dt100_northwest_001:channel_017[$]',NN);
+	   M(:,E(14,2))=mdsdata('\atlas::dt100_northwest_001:channel_018[$]',NN);
+	   M(:,E(15,2))=mdsdata('\atlas::dt100_northwest_001:channel_019[$]',NN);
+	   M(:,E(16,2))=mdsdata('\atlas::dt100_northwest_001:channel_020[$]',NN);
+	   M(:,E(17,2))=mdsdata('\atlas::dt100_northwest_001:channel_021[$]',NN);
+	   M(:,E(18,2))=mdsdata('\atlas::dt100_northwest_001:channel_022[$]',NN);
+	   M(:,E(19,2))=mdsdata('\atlas::dt100_northwest_001:channel_023[$]',NN);
+	   M(:,E(20,2))=mdsdata('\atlas::dt100_northwest_001:channel_024[$]',NN);
+	   M(:,E(21,2))=mdsdata('\atlas::dt100_northwest_001:channel_025[$]',NN);
+	   M(:,E(22,2))=mdsdata('\atlas::dt100_northwest_001:channel_026[$]',NN);
+	   M(:,E(23,2))=mdsdata('\atlas::dt100_northwest_001:channel_027[$]',NN);
+	   M(:,E(24,2))=mdsdata('\atlas::dt100_northwest_001:channel_028[$]',NN);
+	   mdsclose
+	   M=mean(M);
+	   ECE=ECE-repmat(M,length(Tece),1);
+	% SS=0;
+	end
+	%------------------------------------------------------------------------------
+	%	Correction des mauvais cannaux : met les cannaux non-existant a NaN
+	%------------------------------------------------------------------------------
+	[N]=ece_bad_channels(shot);
+	disp(['Pour le shot # ',num2str(shot),' les cannaux ECE qui ne vont pas sont: ',num2str(N)])
+	%N=input('Introduire les cannaux qui ne vont pas')
+	[t,i1,i2,i3,i4,i5,i6]=common_ece(E(N,2),[1:24]);
+	ECE=ECE(:,i5);Fcentral=Fcentral(i5);
+
+else
+
+	[K,L]=ece_conf(shot,1);
+	ece_d;
+	[Fcentral, Rcentral,No]=ece_mode(K,1.5);
+	[t,i1,i2]=common_ece(No(:,1),D(:,1));
+	D=D(i2,:);[D]=sortrows(D,1);
+	E=D(:,2);E(:,2)=[1:24]';[E]=sortrows(E,1);
+
+	%------------------------------------------------------------------------------
+	%	Appel des valeurs dans MDS
+	%	La matrice ECE a 24 lignes correspondant aux 24 cannaux
+	%	
+	%	La matrice est classee par ordre croissant des frequences cesntrales
+	%	des divers cannaux
+	%------------------------------------------------------------------------------
+	if length(T)==2
+	   mdsopen('tcv_shot',shot)
+	   Tece=mdsdata('\atlas::dt100_003:fast:time');
+	   
+	   X=[1:SS:length(Tece)]';
+	   Tece=Tece(X);clear X
+
+	   del=Tece(2)-Tece(1);
+	   NN=Tece(1:max(find(Tece<0))); 
+	   N=find(Tece>=T(1) & Tece<=T(2));
+	   Tece=Tece(N); 
+	   ECE=zeros(length(Tece),24);
+	   ECE(:,E(1,2))=mdsdata('\atlas::dt100_003:fast:channel_012[$]',Tece);
+	   ECE(:,E(2,2))=mdsdata('\atlas::dt100_003:fast:channel_011[$]',Tece);
+	   ECE(:,E(3,2))=mdsdata('\atlas::dt100_003:fast:channel_010[$]',Tece);
+	   ECE(:,E(4,2))=mdsdata('\atlas::dt100_003:fast:channel_009[$]',Tece);
+	   ECE(:,E(5,2))=mdsdata('\atlas::dt100_003:fast:channel_008[$]',Tece);
+	   ECE(:,E(6,2))=mdsdata('\atlas::dt100_003:fast:channel_007[$]',Tece);
+	   ECE(:,E(7,2))=mdsdata('\atlas::dt100_003:fast:channel_006[$]',Tece);
+	   ECE(:,E(8,2))=mdsdata('\atlas::dt100_003:fast:channel_005[$]',Tece);
+	   ECE(:,E(9,2))=mdsdata('\atlas::dt100_003:fast:channel_004[$]',Tece);
+	   ECE(:,E(10,2))=mdsdata('\atlas::dt100_003:fast:channel_003[$]',Tece);
+	   ECE(:,E(11,2))=mdsdata('\atlas::dt100_003:fast:channel_002[$]',Tece);
+	   ECE(:,E(12,2))=mdsdata('\atlas::dt100_003:fast:channel_001[$]',Tece);
+	   ECE(:,E(13,2))=mdsdata('\atlas::dt100_003:fast:channel_017[$]',Tece);
+	   ECE(:,E(14,2))=mdsdata('\atlas::dt100_003:fast:channel_018[$]',Tece);
+	   ECE(:,E(15,2))=mdsdata('\atlas::dt100_003:fast:channel_019[$]',Tece);
+	   ECE(:,E(16,2))=mdsdata('\atlas::dt100_003:fast:channel_020[$]',Tece);
+	   ECE(:,E(17,2))=mdsdata('\atlas::dt100_003:fast:channel_021[$]',Tece);
+	   ECE(:,E(18,2))=mdsdata('\atlas::dt100_003:fast:channel_022[$]',Tece);
+	   ECE(:,E(19,2))=mdsdata('\atlas::dt100_003:fast:channel_023[$]',Tece);
+	   ECE(:,E(20,2))=mdsdata('\atlas::dt100_003:fast:channel_024[$]',Tece);
+	   ECE(:,E(21,2))=mdsdata('\atlas::dt100_003:fast:channel_025[$]',Tece);
+	   ECE(:,E(22,2))=mdsdata('\atlas::dt100_003:fast:channel_026[$]',Tece);
+	   ECE(:,E(23,2))=mdsdata('\atlas::dt100_003:fast:channel_027[$]',Tece);
+	   ECE(:,E(24,2))=mdsdata('\atlas::dt100_003:fast:channel_028[$]',Tece);
+	   M=zeros(length(NN),24);
+	   M(:,E(1,2))=mdsdata('\atlas::dt100_003:fast:channel_012[$]',NN);
+	   M(:,E(2,2))=mdsdata('\atlas::dt100_003:fast:channel_011[$]',NN);
+	   M(:,E(3,2))=mdsdata('\atlas::dt100_003:fast:channel_010[$]',NN);
+	   M(:,E(4,2))=mdsdata('\atlas::dt100_003:fast:channel_009[$]',NN);
+	   M(:,E(5,2))=mdsdata('\atlas::dt100_003:fast:channel_008[$]',NN);
+	   M(:,E(6,2))=mdsdata('\atlas::dt100_003:fast:channel_007[$]',NN);
+	   M(:,E(7,2))=mdsdata('\atlas::dt100_003:fast:channel_006[$]',NN);
+	   M(:,E(8,2))=mdsdata('\atlas::dt100_003:fast:channel_005[$]',NN);
+	   M(:,E(9,2))=mdsdata('\atlas::dt100_003:fast:channel_004[$]',NN);
+	   M(:,E(10,2))=mdsdata('\atlas::dt100_003:fast:channel_003[$]',NN);
+	   M(:,E(11,2))=mdsdata('\atlas::dt100_003:fast:channel_002[$]',NN);
+	   M(:,E(12,2))=mdsdata('\atlas::dt100_003:fast:channel_001[$]',NN);
+	   M(:,E(13,2))=mdsdata('\atlas::dt100_003:fast:channel_017[$]',NN);
+	   M(:,E(14,2))=mdsdata('\atlas::dt100_003:fast:channel_018[$]',NN);
+	   M(:,E(15,2))=mdsdata('\atlas::dt100_003:fast:channel_019[$]',NN);
+	   M(:,E(16,2))=mdsdata('\atlas::dt100_003:fast:channel_020[$]',NN);
+	   M(:,E(17,2))=mdsdata('\atlas::dt100_003:fast:channel_021[$]',NN);
+	   M(:,E(18,2))=mdsdata('\atlas::dt100_003:fast:channel_022[$]',NN);
+	   M(:,E(19,2))=mdsdata('\atlas::dt100_003:fast:channel_023[$]',NN);
+	   M(:,E(20,2))=mdsdata('\atlas::dt100_003:fast:channel_024[$]',NN);
+	   M(:,E(21,2))=mdsdata('\atlas::dt100_003:fast:channel_025[$]',NN);
+	   M(:,E(22,2))=mdsdata('\atlas::dt100_003:fast:channel_026[$]',NN);
+	   M(:,E(23,2))=mdsdata('\atlas::dt100_003:fast:channel_027[$]',NN);
+	   M(:,E(24,2))=mdsdata('\atlas::dt100_003:fast:channel_028[$]',NN);
+	   mdsclose
+	   N=min(find(Tece>0-del&Tece<0+del));
+	   M=mean(M);
+	   ECE=ECE-repmat(M,length(Tece),1);
+
+	elseif T==10
+	   mdsopen('tcv_shot',shot)
+	   Tece=mdsdata('\atlas::dt100_003:fast:time');
+
+	   X=[1:SS:length(Tece)]';
+	   Tece=Tece(X);clear X
+
+	   ECE=zeros(length(Tece),24);
+	   ECE(:,E(1,2))=mdsdata('\atlas::dt100_003:fast:channel_012[$]',Tece);
+	   ECE(:,E(2,2))=mdsdata('\atlas::dt100_003:fast:channel_011[$]',Tece);
+	   ECE(:,E(3,2))=mdsdata('\atlas::dt100_003:fast:channel_010[$]',Tece);
+	   ECE(:,E(4,2))=mdsdata('\atlas::dt100_003:fast:channel_009[$]',Tece);
+	   ECE(:,E(5,2))=mdsdata('\atlas::dt100_003:fast:channel_008[$]',Tece);
+	   ECE(:,E(6,2))=mdsdata('\atlas::dt100_003:fast:channel_007[$]',Tece);
+	   ECE(:,E(7,2))=mdsdata('\atlas::dt100_003:fast:channel_006[$]',Tece);
+	   ECE(:,E(8,2))=mdsdata('\atlas::dt100_003:fast:channel_005[$]',Tece);
+	   ECE(:,E(9,2))=mdsdata('\atlas::dt100_003:fast:channel_004[$]',Tece);
+	   ECE(:,E(10,2))=mdsdata('\atlas::dt100_003:fast:channel_003[$]',Tece);
+	   ECE(:,E(11,2))=mdsdata('\atlas::dt100_003:fast:channel_002[$]',Tece);
+	   ECE(:,E(12,2))=mdsdata('\atlas::dt100_003:fast:channel_001[$]',Tece);
+	   ECE(:,E(13,2))=mdsdata('\atlas::dt100_003:fast:channel_017[$]',Tece);
+	   ECE(:,E(14,2))=mdsdata('\atlas::dt100_003:fast:channel_018[$]',Tece);
+	   ECE(:,E(15,2))=mdsdata('\atlas::dt100_003:fast:channel_019[$]',Tece);
+	   ECE(:,E(16,2))=mdsdata('\atlas::dt100_003:fast:channel_020[$]',Tece);
+	   ECE(:,E(17,2))=mdsdata('\atlas::dt100_003:fast:channel_021[$]',Tece);
+	   ECE(:,E(18,2))=mdsdata('\atlas::dt100_003:fast:channel_022[$]',Tece);
+	   ECE(:,E(19,2))=mdsdata('\atlas::dt100_003:fast:channel_023[$]',Tece);
+	   ECE(:,E(20,2))=mdsdata('\atlas::dt100_003:fast:channel_024[$]',Tece);
+	   ECE(:,E(21,2))=mdsdata('\atlas::dt100_003:fast:channel_025[$]',Tece);
+	   ECE(:,E(22,2))=mdsdata('\atlas::dt100_003:fast:channel_026[$]',Tece);
+	   ECE(:,E(23,2))=mdsdata('\atlas::dt100_003:fast:channel_027[$]',Tece);
+	   ECE(:,E(24,2))=mdsdata('\atlas::dt100_003:fast:channel_028[$]',Tece);
+	   mdsclose
+	   del=Tece(2)-Tece(1);
+	   N=min(find(Tece>0-del&Tece<0+del));
+	   M=mean(ECE([1:N],:));
+	   ECE=ECE-repmat(M,length(Tece),1);
+
+	elseif T~=10 | length(T)>2
+	   mdsopen('tcv_shot',shot)
+	   Tece=mdsdata('\atlas::dt100_003:fast:time');
+	   NN=Tece(1:max(find(Tece<0))); 
+	   Tece=mdsdata('dim_of(\atlas::dt100_003:fast:channel_012[$])',T);
+	   ECE=zeros(length(Tece),24);
+	   ECE(:,E(1,2))=mdsdata('\atlas::dt100_003:fast:channel_012[$]',T);
+	   ECE(:,E(2,2))=mdsdata('\atlas::dt100_003:fast:channel_011[$]',T);
+	   ECE(:,E(3,2))=mdsdata('\atlas::dt100_003:fast:channel_010[$]',T);
+	   ECE(:,E(4,2))=mdsdata('\atlas::dt100_003:fast:channel_009[$]',T);
+	   ECE(:,E(5,2))=mdsdata('\atlas::dt100_003:fast:channel_008[$]',T);
+	   ECE(:,E(6,2))=mdsdata('\atlas::dt100_003:fast:channel_007[$]',T);
+	   ECE(:,E(7,2))=mdsdata('\atlas::dt100_003:fast:channel_006[$]',T);
+	   ECE(:,E(8,2))=mdsdata('\atlas::dt100_003:fast:channel_005[$]',T);
+	   ECE(:,E(9,2))=mdsdata('\atlas::dt100_003:fast:channel_004[$]',T);
+	   ECE(:,E(10,2))=mdsdata('\atlas::dt100_003:fast:channel_003[$]',T);
+	   ECE(:,E(11,2))=mdsdata('\atlas::dt100_003:fast:channel_002[$]',T);
+	   ECE(:,E(12,2))=mdsdata('\atlas::dt100_003:fast:channel_001[$]',T);
+	   ECE(:,E(13,2))=mdsdata('\atlas::dt100_003:fast:channel_017[$]',T);
+	   ECE(:,E(14,2))=mdsdata('\atlas::dt100_003:fast:channel_018[$]',T);
+	   ECE(:,E(15,2))=mdsdata('\atlas::dt100_003:fast:channel_019[$]',T);
+	   ECE(:,E(16,2))=mdsdata('\atlas::dt100_003:fast:channel_020[$]',T);
+	   ECE(:,E(17,2))=mdsdata('\atlas::dt100_003:fast:channel_021[$]',T);
+	   ECE(:,E(18,2))=mdsdata('\atlas::dt100_003:fast:channel_022[$]',T);
+	   ECE(:,E(19,2))=mdsdata('\atlas::dt100_003:fast:channel_023[$]',T);
+	   ECE(:,E(20,2))=mdsdata('\atlas::dt100_003:fast:channel_024[$]',T);
+	   ECE(:,E(21,2))=mdsdata('\atlas::dt100_003:fast:channel_025[$]',T);
+	   ECE(:,E(22,2))=mdsdata('\atlas::dt100_003:fast:channel_026[$]',T);
+	   ECE(:,E(23,2))=mdsdata('\atlas::dt100_003:fast:channel_027[$]',T);
+	   ECE(:,E(24,2))=mdsdata('\atlas::dt100_003:fast:channel_028[$]',T);
+	   M=zeros(length(NN),24);
+	   M(:,E(1,2))=mdsdata('\atlas::dt100_003:fast:channel_012[$]',NN);
+	   M(:,E(2,2))=mdsdata('\atlas::dt100_003:fast:channel_011[$]',NN);
+	   M(:,E(3,2))=mdsdata('\atlas::dt100_003:fast:channel_010[$]',NN);
+	   M(:,E(4,2))=mdsdata('\atlas::dt100_003:fast:channel_009[$]',NN);
+	   M(:,E(5,2))=mdsdata('\atlas::dt100_003:fast:channel_008[$]',NN);
+	   M(:,E(6,2))=mdsdata('\atlas::dt100_003:fast:channel_007[$]',NN);
+	   M(:,E(7,2))=mdsdata('\atlas::dt100_003:fast:channel_006[$]',NN);
+	   M(:,E(8,2))=mdsdata('\atlas::dt100_003:fast:channel_005[$]',NN);
+	   M(:,E(9,2))=mdsdata('\atlas::dt100_003:fast:channel_004[$]',NN);
+	   M(:,E(10,2))=mdsdata('\atlas::dt100_003:fast:channel_003[$]',NN);
+	   M(:,E(11,2))=mdsdata('\atlas::dt100_003:fast:channel_002[$]',NN);
+	   M(:,E(12,2))=mdsdata('\atlas::dt100_003:fast:channel_001[$]',NN);
+	   M(:,E(13,2))=mdsdata('\atlas::dt100_003:fast:channel_017[$]',NN);
+	   M(:,E(14,2))=mdsdata('\atlas::dt100_003:fast:channel_018[$]',NN);
+	   M(:,E(15,2))=mdsdata('\atlas::dt100_003:fast:channel_019[$]',NN);
+	   M(:,E(16,2))=mdsdata('\atlas::dt100_003:fast:channel_020[$]',NN);
+	   M(:,E(17,2))=mdsdata('\atlas::dt100_003:fast:channel_021[$]',NN);
+	   M(:,E(18,2))=mdsdata('\atlas::dt100_003:fast:channel_022[$]',NN);
+	   M(:,E(19,2))=mdsdata('\atlas::dt100_003:fast:channel_023[$]',NN);
+	   M(:,E(20,2))=mdsdata('\atlas::dt100_003:fast:channel_024[$]',NN);
+	   M(:,E(21,2))=mdsdata('\atlas::dt100_003:fast:channel_025[$]',NN);
+	   M(:,E(22,2))=mdsdata('\atlas::dt100_003:fast:channel_026[$]',NN);
+	   M(:,E(23,2))=mdsdata('\atlas::dt100_003:fast:channel_027[$]',NN);
+	   M(:,E(24,2))=mdsdata('\atlas::dt100_003:fast:channel_028[$]',NN);
+	   mdsclose
+	   M=mean(M);
+	   ECE=ECE-repmat(M,length(Tece),1);
+	% SS=0;
+	end
+	%------------------------------------------------------------------------------
+	%	Correction des mauvais cannaux : met les cannaux non-existant a NaN
+	%------------------------------------------------------------------------------
+	[N]=ece_bad_channels(shot);
+	disp(['Pour le shot # ',num2str(shot),' les cannaux ECE qui ne vont pas sont: ',num2str(N)])
+	%N=input('Introduire les cannaux qui ne vont pas')
+	[t,i1,i2,i3,i4,i5,i6]=common_ece(E(N,2),[1:24]);
+	ECE=ECE(:,i5);Fcentral=Fcentral(i5);
+
+
+
+end
+
diff --git a/TCV/private/ece_rho.m b/TCV/private/ece_rho.m
new file mode 100755
index 0000000000000000000000000000000000000000..4ada961ff60d309f4ec5362795ab0081d8ed73ce
--- /dev/null
+++ b/TCV/private/ece_rho.m
@@ -0,0 +1,129 @@
+function [RHO,R,Z,tpsi,Fcentral]=ece_rho(shot,t)
+
+%	[RHO,R,Z,tbtot,Fcentral]=ece_rho(shot,t)
+%
+%	Fonction calculant les rayons normalise rho pour l'ECE
+%	pour tous les temps tpsi de psitbx appartenant a t=[a b]
+%	Si t=10 => tous les temps seront recherche.
+%	Pour le calcul de Btot, on utilise une routine de O.Sauter
+%	intitulee BandBres_allt.m
+%
+%	rho = rayon normalise pour la ligne de visee de l'ECE
+%	R   = Grand rayon du tore correspondant a RHO
+%		
+
+mdsopen('tcv_shot',shot)
+L=mdsdata('GETNCI("\\results::ece:rho","length")');
+LL=mdsdata('GETNCI("\\results::psi_axis:foo","length")');
+mdsclose
+if LL==0
+ disp('----------------------------------')
+ disp('\results::psi_axis not calculated')
+ disp('----------------------------------')
+ return 
+end
+
+[W]=writeece;
+if L==0 | L==28 |W==1
+	disp(' La trace \results::ece:rho est vide ');
+
+	[K,L]=ece_conf(shot,1);
+	if L==1
+	 	Z=0;
+	elseif L==2
+	 	Z=0.21;
+	end
+	[Fcentral,Rcentral,No]=ece_mode(K,1.45); 
+	tt=[0:0.05:3];
+	psi=psitbxtcv(shot,tt,'01');
+	tpsi=psi.psitbxfun.t;
+	if length(t)==2
+		 if min(tpsi)>t(2)
+			  disp('-------------------------------')
+			  disp('No Psitbx for these times')
+			  disp('-------------------------------')
+			  return
+		 end
+	end
+	
+	if length(tpsi)==0
+		 disp('psitbxtcv(shot,tt,''01'') est vide');
+		 return
+	end
+	
+	[Rbtot,Zbtot,BTOT,ttt]=bandbres_allt(shot,tpsi,Fcentral*1e9,2,[]);
+	
+	%-----------------------------------------------------------------
+	%	definition de la ligne de visee en r,z,phi de longueur 50
+	j=50;
+	r=linspace(min(Rcentral)*0.9,max(Rcentral)*1.1,j);
+	rzphiline={r,Z,NaN};
+	GridEceCyl=psitbxgrid('Cylindrical','Grid',rzphiline);%clear R Z rzphiline K L No
+	%-----------------------------------------------------------------
+	%	definition de la grille de psi en rho,theta,phi
+	%psi=psitbxtcv(shot,tbtot,'01');
+	%tpsi=psi.psitbxfun.t; 
+	%GridFluxPsi=psitbxgrid('Flux','Grid','Default',psi);  
+	GridBtotCyl=psitbxgrid('Cylindrical','Grid',{Rbtot,Zbtot,NaN});
+	%-----------------------------------------------------------------
+	%	definition de la ligne de visee en rho,theta,phi
+	GridEcePsi=psitbxg2g(GridEceCyl,'Flux',psi);  
+	%-----------------------------------------------------------------
+	%	Calcul de Btot sur la grille GridFluxPsi
+	%BTOT=reshape(BTOT,41,129,length(tbtot));
+	FTOT=2*1.6022e-19*BTOT/9.1094e-31/2/pi/1e9;clear BTOT Rbtot Zbtot
+	FtotFun=psitbxfun(FTOT,GridBtotCyl,tpsi);clear FTOT
+	%-----------------------------------------------------------------
+	%	Calcul de Ftot sur la grille GridEcePsi
+	FtotLineEcePsi=psitbxf2f(FtotFun,GridEceCyl);   
+	FtotLineEce=FtotLineEcePsi.x; 
+	FtotLineEce(find(isnan(FtotLineEce)))=0;
+	T=repmat(tpsi,1,j)';r=repmat(r,length(tpsi),1)';
+	rho=GridEcePsi.x{1};
+	%error('err')
+	for i=1:length(tpsi)
+	 	jj=find(FtotLineEce(:,i)~=0);
+		R(:,i)=interp1(FtotLineEce(jj,i),r(jj,i),Fcentral);
+		RHO(:,i)=interp1(r(jj,i),rho(jj,1,i),R(:,i));
+        end
+        Z=Z*ones(size(R));
+	if W==2
+		
+       	else
+	       mdsopen('results',shot)   
+	       mdsput('\results::ece:rho',RHO,'f');
+	       mdsput('\results::ece:r',R,'f');
+	       mdsput('\results::ece:z',Z,'f');
+	       mdsput('\results::ece:times',tpsi,'f');
+	       mdsclose
+	       disp('On a remplis les matrices \results::ece:rho,r,z,times')
+	       disp(['Size(RHO) = ',num2str(size(RHO))])
+	end
+       
+else
+      disp('On vas chercher les traces \results::ece:rho,z,r,times dans MDS')
+      mdsopen('results',shot)   
+      RHO=mdsdata('\results::ece:rho');
+      R=mdsdata('\results::ece:r');
+      Z=mdsdata('\results::ece:z');
+      tbtot=mdsdata('\results::ece:times');
+      mdsclose
+      [K,L]=ece_conf(shot,1);
+      [Fcentral, Rcentral,No]=ece_mode(K,1.5);
+      Z=mean(mean(Z))*ones(size(R));
+      tpsi=tbtot;
+end
+
+if t~=10
+	NT=find(tpsi>t(1)-0.005  & tpsi <t(2)+0.005);
+	if isempty(NT)
+		NT=max(find(tpsi<t(2)));
+		disp('Nous n''avons aucun points de T_psi compris dans le vecteur t')
+		disp('Nous avons pris le temps le plus proche')
+	elseif NT(1)==1 & length(NT)~=length(tpsi)
+		NT=[1:max(NT)];
+	elseif length(NT)~=length(tpsi)
+		NT=[min(NT):max(NT)];
+	end
+	RHO=RHO(:,NT);R=R(:,NT);tpsi=tpsi(NT);Z=Z(:,NT);
+end
diff --git a/TCV/private/get_xtomo_gains.m b/TCV/private/get_xtomo_gains.m
new file mode 100755
index 0000000000000000000000000000000000000000..c9c2a2309d08a94368316d061b3fca346e6307e0
--- /dev/null
+++ b/TCV/private/get_xtomo_gains.m
@@ -0,0 +1,87 @@
+function gains = get_xtomo_gains(shot);
+
+%     [gains] = get_xtomo_gains(shot);
+%
+%  emerged from MJD's  XTOMOSEQ/XTOMO_LOAD_GAINS 
+%  purpose: load gains of a certain shot nr. from the database
+%  usage:   'gains' is a row vector containing the gains of 
+%           [array_001(det.1..020), array_002, det. 001...020 etc]
+%
+%
+% This routine works on Matlab5.
+% Original routine for Matlab4 by Anton Mathias.  
+%
+% Last update: 25-08-1999
+%
+%-------------MAC:[FURNO.MATLAB5.XTOMO]----------------------------------
+
+
+
+if nargin~=1
+   shot=0;
+end
+
+
+MAX_DET = 20; 
+
+if isempty(mdsopen('vsystem',shot));
+	  mdsclose
+   info = sprintf('Shot #%.0f not found',shot);
+   return
+end
+
+if shot<=6768
+	% narray =2 for the prototype system only
+	narray=2;
+else
+	narray=10;
+end
+
+
+temp = isempty(mdsdata('_v=\diag2db_i'));
+if temp
+     info = sprintf('Vista database not available for shot #%.0f',shot);
+     mdsclose;
+     return
+end
+
+mdsdata(['_p="_"//translate(text(build_range(1,' int2str(MAX_DET) '),3),"0"," ");']);
+
+G=[];
+info=[];
+for sig=1:narray
+     G=[G, mdsdata(['_s="XTOMO_AMP:' sprintf('%03.0f',sig) '"//_p;_v[_s]'])'];
+end
+
+if isempty(info)
+  info = sprintf('Gains loaded from shot #%.0f',shot);
+else
+  info(1) = '';
+end
+
+disp(info)
+        	
+% G contains log10 of the real gains, so...
+
+gains=(10*ones(size(G))).^G;
+
+% This is the modification after the TCV HSUT down in 1998
+% due to the incorrect insatllation of the camera #2
+if shot>13884  
+	permute=20:-1:1;
+	dummy=gains(21:40);
+	gains(21:40)=dummy(permute);
+end
+
+
+mdsclose
+return
+
+permute=[2,1,4,3,6,5,8,7,10,9,12,11,14,13,16,15,18,17,20,19];
+dummy=gains(181:200);
+gains(181:200)=dummy(permute);
+
+
+	
+
+
diff --git a/TCV/private/thom_rho.m b/TCV/private/thom_rho.m
new file mode 100755
index 0000000000000000000000000000000000000000..e866b767182cc102d706499c53401a50b2741445
--- /dev/null
+++ b/TCV/private/thom_rho.m
@@ -0,0 +1,255 @@
+function [TEthom,NEthom,TEbar,NEbar,Tthom,RHOthom]=thom_rho(shot,mode)
+
+%	[TEthom,NEthom,TEbar,NEbar,Tthom,RHOthom]=thom_rho(shot,mode);
+% 	 	
+%	Fonction calculant le profil de Te et ne provenant de Thomson
+%	en fonction de rho(psi)
+%	mode =	1 => profil fitte \results::th_prof_te
+%		2 => profil brut 2 demi-profil
+%		3 => profil brut 1 demi-profil superieur
+%		4 => profil brut 1 demi-profil inferieur
+%		5 => profil proffit local_time
+%		6 => profil proffit avg_time
+%		7 => profil brut corrige selon z
+%		8 => profil TS_FITDATA
+%		9 => profil TS_RAWDATA
+
+%
+
+if mode ==1
+	mdsopen('tcv_shot',shot)
+	L=mdsdata('GETNCI("\\results::th_prof_te","length")');
+	LL=mdsdata('GETNCI("\\results::thomson:te","length")');
+	if L==0
+	  mdsclose
+	  disp('No Thomson \results::th_prof_te node acquisition')
+	  if LL~=0
+	    disp('but Thomson results::thomson:te node exist!')
+	  end
+	  return 
+	end
+	TEthom=mdsdata('\results::th_prof_te');
+	NEthom=mdsdata('\results::th_prof_ne');
+	Tt=mdsdata('dim_of(\results::th_prof_te)');
+	Tn=mdsdata('dim_of(\results::th_prof_ne)');
+	TEbar=mdsdata('\results::th_prof_te:std_error');
+	NEbar=mdsdata('\results::th_prof_ne:std_error');
+	mdsclose
+	if length(Tt)~=length(Tn)
+	 [t,i1,i2]=common(Tt,Tn);
+	 Tthom=t;TEthom=TEthom(i1,:);NEthom=NEthom(i1,:);
+	 TEbar=TEbar(i1,:);NEbar=NEbar(i1,:);
+	else
+	 Tthom=Tn;
+	end
+	RHOthom=linspace(0,1,41);
+	RHOthom=repmat(RHOthom,length(Tthom),1);
+
+elseif mode >=2 & mode <=4
+
+	mdsopen('tcv_shot',shot)
+	L=mdsdata('GETNCI("\\results::thomson:te","length")');
+	if L==0
+	  mdsclose
+	  disp('No Thomson acquisition')
+	  return 
+	end
+	TEthom=mdsdata('\results::thomson:te');
+	if isstr(TEthom)==1
+	 disp('---------------------------------------')
+	 disp('No data with Thomson')
+	 disp('---------------------------------------')
+	 return
+	end	
+	TEbar=mdsdata('\results::thomson:te:error_bar');
+	NEthom=mdsdata('\results::thomson:ne');
+	NEbar=mdsdata('\results::thomson:ne:error_bar');
+	Tthom=mdsdata('\results::thomson:times');
+	Zthom=mdsdata('\diagz::thomson_set_up:vertical_pos')';
+	Rthom=mdsdata('\diagz::thomson_set_up:radial_pos')'; 
+	Psithom=mdsdata('\results::thomson:psiscatvol');   
+	Psithommax=mdsdata('\results::thomson:psi_max'); 
+	mdsclose
+	Ste=size(TEthom);Spsi=size(Psithom);
+	if Ste(2)~=Spsi(2)
+	 	 disp('ATTENTION: on doit corriger des longueurs car')
+		 disp('TEthom ~= Psithom')
+		 ms=min([Ste(2) Spsi(2)]);
+		 TEbar=TEbar(:,1:ms);NEbar=NEbar(:,1:ms);
+		 TEthom=TEthom(:,1:ms);NEthom=NEthom(:,1:ms);
+		 Rthom=Rthom(1:ms);
+		 Psithom=Psithom(:,1:ms);
+	end
+	
+	LTE=length(find(TEthom==-1));LNE=length(find(NEthom==-1));
+	if LTE>0 | LNE >0
+	  disp(['ATTENTION ',num2str(LTE),' points de mdsdata(''\results::thomson:te'') valent -1']) 
+	  disp(['ATTENTION ',num2str(LNE),' points de mdsdata(''\results::thomson:ne'') valent -1']) 
+	end
+	J=0;
+	if isempty(NEthom)
+	  disp('----------------------')
+	  disp('No Thomson acquisition')
+	  disp('----------------------')
+	  J=1;
+	end
+	if isstr(Psithommax)
+	  disp('----------------------')
+	  disp(Psithommax) 
+	  disp('----------------------')
+	  J=1;
+	end
+	if J==1
+	  return
+	end
+
+	RHOTHOM=sqrt(1-Psithom./repmat(Psithommax,1,length(Zthom)));
+	RHOTHOM(isnan(RHOTHOM))=0; 
+
+	if mode ==2
+	  [RHO,I] = sort(RHOTHOM');
+	  NN=size(RHO);
+	  TEthom=TEthom';TEbar=TEbar';
+	  NEthom=NEthom';NEbar=NEbar';
+	  for j = 1:NN(2)
+	    TE(:,j) = TEthom(I(:,j),j); NE(:,j) = NEthom(I(:,j),j);
+	    TE_bar(:,j) = TEbar(I(:,j),j); NE_bar(:,j) = NEbar(I(:,j),j);
+	  end
+	  TEthom=TE';TEbar=TE_bar';
+	  NEthom=NE';NEbar=NE_bar';
+	  RHOthom=RHO';
+	elseif mode==3
+	  nn=round(mean(mod(find(diff(sign(diff(RHOTHOM')))>0),length(Rthom)-2)))+1;
+	  RHOthom=RHOTHOM(:,[1:nn]);NEthom=NEthom(:,[1:nn]);TEthom=TEthom(:,[1:nn]);
+	  NEbar=NEbar(:,[1:nn]);TEbar=TEbar(:,[1:nn]);
+	  Zthom=Zthom([1:nn]);
+	elseif mode==4
+	  nn=round(mean(mod(find(diff(sign(diff(RHOTHOM')))>0),length(Rthom)-2)))+1;
+	  L=length(RHOTHOM(1,:));
+	  RHOthom=RHOTHOM(:,[nn:L]);NEthom=NEthom(:,[nn:L]);TEthom=TEthom(:,[nn:L]);
+	  NEbar=NEbar(:,[nn:L]);TEbar=TEbar(:,[nn:L]);
+	  Zthom=Zthom([nn:L]);
+	end
+
+elseif mode==5
+	mdsopen('tcv_shot',shot)
+	L=mdsdata('GETNCI("\\results::proffit.local_time:teft","length")');
+	LL=mdsdata('GETNCI("\\results::thomson:te","length")');
+
+	if L==0
+		  mdsclose
+		  disp('No Thomson \results::proffit.local_time:teft node acquisition')
+		  if LL~=0
+	    		disp('but Thomson results::thomson:te node exist!')
+		  end
+		  return 
+	end
+	TEthom=mdsdata('\results::proffit.local_time:teft')';
+	NEthom=mdsdata('\results::proffit.local_time:neft')';
+	Tthom=mdsdata('dim_of(\results::proffit.local_time:teft,1)');
+	RHOthom=mdsdata('dim_of(\results::proffit.local_time:teft,0)')';
+	TEbar=mdsdata('\results::proffit.local_time:teft_std')';
+	NEbar=mdsdata('\results::proffit.local_time:neft_std')';
+	mdsclose
+	RHOthom=repmat(RHOthom,length(Tthom),1);
+elseif mode==6
+	mdsopen('tcv_shot',shot)
+	L=mdsdata('GETNCI("\\results::proffit.avg_time:teft","length")');
+	LL=mdsdata('GETNCI("\\results::thomson:te","length")');
+	if L==0
+	  mdsclose
+	  disp('No Thomson \results::th_prof_te node acquisition')
+	  if LL~=0
+	    disp('but Thomson results::thomson:te node exist!')
+	  end
+	  return 
+	end
+	TEthom=mdsdata('\results::proffit.avg_time:teft')';
+	NEthom=mdsdata('\results::proffit.avg_time:neft')';	
+	Tthom=mdsdata('dim_of(\results::proffit.avg_time:teft,1)');
+	RHOthom=mdsdata('dim_of(\results::proffit.avg_time:teft,0)')';
+	TEbar=mdsdata('\results::proffit.avg_time:teft_std')';
+	NEbar=mdsdata('\results::proffit.avg_time:neft_std')';
+	mdsclose
+	RHOthom=repmat(RHOthom,length(Tthom),1);
+elseif mode==7
+        del=0.03;
+	J=0;
+	mdsopen('tcv_shot',shot)
+	L=mdsdata('GETNCI("\\results::psi_axis:foo","length")');
+	if L==0
+	  disp('----------------------------------')
+	  disp('\results::psi_axis not calculated')
+	  disp('----------------------------------')
+	  mdsclose
+	  return 
+	end
+	TEthom=mdsdata('\results::thomson:te');
+	TEbar=mdsdata('\results::thomson:te:error_bar');
+	NEthom=mdsdata('\results::thomson:ne');
+	NEbar=mdsdata('\results::thomson:ne:error_bar');
+	Tthom=mdsdata('\results::thomson:times');
+	Zthom=mdsdata('\diagz::thomson_set_up:vertical_pos')'+del;
+	Rthom=mdsdata('\diagz::thomson_set_up:radial_pos')'; 
+	PSIMAG = mdsdata('\results::psi_axis');
+	Tpsimag=mdsdata('dim_of(\results::psi_axis)');
+	mdsclose
+	PSI=psitbxtcv(shot);
+	if  exist('PSI')
+	  X=PSI.psitbxfun.x;
+	  T=PSI.psitbxfun.t;
+	  RG=PSI.psitbxfun.grid.x{1}';
+	  ZG=PSI.psitbxfun.grid.x{2}';
+	else
+	  disp('No psitbxtcv ')
+	  return
+	end
+	[t,i1,i2]=common(T,Tthom,0.005);        
+	T=T(i1);X=X(:,:,i1);
+	TEbar=TEbar(i2,:);NEbar=NEbar(i2,:);NEthom=NEthom(i2,:);TEthom=TEthom(i2,:);
+	[t,i1,i2]=common(Tthom(i2),Tpsimag,0.005); 
+	PSIMAG=PSIMAG(i2);
+	%-------------------------------------------------------------
+	%	Psi...= profil de psi pour tous les temps T
+	%-------------------------------------------------------------
+	PSIMAG1=repmat(PSIMAG,1,length(ZG));
+	Psi=X(min(find(RG>=mean(Rthom))),:,:);
+	Psi=reshape(Psi,length(ZG),length(T));
+	rho=sqrt(1-(Psi)./PSIMAG1');
+	[RHOthom]=griddata(repmat(ZG,1,length(T)),repmat(T,length(ZG),1),rho,...
+			repmat(Zthom',1,length(T)),repmat(T,length(Zthom),1));
+	RHOthom=RHOthom';Tthom=T';
+elseif mode==8
+	mdsopen('tcv_shot',shot)
+	ncode='TS_FITDATA("ne","psi",1,1)';
+	tcode='TS_FITDATA("te","psi",1,1)';
+	NEthom=mdsdata(ncode);
+	TEthom=mdsdata(tcode);
+	Tthom=mdsdata(['dim_of(' tcode ',0)']);
+	RHOthom=mdsdata(['dim_of(' tcode ',1)']);
+	mdsclose
+	elseif mode==9
+	mdsopen('tcv_shot',shot)
+	ncode='TS_RAWDATA("ne","psi",1,1)';
+	tcode='TS_RAWDATA("te","psi",1,1)';
+	NEthom=mdsdata(ncode);
+	TEthom=mdsdata(tcode);
+	Tthom=mdsdata(['dim_of(' tcode ',0)']);
+	RHOthom=mdsdata(['dim_of(' tcode ',1)']);
+	mdsclose
+end
+
+[A,B]=size(TEthom);
+
+if mean(TEthom)==-1
+	disp('---------------------------------------------')
+	disp('Toutes les valeurs de Thomson valent -1')
+	disp('---------------------------------------------')
+elseif A==0|B==0
+	disp('---------------------------------------------')
+	disp('No Thomson acquisition') 
+	disp('---------------------------------------------')
+end
+
+
+
diff --git a/TCV/private/writeece.m b/TCV/private/writeece.m
new file mode 100755
index 0000000000000000000000000000000000000000..e8f3efea993557a3f8d3c02307e395b9290171a8
--- /dev/null
+++ b/TCV/private/writeece.m
@@ -0,0 +1,8 @@
+function [W]=writeece
+
+%Si W=2 Si MDS est rempli, on va chercher dans MDS sinon
+%	on calcule tout ce qui faut sans ecrire dans MDS
+%Si W=1 on force a tout recalculer et on ecrit dans MDS
+%Si W=0 Si MDS est rempli, on va chercher dans MDS sinon
+%	on calcule tout ce qui faut et on ecrit dans MDS
+W=0;