diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m index 8db337c55598e313deb6ae616276e0b88690ef21..d420874e2ec971f3de90f8a3371f3098bee6c7c7 100644 --- a/matlab/TCV/gdat_tcv.m +++ b/matlab/TCV/gdat_tcv.m @@ -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 @@ -1247,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 @@ -1525,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{:})]); @@ -1571,7 +1571,7 @@ 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); @@ -1587,23 +1587,23 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') 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 + 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; - + 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 strcmp(lower(source_icd.ec),'toray') 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,... @@ -1695,7 +1695,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') 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_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'); @@ -1736,13 +1736,13 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') 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(ME.identifier,'Problem retrieving TORAY data. \nError message: %s',ME.message); % try to identify cause of the error - if ~check_nodes_filled(shot,'toray') + 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 @@ -1755,16 +1755,16 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end warning(msg); gdat_data.ec.help = msg; - end + end else 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 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]); @@ -1785,9 +1785,9 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') 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_label = []; @@ -1816,7 +1816,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') ec_data.width_cd_dens_label = []; ec_data.cd_dens_doublewidth = []; ec_data.cd_dens_doublewidth_label = []; - ec_data.rho_tor_norm = []; + ec_data.rho_tor_norm = []; gdat_data.ec.ec_data = ec_data; return end @@ -2501,7 +2501,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{:})]);