diff --git a/JET/loadJETdata.m b/JET/loadJETdata.m index 0a8e25f9845910a844fc19bb8ed2138d3f04c608..3fd00fd11e4425247fa5524b45b39ad6c314588d 100644 --- a/JET/loadJETdata.m +++ b/JET/loadJETdata.m @@ -37,10 +37,10 @@ function [trace,error,varargout]=loadJETdata(shot,data_type,varargin) % Meaning of varargin depends on data_type: % % data_type=sxr or ece: -% varargin{1}: channel status: 1=unread yet, 0=read +% varargin{1}: [i1 i2] : if not empty, assumes need many chords from i1 to i2 +% varargin{2}: 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 % % @@ -62,6 +62,7 @@ function [trace,error,varargout]=loadJETdata(shot,data_type,varargin) % varargout=cell(1,1); +error=1; % To allow multiple ways of writing a specific keyword, use data_type_eff within this routine @@ -107,14 +108,14 @@ if size(data_type_eff,1)==1 data_type_eff_noext='zmag'; end else - i_ext=length(data_type_eff(2))+1; + i_ext=length(data_type_eff{2})+1; name_ext=''; - i=findstr('?',data_type_eff(2)); + i=findstr('?',data_type_eff{2}); if ~isempty(i) i_ext=i; - name_ext=data_type_eff(2)(i_ext:end); + name_ext=data_type_eff{2}(i_ext:end); end - data_type_eff_noext=data_type_eff{2}(1:i_ext-1)]; + data_type_eff_noext=data_type_eff{2}(1:i_ext-1); end % all keywords and corresponding case to run below @@ -158,7 +159,14 @@ JETsiglocation(:)={''}; JETsiglocation(:,JETsig.iip)={'ppf'; 'efit/xip'}; JETsiglocation(:,JETsig.izmag)={'ppf'; 'efit/zmag'}; JETsiglocation(:,JETsig.irmag)={'ppf'; 'efit/rmag'}; -JETsiglocation(JETsig.ineint)={'ppf'; 'kg1v/lid3'}; +JETsiglocation(:,JETsig.ineint)={'ppf'; 'kg1v/lid3'}; + +% initialize order of substructures and allows just a "return" if data empty +trace.data=[]; +trace.x=[]; +trace.t=[]; +trace.dim=[]; +trace.dimunits=[]; % find index of signal called upon if size(data_type_eff,1)==2 @@ -185,6 +193,16 @@ if size(data_type_eff,1)==2 end else index=strmatch(data_type_eff_noext,JETkeywrdall,'exact'); + if isempty(index) + disp(' ') + disp('********************') + disp(['no such keyword: ' data_type_eff(1:end-i_23)]) + disp(' ') + disp('Available keywords:') + JETkeywrdall(:) + disp('********************') + return + end end disp(' ') disp(['loading' ' ' char(data_type_eff(end)) ' from JET shot #' num2str(shot)]); @@ -197,21 +215,17 @@ switch JETkeywrdcase{index} ppftype=JETsiglocation{1,index}; if i_efitm; - tracename=['efitm' JETsiglocation{2,index}(5:end) name_ext]; + tracename=['eftm' JETsiglocation{2,index}(5:end) name_ext]; else tracename=[JETsiglocation{2,index} name_ext]; end - [a,t,x,d,e]=jetreaddata(['http://data.jet.uk/' ppftype '/' num2str(shot) '/' tracename]); - trace.data=a'; + [a,x,t,d,e]=rda_eff(shot,ppftype,tracename); + trace.data=a; trace.x=x; trace.t=t; clear error error=e; - if error~=0 - [aaa bbb]=jetgetlasterrordetail; - disp(bbb) - end - if length(size(trace.data))==1 + if length(size(trace.data))==1 | (length(size(trace.data))==2 & size(trace.data,2)==1) trace.dim=[{trace.t}]; trace.dimunits(1)={'time [s]'}; elseif length(size(trace.data))==2 @@ -271,9 +285,18 @@ switch JETkeywrdcase{index} 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}; + if nargin>=3 & ~isempty(varargin{1}) + starti=varargin{1}(1); + endi=varargin{1}(2); + else + starti=1; + endi=24; + end + if nargin>=4 & ~isempty(varargin{2}) + status=varargin{2}; + else + status=ones(endi-starti+1,1); + end for i=starti:endi % Read channels from lowchannel to upchannel if necessary if status(i)==1 @@ -282,82 +305,68 @@ switch JETkeywrdcase{index} ppftype='jpf'; tracename=['db/j3-sxr<v' num2str(i) '''''/1' name_ext]; [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_eff_noext,'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 + trace.data(i,:) = a' * vconvert(i); + trace.t=t; + trace.x(i,:)=x; + error=e; end - trace.dim=[{trace.t} ; {[starti:endi]}]; - trace.dimunits=[{'time [s]'} ; {'channels'}]; + trace.dim=[{[starti:endi]'} ; {trace.t}]; + trace.dimunits=[{'channels'} ; {'time [s]'}]; + end + % calculating intersection of the view lines with magnetics axis + if strcmp(data_type_eff_noext,'sxR') + if nargin>=5 & ~isempty(varargin{3}) + zmag=varargin{3}; + else + zmag=loadJETdata(shot,'zmag'); + end + zmageff=interpos(13,zmag.t,zmag.data,trace.t); + for i=starti:endi + radius(i,:)=2.848 + (2.172-zmageff') .* tan(-4.5/180.*3.14159 - atan2(0.99.*(i-18),35.31)); + end + varargout={{radius}}; end %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& case 'ece' - starti=varargin{1}(1); - endi=varargin{1}(2); - status=varargin{2}; + if nargin>=3 & ~isempty(varargin{1}) + starti=varargin{1}(1); + endi=varargin{1}(2); + else + starti=1; + endi=24; + end + if nargin>=4 & ~isempty(varargin{2}) + status=varargin{2}; + else + status=ones(endi-starti+1,1); + end % 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) name_ext]; - [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) name_ext]; - [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) name_ext]; - [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) name_ext]; - [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 + % ECE, te0 + % Status=1 => Not Read Yet + ppftype='ppf'; + tracename=['kk3/te' num2str(i,'%2.2d') name_ext]; + [a,t,x,d,e]=jetreaddata(['http://data.jet.uk/' ppftype '/' num2str(shot) '/' tracename]); + trace.data(i,:)=a'; + trace.t=t; + trace.x(i,:)=x'; + error=e; + ppftype='ppf'; + tracename=['kk3/rc' num2str(i,'%2.2d') name_ext]; + [a,t,x,d,e]=jetreaddata(['http://data.jet.uk/' ppftype '/' num2str(shot) '/' tracename]); + radius.data(i,:)=a'; + radius.t=t; + radius.x(i,:)=x'; end end - trace.dim=[{trace.t} ; {[starti:endi]}]; - trace.dimunits=[{'time [s]'} ; {'channels'}]; - varargout={radius}; + trace.dim=[{[starti:endi]'} ; {trace.t}]; + trace.dimunits=[{'channels'} ; {'time [s]'}]; + varargout={{radius}}; + otherwise + disp('case not yet defined') + end - - diff --git a/JET/rda_eff.m b/JET/rda_eff.m index 21d7df82cbe47d00d8fa004618f6c33b5baa3b29..a626a0520177306d2fc783a333524d7300f57606 100644 --- a/JET/rda_eff.m +++ b/JET/rda_eff.m @@ -1,17 +1,30 @@ -function [data,time,x,hsig,error]=rda_eff(shot,pftype,tracename,varargin); +function [data,x,time,hsig,error]=rda_eff(shot,pftype,tracename,varargin); % % gets data using RDA or mdsplus +% 1D arrays: assumes dimension is time +% 2D arrays: assumes data vs (x,time) +% 3D arrays: assumes data vs (x,time,hsig) (for mdsplus) % % varargin{1}: time interval or timevalue, will get data closest to that time or within that time interval +% (DOES NOT WORK YET) % +% examples: +% [data,x,time,hsig,error]=rda_eff(51994,'ppf','efit/xip'); +% [data,x,time,hsig,error]=rda_eff(52206,'ppf','equi/rmji?uid=jetthg+seq=122'); +% +% usemds had-coded in this routine determines if RDA or mdsplus is used +% + +usemds=0; -usemds=1; time_int=[]; if nargin>=4 & ~isempty(varargin{1}) time_int=varargin{1}; end if usemds + % use mdsplus + if ~unix('test -d /home/duval/mdsplus') addpath('/home/duval/mdsplus') end @@ -86,21 +99,38 @@ if usemds nbofdim=max(nbofdim,1); switch nbofdim case 1 - eval(['time=mdsvalue(''dim_of(_rdaeff' user ',0)'')']); + eval(['time=mdsvalue(''dim_of(_rdaeff' user ',0)'');']); x=[]; case 2 - eval(['x=mdsvalue(''dim_of(_rdaeff' user ',0)'')']); - eval(['time=mdsvalue(''dim_of(_rdaeff' user ',1)'')']); + eval(['x=mdsvalue(''dim_of(_rdaeff' user ',0)'');']); + eval(['time=mdsvalue(''dim_of(_rdaeff' user ',1)'');']); case 3 - eval(['x=mdsvalue(''dim_of(_rdaeff' user ',0)'')']); - eval(['time=mdsvalue(''dim_of(_rdaeff' user ',1)'')']); + eval(['x=mdsvalue(''dim_of(_rdaeff' user ',0)'');']); + eval(['time=mdsvalue(''dim_of(_rdaeff' user ',1)'');']); disp('3rd dimension in hsig!!!!!!!!!!!!!!!!!!!!!!!!!') - eval(['hsig=mdsvalue(''dim_of(_rdaeff' user ',2)'')']); + eval(['hsig=mdsvalue(''dim_of(_rdaeff' user ',2)'');']); otherwise disp([' more than 3 dimensions for ' num2str(shot) ' ; ' pftype '/' tracename]) error('in rda_eff') + end + + mdsdisconnect + +else + % use RDA + [a,time,x,hsig,error]=jetreaddata(['http://data.jet.uk/' pftype '/' num2str(shot) '/' tracename]); + % transpose data as output in C format, reversed from Fortran and matlab standard + ss=size(a); + nbofdim=length(ss); + if ss(end)==1; nbofdim=nbofdim-1; end + nbofdim=max(nbofdim,1); + if nbofdim==1 + data=a; + else + data=a'; + end end diff --git a/gdat.m b/gdat.m index 17c3a4eacda5999dc235495f06a8591c66d67c2d..e6aa6c644a83eb4ea94da4d8942d54ceeec87894 100644 --- a/gdat.m +++ b/gdat.m @@ -48,10 +48,10 @@ function [trace,error,varargout] = gdat(shot,data_type,varargin) % Additional input arguments for specific traces (passed on to loadMACHINEdata function) % % data_type=sxr or ece: -% varargin{3}: channel status 1= unread yet, 0= read +% varargin{3}: [i1 i2] : if not empty, assumes need many chords from i1 to i2 +% varargin{4}: 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: