diff --git a/JET/loadJETdata.m b/JET/loadJETdata.m index 088fe055a010d8241b3f42f5d1db3bd02bce6fa5..b3f3c360009812700c311ce74013adbbd55638c9 100644 --- a/JET/loadJETdata.m +++ b/JET/loadJETdata.m @@ -1,98 +1,135 @@ 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: % 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 +% data_type: type of the required data. +% +% Meaning of varargin depends on data_type: +% +% 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: % trace.data: data structure % trace.t: time 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: % [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.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 +JETsig.isxr=4; +JETsig.isxR=5; +JETsig.iece=6; +% For each keyword, specify which case to use. As most common is 'simplereaddata', fill in with this and change +% only indices needed. Usually use name of case same as keyword name +JETkeywrdcase=cell(size(JETkeywrdall)); +JETkeywrdcase(:)={'simplereaddata'}; +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 -% 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 +% 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 +JETsigtimeindx=ones(size(JETkeywrdall)); + +% find index of signal called upon +if size(data_type,1)==2 + % in case node name was given in 2 parts directly (as old way) + index=find(strmatch(data_type(1),JETsiglocation(1,:),'exact') & strmatch(data_type(2),JETsiglocation(2,:),'exact')); + 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') + % temporarily add entry in arrays, so can work below + index=length(JETkeywrdall)+1; + JETkeywrdall(end+1)={'new'}; + JETkeywrdcase(end+1)={'simplereaddata'}; + JETsiglocation(1:2,end+1)=data_type; + JETsigtimeindx(end+1)=0; + elseif ~strcmp(JETkeywrdcase{index},'simplereaddata') + msgbox(['Problem in loadJETdata with data_type = ' data_type ... + '. Full paths of nodes should only be for case simplereaddata'],'in loadJETdata','error') + error('in loadJETdata') 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)]; +else + index=strmatch(data_type,JETkeywrdall,'exact'); +end +disp(['loading' ' ' data_type ' from JET shot #' num2str(shot)]); +disp(['case ' JETkeywrdcase{index}]) +switch JETkeywrdcase{index} + + case 'simplereaddata' + + varargout={[]}; + ppftype=JETsiglocation{1,index}; + 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]); trace.data(:,i)=a; trace.t(:,i)=t; @@ -102,50 +139,69 @@ elseif strcmp(data_type,'ece') [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) + % 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 + + case '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 - 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 + varargout={radius}; + end