Commit c1fff6e3 authored by Olivier Sauter's avatar Olivier Sauter
Browse files

starting comment


git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/branches/v_0_0@1811 d63d8f72-b253-0410-a779-e742ad2e26cf
parents
Pipeline #13152 failed with stages
in 7 seconds
function [trace,error,varargout]=lJETdata(shot,data_type,varargin)
%
%
% INPUT:
% shot: shot number
% data_type: type of the required data. Ex.: 'Ip', 'zmag', 'rmag','sxr', 'ece', 'sxR'
% optional:
% varargin{1}: [i1 i2] : if not empty, assumes need many chords from i1 to i2
% varargin{2}: channel staus 1= unread yet, 0= read
% varargin{3}: zmag for varargout{1} computation
%
% OUTPUT:
% trace.data: data structure
% trace.t: time of reference
% trace.x: space of reference
% varargout{1}: intersection of the view lines with magnetics axis
%
% function needed: mds functions-xtomo_geometry-get_xtomo (Furno's routines)
% VsxrTCVradius-jetreaddata
% list of data_type currently available:
% '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}!)
% Example:
% [zmag,error]=lJETdata(shot,'zmag');
%
JETsigkeywrd=[{'Ip'} ; {'zmag'} ; {'rmag'}];
JETsig.iip=1;
JETsig.izmag=2;
JETsig.irmag=3;
JETsiglocation=[{'ppf'; 'efit/xip'} {'ppf'; 'efit/zmag'} {'ppf'; 'efit/rmag'}];
% setting location of the required data
index_sig=strmatch(data_type,JETsigkeywrd);
if ~isempty(index_sig);
location=JETsiglocation(:,index_sig);
elseif size(data_type,1)==2
location=data_type;
end
% LOAD MULTI CHANNEL DATA
% load JET soft x-ray data
if (strcmp(data_type,'sxr') | strcmp(data_type,'sxR'))
% parameters needed for correct convertion of JET Sxr data
vconvert= [1.379 1.311 1.249 1.191 1.139 1.093 1.049 ...
1.011 0.975 0.945 0.917 0.893 0.873 0.856 ...
0.842 0.829 0.821 0.815 0.821 0.829 0.842 ...
0.856 0.873 0.894 0.918 0.946 0.976 1.012 ...
1.050 1.094 1.141 1.193 1.251 1.313 1.382];
starti=varargin{1}(1);
endi=varargin{1}(2);
status=varargin{2};
for i=starti:endi
% Read channels from lowchannel to upchannel if necessary
if status(i)==1
% Status=1 => Not Read Yet
% vertical SXR chords
ppftype='jpf';
tracename=['db/j3-sxr<v' num2str(i) '''''/1'];
[a,t,x,d,e]=jetreaddata(['http://data.jet.uk/' ppftype '/' num2str(shot) '/' tracename]);
trace.data(:,i)=a;
trace.t(:,i)=t;
trace.x(:,i)=x;
error=e;
if error~=0
[aaa bbb]=jetgetlasterrordetail;
disp(bbb)
end
% Convert from raw sxr data to W/m^2
trace.data(i,:) = trace.data(i,:) * vconvert(i);
% calculating intersection of the view lines with magnetics axis
if strcmp(data_type,'sxR')
zmag=varargin{3};
radius(:,i)=2.848 + (2.172-zmag.data) .* ...
tan(-4.5/180.*3.14159 - atan2(0.99.*(i-18),35.31));
varargout={radius};
end
end
end
elseif strcmp(data_type,'ece')
starti=varargin{1}(1);
endi=varargin{1}(2);
status=varargin{2};
% Read channels from lowchannel to upchannel if necessary
for i=starti:endi
if status(i)==1
if i<10
% ECE, te0
% Status=1 => Not Read Yet
ppftype='ppf';
tracename=['kk3/te0'num2str(i)];
[a,t,x,d,e]=jetreaddata(['http://data.jet.uk/' ppftype '/' num2str(shot) '/' tracename]);
trace.data(:,i)=a;
trace.t(:,i)=t;
trace.x(:,i)=x;
error=e;
if error~=0
[aaa bbb]=jetgetlasterrordetail;
disp(bbb)
end
ppftype='ppf';
tracename=['kk3/rc0'num2str(i)];
[a,t,x,d,e]=jetreaddata(['http://data.jet.uk/' ppftype '/' num2str(shot) '/' tracename]);
radius.data(:,i)=a;
radius.t(:,i)=t;
radius.x(:,i)=x;
error=e;
else
ppftype='ppf';
tracename=['kk3/te'num2str(i)];
[a,t,x,d,e]=jetreaddata(['http://data.jet.uk/' ppftype '/' num2str(shot) '/' tracename]);
trace.data(:,i)=a;
trace.t(:,i)=t;
trace.x(:,i)=x;
error=e;
if error~=0
[aaa bbb]=jetgetlasterrordetail;
disp(bbb)
end
ppftype='ppf';
tracename=['kk3/rc'num2str(i)];
[a,t,x,d,e]=jetreaddata(['http://data.jet.uk/' ppftype '/' num2str(shot) '/' tracename]);
radius.data(:,i)=a;
radius.t(:,i)=t;
radius.x(:,i)=x;
end
end
end
varargout={radius};
else
% load other JET data
varargout={[]};
ppftype=location{1};
tracename=location{2};
[a,t,x,d,e]=jetreaddata(['http://data.jet.uk/' ppftype '/' num2str(shot) '/' tracename]);
trace.data=a;
trace.t=t;
trace.x=x;
clear error
error=e;
if error~=0
[aaa bbb]=jetgetlasterrordetail;
disp(bbb)
end
end
gdat.m was first created to get JET data using jetRDA system
It is now generalised to be machine independent in its structure and trace name.
Each machine dependent functions should be in respective directory
Adding a new machine means:
create new subdirectory
change gdatpaths
In new subdirectory, named say: NEWMACHINE
create function: lNEWMACHINEdata.m (for load NEWMACHINE data)
etc.
The explanation of the different traces are in "help gdat" for generic names.
The specificity of a given machine are in "help lNEWMACHINEdata"
Thus the head comments of these functions should be correctly updated and self-explanatory
function [trace,error,varargout]=lTCVdata(shot,data_type,varargin)
%
%
% INPUT:
% shot: shot number
% data_type: type of the required data. Ex.: 'Ip', 'zmag', 'rmag','sxr', 'ece', 'sxR'
% 'MPX'
% optional:
% varargin{1}: channel status 1= unread yet, 0= read
% varargin{2}: [i1 i2] : if not empty, assumes need many chords from i1 to i2
% varargin{3}: zmag for varargout{1} computation
%
% OUTPUT:
% trace.data: data structure
% trace.t: time of reference
% trace.x: space of reference
% varargout{1}: intersection of the view lines with magnetic axis
%
% function needed: mds functions-xtomo_geometry-get_xtomo_data (Furno's routines)
% VsxrTCVradius
% list of data_type currently available:
% '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{4}!)
% 'MPX' = soft x-ray from wire chambers
% Example:
% [zmag,error]=lTCVdata(shot,'zmag');
%
TCVsigkeywrd=[{'Ip'} ; {'zmag'} ; {'rmag'}];
TCVsigtimeindx=['1' ; '1' ; '1'];
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 lTCVdata, data_type= ' data_type ''''])
end
else
disp(['this data_type' ' ' data_type ' ' 'not yet programmed in lTCVdata, ask Andrea.Scarabosio@epfl.ch']);
end
disp(['loading' ' ' data_type ' from TCV shot #' num2str(shot)]);
% 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))
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;
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;
end
function [trace,error,varargout] = gdat(shot,data_type,varargin)
%
%
% INPUT:
% shot: shot number
% data_type: type of the required data. Ex.: 'Ip', 'zmag', 'rmag','sxr', 'ece',
% 'sxR', 'MPX'
% optional arguments, definition of some depend on value of data_type:
%
% 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}:
%
%
% functions needed: lTCVdata, lJETdata
%
% 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}!)
%
% TCV
% '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)
%
%
% 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
eval(['[trace,error,radius] = l' 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
%
% add paths for gdat directory
%
% assumes gdat already available
%
a=which('gdat');
ii=findstr('/',a);
a=a(1:ii(end));
machines=[{'JET'} {'TCV'}];
for i=1:length(machines)
addpath([a machines{i}],'-end')
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment