Skip to content
Snippets Groups Projects
Commit d8a0d3f1 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@1819 d63d8f72-b253-0410-a779-e742ad2e26cf
parent d5966627
No related branches found
No related tags found
No related merge requests found
function [trace,error,varargout]=loadJETdata(shot,data_type,varargin) function [trace,error,varargout]=loadJETdata(shot,data_type,varargin)
% %
% data_type:
% '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}!)
%
% Special case compatible with old gdat.m allows (JET related):
% gdat(51994,'ppf','efit/xip',...)
% %
% INPUT: % INPUT:
% shot: shot number % shot: shot number
% data_type: type of the required data. Ex.: 'Ip', 'zmag', 'rmag','sxr', 'ece', 'sxR' % data_type: type of the required data.
% optional: %
% varargin{1}: [i1 i2] : if not empty, assumes need many chords from i1 to i2 % Meaning of varargin depends on data_type:
% varargin{2}: channel staus 1= unread yet, 0= read %
% varargin{3}: zmag for varargout{1} computation % data_type=sxr or ece:
% varargin{1}: channel status: 1=unread yet, 0=read
% (for traces with many channel, enables to load additional channels,
% like SXR, ECE, etc.)
% varargin{2}: [i1 i2] : if not empty, assumes need many chords from i1 to i2
% varargin{3}: zmag for varargout{1} computation
% %
% OUTPUT: % OUTPUT:
% trace.data: data structure % trace.data: data structure
% trace.t: time of reference % trace.t: time of reference
% trace.x: space of reference % trace.x: space of reference
% varargout{1}: intersection of the view lines with magnetics axis % 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
%
% functions needed: jetreaddata or mdsplus routines
% %
% 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: % Example:
% [zmag,error]=loadJETdata(shot,'zmag'); % [zmag,error]=loadJETdata(shot,'zmag');
% %
JETsigkeywrd=[{'Ip'} ; {'zmag'} ; {'rmag'}];
varargout=cell(1,1);
% all keywords and corresponding case to run below
JETkeywrdall=[{'Ip'} {'zmag'} {'rmag'} {'sxr'} {'sxR'} {'ece'}];
JETsig.iip=1; JETsig.iip=1;
JETsig.izmag=2; JETsig.izmag=2;
JETsig.irmag=3; JETsig.irmag=3;
JETsiglocation=[{'ppf'; 'efit/xip'} {'ppf'; 'efit/zmag'} {'ppf'; 'efit/rmag'}]; JETsig.isxr=4;
% setting location of the required data JETsig.isxR=5;
index_sig=strmatch(data_type,JETsigkeywrd); JETsig.iece=6;
if ~isempty(index_sig); % For each keyword, specify which case to use. As most common is 'simplereaddata', fill in with this and change
location=JETsiglocation(:,index_sig); % only indices needed. Usually use name of case same as keyword name
elseif size(data_type,1)==2 JETkeywrdcase=cell(size(JETkeywrdall));
location=data_type; JETkeywrdcase(:)={'simplereaddata'};
end JETkeywrdcase(JETsig.isxr)=JETkeywrdall(JETsig.isxr);
JETkeywrdcase(JETsig.isxR)=JETkeywrdall(JETsig.isxR);
JETkeywrdcase(JETsig.iece)=JETkeywrdall(JETsig.iece);
% For the 'simplereaddata' cases, we need the full node in case gdat was called with full location directly
% for the other cases, leave this location empty
JETsiglocation=cell(2,size(JETkeywrdall,2));
JETsiglocation(:)={''};
JETsiglocation(:,JETsig.iip)={'ppf'; 'efit/xip'};
JETsiglocation(:,JETsig.izmag)={'ppf'; 'efit/zmag'};
JETsiglocation(:,JETsig.irmag)={'ppf'; 'efit/rmag'};
% LOAD MULTI CHANNEL DATA % Information about which dimension has time, always return 2D data as (x,t) array
% load JET soft x-ray data % as most are 1D arrays with time as first index, fill in with ones and change only those needed
if (strcmp(data_type,'sxr') | strcmp(data_type,'sxR')) JETsigtimeindx=ones(size(JETkeywrdall));
% parameters needed for correct convertion of JET Sxr data
vconvert= [1.379 1.311 1.249 1.191 1.139 1.093 1.049 ... % find index of signal called upon
1.011 0.975 0.945 0.917 0.893 0.873 0.856 ... if size(data_type,1)==2
0.842 0.829 0.821 0.815 0.821 0.829 0.842 ... % in case node name was given in 2 parts directly (as old way)
0.856 0.873 0.894 0.918 0.946 0.976 1.012 ... index=find(strmatch(data_type(1),JETsiglocation(1,:),'exact') & strmatch(data_type(2),JETsiglocation(2,:),'exact'));
1.050 1.094 1.141 1.193 1.251 1.313 1.382]; if isempty(index)
disp('trace not yet registered. If standard data, ask andrea.scarabosio@epfl.ch or olivier.sauter@epfl.ch to create a keyqord entry for this data')
starti=varargin{1}(1); % temporarily add entry in arrays, so can work below
endi=varargin{1}(2); index=length(JETkeywrdall)+1;
status=varargin{2}; JETkeywrdall(end+1)={'new'};
for i=starti:endi JETkeywrdcase(end+1)={'simplereaddata'};
% Read channels from lowchannel to upchannel if necessary JETsiglocation(1:2,end+1)=data_type;
if status(i)==1 JETsigtimeindx(end+1)=0;
% Status=1 => Not Read Yet elseif ~strcmp(JETkeywrdcase{index},'simplereaddata')
% vertical SXR chords msgbox(['Problem in loadJETdata with data_type = ' data_type ...
ppftype='jpf'; '. Full paths of nodes should only be for case simplereaddata'],'in loadJETdata','error')
tracename=['db/j3-sxr<v' num2str(i) '''''/1']; error('in loadJETdata')
[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 end
elseif strcmp(data_type,'ece') else
starti=varargin{1}(1); index=strmatch(data_type,JETkeywrdall,'exact');
endi=varargin{1}(2); end
status=varargin{2}; disp(['loading' ' ' data_type ' from JET shot #' num2str(shot)]);
% Read channels from lowchannel to upchannel if necessary disp(['case ' JETkeywrdcase{index}])
for i=starti:endi switch JETkeywrdcase{index}
if status(i)==1
if i<10 case 'simplereaddata'
% ECE, te0
% Status=1 => Not Read Yet varargout={[]};
ppftype='ppf'; ppftype=JETsiglocation{1,index};
tracename=['kk3/te0'num2str(i)]; tracename=JETsiglocation{2,index};
[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
case {'sxr','sxR'}
% LOAD MULTI CHANNEL DATA
% load JET soft x-ray data
% 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]); [a,t,x,d,e]=jetreaddata(['http://data.jet.uk/' ppftype '/' num2str(shot) '/' tracename]);
trace.data(:,i)=a; trace.data(:,i)=a;
trace.t(:,i)=t; trace.t(:,i)=t;
...@@ -102,50 +139,69 @@ elseif strcmp(data_type,'ece') ...@@ -102,50 +139,69 @@ elseif strcmp(data_type,'ece')
[aaa bbb]=jetgetlasterrordetail; [aaa bbb]=jetgetlasterrordetail;
disp(bbb) disp(bbb)
end end
ppftype='ppf'; % Convert from raw sxr data to W/m^2
tracename=['kk3/rc0'num2str(i)]; trace.data(i,:) = trace.data(i,:) * vconvert(i);
[a,t,x,d,e]=jetreaddata(['http://data.jet.uk/' ppftype '/' num2str(shot) '/' tracename]); % calculating intersection of the view lines with magnetics axis
radius.data(:,i)=a; if strcmp(data_type,'sxR')
radius.t(:,i)=t; zmag=varargin{3};
radius.x(:,i)=x; radius(:,i)=2.848 + (2.172-zmag.data) .* ...
error=e; tan(-4.5/180.*3.14159 - atan2(0.99.*(i-18),35.31));
else varargout={radius};
ppftype='ppf'; end
tracename=['kk3/te'num2str(i)]; end
[a,t,x,d,e]=jetreaddata(['http://data.jet.uk/' ppftype '/' num2str(shot) '/' tracename]); end
trace.data(:,i)=a;
trace.t(:,i)=t; case 'ece'
trace.x(:,i)=x; starti=varargin{1}(1);
error=e; endi=varargin{1}(2);
if error~=0 status=varargin{2};
[aaa bbb]=jetgetlasterrordetail; % Read channels from lowchannel to upchannel if necessary
disp(bbb) 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
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 end
end varargout={radius};
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 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