From f685b3b5f77cdc095ad2f17350ea16f983ac8484 Mon Sep 17 00:00:00 2001
From: Olivier Sauter <olivier.sauter@epfl.ch>
Date: Tue, 16 Apr 2002 20:40:50 +0000
Subject: [PATCH] add JET version of 2002 04 16, 22h

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@1868 d63d8f72-b253-0410-a779-e742ad2e26cf
---
 JET/loadJETdata.m  | 73 ++++++++++++++++++++++++++++++++--------------
 JET/mapflux_fast.m | 16 ++++++++--
 JET/rda_eff.m      |  5 ++++
 3 files changed, 70 insertions(+), 24 deletions(-)

diff --git a/JET/loadJETdata.m b/JET/loadJETdata.m
index 6bf69a39..870b175a 100644
--- a/JET/loadJETdata.m
+++ b/JET/loadJETdata.m
@@ -328,7 +328,13 @@ switch JETkeywrdcase{index}
           [volm,x3,t3,d,e]=rda_eff(shot,'ppf','efit/volm');
           a=56.605.*wdia.*cr0.*rgeo./xip./volm./bvac;
         end
-    end
+
+      case {'LIDR/Z','lidr/z','Lidr/Z','LIDR/Z?uid=jetppf+seq=0'}
+        % 1D but vs R instead of t
+        x=t;
+        t=[];
+        
+      end
     
     trace.data=a;
     trace.x=x;
@@ -445,14 +451,19 @@ switch JETkeywrdcase{index}
     end
     trace.t=[];
     trace.x=[];
+    iloaded_data=0;
     for i=starti:endi
       % Read channels from lowchannel to upchannel if necessary
       if status(i)==1
+        iloaded_data=iloaded_data+1;
         % Status=1 => Not Read Yet
         % vertical SXR chords
         ppftype='jpf';
