Skip to content
Snippets Groups Projects
gdat.m 3.14 KiB
Newer Older
function [trace,error,varargout] = gdat(shot,data_type,varargin)
%
% list of data_type currently available:
%
% All machines
% 'Ip'   =  current
% 'zmag' =  vertical position of the center of the plasma (magnetic axis)
% 'rmag' =  radial position of the center of the plasma 
% 'ece'  =  electron cyclotron emission
% 'sxr'  =  soft x-ray emission 
% 'sxR'  =  soft x-ray emission with varargout{1} option (requires varargin{5}!)
%
% specific to TCV (see help loadTCVdata for more information)
% 'MPX'  =  wire chambers with varargout{1} option (requires varargin{5}!)
%
% Special case compatible with old gdat.m allows (JET related): gdat(51994,'ppf','efit/xip',1)
% data_type: type of the required data.( see above)
%
% optional arguments valid for all values of data_type:
%
% varargin{1}:  0 => no plot (default), 1 => plot 
% varargin{2}:  machine name 'JET', 'TCV' (default)
%
% Additional input arguments for specific traces
%
% data_type=sxr or ece:
%                  varargin{3}:  channel status 1= unread yet, 0= read
%                                (for traces with many channel, enables to load additional channels,
%                                 like SXR, ECE, etc.)
%                  varargin{4}:  [i1 i2] : if not empty, assumes need many chords from i1 to i2
%                  varargin{5}:  zmag for varargout{1} computation
%
% OUTPUT:
% trace.data:   data structure
% trace.t:      time of reference 
% trace.x:      space of reference 
% error:        error in loading signal (0=> OK, 1=> error)
%
% Additional Output arguments depending on data_type
%
% data_type=sxR:
%                varargout{1}: intersection of the view lines with magnetic axis
% data_type=MPX: (specific to TCV) 
%                varargout{1}: see help loadTCVdata
% functions needed: loadTCVdata, loadJETdata
%                  
%
% Examples:
%         [zmag,error]=gdat(shot,'zmag',1);  % gets zmag from TCV and plot
%         [zmag,error]=gdat(shot,'zmag',1,'JET'); % idem but from JET
%         [zmag,error]=gdat(shot,'ppf','efit/zmag',1); as above for JET 
%
%

nargineff=nargin;
if nargineff>=3 & ischar(varargin{1})
  data_type={data_type ; varargin{1}};
  if nargineff>=4; 
    varargin{1}=varargin{2};
  else
    varargin{1}=0;
    nargineff=4;
  end
  varargin{2}='JET';
end  
 

		 
% SETTING MACHINE
doplot=0;
if (nargineff>=3 & ~isempty(varargin{1})); doplot=varargin{1}; end
machine='TCV';
if (nargineff>=4 & ~isempty(varargin{2})); machine=varargin{2}; end
status=ones(1,100);
if (nargineff>=5 & ~isempty(varargin{3})); status=varargin{3}; end
index=[];
if (nargineff>=6 & ~isempty(varargin{4})); index=varargin{4}; end
zmag=[];
if (nargineff>=7 & ~isempty(varargin{5})); zmag=varargin{5}; end

% load data from specified machine
eval(['[trace,error,radius] = load' machine 'data(shot,data_type,status,index,zmag);']);

if (strcmp(data_type,'sxR') | strcmp(data_type,'ece')| strcmp(data_type,'MPX')) 
  varargout={radius}; 
end
 
% PLOT DATA (if required)
if doplot==1
  figure;zoom on
  plot(trace.t,trace.data);
  xlabel('time [s]')
  ylabel(data_type)
  title([machine ' '  num2str(shot)])
  grid
elseif doplot==-1
  hold on
  plot(trace.t,trace.data,'r');
end