diff --git a/matlab/JET/jet_requests_mapping.m b/matlab/JET/jet_requests_mapping.m index 4ed7576f49814d24d16e7af2c3f8655fe71c2749..664bf4be1a85890b5eb2aebb0e9b888cb37ad249 100644 --- a/matlab/JET/jet_requests_mapping.m +++ b/matlab/JET/jet_requests_mapping.m @@ -340,10 +340,20 @@ switch lower(data_request) mapping.timedim = 1; mapping.method = 'signal'; mapping.expression = [{'PPF'},{'EFIT'},{'RMAG'}]; + case {'rnt', 'neutron_rate'} + mapping.label = 'neutron\_rate'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'TIN'},{'RNT'}]; case {'sxr', 'sxr_s40', 'sxr_htv'} mapping.timedim = 1; mapping.gdat_timedim = 2; mapping.method = 'switchcase'; + case {'tbeo'} + mapping.label = 'TBEO'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EDG8'},{'TBEO'}]; case 'te' mapping.timedim = 2; mapping.label = 'Te'; diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m index 11023819e8e91a2c040cf5ba609dc47a6a48855f..a6118f64c65737d25943d7f4ca4bed810cb82bea 100644 --- a/matlab/TCV/gdat_tcv.m +++ b/matlab/TCV/gdat_tcv.m @@ -56,7 +56,7 @@ function [gdat_data,gdat_params,error_status,varargout] = gdat_tcv(shot,data_req % a5=gdat(48836,'ip'); % standard call % a6=gdat(48836,'ip','Opt1',123,'Doplot',1,'opt2','Abc'); % standard call with a few options (note all lowercase in output) % a7 = gdat(48836,'static("r_m")[$1]'',''001'); % note first and last quote of tdi argument added by gdat -% a7 = gdat(48836,'tcv_eq(''''psi'''',''''liuqe.m'''')'); % do not use double quote char so 'liuqe',11 will work +% a7 = gdat(48836,'tcv_eq("psi","liuqe.m")'); % do not use double quote char so 'liuqe',11 will work % a8 = gdat(64770,['\magnetics::bpol_003[*,$1]'',{''001''; ''030''}']); one string full expression % a9 = gdat(64770,{'\magnetics::vloop[*,$1]',{'''001''','''A_001'''}}); cell array (other option) % @@ -143,9 +143,9 @@ if nargin>=1 % means mdsopen(shot) already performed or not shot asked for try if isempty(mdsipmex(8)) - shot_mds = shot; + shot_mds = shot; else - shot_mds = mdsipmex(2,'$SHOT'); + shot_mds = mdsipmex(2,'$SHOT'); end catch shot_mds = shot; @@ -156,18 +156,18 @@ if nargin>=1 if ischar(shot) || isempty(shot) if gdat_params.nverbose>=1 if isstruct(data_request) && isfield(data_request,'data_request') - if ~strcmp(data_request.data_request,'ids') - warning(['shot cannot be opened with ' data_request.data_request]); - return - end + if ~strcmp(data_request.data_request,'ids') + warning(['shot cannot be opened with ' data_request.data_request]); + return + end elseif ischar(data_request) - if ~strcmp(data_request,'ids') - warning(['shot cannot be opened with ' data_request]); - return - end + if ~strcmp(data_request,'ids') + warning(['shot cannot be opened with ' data_request]); + return + end else warning(['shot cannot be opened']); - return + return end end end @@ -230,6 +230,7 @@ end % extract parameters from pairs of varargin: i_liuqe_set_in_pairs = 0; % to know if liuqe was not set explicitely thus use value in expression later +if isstruct(data_request) && isfield(data_request,'liuqe'), i_liuqe_set_in_pairs = 1; end % given in input parameter structure if (nargin>=ivarargin_first_char) if mod(nargin-ivarargin_first_char+1,2)==0 for i=1:2:nargin-ivarargin_first_char+1 @@ -290,14 +291,37 @@ shot = gdat_data.shot; data_request_eff = gdat_data.gdat_params.data_request; error_status = 6; % at least reached this level +mapping_for_tcv = tcv_requests_mapping(data_request_eff,shot); +gdat_data.label = mapping_for_tcv.label; + liuqe_version = 1; -if isfield(gdat_data.gdat_params,'liuqe') && ~isempty(gdat_data.gdat_params.liuqe) +if isfield(gdat_data.gdat_params,'liuqe') && ~isempty(gdat_data.gdat_params.liuqe) && i_liuqe_set_in_pairs==1 liuqe_version = gdat_data.gdat_params.liuqe; else - gdat_data.gdat_params.liuqe = liuqe_version; + % if no specific liuqe requested in the parameter option, but specified e.g. in tcv_eq, use that one otherwise default + if ~iscell(mapping_for_tcv.expression) + bb{1} = mapping_for_tcv.expression; + else + bb = mapping_for_tcv.expression; + end + for i=1:numel(bb) + if any(regexpi(bb{i},'fbte','once')) + liuqe_version = -1 + else + ij = regexpi(bb{i},'LIUQE\.M.?','once'); + if ~isempty(ij) && any(regexpi(bb{i},'LIUQE\.M[2,3]','once')) + liuqe_version = str2num(bb{i}(ij+7)) + end + ij = regexpi(bb{i},'LIUQE[^\.]','once'); + if ~isempty(ij) && any(regexpi(bb{i},'LIUQE[2,3]','once')) + liuqe_version = str2num(bb{i}(ij+5)) + end + end + end end +gdat_data.gdat_params.liuqe = liuqe_version; liuqe_matlab = 1; % now default should be matlab liuqe nodes -if liuqe_version<0 || (liuqe_version > 10 && liuqe_version < 20) +if (liuqe_version > 10 && liuqe_version < 20) liuqe_matlab = 0; end liuqe_version_eff = mod(liuqe_version,10); @@ -310,28 +334,35 @@ if liuqe_version_eff==2 || liuqe_version_eff==3 substr_liuqe_tcv_eq = num2str(liuqe_version_eff); end -mapping_for_tcv = tcv_requests_mapping(data_request_eff,shot); -gdat_data.label = mapping_for_tcv.label; -% special treatment for model shot=-1 or preparation shot >=100'000 +% special treatment for model shot=-1 or preparation shot >=900'000 begstr = ''; if (iscell(mapping_for_tcv.expression) || isempty(strfind(mapping_for_tcv.expression,'\rtc::'))) && ... - ~isempty(shot) && (shot==-1 || (shot>=100000 && shot < 200000) || liuqe_version==-1 ) + ~isempty(shot) && (shot==-1 || (shot>=900000 && shot <= 999999 ) || liuqe_version==-1 ) % requires FBTE liuqe_version_eff = -1; - begstr = 'tcv_eq( "'; - substr_liuqe = '", "FBTE" )'; + liuqe_version = -1; + if isempty(findstr(mapping_for_tcv.expression,'tcv_eq')) + % if tcv_eq in expression, liuqe target will be modified to FBTE below with regexprep + begstr = 'tcv_eq( "'; + substr_liuqe = '", "FBTE" )'; + else + begstr = ''; + substr_liuqe = ''; + end end % should replace all above by just psitbx_str... liuqe_matlab = 1; switch liuqe_version - case {-1}, liuqe_ext=''; psitbx_str='FBTE'; liuqe_matlab = 0; + case {-1}, liuqe_ext=''; psitbx_str='FBTE'; case {1,21}, liuqe_ext=''; psitbx_str='LIUQE.M'; case {11}, liuqe_ext=''; psitbx_str='LIUQE';liuqe_matlab = 0; case {2, 3, 22, 23}, liuqe_ext=['_' num2str(mod(liuqe_version,10))]; psitbx_str=['LIUQE.M' num2str(mod(liuqe_version,10))]; case {12,13}, liuqe_ext=['_' num2str(mod(liuqe_version,10))]; psitbx_str=['LIUQE' num2str(mod(liuqe_version,10))];liuqe_matlab = 0; otherwise, error(['Unknown LIUQE version, liuqe = ' num2str(liuqe_version)]); end +% entry in gdat_request superseded by 'liuqe' option (so remove replacement later) +mapping_for_tcv.expression = regexprep(mapping_for_tcv.expression,'FBTE([",''])|LIUQE[2-3]?([",''])|LIUQE.M[2-3]?([",''])',[psitbx_str '$1'],'preservecase'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -411,22 +442,14 @@ if strcmp(mapping_for_tcv.method(1:3),'tdi') return end else - do_liuqem2liuqef = 0; + do_liuqem2liuqef = 1; if liuqe_version_eff==-1 % trialindx not relevant for fbte mapping_for_tcv_expression_eff = mapping_for_tcv.expression; if length(mapping_for_tcv.expression)>8 && strcmp(lower(mapping_for_tcv.expression(1:8)),'\results') mapping_for_tcv_expression_eff = mapping_for_tcv.expression(11:end); - elseif findstr('tcv_eq',lower(mapping_for_tcv.expression)) - ij = regexpi(mapping_for_tcv.expression,''''''); - if length(ij)<2 - disp(['expected more double quotes in mapping_for_tcv.expression = ' mapping_for_tcv.expression]); - return - else - mapping_for_tcv_expression_eff = mapping_for_tcv.expression(ij(1)+2:ij(2)-1); - end end - eval_expr = ['tdi(''' begstr mapping_for_tcv_expression_eff substr_liuqe ''');'] + eval_expr = ['tdi(''' begstr mapping_for_tcv_expression_eff substr_liuqe ''');']; else aaa_tmp = regexp(mapping_for_tcv.expression,{'toray','conf','ibs','proffit','astra'}); if ~isempty(gdat_data.gdat_params.trialindx) && gdat_data.gdat_params.trialindx >= 0 ... @@ -446,66 +469,25 @@ if strcmp(mapping_for_tcv.method(1:3),'tdi') if ~isempty(ij) mapping_for_tcv.expression(ij+5:ij+6) = substr_liuqe; end - ij = regexpi(mapping_for_tcv.expression,'LIUQE\.M.?','once'); - if ~isempty(ij) - ichar_after_liuqe = 7; - if strcmp(mapping_for_tcv.expression(ij+ichar_after_liuqe),'2') || ... - strcmp(mapping_for_tcv.expression(ij+ichar_after_liuqe),'3') - if i_liuqe_set_in_pairs==0 - gdat_params.liuqe = str2num(mapping_for_tcv.expression(ij+ichar_after_liuqe)); - gdat_data.gdat_params = gdat_params; - substr_liuqe_tcv_eq = mapping_for_tcv.expression(ij+ichar_after_liuqe); - end - ichar_after_liuqe = 8; - end - mapping_for_tcv.expression = [mapping_for_tcv.expression(1:ij+6) substr_liuqe_tcv_eq mapping_for_tcv.expression(ij+ichar_after_liuqe:end)]; - else - % check if liuqe, liuqe2 or liuqe3 is given in expression - ij = regexpi(mapping_for_tcv.expression,'LIUQE[^\.]','once'); - if ~isempty(ij) - ichar_after_liuqe = 5; - if strcmp(mapping_for_tcv.expression(ij+ichar_after_liuqe),'2') || ... - strcmp(mapping_for_tcv.expression(ij+ichar_after_liuqe),'3') - if i_liuqe_set_in_pairs==0 - gdat_params.liuqe = 10+str2num(mapping_for_tcv.expression(ij+ichar_after_liuqe)); - gdat_data.gdat_params = gdat_params; - substr_liuqe_tcv_eq = mapping_for_tcv.expression(ij+ichar_after_liuqe); - end - ichar_after_liuqe = 6; - else - if i_liuqe_set_in_pairs==0 - gdat_params.liuqe = 11; - gdat_data.gdat_params = gdat_params; - substr_liuqe_tcv_eq = ''; - end - end - if i_liuqe_set_in_pairs==1 && liuqe_matlab==1 - % enforce matlab liuqe version even matlab if asked for - substr_liuqe_tcv_eq = ['.M' substr_liuqe_tcv_eq]; - end - mapping_for_tcv.expression = [mapping_for_tcv.expression(1:ij+4) substr_liuqe_tcv_eq mapping_for_tcv.expression(ij+ichar_after_liuqe:end)]; - end - end - else - ij = regexpi(mapping_for_tcv.expression,'LIUQE\.M.?','once'); - if ~isempty(ij) - mapping_for_tcv.expression = [mapping_for_tcv.expression(1:ij+4) substr_liuqe_tcv_eq mapping_for_tcv.expression(ij+7:end)]; - do_liuqem2liuqef = 1; - end end eval_expr = ['tdi(''' mapping_for_tcv.expression ''');']; end % special cases for matching liuqe fortran and matlab if liuqe_matlab == 0 && do_liuqem2liuqef==1 - % assume tcv_eq(''keyword'',''LIUQE..'') + % assume tcv_eq(''keyword'',''LIUQE..'') or tcv_eq("keyword","LIUQE..") liuqe_fortran_matlab = liuqefortran2liuqematlab; - ij = regexpi(eval_expr,''''''); - if numel(ij)>=2 - liuqe_keyword = eval_expr(ij(1)+2:ij(2)-1); + eval_expr_eff = strrep(eval_expr,'''',''); + eval_expr_eff = strrep(eval_expr_eff,'"',''); + ij = regexpi(eval_expr_eff,','); + if isempty(ij) + disp(['expected tdi(tcv_eq(...,...) with quotes or double quotes in eval_expr = ' eval_expr]); + return + else + liuqe_keyword = eval_expr_eff(4+8:ij(1)-1); end ij_row=strmatch(liuqe_keyword,liuqe_fortran_matlab(:,2),'exact'); if ~isempty(ij_row) - eval_expr = [eval_expr(1:ij(1)+1) liuqe_fortran_matlab{ij_row,1} eval_expr(ij(1)+2+length(liuqe_keyword):end)]; + eval_expr = regexprep(eval_expr,['\<' liuqe_keyword '\>'],liuqe_fortran_matlab{ij_row,1},'preservecase'); end end aatmp=eval(eval_expr); @@ -525,7 +507,7 @@ if strcmp(mapping_for_tcv.method(1:3),'tdi') end end end - if isempty(aatmp.data) || (isempty(aatmp.dim) && ischar(aatmp.data) && ~isempty(strfind(lower(aatmp.data),'no data')))% || ischar(aatmp.data) (to add?) + if isempty(aatmp.data) || (isempty(aatmp.dim) && ischar(aatmp.data) && ~isempty(strfind(lower(aatmp.data),'no data')) ) % || ischar(aatmp.data) (to add?) if (gdat_params.nverbose>=1); warning(['problems loading data for ' eval_expr ' for data_request= ' data_request_eff]); end if (gdat_params.nverbose>=3); disp('check .gdat_request list'); end return @@ -688,7 +670,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') if strcmp(data_request_eff,'r_geom_rho'); data_request_eff = 'rgeom_rho'; end % compute average minor or major radius (on z=zaxis normally) if liuqe_matlab==0 - nodenameeff=['tcv_eq(''r_max_psi'',''LIUQE' substr_liuqe_tcv_eq ''')']; + nodenameeff=['tcv_eq("r_max_psi","' psitbx_str '")']; rmaxpsi=tdi(nodenameeff); ijnan = find(isnan(rmaxpsi.data)); if isempty(rmaxpsi.data) || isempty(rmaxpsi.dim) || ischar(rmaxpsi.data) || ... @@ -697,7 +679,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') if (gdat_params.nverbose>=3); disp(['rerun LIUQE?']); end return end - nodenameeff2=['tcv_eq(''r_min_psi'',''LIUQE' substr_liuqe_tcv_eq ''')']; + nodenameeff2=['tcv_eq("r_min_psi","' psitbx_str '")']; rminpsi=tdi(nodenameeff2); ijnan = find(isnan(rminpsi.data)); if isempty(rminpsi.data) || isempty(rminpsi.dim) || ... @@ -730,7 +712,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') gdat_data.dim = rmaxpsi.dim; gdat_data.t = gdat_data.dim{mapping_for_tcv.timedim}; gdat_data.x = gdat_data.dim{1}; - gdat_data.dimunits = rmaxpsi.dimunits(2); + gdat_data.dimunits = rmaxpsi.dimunits; else gdat_data.dim = rmaxpsi.dim(2); gdat_data.t = gdat_data.dim{mapping_for_tcv.timedim}; @@ -742,19 +724,19 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') else if isempty(substr_liuqe); substr_liuqe = '_1'; end if strcmp(data_request_eff,'a_minor') % to update when ready, still buggy, this should be rho,t - nodenameeff=['tcv_eq(''a_minor_mid'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; + nodenameeff=['tcv_eq("a_minor_mid","' psitbx_str '")']; elseif strcmp(data_request_eff,'a_minor_rho') - nodenameeff=['tcv_eq(''r_out_mid'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; - nodenameeff2=['tcv_eq(''r_in_mid'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; - nodenameeff=['tcv_eq(''r_out'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; - nodenameeff2=['tcv_eq(''r_in'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; + nodenameeff=['tcv_eq("r_out_mid","' psitbx_str '")']; + nodenameeff2=['tcv_eq("r_in_mid","' psitbx_str '")']; + nodenameeff=['tcv_eq("r_out","' psitbx_str '")']; + nodenameeff2=['tcv_eq("r_in","' psitbx_str '")']; elseif strcmp(data_request_eff,'rgeom') - nodenameeff=['tcv_eq(''r_geom_mid'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; + nodenameeff=['tcv_eq("r_geom_mid","' psitbx_str '")']; elseif strcmp(data_request_eff,'rgeom_rho') - nodenameeff=['tcv_eq(''r_out_mid'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; - nodenameeff2=['tcv_eq(''r_in_mid'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; - nodenameeff=['tcv_eq(''r_out'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; - nodenameeff2=['tcv_eq(''r_in'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; + nodenameeff=['tcv_eq("r_out_mid","' psitbx_str '")']; + nodenameeff2=['tcv_eq("r_in_mid","' psitbx_str '")']; + nodenameeff=['tcv_eq("r_out","' psitbx_str '")']; + nodenameeff2=['tcv_eq("r_in","' psitbx_str '")']; else if (gdat_params.nverbose>=1); warning(['should not be in this case with data_request_eff = ' data_request_eff]); end return @@ -795,10 +777,10 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') gdat_data.gdat_params.gdat_request = gdat_data.gdat_request; gdat_params = gdat_data.gdat_params; if liuqe_matlab==0 - nodenameeff=['tcv_eq(''z_contour'',''LIUQE' substr_liuqe_tcv_eq ''')']; + nodenameeff=['tcv_eq("z_contour","' psitbx_str '")']; else if isempty(substr_liuqe); substr_liuqe = '_1'; end - nodenameeff=['tcv_eq(''z_edge'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; + nodenameeff=['tcv_eq("z_edge","' psitbx_str '")']; end zcontour=tdi(nodenameeff); if isempty(zcontour.data) || isempty(zcontour.dim) % || ischar(zcontour.data) (to add?) @@ -829,6 +811,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') case {'b0'} % B0 at R0=0.88 r0exp=0.88; + added_correction_str=''; if isfield(gdat_data.gdat_params,'source') && ~isempty(gdat_data.gdat_params.source) ... && length(gdat_data.gdat_params.source)>=5 && strcmp(lower(gdat_data.gdat_params.source(1:5)),'liuqe') % expect liuqe or liuqe.m to have liuqe time-base, otherwise give full time base @@ -849,11 +832,10 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') else if liuqe_matlab==0 added_correction = 1.0; % correction already in liuqe.f - added_correction_str = ['']; - nodenameeff = ['tcv_eq(''BZERO'',''LIUQE' substr_liuqe_tcv_eq ''')']; + nodenameeff = ['tcv_eq("BZERO","' psitbx_str '")']; else if isempty(substr_liuqe); substr_liuqe = '_1'; end - nodenameeff=['tcv_eq(''BZERO'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; + nodenameeff=['tcv_eq("BZERO","' psitbx_str '")']; added_correction = 0.996; % correction removed in liuqe.m at this stage added_correction_str = [num2str(added_correction) ' * ']; end @@ -1265,7 +1247,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') xx=repmat(reshape(gdat_data.dim{1},length(gdat_data.dim{1}),1),1,size(gdat_data.eqdsk(itime).psi,2)); yy=repmat(reshape(gdat_data.dim{2},1,length(gdat_data.dim{2})),size(gdat_data.eqdsk(itime).psi,1),1); aa = interpos2Dcartesian(gdat_data.eqdsk(itime).rmesh,gdat_data.eqdsk(itime).zmesh ... - ,gdat_data.eqdsk(itime).psi,xx,yy,-1,-1); + ,gdat_data.eqdsk(itime).psi,xx,yy,-1,-1); gdat_data.data(:,:,itime) = aa; end else @@ -1307,7 +1289,11 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') gdat_data.gas_request_flux = gasrequest; gdat_data.gas_request_flux.data = max(0.,72.41.*(gasrequest.data-0.6879)./(4.2673-0.6879)); gdat_data.gas_request_flux.units = gasflux.units; - params_eff.data_request = '\draw_feedfor_gas:alim_001'; + if shot < 78667 + params_eff.data_request = '\draw_feedfor_gas:alim_001'; + else + params_eff.data_request = '\draw_refs_gas:ref_001'; + end gasrequest_ref = gdat_tcv(gdat_data.shot,params_eff); gasrequest_ref.units = 'V'; gdat_data.gas_feedforward_volt = gasrequest_ref; gdat_data.gas_feedforward_flux = gasrequest_ref; @@ -1453,6 +1439,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') rethrow(ME); end end + % set default inputs if not given if ~isfield(gdat_data.gdat_params,'error_bar') || isempty(gdat_data.gdat_params.error_bar) gdat_data.gdat_params.error_bar = 'delta'; end @@ -1538,7 +1525,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end elseif ~iscell(gdat_data.gdat_params.source) if ischar(gdat_data.gdat_params.source) - gdat_data.gdat_params.source = lower(gdat_data.gdat_params.source); + gdat_data.gdat_params.source = lower(gdat_data.gdat_params.source); if ~any(strmatch(gdat_data.gdat_params.source,lower(sources_avail))) if (gdat_params.nverbose>=1) warning(['source= ' gdat_data.gdat_params.source ' is not part of the available sources: ' sprintf('''%s'' ',sources_avail{:})]); @@ -1584,123 +1571,231 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') data_fullpath = ''; ec_help = ''; % EC + + % fill ec_inputs from write_pgyro + [~,time,pgyro,pgyro_ecrh,gyro2launcher,freq2launcher,~,~] = write_pgyro(shot,'doplots',0); + + ec_inputs.pgyro.data = pgyro; + ec_inputs.pgyro.t = time; + ec_inputs.pgyro.units = 'W'; + ec_inputs.pgyro.label = 'Power injected per launcher ; last index is total'; + ec_inputs.pgyro.x = 1:numel(pgyro(1,:)); + ec_inputs.pgyro.dim = {ec_inputs.pgyro.x, ec_inputs.pgyro.t}; + launchers_label = cellfun(@num2str, num2cell(1:size(pgyro,2)-1),'UniformOutput',false); + launchers_label{end+1} = 'tot'; + ec_inputs.pgyro.dimunits = {launchers_label, 's'}; + + ec_inputs.launchers_active.data = zeros(numel(pgyro_ecrh),1); + for ii =1:numel(pgyro_ecrh) + if ~isempty(pgyro_ecrh{ii}.data); ec_inputs.launchers_active.data(ii) = 1; end + end + ec_inputs.launchers_active.label = 'Active launchers in the shot (1:active, 0:inactive)'; + + ec_inputs.gyro2launcher.data = gyro2launcher; + ec_inputs.gyro2launcher.label = 'Gyrotron connected to launcher'; + + ec_inputs.freq2launcher.data = freq2launcher; + ec_inputs.freq2launcher.label = 'Frequency in launcher'; + ec_inputs.freq2launcher.units = 'Hz'; + + gdat_data.ec.ec_inputs = ec_inputs; + + % introduce flag to check whether ec_data could be retrieved successfully + filled_successfully = false; + if strcmp(lower(source_icd.ec),'toray') - if isempty(gdat_data.gdat_params.trialindx) - [pabs_gyro,icdtot,pow_dens,currentdrive_dens,rho_dep_pow,drho_pow,pmax,icdmax,currentdrive_dens_w2,rho_dep_icd,drho_icd] = astra_tcv_EC_exp(shot); % centralized function for toray nodes - else - [pabs_gyro,icdtot,pow_dens,currentdrive_dens,rho_dep_pow,drho_pow,pmax,icdmax,currentdrive_dens_w2,rho_dep_icd,drho_icd] = astra_tcv_EC_exp(shot,[],[],[],[],[],gdat_data.gdat_params.trialindx); % centralized function for toray nodes - end - if gdat_data.mapping_for.tcv.gdat_timedim ==2 - tgrid_to_change = {'pabs_gyro','icdtot','pow_dens','currentdrive_dens','rho_dep_pow','drho_pow','pmax', ... - 'icdmax','currentdrive_dens_w2','rho_dep_icd','drho_icd'}; - for i=1:length(tgrid_to_change) - eval([tgrid_to_change{i} '.tgrid = reshape(' tgrid_to_change{i} '.tgrid,1,numel(' tgrid_to_change{i} '.tgrid));']); + try % fill ec_data from TORAY via astra_tcv_exp outputs + % centralized function for toray nodes + [pabs_gyro,icdtot,pow_dens,currentdrive_dens,rho_dep_pow,drho_pow,... + pmax,icdmax,currentdrive_dens_w2,rho_dep_icd,drho_icd,~,power_integrated,currentdrive_integrated] = ... + astra_tcv_EC_exp(shot,[],[],[],[],[],gdat_data.gdat_params.trialindx,1); + if gdat_data.mapping_for.tcv.gdat_timedim ==2 + tgrid_to_change = {'pabs_gyro','icdtot','pow_dens','currentdrive_dens','rho_dep_pow','drho_pow','pmax', ... + 'icdmax','currentdrive_dens_w2','rho_dep_icd','drho_icd'}; + for i=1:length(tgrid_to_change) + eval([tgrid_to_change{i} '.tgrid = reshape(' tgrid_to_change{i} '.tgrid,1,numel(' tgrid_to_change{i} '.tgrid));']); + end end - end - ec_help = 'from toray icdint with extracting of effective Icd for given launcher depending on nb rays used'; - % All EC related quantities, each substructure should have at least fields data,x,t,units,dim,dimunits,label to be copied onto gdat_data - launchers_label = {'1','2','3','4','5','6','7','8','9','tot'}; - launchers_grid = [1:10]'; - % power deposition related: - ec_data.p_abs_plasma.data = pabs_gyro.data * 1e6; - ec_data.p_abs_plasma.data(end+1,:) = sum(ec_data.p_abs_plasma.data,1,'omitnan'); - ec_data.p_abs_plasma.label = [strrep(pabs_gyro.comment,'MW','W') ' ; last index is total']; - ec_data.p_abs_plasma.units = 'W'; - ec_data.p_abs_plasma.x = launchers_grid; - ec_data.p_abs_plasma.t =pabs_gyro.tgrid; - ec_data.p_abs_plasma.dim = {ec_data.p_abs_plasma.x, ec_data.p_abs_plasma.t}; - ec_data.p_abs_plasma.dimunits = {launchers_label, 's'}; - % - ec_data.p_dens.data = pow_dens.data * 1e6; - ec_data.p_dens.data(:,end+1,:) = sum(ec_data.p_dens.data,2,'omitnan'); - ec_data.p_dens.label = [strrep(pow_dens.comment,'MW','W') ' ; last index is total']; - ec_data.p_dens.units = 'W/m^3'; - ec_data.p_dens.x = pow_dens.rgrid'; - ec_data.p_dens.rhotor_norm = ec_data.p_dens.x; - ec_data.p_dens.t = pow_dens.tgrid; - ec_data.p_dens.dim = {ec_data.p_dens.x, launchers_grid, ec_data.p_dens.t}; - ec_data.p_dens.dimunits = {'rhotor_norm', launchers_label, 's'}; - % - ec_data.max_pow_dens.data = pmax.data * 1e6; - ec_data.max_pow_dens.label = strrep(pmax.comment,'MW','W'); - ec_data.max_pow_dens.units = 'W/m^3'; - ec_data.max_pow_dens.x = []; - ec_data.max_pow_dens.t = pmax.tgrid; - ec_data.max_pow_dens.dim = {ec_data.max_pow_dens.t}; - ec_data.max_pow_dens.dimunits = {'s'}; - % - ec_data.rho_max_pow_dens.data = rho_dep_pow.data; - ec_data.rho_max_pow_dens.label = rho_dep_pow.comment; - ec_data.rho_max_pow_dens.units = 'rhotor_norm'; - ec_data.rho_max_pow_dens.x = []; - ec_data.rho_max_pow_dens.t = rho_dep_pow.tgrid; - ec_data.rho_max_pow_dens.dim = {ec_data.rho_max_pow_dens.t}; - ec_data.rho_max_pow_dens.dimunits = {'s'}; - % - ec_data.width_pow_dens.data = drho_pow.data; - ec_data.width_pow_dens.label = drho_pow.comment; - ec_data.width_pow_dens.units = 'rhotor_norm'; - ec_data.width_pow_dens.x = []; - ec_data.width_pow_dens.t = drho_pow.tgrid; - ec_data.width_pow_dens.dim = {ec_data.width_pow_dens.t}; - ec_data.width_pow_dens.dimunits = {'s'}; - % current drive deposition related: - ec_data.cd_tot.data = icdtot.data * 1e6; - ec_data.cd_tot.data(end+1,:) = sum(ec_data.cd_tot.data,1,'omitnan'); - ec_data.cd_tot.label = [strrep(icdtot.comment,'MA','A') ' ; last index is total']; - ec_data.cd_tot.units = 'A'; - ec_data.cd_tot.x = launchers_grid; - ec_data.cd_tot.t = icdtot.tgrid; - ec_data.cd_tot.dim = {ec_data.cd_tot.x, ec_data.cd_tot.t}; - ec_data.cd_tot.dimunits = {launchers_label, 's'}; - % - ec_data.cd_dens.data = currentdrive_dens.data * 1e6; - ec_data.cd_dens.data(:,end+1,:) = sum(ec_data.cd_dens.data,2,'omitnan'); - ec_data.cd_dens.label = [strrep(currentdrive_dens.comment,'MA','A') ' ; last index is total']; - ec_data.cd_dens.units = 'A/m^2'; - ec_data.cd_dens.x = currentdrive_dens.rgrid'; - ec_data.cd_dens.rhotor_norm = ec_data.cd_dens.x; - ec_data.cd_dens.t = currentdrive_dens.tgrid; - ec_data.cd_dens.dim = {ec_data.cd_dens.x, launchers_grid, ec_data.cd_dens.t}; - ec_data.cd_dens.dimunits = {'rhotor_norm', launchers_label, 's'}; - % - ec_data.max_cd_dens.data = icdmax.data * 1e6; - ec_data.max_cd_dens.label = strrep(icdmax.comment,'MA','A'); - ec_data.max_cd_dens.units = 'A/m^2'; - ec_data.max_cd_dens.x = []; - ec_data.max_cd_dens.t = icdmax.tgrid; - ec_data.max_cd_dens.dim = {ec_data.max_cd_dens.t}; - ec_data.max_cd_dens.dimunits = {'s'}; - % - ec_data.rho_max_cd_dens.data = rho_dep_icd.data; - ec_data.rho_max_cd_dens.label = rho_dep_icd.comment; - ec_data.rho_max_cd_dens.units = 'rhotor_norm'; - ec_data.rho_max_cd_dens.x = []; - ec_data.rho_max_cd_dens.t = rho_dep_icd.tgrid; - ec_data.rho_max_cd_dens.dim = {ec_data.rho_max_cd_dens.t}; - ec_data.rho_max_cd_dens.dimunits = {'s'}; - % - ec_data.width_cd_dens.data = drho_icd.data; - ec_data.width_cd_dens.label = drho_icd.comment; - ec_data.width_cd_dens.units = 'rhotor_norm'; - ec_data.width_cd_dens.x = []; - ec_data.width_cd_dens.t = drho_icd.tgrid; - ec_data.width_cd_dens.dim = {ec_data.width_cd_dens.t}; - ec_data.width_cd_dens.dimunits = {'s'}; - % - ec_data.cd_dens_doublewidth.data = currentdrive_dens_w2.data * 1e6; - ec_data.cd_dens_doublewidth.label = [strrep(currentdrive_dens_w2.comment,'MA','A') ' ; last index is total']; - for subfields={'x','rhotor_norm','t','dim','dimunits','units'} - ec_data.cd_dens_doublewidth.(subfields{1}) = ec_data.cd_dens.(subfields{1}); + ec_help = 'from toray icdint with extracting of effective Icd for given launcher depending on nb rays used'; + % All EC related quantities, each substructure should have at least fields data,x,t,units,dim,dimunits,label to be copied onto gdat_data + + launchers_label = cellfun(@num2str, num2cell(1:size(pabs_gyro.data,1)),'UniformOutput',false); + launchers_label{end+1} = 'tot'; + launchers_grid = [1:size(pabs_gyro.data,1)+1]'; + + % power deposition related: + ec_data.p_abs_plasma.data = pabs_gyro.data * 1e6; + ec_data.p_abs_plasma.data(end+1,:) = sum(ec_data.p_abs_plasma.data,1,'omitnan'); + ec_data.p_abs_plasma.label = [strrep(pabs_gyro.comment,'MW','W') ' ; last index is total']; + ec_data.p_abs_plasma.units = 'W'; + ec_data.p_abs_plasma.x = launchers_grid; + ec_data.p_abs_plasma.t =pabs_gyro.tgrid; + ec_data.p_abs_plasma.dim = {ec_data.p_abs_plasma.x, ec_data.p_abs_plasma.t}; + ec_data.p_abs_plasma.dimunits = {launchers_label, 's'}; + % + ec_data.p_dens.data = pow_dens.data * 1e6; + ec_data.p_dens.data(:,end+1,:) = sum(ec_data.p_dens.data,2,'omitnan'); + ec_data.p_dens.label = [strrep(pow_dens.comment,'MW','W') ' ; last index is total']; + ec_data.p_dens.units = 'W/m^3'; + ec_data.p_dens.x = pow_dens.rgrid'; + ec_data.p_dens.rhotor_norm = ec_data.p_dens.x; + ec_data.p_dens.t = pow_dens.tgrid; + ec_data.p_dens.dim = {ec_data.p_dens.x, launchers_grid, ec_data.p_dens.t}; + ec_data.p_dens.dimunits = {'rhotor_norm', launchers_label, 's'}; + % + ec_data.p_integrated.data = power_integrated.data * 1e6; + ec_data.p_integrated.data(:,end+1,:) = sum(ec_data.p_integrated.data,2,'omitnan'); + ec_data.p_integrated.label = [strrep(power_integrated.comment,'MW','W') ' ; last index is total']; + ec_data.p_integrated.units = 'W'; + ec_data.p_integrated.x = power_integrated.rgrid'; + ec_data.p_integrated.rhotor_norm = ec_data.p_integrated.x; + ec_data.p_integrated.t = power_integrated.tgrid; + ec_data.p_integrated.dim = {ec_data.p_integrated.x, launchers_grid, ec_data.p_integrated.t}; + ec_data.p_integrated.dimunits = {'rhotor_norm', launchers_label, 's'}; + % + ec_data.max_pow_dens.data = pmax.data * 1e6; + ec_data.max_pow_dens.label = strrep(pmax.comment,'MW','W'); + ec_data.max_pow_dens.units = 'W/m^3'; + ec_data.max_pow_dens.x = []; + ec_data.max_pow_dens.t = pmax.tgrid; + ec_data.max_pow_dens.dim = {ec_data.max_pow_dens.t}; + ec_data.max_pow_dens.dimunits = {'s'}; + % + ec_data.rho_max_pow_dens.data = rho_dep_pow.data; + ec_data.rho_max_pow_dens.label = rho_dep_pow.comment; + ec_data.rho_max_pow_dens.units = 'rhotor_norm'; + ec_data.rho_max_pow_dens.x = []; + ec_data.rho_max_pow_dens.t = rho_dep_pow.tgrid; + ec_data.rho_max_pow_dens.dim = {ec_data.rho_max_pow_dens.t}; + ec_data.rho_max_pow_dens.dimunits = {'s'}; + % + ec_data.width_pow_dens.data = drho_pow.data; + ec_data.width_pow_dens.label = drho_pow.comment; + ec_data.width_pow_dens.units = 'rhotor_norm'; + ec_data.width_pow_dens.x = []; + ec_data.width_pow_dens.t = drho_pow.tgrid; + ec_data.width_pow_dens.dim = {ec_data.width_pow_dens.t}; + ec_data.width_pow_dens.dimunits = {'s'}; + + % current drive deposition related: + ec_data.cd_tot.data = icdtot.data * 1e6; + ec_data.cd_tot.data(end+1,:) = sum(ec_data.cd_tot.data,1,'omitnan'); + ec_data.cd_tot.label = [strrep(icdtot.comment,'MA','A') ' ; last index is total']; + ec_data.cd_tot.units = 'A'; + ec_data.cd_tot.x = launchers_grid; + ec_data.cd_tot.t = icdtot.tgrid; + ec_data.cd_tot.dim = {ec_data.cd_tot.x, ec_data.cd_tot.t}; + ec_data.cd_tot.dimunits = {launchers_label, 's'}; + % + ec_data.cd_dens.data = currentdrive_dens.data * 1e6; + ec_data.cd_dens.data(:,end+1,:) = sum(ec_data.cd_dens.data,2,'omitnan'); + ec_data.cd_dens.label = [strrep(currentdrive_dens.comment,'MA','A') ' ; last index is total']; + ec_data.cd_dens.units = 'A/m^2'; + ec_data.cd_dens.x = currentdrive_dens.rgrid'; + ec_data.cd_dens.rhotor_norm = ec_data.cd_dens.x; + ec_data.cd_dens.t = currentdrive_dens.tgrid; + ec_data.cd_dens.dim = {ec_data.cd_dens.x, launchers_grid, ec_data.cd_dens.t}; + ec_data.cd_dens.dimunits = {'rhotor_norm', launchers_label, 's'}; + % + ec_data.cd_integrated.data = currentdrive_integrated.data * 1e6; + ec_data.cd_integrated.data(:,end+1,:) = sum(ec_data.cd_integrated.data,2,'omitnan'); + ec_data.cd_integrated.label = [strrep(currentdrive_integrated.comment,'MA','A') ' ; last index is total']; + ec_data.cd_integrated.units = 'A'; + ec_data.cd_integrated.x = currentdrive_integrated.rgrid'; + ec_data.cd_integrated.rhotor_norm = ec_data.cd_integrated.x; + ec_data.cd_integrated.t = currentdrive_integrated.tgrid; + ec_data.cd_integrated.dim = {ec_data.cd_integrated.x, launchers_grid, ec_data.cd_integrated.t}; + ec_data.cd_integrated.dimunits = {'rhotor_norm', launchers_label, 's'}; + % + ec_data.max_cd_dens.data = icdmax.data * 1e6; + ec_data.max_cd_dens.label = strrep(icdmax.comment,'MA','A'); + ec_data.max_cd_dens.units = 'A/m^2'; + ec_data.max_cd_dens.x = []; + ec_data.max_cd_dens.t = icdmax.tgrid; + ec_data.max_cd_dens.dim = {ec_data.max_cd_dens.t}; + ec_data.max_cd_dens.dimunits = {'s'}; + % + ec_data.rho_max_cd_dens.data = rho_dep_icd.data; + ec_data.rho_max_cd_dens.label = rho_dep_icd.comment; + ec_data.rho_max_cd_dens.units = 'rhotor_norm'; + ec_data.rho_max_cd_dens.x = []; + ec_data.rho_max_cd_dens.t = rho_dep_icd.tgrid; + ec_data.rho_max_cd_dens.dim = {ec_data.rho_max_cd_dens.t}; + ec_data.rho_max_cd_dens.dimunits = {'s'}; + % + ec_data.width_cd_dens.data = drho_icd.data; + ec_data.width_cd_dens.label = drho_icd.comment; + ec_data.width_cd_dens.units = 'rhotor_norm'; + ec_data.width_cd_dens.x = []; + ec_data.width_cd_dens.t = drho_icd.tgrid; + ec_data.width_cd_dens.dim = {ec_data.width_cd_dens.t}; + ec_data.width_cd_dens.dimunits = {'s'}; + % + ec_data.cd_dens_doublewidth.data = currentdrive_dens_w2.data * 1e6; + ec_data.cd_dens_doublewidth.label = [strrep(currentdrive_dens_w2.comment,'MA','A') ' ; last index is total']; + for subfields={'x','rhotor_norm','t','dim','dimunits','units'} + ec_data.cd_dens_doublewidth.(subfields{1}) = ec_data.cd_dens.(subfields{1}); + end + + gdat_data.ec.ec_data = ec_data; + filled_successfully = true; %set flag to true + catch ME + warning('Problem retrieving TORAY data. \nError message: %s',ME.message); + getReport(ME) % without ; to get output + % try to identify cause of the error + if ~check_nodes_filled(shot,'toray') + if ~any(ec_inputs.launchers_active.data,1) + msg = 'write_pyro(shot) found NO active launchers, maybe there was no EC in this shot?'; + else + msg = 'write_pyro(shot) found active launchers, but TORAY nodes are no filled, check hldsi(shot), and (ask to) relaunch TORAY.'; + end + elseif ~isempty(gdat_data.gdat_params.trialindx) + msg = 'Is the trial index filled? Check TORAY nodes with hdlsi(shot).'; + else + msg = 'Unknown problem retrieving ec_data.'; + end + warning(msg); + gdat_data.ec.help = msg; end else - disp(['source_icd.ec = ' source_icd.ec ' not yet implemented, ask O. Sauter']) + msg = ['source_icd.ec = ' source_icd.ec ' not yet implemented, ask O. Sauter']; + disp(msg); + gdat_data.ec.help = msg; + end + + % depending if ec_data could be completely retrieved, setup the final gdat output + if filled_successfully + if isempty(ec_data.cd_tot.data) || isempty(ec_data.cd_tot.t) || ischar(ec_data.cd_tot.data) + if (gdat_params.nverbose>=1) + warning(['problems loading data for ' source_icd.ec ... + ' for data_request= ' data_request_eff]); + end + else + % now default is icdtot, will depend on request and data_out param of some kind + data_fullpath = ['from toray nodes using astra_tcv_EC_exp(shot), all results in .ec_data, subfield=' field_for_main_data ... + 'in ec.data, .x, .t, .dim, .dimunits, .label, .units']; + for subfields={'data','x','t','units','dim','dimunits','label'} + gdat_data.ec.(subfields{1}) = gdat_data.ec.ec_data.(field_for_main_data).(subfields{1}); + end + gdat_data.ec.data_fullpath = data_fullpath; + gdat_data.ec.help = ec_help; + % add to main, assume 1st one so just use this time base and x base + % should find launcher tot index + gdat_data.data(end+1,:) = gdat_data.ec.data(end,:); + gdat_data.t = gdat_data.ec.t; + if ischar(gdat_data.label); gdat_data.label = []; end % label was defined in tcv_mapping_request as char so replace 1st time + gdat_data.label{end+1}=gdat_data.ec.label; + end + + else %~filled_successfully + + % fill ec_data empty ec_data.p_abs_plasma = []; - ec_data.p_abs_plasma(end+1,:) = []; ec_data.p_abs_plasma_label = []; ec_data.p_dens = []; - ec_data.p_dens(end+1,:) = []; ec_data.p_dens_label = []; + ec_data.p_integrated = []; + ec_data.p_integrated_label = []; ec_data.max_pow_dens = []; ec_data.max_pow_dens_label = []; ec_data.rho_max_pow_dens = []; @@ -1709,11 +1804,11 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') ec_data.width_pow_dens_label = []; % current drive deposition related: ec_data.cd_tot = []; - ec_data.cd_tot(end+1,:) = []; ec_data.cd_tot_label = []; ec_data.cd_dens = []; - ec_data.cd_dens(:,end+1,:) = []; ec_data.cd_dens_label = []; + ec_data.cd_integrated = []; + ec_data.cd_integrated_label = []; ec_data.max_cd_dens = []; ec_data.max_cd_dens_label = []; ec_data.rho_max_cd_dens = []; @@ -1723,34 +1818,11 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') ec_data.cd_dens_doublewidth = []; ec_data.cd_dens_doublewidth_label = []; ec_data.rho_tor_norm = []; - ec_data.t = []; - ec_data.launchers = []; gdat_data.ec.ec_data = ec_data; return end - gdat_data.ec.ec_data = ec_data; - if isempty(icdtot.data) || isempty(icdtot.tgrid) || ischar(icdtot.data) - if (gdat_params.nverbose>=1) - warning(['problems loading data for ' source_icd.ec ... - ' for data_request= ' data_request_eff]); - end - else - % now default is icdtot, will depend on request and data_out param of some kind - data_fullpath = ['from toray nodes using astra_tcv_EC_exp(shot), all results in .ec_data, subfield=' field_for_main_data ... - 'in ec.data, .x, .t, .dim, .dimunits, .label, .units']; - for subfields={'data','x','t','units','dim','dimunits','label'} - gdat_data.ec.(subfields{1}) = gdat_data.ec.ec_data.(field_for_main_data).(subfields{1}); - end - gdat_data.ec.data_fullpath = data_fullpath; - gdat_data.ec.help = ec_help; - % add to main, assume 1st one so just use this time base and x base - % should find launcher tot index - gdat_data.data(end+1,:) = gdat_data.ec.data(end,:); - gdat_data.t = gdat_data.ec.t; - if ischar(gdat_data.label); gdat_data.label = []; end; % label was defined in tcv_mapping_request as char so replace 1st time - gdat_data.label{end+1}=gdat_data.ec.label; - end - end + + end % end filling ec % if any(strmatch('nb',gdat_data.gdat_params.source)) NBH_in_TCV = 0; @@ -2430,7 +2502,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') gdat_data.gdat_params.source = sources_avail; elseif ~iscell(gdat_data.gdat_params.source) if ischar(gdat_data.gdat_params.source) - gdat_data.gdat_params.source = lower(gdat_data.gdat_params.source); + gdat_data.gdat_params.source = lower(gdat_data.gdat_params.source); if ~any(strmatch(gdat_data.gdat_params.source,lower(sources_avail))) if (gdat_params.nverbose>=1) warning(['source= ' gdat_data.gdat_params.source ' is not part of the available sources: ' sprintf('''%s'' ',sources_avail{:})]); @@ -2685,14 +2757,24 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') case {'q_rho'} % q profile on psi from liuqe if liuqe_matlab==0 - nodenameeff=['tcv_eq(''q_psi'',''LIUQE' substr_liuqe_tcv_eq ''')']; + nodenameeff=['tcv_eq("q_psi","' psitbx_str '")']; else - nodenameeff=['tcv_eq(''q'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; + nodenameeff=['tcv_eq("q","' psitbx_str '")']; end if liuqe_version_eff==-1 nodenameeff=[begstr 'q_psi' substr_liuqe]; end tracetdi=tdi(nodenameeff); + if liuqe_matlab==1 && liuqe_version_eff==-1 + % may have problems with dim{1} being indices instead of rhopol + if max(tracetdi.dim{1}) > 2 + nodenameeff_rho = strrep(nodenameeff,'q_psi','rho'); + rho_eff = mdsvalue(nodenameeff_rho); + if numel(tracetdi.dim{1}) == numel(rho_eff) + tracetdi.dim{1}(:) = rho_eff; % it is not sqrt(linspace...) anymore, hence take rho itself + end + end + end if isempty(tracetdi.data) || isempty(tracetdi.dim) % || ischar(tracetdi.data) (to add?) if (gdat_params.nverbose>=1); warning(['problems loading data for ' nodenameeff ' for data_request= ' data_request_eff]); end if (gdat_params.nverbose>=3); disp(['rerun LIUQE?']); end @@ -2724,10 +2806,10 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') case {'rbphi_rho', 'rbtor_rho'} % R*Bphi(rho,t) from F from FFprime if liuqe_matlab==0 - disp('not yet implemented for liuqe fortran') + fprintf('\n***** not yet implemented for liuqe fortran ******\n'); return else - nodenameeff=['tcv_eq(''rbtor_rho'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; + nodenameeff=['tcv_eq("rbtor_rho","' psitbx_str '")']; end if liuqe_version_eff==-1 disp('not yet implemented for fbte') @@ -2769,7 +2851,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') % need to get q_rho but to avoid loop for rhotor in grids_1d, get q_rho explicitely here params_eff = gdat_data.gdat_params; if liuqe_matlab==1 - nodenameeff = ['tcv_eq(''tor_flux_tot'',''' psitbx_str ''')']; + nodenameeff = ['tcv_eq("tor_flux_tot","' psitbx_str '")']; phi_tor = tdi(nodenameeff); else phi_tor.data = []; @@ -2777,7 +2859,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end if ~any(any(isfinite(phi_tor.data))) || ischar(phi_tor.data) % no phi_tor, compute it from q profile - q_rho = tdi(['tcv_eq(''''''' liuqefortran2liuqematlab('q',1,liuqe_matlab) ''''''',''''''' psitbx_str ''''''')']); + q_rho = tdi(['tcv_eq("' liuqefortran2liuqematlab('q',1,liuqe_matlab) '","' psitbx_str '")']); if liuqe_matlab==0 q_rho.dim{1} = sqrt(linspace(0,1,numel(q_rho.dim{1}))); end @@ -2805,7 +2887,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') if any(any(~isfinite(phi_tor.data(1:end-1,:)))) only_edge = 1; end - q_rho = tdi(['tcv_eq(''''''' liuqefortran2liuqematlab('q',1,liuqe_matlab) ''''''',''''''' psitbx_str ''''''')']); + q_rho = tdi(['tcv_eq("' liuqefortran2liuqematlab('q',1,liuqe_matlab) '","' psitbx_str '")']); if liuqe_matlab==0 q_rho.dim{1} = sqrt(linspace(0,1,numel(q_rho.dim{1}))); end @@ -2868,14 +2950,14 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'pprime', 'pprime_rho'} if liuqe_matlab==0 - nodenameeff = ['tcv_eq("' liuqefortran2liuqematlab('pprime_rho',1,0) '",''' psitbx_str ''')']; + nodenameeff = ['tcv_eq("' liuqefortran2liuqematlab('pprime_rho',1,0) '","' psitbx_str '")']; tracetdi=tdi(nodenameeff); if ~isempty(tracetdi.dim) && length(tracetdi.dim)>=1 tracetdi.dim{1} = sqrt(tracetdi.dim{1}); % correct x-axis psi_norm to rhopol end tracetdi.data = tracetdi.data ./2 ./pi; % correct node assumption (same for liuqe_fortran and fbte) else - nodenameeff = ['tcv_eq(''pprime_rho'',''' psitbx_str ''')']; + nodenameeff = ['tcv_eq("pprime_rho","' psitbx_str '")']; tracetdi=tdi(nodenameeff); end gdat_data.data = tracetdi.data; @@ -2895,14 +2977,14 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end case {'pressure', 'pressure_rho', 'p_rho'} if liuqe_matlab==0 - nodenameeff = ['tcv_eq("' liuqefortran2liuqematlab('p_rho',1,0) '",''' psitbx_str ''')']; + nodenameeff = ['tcv_eq("' liuqefortran2liuqematlab('p_rho',1,0) '","' psitbx_str '")']; tracetdi=tdi(nodenameeff); if ~isempty(tracetdi.dim) && length(tracetdi.dim)>=1 tracetdi.dim{1} = sqrt(tracetdi.dim{1}); % correct x-axis psi_norm to rhopol end tracetdi.data = tracetdi.data ./2 ./pi; % correct node assumption (same for liuqe_fortran and fbte) else - nodenameeff = ['tcv_eq(''p_rho'',''' psitbx_str ''')']; + nodenameeff = ['tcv_eq("p_rho","' psitbx_str '")']; tracetdi=tdi(nodenameeff); end gdat_data.data = tracetdi.data; @@ -2966,7 +3048,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') tracetdi=tdi(nodenameeff); gdat_data.request_description = 'NaNs when smaller nb of boundary points at given time, can use \results::npts_contour'; else - nodenameeff = ['tcv_eq(''' data_request_eff(1) '_edge'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; + nodenameeff = ['tcv_eq("' data_request_eff(1) '_edge","' psitbx_str '")']; tracetdi=tdi(nodenameeff); gdat_data.request_description = 'lcfs on same nb of points for all times'; end @@ -2991,7 +3073,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') % need to get q_rho but to avoid loop for rhotor in grids_1d, get q_rho explicitely here params_eff = gdat_data.gdat_params; if liuqe_matlab==0 - nodenameeff=['tcv_eq(''q_psi'',''LIUQE' substr_liuqe_tcv_eq ''')']; + nodenameeff=['tcv_eq("q_psi","' psitbx_str '")']; if liuqe_version_eff==-1 nodenameeff=[begstr 'q_psi' substr_liuqe]; end @@ -3134,11 +3216,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') return end else - nodenameeff=['tcv_eq(''vol'',''' psitbx_str ''')']; - end - if liuqe_version_eff==-1 - data_request_eff = 'volume'; % only LCFS - nodenameeff=[begstr 'volume' substr_liuqe]; + nodenameeff=['tcv_eq("vol","' psitbx_str '")']; end tracetdi=tdi(nodenameeff); if (isempty(tracetdi.data) || isempty(tracetdi.dim)) && liuqe_matlab==0 @@ -3147,6 +3225,15 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') psitbxput(psitbxput_version,shot); ishot = mdsopen(shot); tracetdi=tdi(nodenameeff); + elseif liuqe_matlab==1 && liuqe_version_eff==-1 + % may have problems with dim{1} being indices instead of rhopol + if max(tracetdi.dim{1}) > 2 + nodenameeff_rho = 'tcv_eq("rho","FBTE")'; + rho_eff = mdsvalue(nodenameeff_rho); + if numel(tracetdi.dim{1}) == numel(rho_eff) + tracetdi.dim{1}(:) = rho_eff; + end + end end if isempty(tracetdi.data) || isempty(tracetdi.dim) || ischar(tracetdi.data) return @@ -3222,17 +3309,20 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'sxr', 'mpx'} + case {'sxr', 'mpx', 'radcam'} - if strcmp(data_request_eff,'mpx') - data_request_eff = 'mpx'; % mpx chosen through parameter 'source' within 'sxr' - gdat_data.data_request = data_request_eff; - gdat_data.gdat_params.source = 'mpx'; + if any(contains(data_request_eff,{'mpx','radcam'})) + % effective source chosen through parameter 'source' within 'sxr' + gdat_data.gdat_params.source = data_request_eff; end % sxr from dmpx by default or xtomo if 'camera','xtomo' is provided if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) - gdat_data.gdat_params.source = 'mpx'; - elseif ~strcmp(lower(gdat_data.gdat_params.source),'xtomo') && ~strcmp(lower(gdat_data.gdat_params.source),'mpx') + if shot < 70144 + gdat_data.gdat_params.source = 'mpx'; + else + gdat_data.gdat_params.source = 'radcam'; + end + elseif ~any(contains(lower(gdat_data.gdat_params.source),{'xtomo','mpx','radcam'})) if gdat_data.gdat_params.nverbose>=1 warning(['source = ' gdat_data.gdat_params.source ' not expected with data_request= ' data_request_eff]) end @@ -3253,10 +3343,125 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') num2str(time_interval(1)) ',' num2str(time_interval(2)) ']' char(10)]) end end + % at this stage 2 option for freq, raw data (fast, default), 10kHz or similar (slow) + freq_opt = 1; if ~isfield(gdat_data.gdat_params,'freq') - gdat_data.gdat_params.freq = 'slow'; + gdat_data.gdat_params.freq = 'fast'; + end + if strcmp(gdat_data.gdat_params.freq,'slow'); freq_opt = 0; end + % fit_tension for smoothing on slow timescale (radcam for example) + if ~isfield(gdat_data.gdat_params,'fit_tension') || isempty(gdat_data.gdat_params.fit_tension) + gdat_data.gdat_params.fit_tension = -1e2; end switch lower(gdat_data.gdat_params.source) + case {'radcam'} + gdat_data.gdat_params.source = 'radcam'; + gdat_data.camera_list = {'top', 'upper','equatorial','bottom'}; + gdat_data.channel_list = {[1:20],[21:40],[41:80], [81:100]}; + if ~isfield(gdat_data.gdat_params,'camera') || isempty(gdat_data.gdat_params.camera) + gdat_data.gdat_params.camera = {'equatorial'}; % default equatorial + disp(['loads all radcam cameras, each data also in subfield ' gdat_data.gdat_params.camera]) + else + if ischar(gdat_data.gdat_params.camera) || (isstring(gdat_data.gdat_params.camera) && numel(gdat_data.gdat_params.camera)==1) + gdat_data.gdat_params.camera = {char(gdat_data.gdat_params.camera)}; + end + if isnumeric(gdat_data.gdat_params.camera) && (min(gdat_data.gdat_params.camera)<5 && max(gdat_data.gdat_params.camera)>0) + ij = gdat_data.gdat_params.camera([gdat_data.gdat_params.camera>0 & gdat_data.gdat_params.camera<5]); + gdat_data.gdat_params.camera = gdat_data.camera_list(ij); + elseif any(startsWith(gdat_data.gdat_params.camera,gdat_data.camera_list).*endsWith(gdat_data.gdat_params.camera,gdat_data.camera_list)) + ij = startsWith(gdat_data.gdat_params.camera,gdat_data.camera_list).*endsWith(gdat_data.gdat_params.camera,gdat_data.camera_list); + gdat_data.gdat_params.camera = lower(gdat_data.gdat_params.camera(ij>0)); + if any(ij==0) + warning(['camera not defined: ' gdat_data.gdat_params.camera(ij==0)]); + disp(['list of cameras: ' gdat_data.camera_list]) + end + else + error(['camera: ' gdat_data.gdat_params.camera ' not in list: ' gdat_data.camera_list]) + end + end + if ~isfield(gdat_data.gdat_params,'channel') || isempty(gdat_data.gdat_params.channel) + for i=1:numel(gdat_data.gdat_params.camera) + gdat_data.gdat_params.(gdat_data.gdat_params.camera{i}).channel = ... + gdat_data.channel_list{[contains(gdat_data.camera_list,gdat_data.gdat_params.camera{i})]}; + gdat_data.gdat_params.channel{i} = gdat_data.gdat_params.(gdat_data.gdat_params.camera{i}).channel; + end + else + if isnumeric(gdat_data.gdat_params.channel) + gdat_data.gdat_params.channel = {gdat_data.gdat_params.channel}; + end + if numel(gdat_data.gdat_params.camera) ~= numel(gdat_data.gdat_params.channel) + gdat_data.gdat_params + error('expects same number of camera as number of channel group in each cell list') + end + all_channels = []; + for i=1:numel(gdat_data.gdat_params.camera) + all_channels(end+1:end+numel(gdat_data.gdat_params.channel{i})) = gdat_data.gdat_params.channel{i}; + end + % check camera and channel chosen are consistent within camera interval, just redistribute + icount = 0; + for i=1:numel(gdat_data.camera_list) + ij = intersect(gdat_data.channel_list{i},all_channels); + if ~isempty(ij) + icount = icount + 1; + camera{icount} = gdat_data.camera_list{i}; + channel{icount} = ij; + end + end + if ~isequal(sort(camera),sort(gdat_data.gdat_params.camera)) + disp('***************************************************************************') + warning(sprintf('channel nbs and camera did not match, camera chosen adapted: %s %s %s %s',camera{:})); + disp('***************************************************************************') + gdat_data.gdat_params.camera = camera; + end + if ~isequal(sort(cell2mat(channel)),sort(cell2mat(gdat_data.gdat_params.channel))) || ... + numel(gdat_data.gdat_params.channel) ~= numel(channel) + warning(sprintf('channel nbs and channel did not match, channel chosen adapted')); + gdat_data.gdat_params.channel = channel; + end + for i=1:numel(gdat_data.gdat_params.camera) + gdat_data.gdat_params.(gdat_data.gdat_params.camera{i}).channel = gdat_data.gdat_params.channel{i}; + end + end + gdat_data.x = []; + for i=1:numel(gdat_data.gdat_params.camera) + gdat_data.(gdat_data.gdat_params.camera{i}).x = gdat_data.gdat_params.(gdat_data.gdat_params.camera{i}).channel; + gdat_data.x(end+1:end+numel(gdat_data.(gdat_data.gdat_params.camera{i}).x)) = gdat_data.(gdat_data.gdat_params.camera{i}).x; + end + sxr = rc_load_diodes(shot,'diag_name',"sxr",'channels',gdat_data.x); % since all cameras with different channel number + if freq_opt == 1 + gdat_data.data = sxr.data'; + gdat_data.t = sxr.time; + else + gdat_data.t = linspace(sxr.time(1),sxr.time(end),round((sxr.time(end)-sxr.time(1))/1e-4)); + for i=1:size(sxr.data,2) + gdat_data.data(i,:) = interpos(sxr.time,sxr.data(:,i),gdat_data.t,gdat_data.gdat_params.fit_tension); + end + end + gdat_data.r_x = sxr.geometry.xchord(gdat_data.x,:); + gdat_data.z_x = sxr.geometry.ychord(gdat_data.x,:); + gdat_data.r_at_z0 = gdat_data.r_x(:,1) + ... + diff(gdat_data.r_x(:,:)')' .* (0-gdat_data.z_x(:,1))./(gdat_data.z_x(:,2)-gdat_data.z_x(:,1)); + gdat_data.z_at_r09 = gdat_data.z_x(:,1) + ... + diff(gdat_data.z_x(:,:)')' .* (0.9-gdat_data.r_x(:,1))./(gdat_data.r_x(:,2)-gdat_data.r_x(:,1)); + gdat_data.good_channels = sxr.good_channels; + gdat_data.data_fullpath = ['using rc_load_diodes(shot,''diag_name'',"sxr",...) with params in gdat_data.gdat_params']; + gdat_data.units = 'au'; + gdat_data.dim = {gdat_data.x, gdat_data.t}; + gdat_data.dimunits = {'channel', 's'}; + gdat_data.label = strtrim(sprintf('radcam %s %s %s %s %s',gdat_data.gdat_params.camera{:})); + for i=1:numel(gdat_data.gdat_params.camera) + ij = iround_os(sxr.channels,gdat_data.(gdat_data.gdat_params.camera{i}).x); + gdat_data.(gdat_data.gdat_params.camera{i}).data = gdat_data.data(:,ij)'; + gdat_data.(gdat_data.gdat_params.camera{i}).t = gdat_data.t; + gdat_data.(gdat_data.gdat_params.camera{i}).r_x = sxr.geometry.xchord(gdat_data.(gdat_data.gdat_params.camera{i}).x,:); + gdat_data.(gdat_data.gdat_params.camera{i}).z_x = sxr.geometry.ychord(gdat_data.(gdat_data.gdat_params.camera{i}).x,:); + gdat_data.(gdat_data.gdat_params.camera{i}).r_at_z0 = gdat_data.r_at_z0(ij); + gdat_data.(gdat_data.gdat_params.camera{i}).z_at_r09 = gdat_data.z_at_r09(ij); + gdat_data.(gdat_data.gdat_params.camera{i}).good_channels = intersect(gdat_data.(gdat_data.gdat_params.camera{i}).x,sxr.good_channels); + gdat_data.(gdat_data.gdat_params.camera{i}).label = sprintf('radcam %s nb chords: %d', ... + gdat_data.gdat_params.camera{i},numel(gdat_data.(gdat_data.gdat_params.camera{i}).x)); + end + case {'mpx', 'dmpx'} gdat_data.gdat_params.source = 'mpx'; if ~isfield(gdat_data.gdat_params,'camera') || isempty(gdat_data.gdat_params.camera) @@ -3270,8 +3475,6 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end return end - freq_opt = 0; - if strcmp(gdat_data.gdat_params.freq,'fast'); freq_opt = 1; end t_int = [0 10]; % starts from 0 otherwise mpxdata gives data from t<0 if ~isempty(time_interval); t_int = time_interval; end gdat_data.top.data = []; @@ -3388,7 +3591,6 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'transp'} % read transp netcdf output file provided in source parameter and generate substructure with all variables @@ -3422,14 +3624,14 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'ttprime', 'ttprime_rho'} if liuqe_matlab==0 - nodenameeff = ['tcv_eq("' liuqefortran2liuqematlab('ttprime_rho',1,0) '",''' psitbx_str ''')']; + nodenameeff = ['tcv_eq("' liuqefortran2liuqematlab('ttprime_rho',1,0) '","' psitbx_str '")']; tracetdi=tdi(nodenameeff); if ~isempty(tracetdi.dim) && length(tracetdi.dim)>=1 tracetdi.dim{1} = sqrt(tracetdi.dim{1}); % correct x-axis psi_norm to rhopol end tracetdi.data = tracetdi.data ./2 ./pi; % correct node assumption (same for liuqe_fortran and fbte) else - nodenameeff = ['tcv_eq(''ttprime_rho'',''' psitbx_str ''')']; + nodenameeff = ['tcv_eq("ttprime_rho","' psitbx_str '")']; tracetdi=tdi(nodenameeff); end gdat_data.data = tracetdi.data; @@ -3612,14 +3814,14 @@ catch gdat_data.error_bar_raw = gdat_data.error_bar; end - if (nverbose>=1) && shot<100000 + if (nverbose>=1) && shot<900000 warning('Problems with \results::thomson:times') warning(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' data_request_eff]) end return end if isempty(time) || ischar(time) - if (nverbose>=1) && shot<100000 + if (nverbose>=1) && shot<900000 warning('!!!!!!!!!!!!!!!!!!!!!!!!!\results::thomson:times is empty? Check') disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' data_request_eff]) end diff --git a/matlab/TCV/loadTCVdata.m b/matlab/TCV/loadTCVdata.m deleted file mode 100644 index 49f83dcfe2d9e56ae0987a296c312b64e0808a23..0000000000000000000000000000000000000000 --- a/matlab/TCV/loadTCVdata.m +++ /dev/null @@ -1,1424 +0,0 @@ - function [trace,error_status,varargout]=loadTCVdata(shot,data_type,varargin) -% -% Added option to load shot=-1 or >=100000 -% Added option shot=-9 to list keywords -% -% list of data_type currently available (when [_2,_3] is added, means can add _i to get Liuqe i): -% if -1 is added, can also get it from FBTE with shot=-1, >=100000 or liuqe_version='_-1' (to get model file) -% -% 'Ip'[_2,_3] = current -% 'B0'[_2,_3] = current -% 'zmag'[_2,_3] = vertical position of the center of the plasma (magnetic axis) -% 'rmag'[_2,_3] = radial position of the center of the plasma -% 'rcont'[_2,_3] = R of plama boundary vs time -% 'zcont'[_2,_3] = Z of plama boundary vs time -% 'vol'[_2,_3] = volume of flux surfaces -% 'rhovol'[_2,_3] = sqrt(V(:,t)/V(edge,t)), normalised rho variable based on volume of flux surfaces -% 'qrho'[_2,_3] = q profile on rho mesh -% 'q95'[_2,_3] = q95 vs time -% 'kappa', 'elon'[_2,_3] = edge elongation vs time -% 'delta', 'triang'[_2,_3] = edge averaged triangularity vs time -% 'deltatop', 'triangtop'[_2,_3] = edge upper (top) triangularity vs time -% 'deltabot', 'triangbot'[_2,_3] = edge lower (bottom) triangularity vs time -% 'j_tor'[_2,_3] = J_TOR vs (R,Z,time) -% 'neint' = line-integrated electron density [m/m^3] -% 'nel' = line-averaged electron density [1/m^3] -% 'ne'= ne raw profile on (z,t). ADD error bars in .std -% 'te'= Te raw profile on (z,t). ADD error bars in .std -% 'nerho'[_2,_3]= ne profile on (rho=sqrt(psi),time) mesh.Note rho is a 2D array as depends on time. ADD error bars in .std -% 'terho'[_2,_3]= Te profile on (rho=sqrt(psi),time) mesh.Note rho is a 2D array as depends on time. ADD error bars in .std -% 'nerhozshift'[_2,_3]= same as nerho but allows for zshift [m] in equil given by varargin{1} -% 'terhozshift'[_2,_3]= same as terho but allows for zshift [m] in equil given by varargin{1} -% 'profnerho' = ne smoothed or fitted , vs (rho,t) (from Thomson auto fit) -% 'profterho' = te smoothed or fitted , vs (rho,t) (from Thomson auto fit) -% 'neft' = ne fitted from data on rho mesh (from proffit.local_time:neft_abs) -% 'neft:4' = ne fitted from data on rho mesh (from proffit.local_time:neft_abs from trial:trial_indx=4) -% 'teft' = te fitted from data on rho mesh (from proffit.local_time:teft) -% 'neftav' = ne fitted from averaged over time data on rho mesh (from proffit.avg_time:neft_abs) -% 'teftav' = te fitted from averaged over time data on rho mesh (from proffit.avg_time:teft) -% 'vtor'= Toroidal rotation of C raw profile on (rho,t). ADD error bars in .std, as well as time and rho error bars -% 'vtorfit'= Toroidal rotation of C fitted profile on (rho,t) -% 'vpol'= Poloidal rotation of C raw profile on (rho,t). ADD error bars in .std, as well as time and rho error bars -% 'vpolfit'= Poloidal rotation of C fitted profile on (rho,t) -% 'Ti' (or Tc), 'Tifit', 'ni' (or nC), 'nifit', 'zeffcxrs', 'zeffcxrsfit': similar to 'vtor' from CXRS -% '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 -% 'IOH' = current in ohmic transformer coils IOH_1 -% 'vloop' = loop voltage -% 'pgyro' = ECH power for each gyro(1:9) and total (10) -% -% 'xx_2 or xx_3' for Liuqe2 or 3: same as above for xx related to equilibrium -% 'xx_-1 or xx_-1' for FBTE values (model or shot=-1 or shot>=100000): same as above for xx related to equilibrium -% -% INPUT: -% shot: shot number -% data_type: type of the required data -% -% Definition of varargin depends on data_type: -% -% data_type=sxr or ece: -% 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{3}: zmag for varargout{1} computation -% (can have more inputs for AUG, but not used here) -% data_type=nerhozshift or terhozshift: -% varargin{1}: zshift [m] constant or (t) : positive, moves equil up (that is thomson effective z down) -% time dependent: needs same time base as psitbx:psi -% -% OUTPUT: -% -% trace.data: data -% trace.t: time of reference -% trace.x: space of reference -% trace.dim: cell array of grids, trace.dim{1}, {2}, ... -% trace.dimunits: units of dimensions -% trace.units: units of data -% -% Additional Output arguments depending on data_type -% -% data_type=sxR, ece: -% varargout{1}: major radius: intersection/projection of the view lines with z=zmag -% data_type=MPX: -% varargout{1}: te be determined -% -% -% function needed: mds functions-xtomo_geometry-get_xtomo_data (Furno's routines) -% VsxrTCVradius -% Example: -% [ip,error_status]=loadTCVdata(shot,'Ip',1); -% [sxr,error_status,R]=loadTCVdata(shot,'sxR',1); -% - -varargout{1}=cell(1,1); -error_status=1; - -% To allow multiple ways of writing a specific keyword, use data_type_eff within this routine -if exist('data_type') && ~isempty(data_type) - data_type_eff=data_type; -else - data_type_eff=' '; -end -i_23=0; -% LIUQE tree -begstr = '\results::'; -endstr = ''; -liuqe_version = 1; -if length(data_type_eff)>2 - if strcmp(data_type_eff(end-1:end),'_2') | strcmp(data_type_eff(end-1:end),'_3') - i_23=2; - endstr=data_type_eff(end-1:end); - liuqe_version = str2num(data_type_eff(end:end)); - elseif strcmp(upper(data_type_eff(end-2:end)),'_-1') - i_23=3; - begstr = 'tcv_eq( "'; - endstr = '", "FBTE" )'; - liuqe_version = -1; - end -end -if shot==-1 || (shot>=100000 && shot<200000) - % requires FBTE - liuqe_version = -1; - begstr = 'tcv_eq( "'; - endstr = '", "FBTE" )'; -end - -% use keyword without eventual _2 or _3 extension to check for multiple possibilities -% Also remove ":4" for trial_indx specification -jj=strfind(data_type_eff,':'); -trialindx=[]; -if ~isempty(jj) - ii=strmatch(data_type_eff(1:jj-1),[{'teft'},{'neft'},{'teftav'},{'neftav'}]); - if ~isempty(ii) - trialindx=str2num(data_type_eff(jj+1:end)); - data_type_eff_noext=[data_type_eff(1:jj-1) ':trial']; - else - data_type_eff_noext=data_type_eff(1:end-i_23); - end -else - data_type_eff_noext=data_type_eff(1:end-i_23); -end - -if ~isempty(strmatch(data_type_eff_noext,[{'ip'} {'i_p'} {'xip'}],'exact')) - data_type_eff_noext='Ip'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'b0'} {'B_0'} {'Bgeom'} {'BGEOM'}],'exact')) - data_type_eff_noext='B0'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Te'} {'t_e'} {'TE'} {'T_e'}],'exact')) - data_type_eff_noext='te'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Te_edge'} {'TE_edge'}],'exact')) - data_type_eff_noext='te_edge'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Ne_edge'} {'NE_edge'}],'exact')) - data_type_eff_noext='ne'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Rcont'}],'exact')) - data_type_eff_noext='rcont'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Zcont'}],'exact')) - data_type_eff_noext='zcont'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Terho'}],'exact')) - data_type_eff_noext='terho'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Terhozshift'}],'exact')) - data_type_eff_noext='terhozshift'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'SXR'}],'exact')) - data_type_eff_noext='sxr'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'ECE'}],'exact')) - data_type_eff_noext='ece'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'VOL'} {'volume'}],'exact')) - data_type_eff_noext='vol'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'RHOVOL'}],'exact')) - data_type_eff_noext='rhovol'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'q_95'} {'Q95'}],'exact')) - data_type_eff_noext='q95'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'elongation'} {'elon'}],'exact')) - data_type_eff_noext='kappa'; -end -if ~isempty(strmatch(lower(data_type_eff_noext),[{'j_tor'} {'jtor'} {'\results::j_tor'}],'exact')) - data_type_eff_noext='jtor'; - data_type_eff = ['jtor' endstr]; -end -if ~isempty(strmatch(data_type_eff_noext,[{'triangularity'} {'triang'}],'exact')) - data_type_eff_noext='delta'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'deltaup'} {'deltau'} {'triangtop'} {'triangu'} {'triangup'}],'exact')) - data_type_eff_noext='deltatop'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'deltalow'} {'deltal'} {'triangbot'} {'triangl'} {'trianglow'}],'exact')) - data_type_eff_noext='deltabot'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Rmag'}],'exact')) - data_type_eff_noext='rmag'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Zmag'}],'exact')) - data_type_eff_noext='zmag'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'MPX'}],'exact')) - data_type_eff_noext='MPX'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'ioh'} {'Ioh'} {'iot'} {'IOT'}],'exact')) - data_type_eff_noext='IOH'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Vloop'} {'Vsurf'} {'vsurf'}],'exact')) - data_type_eff_noext='vloop'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'vtor'} {'v_tor'} {'vi'} {'vc'} {'v_i'} {'v_c'} {'VTOR'} {'V_TOR'} {'VI'} {'VC'} {'V_I'} {'V_C'}],'exact')) - data_type_eff_noext='vi_tor'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'vtorfit'} {'vtorft'} {'v_torfit'} {'vifit'} {'vcfit'} {'v_ifit'} {'v_cfit'} {'VTORfit'} {'V_TORfit'} {'VIfit'} {'VCfit'} {'V_Ifit'} {'V_Cfit'}],'exact')) - data_type_eff_noext='vi_torfit'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'vpol'} {'v_pol'} {'VPOL'} {'V_POL'}],'exact')) - data_type_eff_noext='vi_pol'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'vpolfit'} {'vpolft'} {'v_polfit'} {'VPOLfit'} {'V_POLfit'}],'exact')) - data_type_eff_noext='vi_polfit'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Ti'} {'ti'} {'TC'} {'tc'} {'T_C'} {'t_c'}],'exact')) - data_type_eff_noext='Ti'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Tifit'} {'tifit'} {'TCfit'} {'tcfit'} {'T_Cfit'} {'t_cfit'}],'exact')) - data_type_eff_noext='Tifit'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Ni'} {'ni'} {'NC'} {'nc'} {'N_C'} {'n_c'}],'exact')) - data_type_eff_noext='ni'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Nifit'} {'nifit'} {'NCfit'} {'ncfit'} {'N_Cfit'} {'n_cfit'}],'exact')) - data_type_eff_noext='nifit'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Zeffcxrs'} {'zeffcxrs'} {'Z_effcxrs'} {'z_effcxrs'} {'Zeff_cxrs'} {'zeff_cxrs'} {'Z_eff_cxrs'} {'z_eff_cxrs'}],'exact')) - data_type_eff_noext='zeffcxrs'; -end -if ~isempty(strmatch(data_type_eff_noext,[{'Zeffcxrsfit'} {'zeffcxrsfit'} {'Z_effcxrsfit'} {'z_effcxrsfit'} {'Zeff_cxrsfit'} {'zeff_cxrsfit'} {'Z_eff_cxrsfit'} {'z_eff_cxrsfit'}],'exact')) - data_type_eff_noext='zeffcxrsfit'; -end - -% some defaults - -% nodes which have _2 and _3 equivalence, related to simpletdi case -liuqe23=[{'\results::area'} {'\results::beta_pol'} {'\results::beta_tor'} ... - {'\results::delta_95'} {'\results::delta_95_bot'} {'\results::delta_95_top'} ... - {'\results::delta_edge'} {'\results::delta_ed_bot'} {'\results::delta_ed_top'} ... - {'\results::diamag'} {'\results::i_p'} {'\results::j_tor'} ... - {'\results::kappa_95'} {'\results::kappa_edge'} {'\results::kappa_zero'} ... - {'\results::lambda'} {'\results::l_i'} {'\results::psi_axis'} {'\results::psi_values'} ... - {'\results::q_95'} {'\results::q_edge'} {'\results::q_zero'} {'\results::rms_error'} ... - {'\results::z_axis'} {'\results::r_axis'} {'\results::q_psi'} ... - {'\results::total_energy'} {'\results::tor_flux'} {'\results::volume'} ... - {'\results::r_contour'} {'\results::z_contour'} ... - {'\results::thomson:psiscatvol'} {'\results::thomson:psi_max'}]; - -% nodes which have FBTE equivalence, related to simpletdi case -liuqeFBTE=[{'\results::i_p'} {'\results::z_axis'} {'\results::r_axis'} {'\results::q_psi'} ... - {'\results::beta_tor'} {'\results::beta_pol'} {'\results::q_95'} {'\results::l_i'} {'\results::delta_95'} ... - {'\results::kappa_95'} {'\results::r_contour'} {'\results::z_contour'} {'\results::psi_axis'}]; - -% keywords which do not have FBTE equivalence and are returned empty -noFBTE=[{'ne'} {'te'} {'nerho'} {'terho'} {'ne_edge'} {'te_edge'} {'nerho_edge'} {'terho_edge'} {'nerhozshift'} {'terhozshift'} {'profnerho'} {'profterho'} ... - {'neft'} {'neft:trial'} {'teft:trial'} {'neftav:trial'} {'teftav:trial'} {'sxr'} {'sxR'} {'ece'} {'MPX'} {'IOH'} {'vloop'} {'neint'} {'nel'} ... - {'vi_tor'} {'vi_torfit'} {'vi_pol'} {'vi_polfit'} {'Ti'} {'Tifit'} {'ni'} {'nifit'} {'zeffcxrs'} {'zeffcxrsfit'}]; - -% all keywords and corresponding case to run below -TCVkeywrdall=[{'Ip'} {'B0'} {'zmag'} {'rmag'} {'rcont'} {'zcont'} {'vol'} {'rhovol'} {'qrho'} {'q95'} {'kappa'} ... - {'delta'} {'deltatop'} {'deltabot'} {'neint'} {'nel'} ... - {'ne'} {'te'} {'nerho'} {'terho'} {'ne_edge'} {'te_edge'} {'nerho_edge'} {'terho_edge'} {'nerhozshift'} {'terhozshift'} {'profnerho'} {'profterho'} ... - {'neft'} {'teft'} {'neftav'} {'teftav'} {'neft:trial'} {'teft:trial'} {'neftav:trial'} {'teftav:trial'} ... - {'sxr'} {'sxR'} {'ece'} {'MPX'} {'IOH'} {'vloop'} {'pgyro'} {'jtor'} {'vi_tor'} {'vi_torfit'} {'vi_pol'} {'vi_polfit'} {'Ti'} {'Tifit'} {'ni'} {'nifit'} {'zeffcxrs'} {'zeffcxrsfit'}]; - -TCVsig.iip=strmatch('Ip',TCVkeywrdall,'exact'); -TCVsig.iB0=strmatch('B0',TCVkeywrdall,'exact'); -TCVsig.izmag=strmatch('zmag',TCVkeywrdall,'exact'); -TCVsig.irmag=strmatch('rmag',TCVkeywrdall,'exact'); -TCVsig.ircont=strmatch('rcont',TCVkeywrdall,'exact'); -TCVsig.izcont=strmatch('zcont',TCVkeywrdall,'exact'); -TCVsig.ivol=strmatch('vol',TCVkeywrdall,'exact'); -TCVsig.irhovol=strmatch('rhovol',TCVkeywrdall,'exact'); -TCVsig.iqrho=strmatch('qrho',TCVkeywrdall,'exact'); -TCVsig.iq95=strmatch('q95',TCVkeywrdall,'exact'); -TCVsig.ikappa=strmatch('kappa',TCVkeywrdall,'exact'); -TCVsig.idelta=strmatch('delta',TCVkeywrdall,'exact'); -TCVsig.ideltatop=strmatch('deltatop',TCVkeywrdall,'exact'); -TCVsig.ideltabot=strmatch('deltabot',TCVkeywrdall,'exact'); -TCVsig.ineint=strmatch('neint',TCVkeywrdall,'exact'); -TCVsig.inel=strmatch('nel',TCVkeywrdall,'exact'); -TCVsig.ine=strmatch('ne',TCVkeywrdall,'exact'); -TCVsig.ite=strmatch('te',TCVkeywrdall,'exact'); -TCVsig.ine_edge=strmatch('ne_edge',TCVkeywrdall,'exact'); -TCVsig.ite_edge=strmatch('te_edge',TCVkeywrdall,'exact'); -TCVsig.inerho=strmatch('nerho',TCVkeywrdall,'exact'); -TCVsig.iterho=strmatch('terho',TCVkeywrdall,'exact'); -TCVsig.inerho_edge=strmatch('nerho_edge',TCVkeywrdall,'exact'); -TCVsig.iterho_edge=strmatch('terho_edge',TCVkeywrdall,'exact'); -TCVsig.inerhozshift=strmatch('nerhozshift',TCVkeywrdall,'exact'); -TCVsig.iterhozshift=strmatch('terhozshift',TCVkeywrdall,'exact'); -TCVsig.iprofnerho=strmatch('profnerho',TCVkeywrdall,'exact'); -TCVsig.iprofterho=strmatch('profterho',TCVkeywrdall,'exact'); -TCVsig.ineft=strmatch('neft',TCVkeywrdall,'exact'); -TCVsig.ineft_trial=strmatch('neft:trial',TCVkeywrdall); -TCVsig.iteft=strmatch('teft',TCVkeywrdall,'exact'); -TCVsig.iteft_trial=strmatch('teft:trial',TCVkeywrdall); -TCVsig.ineftav=strmatch('neftav',TCVkeywrdall,'exact'); -TCVsig.ineftav_trial=strmatch('neftav:trial',TCVkeywrdall); -TCVsig.iteftav=strmatch('teftav',TCVkeywrdall,'exact'); -TCVsig.iteftav_trial=strmatch('teftav:trial',TCVkeywrdall); -TCVsig.isxr=strmatch('sxr',TCVkeywrdall,'exact'); -TCVsig.isxR=strmatch('sxR',TCVkeywrdall,'exact'); -TCVsig.iece=strmatch('ece',TCVkeywrdall,'exact'); -TCVsig.iMPX=strmatch('MPX',TCVkeywrdall,'exact'); -TCVsig.iIOH=strmatch('IOH',TCVkeywrdall,'exact'); -TCVsig.ivloop=strmatch('vloop',TCVkeywrdall,'exact'); -TCVsig.ipgyro=strmatch('pgyro',TCVkeywrdall,'exact'); -TCVsig.ijtor=strmatch('jtor',TCVkeywrdall,'exact'); -TCVsig.ivi_tor=strmatch('vi_tor',TCVkeywrdall,'exact'); -TCVsig.ivi_torfit=strmatch('vi_torfit',TCVkeywrdall,'exact'); -TCVsig.ivi_pol=strmatch('vi_pol',TCVkeywrdall,'exact'); -TCVsig.ivi_polfit=strmatch('vi_polfit',TCVkeywrdall,'exact'); -TCVsig.iTi=strmatch('Ti',TCVkeywrdall,'exact'); -TCVsig.iTifit=strmatch('Tifit',TCVkeywrdall,'exact'); -TCVsig.ini=strmatch('ni',TCVkeywrdall,'exact'); -TCVsig.inifit=strmatch('nifit',TCVkeywrdall,'exact'); -TCVsig.izeffcxrs=strmatch('zeffcxrs',TCVkeywrdall,'exact'); -TCVsig.izeffcxrsfit=strmatch('zeffcxrsfit',TCVkeywrdall,'exact'); - -% 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.iB0)=TCVkeywrdall(TCVsig.iB0); % through iphi -TCVkeywrdcase(TCVsig.iqrho)=TCVkeywrdall(TCVsig.iqrho); % special as liuqe q_psi on psi -TCVkeywrdcase(TCVsig.ivol)=TCVkeywrdall(TCVsig.ivol); % special as nodes _2 or _3 not existing with psitbx -TCVkeywrdcase(TCVsig.irhovol)=TCVkeywrdall(TCVsig.irhovol); % idem vol -TCVkeywrdcase(TCVsig.ine)=TCVkeywrdall(TCVsig.ine); % special as dimensions from other nodes -TCVkeywrdcase(TCVsig.ite)=TCVkeywrdall(TCVsig.ite); % idem -TCVkeywrdcase(TCVsig.ine_edge)=TCVkeywrdall(TCVsig.ine_edge); % special as dimensions from other nodes -TCVkeywrdcase(TCVsig.ite_edge)=TCVkeywrdall(TCVsig.ite_edge); % idem -TCVkeywrdcase(TCVsig.inerho)=TCVkeywrdall(TCVsig.inerho); % idem -TCVkeywrdcase(TCVsig.inerho_edge)=TCVkeywrdall(TCVsig.inerho_edge); % idem -TCVkeywrdcase(TCVsig.iteft_trial)=TCVkeywrdall(TCVsig.iteft_trial); % special to extract trial_indx if needed -TCVkeywrdcase(TCVsig.ineft_trial)=TCVkeywrdall(TCVsig.ineft_trial); % special to extract trial_indx if needed -TCVkeywrdcase(TCVsig.iteftav_trial)=TCVkeywrdall(TCVsig.iteftav_trial); % special to extract trial_indx if needed -TCVkeywrdcase(TCVsig.ineftav_trial)=TCVkeywrdall(TCVsig.ineftav_trial); % special to extract trial_indx if needed -TCVkeywrdcase(TCVsig.iterho)=TCVkeywrdall(TCVsig.iterho); % idem -TCVkeywrdcase(TCVsig.iterho_edge)=TCVkeywrdall(TCVsig.iterho_edge); % idem -TCVkeywrdcase(TCVsig.inerhozshift)=TCVkeywrdall(TCVsig.inerhozshift); % idem -TCVkeywrdcase(TCVsig.iterhozshift)=TCVkeywrdall(TCVsig.iterhozshift); % idem -TCVkeywrdcase(TCVsig.iprofnerho)=TCVkeywrdall(TCVsig.iprofnerho); -TCVkeywrdcase(TCVsig.iprofterho)=TCVkeywrdall(TCVsig.iprofterho); -TCVkeywrdcase(TCVsig.isxr)=TCVkeywrdall(TCVsig.isxr); -TCVkeywrdcase(TCVsig.isxR)=TCVkeywrdall(TCVsig.isxR); -TCVkeywrdcase(TCVsig.iece)=TCVkeywrdall(TCVsig.iece); -TCVkeywrdcase(TCVsig.iMPX)=TCVkeywrdall(TCVsig.iMPX); -TCVkeywrdcase(TCVsig.iIOH)=TCVkeywrdall(TCVsig.iIOH); -TCVkeywrdcase(TCVsig.ivloop)=TCVkeywrdall(TCVsig.ivloop); -TCVkeywrdcase(TCVsig.ipgyro)=TCVkeywrdall(TCVsig.ipgyro); -TCVkeywrdcase(TCVsig.ijtor)=TCVkeywrdall(TCVsig.ijtor); -TCVkeywrdcase(TCVsig.ivi_tor)=TCVkeywrdall(TCVsig.ivi_tor); -TCVkeywrdcase(TCVsig.ivi_torfit)=TCVkeywrdall(TCVsig.ivi_torfit); -TCVkeywrdcase(TCVsig.ivi_pol)=TCVkeywrdall(TCVsig.ivi_pol); -TCVkeywrdcase(TCVsig.ivi_polfit)=TCVkeywrdall(TCVsig.ivi_polfit); -TCVkeywrdcase(TCVsig.iTi)=TCVkeywrdall(TCVsig.iTi); -TCVkeywrdcase(TCVsig.iTifit)=TCVkeywrdall(TCVsig.iTifit); -TCVkeywrdcase(TCVsig.ini)=TCVkeywrdall(TCVsig.ini); -TCVkeywrdcase(TCVsig.inifit)=TCVkeywrdall(TCVsig.inifit); -TCVkeywrdcase(TCVsig.izeffcxrs)=TCVkeywrdall(TCVsig.izeffcxrs); -TCVkeywrdcase(TCVsig.izeffcxrsfit)=TCVkeywrdall(TCVsig.izeffcxrsfit); - -% 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)); - -% 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'}; -TCVsiglocation(TCVsig.ircont)={'\results::r_contour'}; TCVsigtimeindx(TCVsig.ircont)=2; -TCVsiglocation(TCVsig.izcont)={'\results::z_contour'}; TCVsigtimeindx(TCVsig.izcont)=2; -TCVsiglocation(TCVsig.iq95)={'\results::q_95'}; -TCVsiglocation(TCVsig.ikappa)={'\results::kappa_edge'}; -TCVsiglocation(TCVsig.idelta)={'\results::delta_edge'}; -TCVsiglocation(TCVsig.ideltatop)={'\results::delta_ed_top'}; -TCVsiglocation(TCVsig.ideltabot)={'\results::delta_ed_bot'}; -TCVsiglocation(TCVsig.ineint)={'\results::fir:lin_int_dens'}; -TCVsiglocation(TCVsig.inel)={'\results::fir:n_average'}; -%TCVsiglocation(TCVsig.iprofnerho)={'\results::THOMSON.PROFILES.AUTO:ne'}; -%TCVsiglocation(TCVsig.iprofterho)={'\results::THOMSON.PROFILES.AUTO:te'}; -TCVsiglocation(TCVsig.ineft)={'\results::proffit.local_time:neft_abs'}; TCVsigtimeindx(TCVsig.ineft)=2; -TCVsiglocation(TCVsig.iteft)={'\results::proffit.local_time:teft'}; TCVsigtimeindx(TCVsig.iteft)=2; -TCVsiglocation(TCVsig.ineftav)={'\results::proffit.avg_time:neft_abs'}; TCVsigtimeindx(TCVsig.ineftav)=2; -TCVsiglocation(TCVsig.iteftav)={'\results::proffit.avg_time:teft'}; TCVsigtimeindx(TCVsig.iteftav)=2; -TCVsiglocation(TCVsig.ineft_trial)=TCVsiglocation(TCVsig.ineft); TCVsigtimeindx(TCVsig.ineft_trial)=2; -TCVsiglocation(TCVsig.iteft_trial)=TCVsiglocation(TCVsig.iteft); TCVsigtimeindx(TCVsig.iteft_trial)=2; -TCVsiglocation(TCVsig.ineftav_trial)=TCVsiglocation(TCVsig.ineftav); TCVsigtimeindx(TCVsig.ineftav_trial)=2; -TCVsiglocation(TCVsig.iteftav_trial)=TCVsiglocation(TCVsig.iteftav); TCVsigtimeindx(TCVsig.iteftav_trial)=2; - -if shot==-9 - clear trace - for i=1:length(TCVkeywrdall) - fieldname_eff = lower(TCVkeywrdall{i}); - keyword_eff = TCVkeywrdall{i}; - ij=findstr(fieldname_eff,':'); - if ~isempty(ij); - fieldname_eff(ij)='_'; - keyword_eff(ij:end+1)=[':i' keyword_eff(ij+1:end)] ; - end - trace.(fieldname_eff) = keyword_eff; - end - % add example for Ip trace full call - trace.ipfullcall = TCVsiglocation{TCVsig.iip}; - % trace.data=[]; - return -end - -% initialize order of substructures and allows just a "return" if data empty -trace.data=[]; -trace.x=[]; -trace.t=[]; -trace.dim=[]; -trace.dimunits=[]; -trace.units=[]; -iprintwarn=0; -% find index of signal called upon -if strcmp(data_type_eff(1:1),'\') - % in case full node name was given - index=strmatch(data_type_eff(1:end-i_23),TCVsiglocation,'exact'); - if iprintwarn & isempty(index) - disp('********************') - disp('trace not yet registered.') - disp('If standard data, ask olivier.sauter@epfl.ch to create a keyqord entry for this data') -% eval(['!mail -s ''' data_type_eff ' ' num2str(shot) ' ' getenv('USER') ' TCV'' olivier.sauter@epfl.ch < /dev/null']) - disp('********************') - elseif isempty(index) - % temporarily add entry in arrays, so can work below - index=length(TCVkeywrdall)+1; - TCVkeywrdall(end+1)={'new'}; - TCVkeywrdcase(end+1)={'simpletdi'}; - TCVsiglocation(end+1)={data_type_eff(1:end-i_23)}; - TCVsigtimeindx(end+1)=0; - elseif ~strcmp(TCVkeywrdcase{index},'simpletdi') - msgbox(['Problem in loadTCVdata with data_type_eff = ' data_type_eff ... - '. Full paths of nodes should only be for case simpletdi'],'in loadTCVdata','error') - error('in loadTCVdata') - end -else - index=strmatch(data_type_eff_noext,TCVkeywrdall,'exact'); - if isempty(index) - disp(' ') - disp('********************') - disp(['no such keyword: ' data_type_eff(1:end-i_23)]) - disp(' ') - disp('Available keywords:') - TCVkeywrdall(:) - disp('********************') - return - end - if liuqe_version==-1 && ~isempty(strmatch(TCVkeywrdall{index},noFBTE,'exact')) - disp(['node ' TCVkeywrdall{index} ' not defined within FBTE']) - return - end -end -if iprintwarn - disp(['loading' ' ' data_type_eff_noext ' from TCV shot #' num2str(shot)]); - disp(['case ' TCVkeywrdcase{index}]) -end -if i_23==2 & isempty(strmatch(TCVsiglocation(index),liuqe23,'exact')) & strcmp(TCVkeywrdcase{index},'simpletdi') - disp('********') - disp('Warning asks for liuqe 2 or 3 of a signal, but not in liuqe23 list in loadTCVdata') -% eval(['!mail -s ''' data_type_eff ' ' num2str(shot) ' ' getenv('USER') ' TCV: not in liuqe23 list'' olivier.sauter@epfl.ch < /dev/null']) - disp('********') -end - -status=ones(1,100); -zmag=cell(0,0); -nargineff=nargin; -if iprintwarn - disp('TCVsiglocation{index} in loadTCVdata') - TCVsiglocation{index} -end - -switch TCVkeywrdcase{index} - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case 'simpletdi' - - % load TCV other data - if liuqe_version==-1 - mdsopen( 'pcs', shot); %synthetic shot generated with FBTE and MGAMS. - else - mdsopen(shot); - % test if node exists - error_status=1; - ij=findstr(TCVsiglocation{index},'['); - if isempty(ij); ij=length(TCVsiglocation{index})+1; end - if eval(['~mdsdata(''node_exists("\' TCVsiglocation{index}(1:ij-1) '")'')']) - disp(['node ' TCVsiglocation{index}(1:ij-1) ' does not exist for shot = ' num2str(shot)]) - return -% $$$ elseif eval(['mdsdata(''getnci("\' nodenameeff ':foo","length")'')==0']) -% $$$ disp(['no data for node ' nodenameeff ' for shot = ' num2str(shot)]) -% $$$ return - end - end - if strcmp(TCVsiglocation{index}(1:9),'\psitbx::') - begstr = 'tcv_psitbx("'; - nodenameeff=[begstr TCVsiglocation{index}(10:end) endstr]; - elseif length(TCVsiglocation{index})>16 && strcmp(TCVsiglocation{index}(1:16),'\results::psitbx') - begstr = 'tcv_psitbx("'; - nodenameeff=[begstr TCVsiglocation{index}(18:end) endstr]; - elseif strcmp(TCVsiglocation{index}(1:10),'\results::') - nodenameeff=[begstr TCVsiglocation{index}(11:end) endstr]; - else - nodenameeff=TCVsiglocation{index}; - disp(['should not have gone through here, mention this example to O. Sauter']); - end - tracetdi=tdi(nodenameeff); - mdsclose; - if isempty(tracetdi.data) || (~iscell(tracetdi.data) && (length(tracetdi.data)<=1) && isnan(tracetdi.data)) - disp(['node ' nodenameeff ' is empty for shot = ' num2str(shot)]) - return - end - trace.data=tracetdi.data; - - if length(tracetdi.dim)==0 - % scalar - trace.x=[]; - trace.t=[]; - elseif TCVsigtimeindx(index)>0 | length(tracetdi.dim)==1 - trace.t=tracetdi.dim{max(1,TCVsigtimeindx(index))}; - ix=3-TCVsigtimeindx(index); % works only for 2D arrays - else - % if dim=41 assumes is x (usual for TCV) - if length(tracetdi.dim{1})==41 - ix=1; - trace.t=tracetdi.dim{2}; - elseif length(tracetdi.dim{2})==41 - ix=2; - trace.t=tracetdi.dim{1}; - elseif length(tracetdi.dim)==2 - % if one has 2D or more and the other 1D, assume rho is 2D or more and time is 1D - if min(size(tracetdi.dim{1}))==1 && (min(size(tracetdi.dim{2}))>1 || length(size(tracetdi.dim{2}))>2) - ix=2; - trace.t=tracetdi.dim{1}; - disp(['assumes time array is 1D array, so x from dim{' num2str(ix) '}']) - elseif min(size(tracetdi.dim{2}))==1 && (min(size(tracetdi.dim{1}))>1 || length(size(tracetdi.dim{1}))>2) - ix=1; - trace.t=tracetdi.dim{2}; - disp(['assumes time array is 1D array, so x from dim{' num2str(ix) '}']) - elseif tracetdi.dim{1}(end)<1.1 && tracetdi.dim{2}(end)>1.1 - ix=1; - trace.t=tracetdi.dim{2}; - disp(['assumes x array is 1D array with max <1.1']) - elseif tracetdi.dim{1}(end)>1.1 && tracetdi.dim{2}(end)<1.1 - ix=2; - trace.t=tracetdi.dim{1}; - disp(['assumes x array is 1D array with max <1.1']) - elseif length(size(tracetdi.dim{1}))==2 && min(size(tracetdi.dim{1}))==1 && length(size(tracetdi.dim{2}))==2 && min(size(tracetdi.dim{2}))==1 - % if both are 1D arrays, assumes time array with values having most number of digits - ab1=num2str(tracetdi.dim{1}-fix(tracetdi.dim{1})); - ab2=num2str(tracetdi.dim{2}-fix(tracetdi.dim{2})); - if size(ab1,2)<size(ab2,2); - ix=1; - trace.t=tracetdi.dim{2}; - else - ix=2; - trace.t=tracetdi.dim{1}; - end - disp(['assumes time array has more digits, so x from dim{' num2str(ix) '}']) - end - end - end - if length(tracetdi.dim)==2 - trace.x=tracetdi.dim{ix}; - % make sure data is of (x,t) - if ix==2 - % transpose data - trace.data=trace.data'; - end - elseif length(tracetdi.dim)>2 - msgbox(['data more than 2D (data_type_eff=' data_type_eff ... - '), check how to save it, contact andrea.scarabosio@epfl.ch or olivier.sauter@epfl.ch'],... - 'in simpletdi','warn') - warning('in simpletdi of loadTCVdata') - else - if max(1,TCVsigtimeindx(index))~=1 - disp('Problems in loadTCVdata, max(1,TCVsigtimeindx(index)) should be 1') - end - end - if length(tracetdi.dim)==1 - trace.dim=[{trace.t}]; - trace.dimunits=tracetdi.dimunits(1); - elseif length(tracetdi.dim)==2 - trace.dim=[{trace.x} ; {trace.t}]; - trace.dimunits=[tracetdi.dimunits(ix) ; tracetdi.dimunits((2-ix)+1)]; - else - trace.dim=tracetdi.dim; - trace.dimunits=tracetdi.dimunits; - end - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - - trace.name=[num2str(shot) ';' nodenameeff]; - error_status=0; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'ne','te'} - % ne or Te from Thomson data on raw z mesh vs (z,t) - mdsopen(shot); - if strcmp(TCVkeywrdcase{index},'ne') - nodenameeff='\results::thomson:ne'; - tracetdi=tdi(nodenameeff); - tracestd=tdi('\results::thomson:ne:error_bar'); - else - nodenameeff='\results::thomson:te'; - tracetdi=tdi(nodenameeff); - tracestd=tdi('\results::thomson:te:error_bar'); - trace_abs=tdi('\results::thomson:fir_thom_rat'); - end - trace.data=tracetdi.data'; % Thomson data as (t,z) - trace.std=tracestd.data'; - trace.name=[num2str(shot) ';' nodenameeff]; - % add correct dimensions - try - time=mdsdata('\results::thomson:times'); - catch - warning('Problems with \results::thomson:times') - disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' TCVkeywrdcase{index}]) - return - end - if isempty(time) || ischar(time) - thomsontimes=time - warning('!!!!!!!!!!!!!!!!!!!!!!!!!\results::thomson:times is empty? Check') - disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' TCVkeywrdcase{index}]) - return - end - z=mdsdata('\diagz::thomson_set_up:vertical_pos'); - trace.dim=[{z};{time}]; - trace.dimunits=[{'Z [m]'} ; {'time [s]'}]; - trace.x=z; - trace.t=time; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - mdsclose('mdsip'); - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'ne_edge','te_edge'} - % ne or Te from Thomson.edge data on raw z mesh vs (z,t) - mdsopen(shot); - if strcmp(TCVkeywrdcase{index},'ne_edge') - nodenameeff='\results::thomson.edge:ne'; - tracetdi=tdi(nodenameeff); - tracestd=tdi('\results::thomson.edge:ne:error_bar'); - else - nodenameeff='\results::thomson.edge:te'; - tracetdi=tdi(nodenameeff); - tracestd=tdi('\results::thomson.edge:te:error_bar'); - trace_abs=tdi('\results::thomson.edge:fir_thom_rat'); - end - trace.data=tracetdi.data'; % Thomson.Edge data as (t,z) - trace.std=tracestd.data'; - trace.name=[num2str(shot) ';' nodenameeff]; - % add correct dimensions - try - time=mdsdata('\results::thomson:times'); - catch - warning('Problems with \results::thomson:times') - disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' TCVkeywrdcase{index}]) - return - end - if isempty(time) || ischar(time) - thomsontimes=time - warning('!!!!!!!!!!!!!!!!!!!!!!!!!\results::thomson:times is empty? Check') - disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' TCVkeywrdcase{index}]) - return - end - z=mdsdata('\diagz::thomson_set_up.edge:vertical_pos'); - trace.dim=[{z};{time}]; - trace.dimunits=[{'Z [m]'} ; {'time [s]'}]; - trace.x=z; - trace.t=time; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - mdsclose('mdsip'); - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'nerho','terho'} - % ne or Te from Thomson data on rho=sqrt(psi_normalised) mesh: (rho,t) - mdsopen(shot); - try - time=mdsdata('\results::thomson:times'); - catch - warning('Problems with \results::thomson:times') - disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' TCVkeywrdcase{index}]) - return - end - if isempty(time) || ischar(time) - thomsontimes=time - warning('!!!!!!!!!!!!!!!!!!!!!!!!!\results::thomson:times is empty? Check') - disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' TCVkeywrdcase{index}]) - return - end - if strcmp(TCVkeywrdcase{index},'nerho') - nodenameeff='\results::thomson:ne'; - tracetdi=tdi(nodenameeff); - if isempty(tracetdi.data) - ishot=mdsopen(shot) - tracetdi=tdi(nodenameeff) - end - nodenameeff='\results::thomson:ne; error_bar ; fir_thom_rat; (ne,std)*fir_thom_rat'; - tracestd=tdi('\results::thomson:ne:error_bar'); - if shot>=23801 - tracefirrat=tdi('\results::thomson.profiles.auto:fir_thom_rat'); %time base not same!! - if isempty(tracefirrat.data) || ischar(tracefirrat.data) - disp('problem with \results::thomson.profiles.auto:fir_thom_rat: empty') - end - else - tracefirrat=tdi('\results::thomson:fir_thom_rat'); - if isempty(tracefirrat.data) || ischar(tracefirrat.data) - disp('problem with \results::thomson.profiles.auto:fir_thom_rat: empty') - tracefirrat.dim{1}=[]; - else - tracefirrat.dim{1}=time; - end - end - if ~isempty(tracefirrat.data) || ischar(tracefirrat.data) - tracefirrat_data=NaN*ones(size(tracetdi.dim{1})); - itim=iround(time,tracefirrat.dim{1}); - tracefirrat_data(itim)=tracefirrat.data; - else - tracefirrat_data=NaN; - end - else - nodenameeff='\results::thomson:te'; - tracetdi=tdi(nodenameeff); - nodenameeff='\results::thomson:te; error_bar'; - tracestd=tdi('\results::thomson:te:error_bar'); - end - trace.data=tracetdi.data'; % Thomson data as (t,z) - trace.std=tracestd.data'; - if strcmp(TCVkeywrdcase{index},'nerho') - trace.firrat=tracefirrat_data; - trace.data_abs=trace.data*diag(tracefirrat_data); - trace.std_abs=trace.std*diag(tracefirrat_data); - end - trace.name=[num2str(shot) ';' nodenameeff]; - % add correct dimensions - % construct rho mesh - psi_max=tdi(['\results::thomson:psi_max' endstr]); - psiscatvol=tdi(['\results::thomson:psiscatvol' endstr]); - if ~isempty(psiscatvol.data) && ~ischar(psiscatvol.data) && ~isempty(psi_max.data) && ~ischar(psi_max.data) - for ir=1:length(psiscatvol.dim{2}) - rho(ir,:)= sqrt(1.-psiscatvol.data(:,ir)./psi_max.data(:))'; - end - else - rho=NaN; - end - trace.dim=[{rho};{time}]; - trace.dimunits=[{'sqrt(psi)'} ; {'time [s]'}]; - trace.x=rho; - trace.t=time; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - mdsclose; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'nerho_edge','terho_edge'} - % ne or Te from Thomson.Edge data on rho=sqrt(psi_normalised) mesh: (rho,t) - mdsopen(shot); - try - time=mdsdata('\results::thomson:times'); - catch - warning('Problems with \results::thomson:times') - disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' TCVkeywrdcase{index}]) - return - end - if isempty(time) || ischar(time) - thomsontimes=time - warning('!!!!!!!!!!!!!!!!!!!!!!!!!\results::thomson:times is empty? Check') - disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' TCVkeywrdcase{index}]) - return - end - if strcmp(TCVkeywrdcase{index},'nerho_edge') - nodenameeff='\results::thomson.edge:ne'; - tracetdi=tdi(nodenameeff); - if isempty(tracetdi.data) || ischar(tracetdi.data) - ishot=mdsopen(shot) - tracetdi=tdi(nodenameeff) - end - nodenameeff='\results::thomson.edge:ne; error_bar ; fir_thom_rat; (ne,std)*fir_thom_rat'; - tracestd=tdi('\results::thomson.edge:ne:error_bar'); - if shot>=23801 - tracefirrat=tdi('\results::thomson.profiles.auto:fir_thom_rat'); %time base not same!! - if isempty(tracefirrat.data) || ischar(tracefirrat.data) - disp('problem with \results::thomson.profiles.auto:fir_thom_rat: empty') - end - else - tracefirrat=tdi('\results::thomson.edge:fir_thom_rat'); - tracefirrat.dim{1}=time; - end - if ~isempty(tracetdi.dim) - tracefirrat_data=NaN*ones(size(tracetdi.dim{1})); - else - tracefirrat_data=[]; - end - if ~isempty(tracefirrat.data) && ~ischar(tracefirrat.data) - itim=iround(time,tracefirrat.dim{1}); - tracefirrat_data(itim)=tracefirrat.data; - end - else - nodenameeff='\results::thomson.edge:te'; - tracetdi=tdi(nodenameeff); - nodenameeff='\results::thomson.edge:te; error_bar'; - tracestd=tdi('\results::thomson.edge:te:error_bar'); - end - if ~ischar(tracetdi.data); trace.data=tracetdi.data'; end % Thomson.Edge data as (t,z) - trace.std=tracestd.data'; - if strcmp(TCVkeywrdcase{index},'nerho') - trace.firrat=tracefirrat_data; - trace.data_abs=trace.data*diag(tracefirrat_data); - trace.std_abs=trace.std*diag(tracefirrat_data); - end - trace.name=[num2str(shot) ';' nodenameeff]; - % add correct dimensions - % construct rho mesh - psi_max=tdi(['\results::thomson.edge:psi_max' endstr]); - psiscatvol=tdi(['\results::thomson.edge:psiscatvol' endstr]); - if ~isempty(psiscatvol.data) && ~ischar(psiscatvol.data) - for ir=1:length(psiscatvol.dim{2}) - rho(ir,:)= sqrt(1.-psiscatvol.data(:,ir)./psi_max.data(:))'; - end - trace.dim=[{rho};{time}]; - trace.dimunits=[{'sqrt(psi)'} ; {'time [s]'}]; - trace.x=rho; - trace.t=time; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - else - trace.dim={}; - trace.dimunits={}; - trace.x=[]; - trace.t=[]; - trace.units={}; - end - mdsclose; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'nerhozshift','terhozshift'} - % ne or Te from Thomson data on rho=sqrt(psi_normalised) mesh: (rho,t) - % allow for z shift of equil - if nargin>=3 & ~isempty(varargin{1}) - zshift=varargin{1}; - else - zshift=0.; - end - mdsopen(shot); - try - time=mdsdata('\results::thomson:times'); - catch - warning('Problems with \results::thomson:times') - disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' TCVkeywrdcase{index}]) - return - end - if isempty(time) || ischar(time) - thomsontimes=time - warning('!!!!!!!!!!!!!!!!!!!!!!!!!\results::thomson:times is empty? Check') - disp(['!!!!!!!!!!!!!!!!!!!!!!!!! cannot continue with ' TCVkeywrdcase{index}]) - return - end - if strcmp(TCVkeywrdcase{index},'nerhozshift') - nodenameeff='\results::thomson:ne'; - tracetdi=tdi(nodenameeff); - tracestd=tdi('\results::thomson:ne:error_bar'); - if shot>=23801 - tracefirrat=tdi('\results::thomson.profiles.auto:fir_thom_rat'); %time base not same!! - if isempty(tracefirrat.data) || ischar(tracefirrat.data) - disp('problem with \results::thomson.profiles.auto:fir_thom_rat: empty') - end - else - tracefirrat=tdi('\results::thomson:fir_thom_rat'); - if isempty(tracefirrat.data) || ischar(tracefirrat.data) - disp('problem with \results::thomson.profiles.auto:fir_thom_rat: empty') - tracefirrat.dim{1}=[]; - else - tracefirrat.dim{1}=time; - end - end - if ~isempty(tracefirrat.data) || ischar(tracefirrat.data) - tracefirrat_data=NaN*ones(size(tracetdi.dim{1})); - itim=iround(time,tracefirrat.dim{1}); - tracefirrat_data(itim)=tracefirrat.data; - else - tracefirrat_data=NaN; - end - else - nodenameeff='\results::thomson:te'; - tracetdi=tdi(nodenameeff); - tracestd=tdi('\results::thomson:te:error_bar'); - end - trace.data=tracetdi.data'; % Thomson data as (t,z) - trace.std=tracestd.data'; - if strcmp(TCVkeywrdcase{index},'nerhozshift') - trace.firrat=tracefirrat_data; - trace.data_abs=trace.data*diag(tracefirrat_data); - trace.std_abs=trace.std*diag(tracefirrat_data); - end - trace.name=[num2str(shot) ';' nodenameeff]; - % add correct dimensions - % construct rho mesh - if strcmp(endstr,'_-1') - error(['in ' TCVkeywrdcase{index} ' endstr should not be ' endstr]); - end - psi_max=tdi(['\results::thomson:psi_max' endstr]); - psiscatvol=tdi(['\results::thomson:psiscatvol' endstr]); - if abs(zshift)>1e-5 - % calculate new psiscatvol - psitdi=tdi('\results::psi'); - rmesh=psitdi.dim{1}; - zmesh=psitdi.dim{2}; - zthom=mdsdata('dim_of(\thomson:te,1)'); - zeffshift=zshift; - % set zeffshift time array same as psitdi - switch length(zeffshift) - case 1 - zeffshift=zeffshift * ones(size(psitdi.dim{3})); - case length(psitdi.dim{3}) - % ok - case length(psiscatvol.dim{1}) - zeffshift=interp1(psiscatvol.dim{1},zeffshift,psitdi.dim{3}); - otherwise - disp(' bad time dimension for zshift') - disp(['it should be 1 or ' num2str(length(psiscatvol.dim{1})) ' or ' num2str(length(psitdi.dim{3}))]) - end - for it=1:length(psiscatvol.dim{1}) - itpsitdi=iround(psitdi.dim{3},psiscatvol.dim{1}(it)); - psirz=psitdi.data(:,:,itpsitdi); - psiscatvol0=griddata(rmesh,zmesh,psirz',0.9*ones(size(zthom)),zthom-zeffshift(itpsitdi)); - psiscatvol.data(it,:)=psiscatvol0; - end - end - if ~isempty(psiscatvol.data) && ~ischar(psiscatvol.data) && ~isempty(psi_max.data) && ~ischar(psi_max.data) - for ir=1:length(psiscatvol.dim{2}) - rho(ir,:)= sqrt(1.-psiscatvol.data(:,ir)./psi_max.data(:))'; - end - else - rho=NaN; - end - trace.dim=[{rho};{time}]; - trace.dimunits=[{'sqrt(psi)'} ; {'time [s]'}]; - trace.x=rho; - trace.t=time; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - mdsclose; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'profnerho','profterho'} - % vol from psitbx - mdsopen(shot); - error_status=1; - if strcmp(TCVkeywrdcase{index},'profnerho') - nodenameeff=['\results::THOMSON.PROFILES.AUTO:ne']; - avers=tdi('\results::THOMSON.PROFILES.AUTO:ne:version_num'); - end - if strcmp(TCVkeywrdcase{index},'profterho') - nodenameeff=['\results::THOMSON.PROFILES.AUTO:te']; - avers=tdi('\results::THOMSON.PROFILES.AUTO:te:version_num'); - end - if avers.data==0 - % may be because nodes not yet filled in, so call once a node - ab=tdi(nodenameeff); - avers=tdi([nodenameeff ':version_num']); - end - if avers.data>0 - tracetdi=tdi(nodenameeff); - if avers.data < 2.99 - % for earlier version the bug made it to have logically (rho,t) - if ~isempty(tracetdi.dim) && ~ischar(tracetdi.data) - trace.x=tracetdi.dim{1}; - trace.t=tracetdi.dim{2}; - error_status=0; - else - error_status=2; - trace.x=[]; - trace.t=[]; - end - else - trace.data=tracetdi.data'; % error in dimensions for autofits - if ~isempty(tracetdi.dim) && ~ischar(tracetdi.data) - disp('assumes dim{2} for x in THOMSON.PROFILES.AUTO') - trace.x=tracetdi.dim{2}; - trace.t=tracetdi.dim{1}; - error_status=0; - else - trace.x=[]; - trace.t=[]; - error_status=2; - end - end - else - tracetdi=avers; - trace.x=[]; - trace.t=[]; - end - trace.dim=[{trace.x};{trace.t}]; - trace.dimunits=[{'sqrt(psi)'} ; {'time [s]'}]; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - trace.name=[num2str(shot) '; Thomson autfits from ' nodenameeff ]; - mdsclose; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'B0'} - % B0 at R0=0.88 - if liuqe_version==-1 - % mdsopen( 'pcs', shot); %synthetic shot generated with FBTE and MGAMS. - mdsopen(shot) - nodenameeff = 'tcv_eq("BZERO","FBTE")'; - tracetdi=tdi(nodenameeff); - trace.data = tracetdi.data; - trace.t = tracetdi.dim{1}; - - else - mdsopen(shot); - nodenameeff=['\magnetics::iphi']; - tracetdi=tdi(nodenameeff); - R0EXP=0.88; - trace.data=192.E-07 * 0.996 *tracetdi.data/R0EXP; - trace.t=tracetdi.dim{1}; - end - trace.x=[]; -%keyboard - trace.dim=[{trace.t}]; - trace.dimunits=[{'time [s]'}]; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - trace.name=[num2str(shot) ';' nodenameeff]; - mdsclose; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'qrho'} - % q profile on psi from liuqe - if liuqe_version==-1 - mdsopen( 'pcs', shot); %synthetic shot generated with FBTE and MGAMS. - else - mdsopen(shot); - end - nodenameeff=[begstr 'q_psi' endstr]; - tracetdi=tdi(nodenameeff); - trace.data=tracetdi.data; - trace.x=sqrt(tracetdi.dim{1}/(length(tracetdi.dim{1})-1)); - trace.t=tracetdi.dim{2}; - trace.dim=[{trace.x};{trace.t}]; - trace.dimunits=[{'sqrt(psi)'} ; {'time [s]'}]; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - trace.name=[num2str(shot) ';' nodenameeff]; - mdsclose; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'vol'} - % vol from psitbx - if liuqe_version==-1 - begstr = 'tcv_psitbx("'; - mdsopen( 'pcs', shot); %synthetic shot generated with FBTE and MGAMS. - nodenameeff=[begstr 'vol' endstr]; - tracetdi=tdi(nodenameeff); - else - mdsopen(shot); - nodenameeff=['\results::psitbx:vol']; - tracetdi=tdi(nodenameeff); - if i_23==2 - ['LIUQE' endstr(2:2)] - psi=psitbxtcv(shot,'+0',['LIUQE' endstr(2:2)]); - fsd=psitbxp2p(psi,'FS'); - fsg=psitbxfsg(fsd); - tracetdi.data = fsg.vol.x; - tracetdi.dim{1}=fsg.vol.grid.x{:}'; - tracetdi.dim{2}=fsg.vol.grid.t'; - end - end - trace.data=tracetdi.data; - if isempty(tracetdi.data) || ischar(tracetdi.data) - trace.x=tracetdi.dim; - trace.t=tracetdi.dim; - trace.dim=tracetdi.dim; - else - trace.x=tracetdi.dim{1}; - trace.t=tracetdi.dim{2}; - trace.dim=[{trace.x};{trace.t}]; - end - trace.dimunits=[{'sqrt(psi)'} ; {'time [s]'}]; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - trace.name=[num2str(shot) ';' nodenameeff '_' num2str(liuqe_version)]; - mdsclose; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'rhovol'} - % vol from psitbx - if liuqe_version==-1 - begstr = 'tcv_psitbx("'; - mdsopen( 'pcs', shot); %synthetic shot generated with FBTE and MGAMS. - nodenameeff=[begstr 'vol' endstr]; - tracetdi=tdi(nodenameeff); - else - mdsopen(shot); - nodenameeff=['\results::psitbx:vol']; - tracetdi=tdi(nodenameeff); - if i_23==2 - ['LIUQE' endstr(2:2)] - psi=psitbxtcv(shot,'+0',['LIUQE' endstr(2:2)]); - fsd=psitbxp2p(psi,'FS'); - fsg=psitbxfsg(fsd); - tracetdi.data = fsg.vol.x; - tracetdi.dim{1}=fsg.vol.grid.x{:}'; - tracetdi.dim{2}=fsg.vol.grid.t'; - end - end - trace.data=tracetdi.data; - for i=1:size(tracetdi.data,2) - trace.data(:,i)=sqrt(tracetdi.data(:,i)./tracetdi.data(end,i)); - end - trace.x=tracetdi.dim{1}; - trace.t=tracetdi.dim{2}; - trace.dim=[{trace.x};{trace.t}]; - trace.dimunits=[{'sqrt(psi)'} ; {'time [s]'}]; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - trace.name=[num2str(shot) '; sqrt(V/Va) from ' nodenameeff '_' num2str(liuqe_version)]; - mdsclose; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'sxr','sxR'} - % load TCV soft x-ray data - if nargin>=3 & ~isempty(varargin{1}) - i1=varargin{1}(1); - i2=varargin{1}(2); - else - i1=1; - i2=20; - end - if nargin>=4 & ~isempty(varargin{2}) - status=varargin{2}; - else - status=ones(i2-i1+1,1); - end - - % 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 - 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_eff,'sxR') - if nargin>=5 & ~isempty(varargin{3}) - zmag=varargin{3}; - else - zmag=loadTCVdata(shot,['zmag' '_' num2str(liuqe_version)]); - end - t_1=zmag.t(1); - t_2=zmag.t(end); - [xtomo_signal,t]=get_xtomo_data(shot,t_1,t_2,13e-6*16,icamera,angfact); - data=interp1(zmag.t,zmag.data,t'); - radius.data=VsxrTCVradius(data,xchord,ychord)'; - radius.t=t'; - varargout{1}={radius}; - trace.R=radius.data; - else - t_1=0.001; - t_2=3; - [xtomo_signal,t]=get_xtomo_data(shot,t_1,t_2,13e-6*16, ... - icamera,angfact); - end - end - trace.data=xtomo_signal; - trace.x=[1:size(trace.data,1)]'; - trace.t=t'; - trace.dim=[{trace.x} ; {trace.t}]; - trace.dimunits=[{'channel #'} ; {'time [s]'}]; - trace.name=[num2str(shot) ';' 'get_xtomo_data']; - error_status=0; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case 'ece' - % load TCV ECE data - % Status=1 => Not Read Yet - mdsopen(shot); - if ~isempty(find(status == 1)) - if eval(['~mdsdata(''node_exists("\\RESULTS::ECE:rho")'')']) - disp(['node \RESULTS::ECE:rho does not exist for shot = ' num2str(shot)]) - return - end - if eval(['mdsdata(''getnci("\\RESULTS::ECE:rho","length")'')==0']) - disp(['no data for \RESULTS::ECE:rho for shot = ' num2str(shot)]) - return - end - [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)); - trace.data=TE_ECE(a:b,:)'; - trace.t=T(a:b); - trace.x=[1:size(trace.data,1)]'; - trace.dim=[{trace.x} ; {trace.t}]; - trace.dimunits=[{'channel #'} ; {'time [s]'}]; - trace.R=R(a:b,:)'; - trace.name=[num2str(shot) ';' '\results::ece...']; - radius.data=trace.R; - radius.t=trace.t; - varargout{1}={radius}; - error_status=0; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - mdsclose; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case 'MPX' - % load TCV MPX data - % Status=1 => Not Read Yet - if isempty(zmag) - zmag=loadTCVdata(shot,'zmag'); - end - t_1=zmag.t(1); - t_2=zmag.t(end); - if ~isempty(find(status == 1)) - mdsopen(shot); - keyboard - signal=get_mds_mio('MPX',[t_1 t_2]); - mdsclose; - trace.data=signal.data; - for i=1:size(signal.dim{2},2) - trace.t(:,i)=signal.dim{1}; - end - end - trace.dim{1}={trace.t}; - trace.dimunits={'time [s]'}; - trace.name=[num2str(shot) ';' 'get_mds_mio(MPX)']; - [xchord,ychord]=mpx_geometry; - varargout{1}={VsxrTCVradius(zmag.data,xchord,ychord)}; - error_status=0; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case 'IOH' - % Ohmic transformer current - mdsopen(shot); - nodenameeff=[{'\magnetics::ipol[*,$1]'} {'OH_001'}]; - tracetdi=tdi(nodenameeff{:}); - trace.data=tracetdi.data; - trace.x=[]; - trace.t=tracetdi.dim{1}; - trace.dim=tracetdi.dim; - trace.dimunits={'time [s]'}; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - trace.name=[num2str(shot) ';' nodenameeff{1} ',' nodenameeff{2}]; - mdsclose; - error_status=0; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case 'vloop' - % Loop voltage - mdsopen(shot); - nodenameeff=[{'\magnetics::vloop[*,$1]'} {'001'}]; - tracetdi=tdi(nodenameeff{:}); - trace.data=tracetdi.data; - trace.x=[]; - trace.t=tracetdi.dim{1}; - trace.dim=tracetdi.dim; - trace.dimunits={'time [s]'}; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - trace.name=[num2str(shot) ';' nodenameeff{1} ',' nodenameeff{2}]; - mdsclose; - error_status=0; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case 'pgyro' - % ECH power for each gyro(1:9) and total (10) - mdsopen(shot); - nodenameeff=[{'\results::toray.input:p_gyro'}]; - tracetdi=tdi(nodenameeff{:}); - trace.data=tracetdi.data; - trace.x=[]; - trace.t=tracetdi.dim{1}; - trace.dim=tracetdi.dim; - trace.dimunits=tracetdi.dimunits; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - trace.name=[num2str(shot) ';' nodenameeff]; - mdsclose; - error_status=0; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case 'jtor' - % \results::j_tor , 3-D so need to specify time dim index - mdsopen(shot); - nodenameeff=[{'\results::j_tor'} endstr]; - tracetdi=tdi(nodenameeff{:}); - trace.data=tracetdi.data; - trace.x=tracetdi.dim{1}; - trace.t=tracetdi.dim{3}; - trace.dim=tracetdi.dim; - trace.dimunits=tracetdi.dimunits; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - trace.name=[num2str(shot) ';' nodenameeff]; - mdsclose; - error_status=0; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'neft:trial','teft:trial','neftav:trial','teftav:trial'} - % trial indx - mdsopen(shot); - eval(['nodenameeff={''' TCVsiglocation{index} ':trial''};']); - tracetdi=tdi(nodenameeff{:}); - if isempty(trialindx) - error('trialindx should not be empty, check call or ask O. Sauter'); - end - trace.data=tracetdi.data(:,:,trialindx+1); - trace.x=tracetdi.dim{1}; - trace.t=tracetdi.dim{2}; - trace.dim=tracetdi.dim(1:2); - trace.dimunits=tracetdi.dimunits(1:2); - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - trace.name=[num2str(shot) ' ; ' nodenameeff{:} ' ; trialindx=' num2str(trialindx) ]; - mdsclose; - error_status=0; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'vi_tor', 'vi_torfit', 'vi_pol', 'vi_polfit', 'Ti', 'Tifit', 'ni', 'nifit', 'zeffcxrs', 'zeffcxrsfit'} - proffit = ''; - kwd_eff = TCVkeywrdcase{index}; - ii=strfind(kwd_eff,'fit'); - if ~isempty(ii); - proffit = ':proffit'; - kwd_eff = kwd_eff(1:ii-1); - end - if strcmp(kwd_eff,'zeffcxrs'); kwd_eff = 'zeff'; end - mdsopen(shot); - eval(['nodenameeff=''\results::cxrs' proffit ':' kwd_eff endstr ''';']); - tracetdi=tdi(nodenameeff); - trace.data=tracetdi.data; - if length(tracetdi.dim)>1; - trace.x=tracetdi.dim{1}; - trace.t=tracetdi.dim{2}; - else - trace.x=[]; - trace.t=[]; - end - trace.dim=tracetdi.dim; - trace.dimunits=tracetdi.dimunits; - % isfield does not work since tracetdi is not a 'struct' but a tdi object, thus isfield using isa does not work - if any(strcmp(fieldnames(tracetdi),'units')) - trace.units=tracetdi.units; - end - trace.name=[num2str(shot) ';' nodenameeff]; - % add error bars - eval(['nodenameeff=''\results::cxrs' proffit ':' kwd_eff ':err' endstr ''';']); - nodenameeff=[{'\results::cxrs:vi_tor:err'} endstr]; - tracetdi=tdi(nodenameeff{:}); - trace.std = tracetdi.data; - if length(tracetdi.dim)>2; - trace.std_rho = tracetdi.dim{1}; - trace.std_t = tracetdi.dim{2}; - else - trace.std_rho = []; - trace.std_t = []; - end - mdsclose; - error_status=0; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - otherwise - % eval(['!mailto_Andrea ''from loadTCVdata, data_type_eff= ' data_type_eff '''']) - disp(['this data_type_eff' ' ' data_type_eff ' ' 'not yet programmed in loadTCVdata, ask Andrea.Scarabosio@epfl.ch']); - -end diff --git a/matlab/TCV/tcv_help_parameters.m b/matlab/TCV/tcv_help_parameters.m index 2c6c74c0b91bc015c0558a43e33af1c0f98ec3c0..15de8984169996ffdd2c5f1ea0e1b99a310aaa33 100644 --- a/matlab/TCV/tcv_help_parameters.m +++ b/matlab/TCV/tcv_help_parameters.m @@ -29,7 +29,8 @@ help_struct_all.cxrs_time_interval = ['cxrs: (time_interval can have several nbs ' as well']; help_struct_all.fit_tension = ['smoothing value used in interpos fitting routine, -30 means ''30 times default value'', thus -1 often a' ... ' good value' char(10) ... - 'cxrs: if numeric, default for all cases, if structure, default for non given fields']; + 'cxrs: if numeric, default for all cases, if structure, default for non given fields' char(10) ... + 'radcam: tension for interpos smoothing of data to have lower time samples']; help_struct_all.time = 'eqdsk: time(s) value(s) requested, by default time=1.0s (see time_out for other requests)'; help_struct_all.time_out = ['requested time for output: data points within interval if time_out=[t1 t2], otherwise assumes series of points, uses linear interpolation in that case (default [-Inf Inf])'... char(10) 'for sxr, mpx: only time interval provided in time_out is relevant']; @@ -56,17 +57,19 @@ help_struct_all.error_bar = sprintf('%s\n','for ids: choice of nodes fill in and '''delta'' (default): only upper fill in with the abs(value) to add or subtract to data to get upper and lower values (symmetric)', ... '''delta_with_lower'': same as delta but fill in lower node as well (with delta as well, same as upper)', ... '''added'': add the delta values (old cpo style), so upper=data+error_bar and lower=data+error_bar'); -help_struct_all.camera = ['sxr: for MPX: ''central'', ''top'' (default), ''bottom'' or ''both'' ; ' ... - ' for XTOMO: ''central'' (a central chord only), defaults if empty, [1 3 5] if only camera 1, 3 and 5 are desired']; -help_struct_all.freq = '''slow'', default, lower sampling; ''fast'' full samples for both mpx and xtomo'; +help_struct_all.camera = sprintf('%s\n%s\n%s', ... + 'sxr: for radcam: 1 to 4 or ''top'' (default), ''upper'', ''equatorial'', ''bottom'' array or cell array ok as well;', ... + ' for MPX: ''central'', ''top'' (default), ''bottom'' or ''both'' ;', ... + ' for XTOMO: ''central'' (a central chord only), defaults if empty, [1 3 5] if only camera 1, 3 and 5 are desired'); +help_struct_all.channel = sprintf('%s\n%s\n%s', ... + 'radcam: chord to choose within camera interval, or simply chords, then it is re-distributed to correct camera'); +help_struct_all.freq = '''slow'', default, lower sampling (for radcam smoothing on dt=0.1ms); ''fast'' full samples for radcam, mpx and xtomo'; help_struct_all.max_adcs = 'rtc: source=''adcs'' maximum nb of adc channels loaded for each board in each active node'; help_struct_all.nfft = '512 (default) changes time resolution in spectrogram in gdat_plot for ''mhd'' request'; help_struct_all.map_eqdsk_psirz = 'eqdsk: if time array provided, maps all psi(R,Z,t) on same R,Zmesh in .data (1) or not (0, default)'; help_struct_all.write = 'eqdsk: write eqdsk while loading data (1, default) or not (0)'; %help_struct_all. = ''; - - if ~exist('parameter_list') || isempty(parameter_list) help_struct = help_struct_all; return diff --git a/matlab/TCV/tcv_requests_mapping.m b/matlab/TCV/tcv_requests_mapping.m index 9909a953e12faf245943034c299fe7db3eee168c..04dcc1f5c8e483714b1882bb15b8e965bb07ed20 100644 --- a/matlab/TCV/tcv_requests_mapping.m +++ b/matlab/TCV/tcv_requests_mapping.m @@ -53,17 +53,17 @@ switch lower(data_request) mapping.timedim = 1; mapping.label = 'area'; mapping.method = 'tdiliuqe'; - mapping.expression = 'tcv_eq(''''area'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("area","LIUQE.M")'; case 'area_rho' mapping.timedim = 2; mapping.label = 'area_rho'; mapping.method = 'tdiliuqe'; - mapping.expression = 'tcv_eq(''''area_rho'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("area_rho","LIUQE.M")'; case 'area_edge' mapping.timedim = 1; mapping.label = 'area\_lcfs'; mapping.method = 'tdiliuqe'; - mapping.expression = 'tcv_eq(''''area_edge'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("area_edge","LIUQE.M")'; case 'b0' mapping.timedim = 1; mapping.label = 'B_0'; @@ -74,7 +74,7 @@ switch lower(data_request) mapping.label = '\beta'; mapping.method = 'tdiliuqe'; mapping.expression = '\results::beta_tor'; - mapping.expression = 'tcv_eq(''''beta_tor'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("beta_tor","LIUQE.M")'; case {'betan', 'beta_tor_norm'} mapping.timedim = 1; mapping.label = '\beta_N'; @@ -86,7 +86,7 @@ switch lower(data_request) mapping.method = 'tdiliuqe'; mapping.expression = '\results::beta_pol'; mapping.expression = '\tcv_shot::top.results.equil_1.results:beta_pol'; - mapping.expression = 'tcv_eq(''''beta_pol'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("beta_pol","LIUQE.M")'; case 'cxrs' mapping.timedim = 2; mapping.label = 'cxrs'; @@ -102,7 +102,7 @@ switch lower(data_request) mapping.method = 'tdiliuqe'; mapping.expression = '\results::delta_edge'; mapping.expression = '\tcv_shot::top.results.equil_1.results:delta_edge'; - mapping.expression = 'tcv_eq(''''delta_edge'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("delta_edge","LIUQE.M")'; % mapping.method = 'expression'; % mapping.expression = ['tdi(''\results::q_psi'');']; % for tests case 'delta_bottom' @@ -111,19 +111,19 @@ switch lower(data_request) mapping.method = 'tdiliuqe'; mapping.expression = '\results::delta_ed_bot'; mapping.expression = '\tcv_shot::top.results.equil_1.results:delta_bot'; - mapping.expression = 'tcv_eq(''''delta_ed_bot'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("delta_ed_bot","LIUQE.M")'; case 'delta_rho' mapping.timedim = 2; mapping.method = 'tdiliuqe'; mapping.expression = '\tcv_shot::top.results.equil_1.results:delta'; - mapping.expression = 'tcv_eq(''''delta'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("delta","LIUQE.M")'; case 'delta_top' mapping.timedim = 1; mapping.label = 'delta\_top'; mapping.method = 'tdiliuqe'; mapping.expression = '\results::delta_ed_top'; mapping.expression = '\tcv_shot::top.results.equil_1.results:delta_top'; - mapping.expression = 'tcv_eq(''''delta_ed_top'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("delta_ed_top","LIUQE.M")'; case 'ece' mapping.timedim = 2; mapping.method = 'switchcase'; @@ -141,8 +141,8 @@ switch lower(data_request) mapping.label = 'gap hfs/lfs'; mapping.method = 'expression'; mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''tcv_eq("r_contour","LIUQE.M")'';' ... - 'gdat_tmp=gdat_tcv([],params_eff);aa_data(1,:)=min(gdat_tmp.data,[],1)-0.624;' ... - 'aa_data(2,:)=1.136-max(gdat_tmp.data,[],1);gdat_tmp.data=aa_data;gdat_tmp.x=[1:2];gdat_tmp.dim{1}=gdat_tmp.x;' ... + 'gdat_tmp=gdat_tcv([],params_eff);aa_data(1,:)=min(gdat_tmp.data,[],1)-0.624;aa_data(1,[aa_data(1,:)<0]) = 0.;' ... + 'aa_data(2,:)=1.1376-max(gdat_tmp.data,[],1);aa_data(2,[aa_data(2,:)<0]) = 0.;gdat_tmp.data=aa_data;gdat_tmp.x=[1:2];gdat_tmp.dim{1}=gdat_tmp.x;' ... 'gdat_tmp.dimunits{1}={''HFS'',''LFS''};gdat_tmp.units=''m'';']; case {'gas', 'gas_flux', 'gas_request', 'gas_feedforward','gas_valve'} mapping.timedim = 1; @@ -204,24 +204,40 @@ switch lower(data_request) mapping.label = 'Plasma current'; mapping.timedim = 1; mapping.method = 'tdiliuqe'; - mapping.expression = 'tcv_eq(''''i_pl'''',''''LIUQE.M'''')'; % to be able to get ip consistent with relevant LIUQE value + mapping.expression = 'tcv_eq("i_pl","LIUQE.M")'; % to be able to get ip consistent with relevant LIUQE value + case 'i_pol' + disp('use ''ipol'' to get values from magnetics'); + mapping.timedim = 2; + mapping.method = 'expression'; + mapping.label = 'ipol from liuqe'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''tcv_eq("i_pol","LIUQE.M")''; ' ... + 'gdat_tmp=gdat_tcv([],params_eff);coilsname=mdsvalue(''dim_of(\magnetics::ipol,1)''); ' ... + 'gdat_tmp.dimunits{1}=coilsname([3:18 20 1:2]);']; + case 'ipol' + disp('use ''i_pol'' to get values from liuqe'); + mapping.timedim = 2; % changed to match usual time as last one and match liuqe i_pol + mapping.method = 'expression'; + mapping.label = 'ipol from magnetics'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''\magnetics::ipol''; ' ... + 'gdat_tmp=gdat_tcv([],params_eff);gdat_tmp.dimunits{2}=''s'';gdat_tmp.dimunits{1}=gdat_tmp.dim{2};' ... + 'gdat_tmp.dim{2}=gdat_tmp.dim{1};gdat_tmp.dim{1}=[0:numel(gdat_tmp.dimunits{1})-1]'';gdat_tmp.data=gdat_tmp.data''']; case 'kappa' mapping.timedim = 1; mapping.method = 'tdiliuqe'; mapping.expression = '\results::kappa_edge'; mapping.expression = '\tcv_shot::top.results.equil_1.results:kappa_edge'; - mapping.expression = 'tcv_eq(''''kappa_edge'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("kappa_edge","LIUQE.M")'; case 'kappa_rho' mapping.timedim = 2; mapping.method = 'tdiliuqe'; mapping.expression = '\tcv_shot::top.results.equil_1.results:kappa'; - mapping.expression = 'tcv_eq(''''kappa'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("kappa","LIUQE.M")'; case 'li' mapping.timedim = 1; mapping.method = 'tdiliuqe'; mapping.expression = '\results::l_i'; mapping.expression = '\tcv_shot::top.results.equil_1.results:l_i_3'; - mapping.expression = 'tcv_eq(''''l_i_3'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("l_i_3","LIUQE.M")'; case 'mhd' mapping.timedim = 1; mapping.label = 'n=1,2, etc'; @@ -287,7 +303,7 @@ switch lower(data_request) case {'phi_tor', 'phitor', 'toroidal_flux'} mapping.timedim = 2; mapping.method = 'tdiliuqe'; - mapping.expression = 'tcv_eq(''''tor_flux_tot'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("tor_flux_tot","LIUQE.M")'; % node not filled in and in any case need special case for mapping.label = 'toroidal_flux'; mapping.method = 'switchcase'; @@ -318,7 +334,7 @@ switch lower(data_request) mapping.timedim = 1; mapping.label = 'psi(R,Z)'; mapping.method = 'tdiliuqe'; - mapping.expression = 'tcv_eq(''''psi'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("psi","LIUQE.M")'; case 'powers' mapping.timedim = 1; mapping.label = 'various powers'; @@ -336,7 +352,7 @@ switch lower(data_request) mapping.method = 'tdiliuqe'; mapping.expression = '\results::psi_axis'; mapping.expression = '\tcv_shot::top.results.equil_1.results:psi_axis'; - mapping.expression = 'tcv_eq(''''psi_axis'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("psi_axis","LIUQE.M")'; mapping.label = 'psi\_axis with psi_edge=0'; case 'psi_edge' mapping.timedim = 1; @@ -345,25 +361,25 @@ switch lower(data_request) mapping.method = 'tdiliuqe'; mapping.expression = '\results::surface_flux'; mapping.expression = '\tcv_shot::top.results.equil_1.results:psi_surf'; - mapping.expression = 'tcv_eq(''''psi_surf'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("psi_surf","LIUQE.M")'; case 'q0' mapping.timedim = 1; mapping.method = 'tdiliuqe'; mapping.expression = '\results::q_zero'; mapping.expression = '\tcv_shot::top.results.equil_1.results:q_axis'; - mapping.expression = 'tcv_eq(''''q_axis'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("q_axis","LIUQE.M")'; case 'q95' mapping.timedim = 1; mapping.method = 'tdiliuqe'; % mapping.expression = '\results::q_95'; mapping.expression = '\tcv_shot::top.results.equil_1.results:q_95'; - mapping.expression = 'tcv_eq(''''q_95'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("q_95","LIUQE.M")'; case 'qedge' mapping.timedim = 1; mapping.method = 'tdiliuqe'; mapping.expression = '\results::q_edge'; mapping.expression = '\tcv_shot::top.results.equil_1.results:q_edge'; - mapping.expression = 'tcv_eq(''''q_edge'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("q_edge","LIUQE.M")'; case 'q_rho' mapping.timedim = 2; mapping.label = 'q'; @@ -377,19 +393,19 @@ switch lower(data_request) % $$$ mapping.method = 'tdiliuqe'; % $$$ mapping.expression = '\results::r_contour'; % $$$ mapping.expression = '\tcv_shot::top.results.equil_1.results:r_rho'; % several flux surfaces R coordinates (irho,itheta,t) -% $$$ mapping.expression = 'tcv_eq(''''r_rho'''',''''LIUQE.M'''')'; +% $$$ mapping.expression = 'tcv_eq("r_rho","LIUQE.M")'; case 'r_contour_edge' mapping.timedim = 2; mapping.method = 'tdiliuqe'; mapping.expression = '\results::r_contour'; mapping.expression = '\tcv_shot::top.results.equil_1.results:r_surf'; % LCFS R coordinates (r,t) - mapping.expression = 'tcv_eq(''''r_edge'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("r_edge","LIUQE.M")'; mapping.label = 'R\_lcfs'; mapping.method = 'switchcase'; % $$$ mapping.method = 'expression'; -% $$$ mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''tcv_eq(''''''''r_edge'''''''',''''''''LIUQE.M'''''''')''; ' ... +% $$$ mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''tcv_eq("r_edge","LIUQE.M")''; ' ... % $$$ 'gdat_tmp=gdat_tcv(shot,params_eff);gdat_tmp.data=gdat_tmp.data(:,:,end);' ... % $$$ 'gdat_tmp.dim=gdat_tmp.dim(1:2);gdat_tmp.dimunits=gdat_tmp.dimunits(1:2);']; case {'rgeom', 'r_geom'} @@ -422,7 +438,7 @@ switch lower(data_request) mapping.method = 'tdiliuqe'; mapping.expression = '\results::r_axis'; mapping.expression = '\tcv_shot::top.results.equil_1.results:r_axis'; - mapping.expression = 'tcv_eq(''''r_axis'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("r_axis","LIUQE.M")'; case {'rtc','scd'} if strcmp('scd',lower(data_request)); error('********* should call with request****** ''rtc'''); end mapping.timedim = 1; @@ -433,16 +449,16 @@ switch lower(data_request) mapping.timedim = 1; mapping.label = 'surface\_tor(rho)'; mapping.method = 'tdiliuqe'; - mapping.expression = 'tcv_eq(''''surf'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("surf","LIUQE.M")'; mapping.help = 'toroidal surface'; % works for method tdi..., in method expression, gdat_tmp.help should be defined case {'surface', 'surface_edge'} mapping.timedim = 1; mapping.label = 'surface'; mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''tcv_eq(''''''''surf'''''''',''''''''LIUQE.M'''''''')'';' ... + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''tcv_eq("surf","LIUQE.M")'';' ... 'gdat_tmp=gdat_tcv(shot,params_eff); gdat_tmp.dim = {gdat_tmp.t}; gdat_tmp.x=[]; gdat_tmp.data= gdat_tmp.data(end,:);' ... 'gdat_tmp.dimunits{1}=''s'';gdat_tmp.help=''toroidal surface of LCFS'';']; - case 'sxr' + case {'sxr', 'mpx', 'radcam'} mapping.timedim = 1; mapping.gdat_timedim = 2; mapping.method = 'switchcase'; @@ -503,7 +519,7 @@ switch lower(data_request) % $$$ corr = [4e3,4.5e3]; % $$$ if shot==57732; corr=[4650,4650]; end % $$$ mapping.method = 'expression'; -% $$$ mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''tcv_eq(''''''''w_mhd'''''''',''''''''LIUQE.M'''''''')'';' ... +% $$$ mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''tcv_eq("w_mhd","LIUQE.M")'';' ... % $$$ 'gdat_tmp=gdat_tcv(shot,params_eff);ij=find(gdat_tmp.t>0.5&gdat_tmp.t<1.03);' ... % $$$ 'aa=interp1([' num2str(time_for_corr(1)) ' ' num2str(time_for_corr(2)) ... % $$$ '],[' num2str(corr(1)) ' ' num2str(corr(2)) '],gdat_tmp.t(ij));' ... @@ -512,26 +528,26 @@ switch lower(data_request) mapping.method = 'tdiliuqe'; mapping.expression = '\results::total_energy'; mapping.expression = '\tcv_shot::top.results.equil_1.results:w_mhd'; - mapping.expression = 'tcv_eq(''''w_mhd'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("w_mhd","LIUQE.M")'; % $$$ end % $$$ case 'z_contour' % z_rho not yet implemented % $$$ mapping.timedim = 2; % $$$ mapping.method = 'tdiliuqe'; % $$$ mapping.expression = '\results::z_contour'; % $$$ mapping.expression = '\tcv_shot::top.results.equil_1.results:z_rho'; % several flux surfaces Z coordinates (irho,itheta,t) -% $$$ mapping.expression = 'tcv_eq(''''z_rho'''',''''LIUQE.M'''')'; +% $$$ mapping.expression = 'tcv_eq("z_rho","LIUQE.M")'; case 'z_contour_edge' mapping.timedim = 2; mapping.method = 'tdiliuqe'; mapping.expression = '\results::z_contour'; mapping.expression = '\tcv_shot::top.results.equil_1.results:z_surf'; % LCFS Z coordinates (r,t) - mapping.expression = 'tcv_eq(''''z_edge'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("z_edge","LIUQE.M")'; mapping.label = 'Z\_lcfs'; mapping.method = 'switchcase'; % $$$ mapping.method = 'expression'; -% $$$ mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''tcv_eq(''''''''z_edge'''''''',''''''''LIUQE.M'''''''')''; ' ... +% $$$ mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''tcv_eq("z_edge","LIUQE.M")''; ' ... % $$$ 'gdat_tmp=gdat_tcv(shot,params_eff);gdat_tmp.data=gdat_tmp.data(:,:,end);' ... % $$$ 'gdat_tmp.dim=gdat_tmp.dim(1:2);gdat_tmp.dimunits=gdat_tmp.dimunits(1:2);']; case 'zeff' @@ -549,7 +565,7 @@ switch lower(data_request) mapping.method = 'tdiliuqe'; mapping.expression = '\results::z_axis'; mapping.expression = '\tcv_shot::top.results.equil_1.results:z_axis'; - mapping.expression = 'tcv_eq(''''z_axis'''',''''LIUQE.M'''')'; + mapping.expression = 'tcv_eq("z_axis","LIUQE.M")'; % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % extra TCV cases (not necessarily in official data_request name list) @@ -567,10 +583,6 @@ switch lower(data_request) % $$$ mapping.method = 'tdiliuqe'; % $$$ % mapping.expression = '\results::thomson:psiscatvol:foo'; % $$$ mapping.expression = '\results::thomson:psiscatvol'; - case 'mpx' - mapping.timedim = 1; - mapping.gdat_timedim = 2; - mapping.method = 'switchcase'; case {'profnerho','profterho'} mapping.timedim = 1; mapping.label = data_request; diff --git a/matlab/TCV/xtomo_geometry.m b/matlab/TCV/xtomo_geometry.m deleted file mode 100644 index a809b9e65cca29d8df8eff407eaac96d7b7ebc4c..0000000000000000000000000000000000000000 --- a/matlab/TCV/xtomo_geometry.m +++ /dev/null @@ -1,402 +0,0 @@ -function [fans,vangle,xchord,ychord,aomega,angfact]=xtomo_geometry(i_detec,fans) - -% ----[anton.public] -% -% function -% -% [fans,vangle,xchord,ychord,aomega,angfact]=xtomo_geometry(i_detec,fans); -% -% inputs: -% -% i_detec: =2: Xtomo prototype cameras (shot# < 6768) -% =1: Xtomo 9-cameras (shot# > 682x) -% -% outputs: -% -% fans: camera switch, 1=on,0=off (1x10) -% vangle: angle between detect. surface normal and pos. x-axis (1x10) -% xchord: two x-coordinates (2xnl) and -% ychord: two y-coord. for each line (2xnl), they specify start + end points -% aomega: etendue in mm^2 x steradians -% angfact: angular factors, inverse of relative etendue (throughput) (20x10) -% -% uses: -% AOMEGA=etendue_n2(b1x,b1y,b1z,b2x,b2y,b2z,z01,z02,X0,cw); -% angular_fact_*.mat , '*'=i_detec -% -% -%---------------- M.Anton 14/3/95 ------------------------------------------- - -disp('*----------------------------*') -disp('| this is xtomo_geometry |') -disp('*----------------------------*') - -global xap yap xdet ydet -global ae da -% ======== tokamak parameters ================================================ - -load tcv_vesc1 - - - - -xcont=rzvin(:,1); -ycont=rzvin(:,2); -xmin=min(xcont); -ymin=min(ycont); -xmax=max(xcont); -ymax=max(ycont); -xedge=100; -yedge=60; - - - - -% ========= detector parameters ============================================= - -if i_detec==2 - - cw=1; % detector numbers cw=1:clockwise cw=0:ccw - - if nargin<2 - fans=[0 0 0 0 0 0 1 0 1 0]; % camera switch - end - - vangle=[90 90 90 0 0 0 0 -90 -90 -90]; - % angle of detector surface normal - xpos=[0 0 0 0 0 0 118.05 0 87.84 0]; - % x position of the diaphragmas in [cm] - ypos=[0 0 0 0 0 0 -46 0 -80.45 0]; - % y position of the diaphragmas in [cm] - ae=[0 0 0 0 0 0 -2.5 0 -0.1 0]/10; - %excentricity array/diaphragm in [cm] - da=[0 0 0 0 0 0 10.1 0 -11.7 0]/10; - % diaphragma-array distance in [cm] - da2=da; - - d1=0.950; % detector width in mm - d2=4.050; % detector length in mm - b1=1.000; % aperture width in mm - b2=4.000*ones(1,10); % aperture length in mm - b3x=0; % aperture thickness in mm - b3y=0; - -elseif i_detec==1 - - cw=1; % detector numbers cw=1:clockwise cw=0:ccw - - if nargin<2 - fans=[1 1 1 1 1 1 1 1 0 1]; % camera switch - end - - vangle=[90 90 90 0 0 0 0 -90 -90 -90]; - % angle of detector surface normal - xpos=[71.5 87.7 103.9 123.1 123.1 123.1 123.1 104.04 87.84 71.64]; - % x position of the diaphragmas in [cm] - ypos=[80.35 80.35 80.35 48.1 1.95 -2.45 -48.6 -80.35 -80.35 -80.35]; - % y position of the diaphragmas in [cm] - ae=[-8 0 8 5 9 -9 -5 8 0 -8]/10; %excentricity array/diaphragm [cm] - - - ae= ae + [-0.0915 0 0.1361 0.2123 0.0923 -0.0994 ... - 0.0872 -0.1520 0 0.9410 ]/10; - ae(1)=ae(1)+0.1/10; - ae(3)=8/10+0.14/10; - ae(4)=4.9/10; - ae(5)=9/10+0.2/10; - ae(6)=ae(6)-0.2/10; - ae(7)=-4.9/10; - ae(10)=-7.1/10; - - da= [12.4 9.9 12.4 9.9 13.4 13.4 9.9 -12.4 -9.9 -12.4]/10; - % diaphragma-array distance in [cm] (poloidal) - da2=[37 34.4 37 55.9 59.4 59.4 55.9 37 34.4 37]/10; - % dist to diaphragm in toroidal direction [cm]; - deltada=[ -0.0311 0 -0.0458 -0.1179 -0.0615 -0.1105 ... - -0.0510 -0.0515 0 -0.3223]/10; - deltada(4)=0; - deltada(6)=0; - - - da=da+ deltada; - - da2=da2+deltada; - - - d1=0.90; % detector width in mm - d2=4.0; % detector length in mm - b1=0.800; % aperture width in mm (pol.) - b2=[8 8 8 15 15 15 15 8 8 8]; - % aperture length in mm (tor.) - b3x=0.020; % aperture thickness in mm (poloidal) - b3y=0; % aperture thickness in mm (toroidal) -end - - - -%======== calculation of the chords of view =================================== - -nact=sum(fans); -iact=find(fans); -ndet=20; -ncam=10; - - - -% ---- apertures: ------------------ - -xap=ones(ndet,1)*xpos(iact); -xap=xap(:)'; -yap=ones(ndet,1)*ypos(iact); -yap=yap(:)'; - -% ---- detectors: ------------------ - -vorz(find(vangle==90))=(-1)^(cw+1)*ones(size(find(vangle==90))); -vorz(find(vangle==0))=(-1)^cw*ones(size(find(vangle==0))); -vorz(find(vangle==-90))=(-1)^cw*ones(size(find(vangle==-90))); - - -dete=(-9.025:0.950:9.025)'/10*vorz(iact)+ones(ndet,1)*ae(iact); - -dum_ae=dete(:)'; - -dum_vangle=ones(ndet,1)*vangle(iact); -dum_vangle=dum_vangle(:)'; - - - -ivert=find(dum_vangle==90 | dum_vangle==-90); -ihori=find(dum_vangle==0); - -dum_da=ones(ndet,1)*da(iact); -dum_da=dum_da(:)'; - -dxd=zeros(1,ndet*nact); -dyd=zeros(1,ndet*nact); - -dxd(ivert)=dum_ae(ivert); -dxd(ihori)=dum_da(ihori); - -dyd(ivert)=dum_da(ivert); -dyd(ihori)=dum_ae(ihori); - -xdet=xap+dxd; -ydet=yap+dyd; - - -%plot_vessel(rzvin,rzvout) -%hold on -% plot(xap,yap,'.g',xdet,ydet,'.m') - - -% ---- calculate the equations of lines of sight - -m=(ydet-yap)./(xdet-xap); -b=ydet-m.*xdet; - -nl=length(xdet); -xchord=zeros(2,nl); -ychord=zeros(2,nl); - - -xchord(1,:)=xdet;ychord(1,:)=ydet; - -iup=find(dum_vangle==90); -isi=find(dum_vangle==0); -ido=find(dum_vangle==-90); - -if ~isempty(iup) -ychord(2,iup)=ymin*ones(size(iup)); -xchord(2,iup)=(ychord(2,iup)-b(iup))./m(iup); -end -if ~isempty(ido) -ychord(2,ido)=ymax*ones(size(ido)); -xchord(2,ido)=(ychord(2,ido)-b(ido))./m(ido); -end -if ~isempty(isi) -xchord(2,isi)=xmin*ones(size(isi)); -ychord(2,isi)=m(isi).*xchord(2,isi)+b(isi); -end - -ileft=find(xchord(2,:)<xmin); - -if ~isempty(ileft) -xchord(2,ileft)=xmin*ones(size(ileft)); -ychord(2,ileft)=m(ileft).*xchord(2,ileft)+b(ileft); -end -irig=find(xchord(2,:)>xmax); -if ~isempty(irig) -xchord(2,irig)=xmax*ones(size(irig)); -ychord(2,irig)=m(irig).*xchord(2,irig)+b(irig); -end - - - -%======== prepare output ====================================================== - -vangle=vangle(iact); - -%======== calculation of angular correction factors, if necessary ============= - -if i_detec==2 & exist('angular_fact_2.mat')==2 - - disp('loading angular_fact_2') - load angular_fact_2 - - -elseif i_detec==1 & exist('angular_fact_1.mat')==2 - - disp('loading angular_fact_1') - load angular_fact_1 - -else - - aomega=zeros(ndet,ncam); - angfact=ones(ndet,ncam); - - - for l=1:sum(fans) - -% Z0X=abs(da(iact(l))*10) -% Z0Y=abs(da2(iact(l))*10) -% X0=ae(iact(l))*10 % back to mm, sorry about that... -% X0=X0*vorz(iact(l)) -% B2=b2(iact(l)) -% AOMEGA=etendue_n(b1,B2,b3x,b3y,Z0X,Z0Y,X0,cw); - - b1x=0.8; - b1y=6; - b1z=0.02; - b2x=10000000; - b2y=b2(iact(l)); - b2z=0; - z01=abs(da(iact(l))*10); - z02=abs(da2(iact(l))*10); - X0=ae(iact(l))*10*vorz(iact(l)); -keyboard - AOMEGA=etendue_n2(b1x,b1y,b1z,b2x,b2y,b2z,z01,z02,X0,cw); - - aomega(:,iact(l))=AOMEGA(:,1); - - - end - - - indm=min(find(aomega==max(aomega(:)))); - aomegan=aomega/aomega(indm); - nonz=find(aomega); - angfact(nonz)=ones(size(nonz))./aomegan(nonz); - - angfact=round(1000*angfact)/1000; - - - unitstring='units aomega: mm^2 * sterad'; - - if i_detec==1 - save angular_fact_1 angfact aomega unitstring - elseif i_detec==2 - save angular_fact_2 angfact aomega unitstring - end - -end -return - -th=atan(diff(ychord)./diff(xchord)); -thp=th; -neg=find(thp<0); -thp(neg)=180+thp(neg); -thdet=ones(1,20*sum(fans)); -for k=1:sum(fans) - thdet((k-1)*20+1:k*20)=vangle(k)*ones(1,20); -end -angles=thdet-thp; -mist=find(angles<0 & abs(angles)>90); -angles(mist)=angles(mist)+180; -th_inc=angles*pi/180; - - -% ---- correct for the edges of tcv ( some chords may be too long ) - - - - - - down=find(xcont>xedge & ycont<-yedge); - up=find(xcont>xedge & ycont>yedge); - cd=polyfit(xcont(down),ycont(down),1); - cu=polyfit(xcont(up),ycont(up),1); - - - iu1=find(xchord(1,:)>xedge & ychord(1,:)>0 & dum_vangle==-90 ); - if ~isempty(iu1) - xchord(1,iu1)=-(b(iu1)-cu(2))./(m(iu1)-cu(1)+eps); - ychord(1,iu1)=m(iu1).*xchord(1,iu1)+b(iu1); - end - - iu2=find(xchord(2,:)>xedge & ychord(2,:)>0 & ychord(1,:) & .... - dum_vangle==-90); - if ~isempty(iu2) - xchord(2,iu2)=-(b(iu2)-cu(2))./(m(iu2)-cu(1)+eps); - ychord(2,iu2)=m(iu2).*xchord(2,iu2)+b(iu2); - end - - id1=find(xchord(1,:)>xedge & ychord(1,:)<0 & dum_vangle==90); - if ~isempty(id1) - xchord(1,id1)=-(b(id1)-cd(2))./(m(id1)-cd(1)+eps); - ychord(1,id1)=m(id1).*xchord(1,id1)+b(id1); - end - - id2=find(xchord(2,:)>xedge & ychord(2,:)<0 & dum_vangle==90); - if ~isempty(id2) - xchord(2,id2)=-(b(id2)-cd(2))./(m(id2)-cd(1)+eps); - ychord(2,id2)=m(id2).*xchord(2,id2)+b(id2); - end - - ilow=find(ychord(1,:)<ymin); - ihig=find(ychord(1,:)>ymax); - ilef=find(xchord(1,:)<xmin); - irig=find(xchord(1,:)>xmax); - if ~isempty(ilow) - ychord(1,ilow)=ymin*ones(size(ilow)); - xchord(1,ilow)=ymin./m(ilow)-b(ilow)./m(ilow); - end - if ~isempty(ihig) - ychord(1,ihig)=ymax*ones(size(ihig)); - xchord(1,ihig)=ymax./m(ihig)-b(ihig)./m(ihig); - end - if ~isempty(ilef) - xchord(1,ilef)=xmin*ones(size(ilef)); - ychord(1,ilef)=m(ilef)*xmin+b(ilef); - end - if ~isempty(irig) - xchord(1,irig)=xmax*ones(size(irig)); - ychord(1,irig)=m(irig)*xmax+b(irig); - end - - - ilow=find(ychord(2,:)<ymin); - ihig=find(ychord(2,:)>ymax); - ilef=find(xchord(2,:)<xmin); - irig=find(xchord(2,:)>xmax); - if ~isempty(ilow) - ychord(2,ilow)=ymin*ones(size(ilow)); - xchord(2,ilow)=ymin./m(ilow)-b(ilow)./m(ilow); - end - if ~isempty(ihig) - ychord(2,ihig)=ymax*ones(size(ihig)); - xchord(2,ihig)=ymax./m(ihig)-b(ihig)./m(ihig); - end - if ~isempty(ilef) - xchord(2,ilef)=xmin*ones(size(ilef)); - ychord(2,ilef)=m(ilef)*xmin+b(ilef); - end - if ~isempty(irig) - xchord(2,irig)=xmax*ones(size(irig)); - ychord(2,irig)=m(irig)*xmax+b(irig); - end - - - - - diff --git a/matlab/liuqefortran2liuqematlab.m b/matlab/liuqefortran2liuqematlab.m index 623d6b520a83785ed10b2fa8b1ce7211ff4883a3..4a337a814222c98ef9707ab403d4547d994bd465 100644 --- a/matlab/liuqefortran2liuqematlab.m +++ b/matlab/liuqefortran2liuqematlab.m @@ -8,7 +8,7 @@ function liuqe_fortran_matlab = liuqefortran2liuqematlab(varargin); % liuqe_fortran_matlab{:,2} give liuqe matlab names % % Note that you can have multiple entries (for liuqe fortran since it has less nodes) but the first one should be the closest match (see r_contour/r_rho/r_surf) -% +% % varargin: If absent, then return full table % varargin{1}: 'node_name_to_convert' % varargin{2}: origin of node_name given=varargin{1}: 0: fortran, 1(default): matlab @@ -27,6 +27,7 @@ function liuqe_fortran_matlab = liuqefortran2liuqematlab(varargin); liuqe_fortran_matlab_table = [ ... {'l_i'} , {'l_i_3'} ; ... {'i_p'} , {'i_pl'} ; ... + {'i_pol_fit'} , {'i_pol'} ; ... {'pprime_psi'} , {'pprime_rho'} ; ... % warning on different x-mesh {'surface_flux'} , {'psi_surf'} ; ... {'q_zero'} , {'q_axis'} ; ... diff --git a/matlab/subcall_all2str.m b/matlab/subcall_all2str.m index 6e5d1ee125d25ccaad650eb1ba91d844a6c8ebd4..8966d184da44bc48e0c6973f93e9f0c7e8742ab0 100644 --- a/matlab/subcall_all2str.m +++ b/matlab/subcall_all2str.m @@ -56,11 +56,7 @@ for i_in=1:length(varargin) elseif ischar(var_to_treat) subcall = [subcall ',''' var_to_treat '''']; elseif iscell(var_to_treat) - subcall = [subcall ',{''' var_to_treat{1} '''']; - for i=2:length(var_to_treat) - subcall = [subcall ',''' var_to_treat{i} '''']; - end - subcall = [subcall '}']; + subcall = [subcall ',' cell2str(var_to_treat,3) '']; else warning('in subcall_all2str: case not foreseen'); end diff --git a/matlab/tests/test_requestnames.m b/matlab/tests/test_requestnames.m index 63595919b38cbbbedf2ad19c8636348badc1df83..557144ccdb55fdc352bb83cf17315892f15429ad 100644 --- a/matlab/tests/test_requestnames.m +++ b/matlab/tests/test_requestnames.m @@ -1,48 +1,63 @@ classdef (SharedTestFixtures={... check_mds,check_gdatpaths}) ... test_requestnames < matlab.unittest.TestCase - + properties (Abstract) Machine; end - + properties(TestParameter,Abstract) % parameters that will vary during tests shot; requests_fast; % placeholders requests_slow; end - + methods(Static) function test_gdat_call(testCase,shot,request) % actual function to test gdat call testCase.assertTrue(isnumeric(str2double(shot))); testCase.assertTrue(ischar(request)); - + % gdat call gdat_call = sprintf(['gdat_' lower(testCase.Machine) '(%s,''%s'')'],shot,request); do_gdat_call = 1; - + switch request case 'eqdsk' % avoid writing files in /tmp, may not be allowed gdat_call = sprintf(['gdat_%s(%s,''%s'',''write'',0)'],lower(testCase.Machine),shot,request); + case 'radcam' + % need a newer shot for tcv radcam + shot = 81102; + gdat_call = sprintf(['gdat_' lower(testCase.Machine) '(%s,''%s'')'],shot,request); end - + % logging fprintf('Testing gdat call: %s\n',gdat_call); - + if do_gdat_call gdat_out = eval(gdat_call); %#ok<NASGU> else gdat_out = struct([]); end - + % in some future: check for warnings %gdat_out = verifyWarningFree(testCase,eval(gdat_call),... % 'Warning issued from gdat call:\n %s\n',gdat_call); - + % (add optional sanity checks of gdat_out here) + gdat_out + switch request + case {'ece', 'expcode', 'ids', 'ni', 'ti', 'transp'} + % tests not yet fully implemented and empty + case 'rtc' + % in this case .data is empty, all in .scd_mems + testCase.assertTrue(isfield(gdat_out,'scd_mems') && isstruct(gdat_out.scd_mems)); + % testCase.assertTrue(isstruct(gdat_out.scd_mems)); + otherwise + testCase.assertTrue(isnumeric(gdat_out.data) & numel(gdat_out.data)>0); + end end end -end \ No newline at end of file +end diff --git a/matlab/tests/test_requestnames_tcv.m b/matlab/tests/test_requestnames_tcv.m index f40ecbfa9348473a86ef5552e37e9ad0340510a7..6941e96ddac1f9ae3cc07d32ee0dc76e58b0c5d5 100644 --- a/matlab/tests/test_requestnames_tcv.m +++ b/matlab/tests/test_requestnames_tcv.m @@ -11,17 +11,17 @@ classdef (TestTags={'tcv'})test_requestnames_tcv < test_requestnames requests_fast = get_all_gdat_requests('TCV','fast'); requests_slow = get_all_gdat_requests('TCV','slow'); end - + methods(Test,TestTags = {'fast'}) function test_gdat_call_fast(testCase,shot,requests_fast) testCase.test_gdat_call(testCase,shot,requests_fast); end end - + methods(Test,TestTags = {'slow'}) function test_gdat_call_slow(testCase,shot,requests_slow) testCase.test_gdat_call(testCase,shot,requests_slow); end end - + end