-        tracename=['db/j3-sxr<v' num2str(i) '''''/1' name_ext];
         tracename=['db/j3-sxr<v' num2str(i) '/1' name_ext];
+        if shot<48000
+          tracename=['db/j3-sxr<t' num2str(i) '/1' name_ext];
+          disp('Using T camera: Radius data probably wrong')
+        end
         [a,x,t,d,e]=rda_eff(shot,ppftype,tracename);
         % Convert from raw sxr data to W/m^2
         if ~isempty(a)
@@ -466,22 +477,27 @@ switch JETkeywrdcase{index}
       end  
       trace.dim=[{[starti:endi]'} ; {trace.t}];
       trace.dimunits=[{'channels'} ; {'time [s]'}];
-      trace.name=[ppftype '/' num2str(shot) '/' tracename];
+      trace.name=[ 'jpf/' num2str(shot) '/' 'db/j3-sxr<vXX' '/1' name_ext];
     end
     % calculating intersection of the view lines with magnetics axis 
     if strcmp(data_type_eff_noext,'sxR')
-      if nargin>=5 & ~isempty(varargin{3})
-        zmag=varargin{3};
+      if iloaded_data>0
+        if nargin>=5 & ~isempty(varargin{3})
+          zmag=varargin{3};
+        else
+          zmag=loadJETdata(shot,'zmag');
+        end
+        zmageff=interp1(zmag.t,zmag.data,trace.t);
+        for i=starti:endi
+          radius.data(i,:)=2.848 + (2.172-zmageff') .* tan(-4.5/180.*3.14159 - atan2(0.99.*(i-18),35.31));
+        end
+        radius.t=t;
+        varargout{1}={radius}; 
+        trace.R=radius.data;
       else
-        zmag=loadJETdata(shot,'zmag');
-      end
-      zmageff=interp1(zmag.t,zmag.data,trace.t);
-      for i=starti:endi
-        radius.data(i,:)=2.848 + (2.172-zmageff') .* tan(-4.5/180.*3.14159 - atan2(0.99.*(i-18),35.31));
+        varargout{1}={struct([])};
+        trace.R=[];
       end
-      radius.t=t;
-      varargout{1}={radius}; 
-      trace.R=radius.data;
     end
 
   %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
@@ -507,24 +523,37 @@ switch JETkeywrdcase{index}
         tracename=['kk3/te' num2str(i,'%2.2d') name_ext];
         disp(tracename)
         [a,x,t,d,e]=rda_eff(shot,ppftype,tracename);
-        trace.data(i,:)=a;
-        trace.t=t;
+        if isempty(a) & size(trace.data,2)>1
+          trace.data(i,:)=NaN;
+        else
+          trace.data(i,:)=a;
+          trace.t=t;
+        end
         if ~isempty(x); trace.x(i,:)=x'; end;
         error=e;
         ppftypeR='ppf';
         tracenameR=['kk3/rc' num2str(i,'%2.2d') name_ext];
         [a,x,t,d,e]=rda_eff(shot,ppftypeR,tracenameR);
-        radius.data(i,:)=a;
-        radius.t=t;
-        radius.x=x;
+       if isempty(a) & size(trace.data,2)>1
+         radius.data(i,:)=NaN;
+       else
+         radius.data(i,:)=a;
+         radius.t=t;
+         radius.x=x;
+       end
       end
     end 
     trace.dim=[{[starti:endi]'} ; {trace.t}];
     trace.dimunits=[{'channels'} ; {'time [s]'}];
-    trace.name=[ppftype '/' num2str(shot) '/' tracename];
-    varargout={{radius}}; 
-    for i=starti:endi
-      trace.R(i,:)=interp1(radius.t,radius.data(i,:),trace.t);
+    trace.name=[ 'ppf/' num2str(shot) '/' 'kk3/teXX' name_ext ];
+    if exist('radius')
+      varargout={{radius}}; 
+      for i=starti:endi
+        trace.R(i,:)=interp1(radius.t,radius.data(i,:),trace.t);
+      end
+    else
+      varargout={{struct([])}};
+      trace.R=[];
     end
 
   otherwise
diff --git a/JET/mapflux_fast.m b/JET/mapflux_fast.m
index 4cb5fee3..d7698a5c 100644
--- a/JET/mapflux_fast.m
+++ b/JET/mapflux_fast.m
@@ -30,13 +30,20 @@ nr=length(ri);
 nz=length(zi);
 nrout=length(r);
 nzout=length(z);
+r=reshape(r,1,length(r));
+z=reshape(z,1,length(z));
 absplr=zeros(nrout,nr-4);
 if nargin>6 & varargin{2}==0
   i1=1;
   i2=nr-4;
 else
   ii=find(ri>=min(r));i1=ii(1);
-  ii=find(ri>max(r));i2=ii(1);
+  ii=find(ri>max(r));
+  if ~isempty(ii)
+    i2=ii(1);
+  else
+    i2=nr;
+  end
 end
 for i=max(1,i1-4):min(nr-4,i2-1)
    absplr(:,i)=bsplinev(ri,r,3,i)';
@@ -47,7 +54,12 @@ if nargin>6 & varargin{2}==0
   i2=nz-4;
 else
   ii=find(zi>=min(z));i1=ii(1);
-  ii=find(zi>max(z));i2=ii(1);
+  ii=find(zi>max(z));
+  if ~isempty(ii)
+    i2=ii(1);
+  else
+    i2=nz;
+  end
 end
 for j=max(1,i1-4):min(nz-4,i2-1)
   absplz(j,:)=bsplinev(zi,z,3,j);
diff --git a/JET/rda_eff.m b/JET/rda_eff.m
index bbb3fa16..a42d3e9f 100644
--- a/JET/rda_eff.m
+++ b/JET/rda_eff.m
@@ -153,3 +153,8 @@ end
 if isempty(x) & ~isempty(data) & data==0
   data=[];
 end
+
+if isempty(data)
+  x=[];
+  time=[];
+end
-- 
GitLab