Skip to content
Snippets Groups Projects
Commit 378cf4ba authored by Olivier Sauter's avatar Olivier Sauter
Browse files

change the structure of defining the different cases for different traces

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@1817 d63d8f72-b253-0410-a779-e742ad2e26cf
parent 5ffec959
No related branches found
No related tags found
No related merge requests found
......@@ -30,112 +30,151 @@
% [zmag,error]=loadTCVdata(shot,'zmag');
%
TCVsigkeywrd=[{'Ip'} ; {'zmag'} ; {'rmag'}];
TCVsigtimeindx=['1' ; '1' ; '1'];
varargout=cell(1,1);
% all keywords and corresponding case to run below
TCVkeywrdall=[{'Ip'} {'zmag'} {'rmag'} {'sxr'} {'sxR'} {'ece'}];
TCVsig.iip=1;
TCVsig.izmag=2;
TCVsig.irmag=3;
TCVsiglocation=[{'\results::i_p'} ; {'\results::z_axis'} ; {'\results::r_axis'}];
% setting location of the required data
index_sig=strmatch(data_type,TCVsigkeywrd);
if ~isempty(index_sig);
location={TCVsiglocation{index_sig} TCVsigtimeindx(index_sig)};
elseif strcmp(data_type(1:1),'\')
index_sig=strmatch(data_type,TCVsiglocation);
if ~isempty(index_sig)
fprintf(['Note: you can also get this data simply with gdat(shot,' ...
char(TCVsigkeywrd(index_sig)) ') instead of the full node name' ' ' data_type]);
location={data_type ; '1'};
else
% eval(['!mailto_Andrea ''from loadTCVdata, data_type= ' data_type ''''])
end
TCVsig.isxr=4;
TCVsig.isxR=5;
TCVsig.iece=6;
% For each keyword, specify which case to use. As most common is 'simpletdi', fill in with this and change
% only indices needed. Usually use name of case same as keyword name
TCVkeywrdcase=cell(size(TCVkeywrdall));
TCVkeywrdcase(:)={'simpletdi'};
TCVkeywrdcase(TCVsig.isxr)=TCVkeywrdall(TCVsig.isxr);
TCVkeywrdcase(TCVsig.isxR)=TCVkeywrdall(TCVsig.isxR);
TCVkeywrdcase(TCVsig.iece)=TCVkeywrdall(TCVsig.iece);
% For the 'simpletdi' cases, we need the full node in case gdat was called with full location directly
% for the other cases, leave this location empty
TCVsiglocation=cell(size(TCVkeywrdall));
TCVsiglocation(:)={''};
TCVsiglocation(TCVsig.iip)={'\results::i_p'};
TCVsiglocation(TCVsig.izmag)={'\results::z_axis'};
TCVsiglocation(TCVsig.irmag)={'\results::r_axis'};
% Information about which dimension has time, always return 2D data as (x,t) array
% as most are 1D arrays with time as first index, fill in with ones and change only those needed
TCVsigtimeindx=ones(size(TCVkeywrdall));
% find index of signal called upon
if strcmp(data_type(1:1),'\')
% in case full node name was given
index=strmatch(data_type,TCVsiglocation,'exact');
if ~strcmp(TCVkeywrdcase{index},'simpletdi')
msgbox(['Problem in loadTCVdata with data_type = ' data_type ...
'. Full paths of nodes should only be for case simpletdi'],'in loadTCVdata','error')
error('in loadTCVdata')
end
else
disp(['this data_type' ' ' data_type ' ' 'not yet programmed in loadTCVdata, ask Andrea.Scarabosio@epfl.ch']);
index=strmatch(data_type,TCVkeywrdall,'exact');
end
disp(['loading' ' ' data_type ' from TCV shot #' num2str(shot)]);
disp(['case ' TCVkeywrdcase{index}])
switch TCVkeywrdcase{index}
case 'simpletdi'
% LOAD DATA
if (strcmp(data_type,'sxr') | strcmp(data_type,'sxR'))
% load TCV soft x-ray data
% 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
status=varargin{1};
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_type,'sxR')
zmag=varargin{3};
varargout={VsxrTCVradius(zmag.data,xchord,ychord)};
t_1=zmag.t(1);
t_2=zmag.t(end);
else
t_1=0.001;
t_2=3;
varargout={};
end
[xtomo_signal,t]=get_xtomo_data(shot,t_1,t_2,13e-6*16, ...
icamera,angfact);
end
for i=1:(20*icamera*ones(10,1))
trace.t(:,i)=t';
end
trace.data=xtomo_signal';
error=0;
% load TCV ECE data
elseif (strcmp(data_type,'ece'))
status=varargin{2};
% 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 ...
(shot,[0.1 0.29],10,10);
end
a=min(find(R(:,1)>=0));
b=max(find(R(:,1)>=0));
for i=1:size(TE_ECE,2)
trace.t(:,i)=T(a:b);
end
trace.data=TE_ECE(a:b,:);
radius.t=trace.t;
radius.data=R(a:b,:);
varargout={radius};
error=0;
% load TCV MPX data
elseif (strcmp(data_type,'MPX'))
status=varargin{1};
% Status=1 => Not Read Yet
zmag=varargin{3};
t_1=zmag.t(1);
t_2=zmag.t(end);
if ~isempty(find(status == 1))
% load TCV other data
mdsopen(shot);
signal=get_mds_mio('MPX',[t_1 t_2]);
tracetdi=tdi(TCVsiglocation{index});
mdsclose(shot)
trace.data=signal.data;
for i=1:size(signal.dim{2},2)
trace.t(:,i)=signal.dim{1};
trace.data=tracetdi.data;
trace.t=tracetdi.dim{TCVsigtimeindx(index)};
if (length(tracetdi.dim)>1)
ix=2;
if TCVsigtimeindx(index)==2; ix=1; end;
trace.x=tracetdi.dim{ix};
% make sure data is of (x,t)
if ix==2
% transpose data
if length(size(trace.data))==2
trace.data=trace.data';
else
msgbox(['data more than 2D (data_type=' data_type ...
'), check how to save it, contact andrea.scarabosio@epfl.ch or olivier.sauter@epfl.ch'],...
'in simpletdi','warning')
warning('in simpletdi of loadTCVdata')
end
end
else
trace.x=[];
end
error=0;
case {'sxr','sxR'}
% load TCV soft x-ray data
% 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
status=varargin{1};
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_type,'sxR')
zmag=varargin{3};
varargout={VsxrTCVradius(zmag.data,xchord,ychord)};
t_1=zmag.t(1);
t_2=zmag.t(end);
else
t_1=0.001;
t_2=3;
end
[xtomo_signal,t]=get_xtomo_data(shot,t_1,t_2,13e-6*16, ...
icamera,angfact);
end
end
[xchord,ychord]=mpx_geometry;
varargout={VsxrTCVradius(zmag.data,xchord,ychord)};
error=0;
else
% load TCV other data
varargout={[]};
mdsopen(shot);
tracetdi=tdi(location{1});
mdsclose(shot)
trace.data=tracetdi.data;
time_pos=str2num(location{2});
trace.t=tracetdi.dim{time_pos};
if (length(tracetdi.dim)>1)
ii=2;
if time_pos==2; ii=1; end;
trace.x=tracetdi.dim{ii};
else
trace.x=[];
end
error=0;
for i=1:(20*icamera*ones(10,1))
trace.t(:,i)=t';
end
trace.data=xtomo_signal';
error=0;
case 'ece'
% load TCV ECE data
status=varargin{2};
% 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 ...
(shot,[0.1 0.29],10,10);
end
a=min(find(R(:,1)>=0));
b=max(find(R(:,1)>=0));
for i=1:size(TE_ECE,2)
trace.t(:,i)=T(a:b);
end
trace.data=TE_ECE(a:b,:);
radius.t=trace.t;
radius.data=R(a:b,:);
varargout={radius};
error=0;
case 'MPX'
% load TCV MPX data
status=varargin{1};
% Status=1 => Not Read Yet
zmag=varargin{3};
t_1=zmag.t(1);
t_2=zmag.t(end);
if ~isempty(find(status == 1))
mdsopen(shot);
signal=get_mds_mio('MPX',[t_1 t_2]);
mdsclose(shot)
trace.data=signal.data;
for i=1:size(signal.dim{2},2)
trace.t(:,i)=signal.dim{1};
end
end
[xchord,ychord]=mpx_geometry;
varargout={VsxrTCVradius(zmag.data,xchord,ychord)};
error=0;
otherwise
% eval(['!mailto_Andrea ''from loadTCVdata, data_type= ' data_type ''''])
disp(['this data_type' ' ' data_type ' ' 'not yet programmed in loadTCVdata, ask Andrea.Scarabosio@epfl.ch']);
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment