diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m index cc515708ff3ca0a4ad564e185b9223505664af58..e7ab04f1c2cc6789950a62dce34bfc3af88dbd9c 100644 --- a/matlab/TCV/gdat_tcv.m +++ b/matlab/TCV/gdat_tcv.m @@ -83,6 +83,7 @@ varargout{1}=cell(1,1); error_status=1; % construct main default parameters structure +% parameters and defaults related to a specific request should be defined in the relevant switch case section gdat_params.data_request = ''; default_machine = 'tcv'; @@ -1511,7 +1512,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') if ~isempty(gdat_data.gdat_params.trialindx) && gdat_data.gdat_params.trialindx < 0 gdat_data.gdat_params.trialindx = []; end - + % specific parameters check and default settings if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) switch data_request_eff case 'ec_data' @@ -1548,6 +1549,10 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end end end + if ~isfield(gdat_data.gdat_params,'ec_inputs') || isempty(gdat_data.gdat_params.ec_inputs) || ~isnumeric(gdat_data.gdat_params.ec_inputs) + gdat_data.gdat_params.ec_inputs = 0; + end + gdat_params.ec_inputs = gdat_data.gdat_params.ec_inputs; % create structure for icd sources from params and complete with defaults source_icd.ec = 'toray'; @@ -1572,32 +1577,41 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') 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)'; + if gdat_data.gdat_params.ec_inputs + % 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.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'; + ec_inputs.freq2launcher.data = freq2launcher; + ec_inputs.freq2launcher.label = 'Frequency in launcher'; + ec_inputs.freq2launcher.units = 'Hz'; + ec_inputs.comment = 'ec_inputs loaded from write_pyro(shot)'; + else + ec_inputs.pgyro = []; + ec_inputs.launchers_active = []; + ec_inputs.gyro2launcher = []; + ec_inputs.freq2launcher = []; + ec_inputs.comment = 'Run gdat with name-value pair (''ec_inputs'',1) for ec_input information from write_pgyro'; + end gdat_data.ec.ec_inputs = ec_inputs; % introduce flag to check whether ec_data could be retrieved successfully @@ -1744,10 +1758,12 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') 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.'; + if ~isempty(ec_inputs.launchers_active) + 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 not filled, check hldsi(shot), and (ask to) relaunch TORAY.'; + end end elseif ~isempty(gdat_data.gdat_params.trialindx) msg = 'Is the trial index filled? Check TORAY nodes with hdlsi(shot).'; diff --git a/matlab/TCV/tcv_help_parameters.m b/matlab/TCV/tcv_help_parameters.m index 15de8984169996ffdd2c5f1ea0e1b99a310aaa33..f864a08468e84d120646871535122a4e2c54b2e4 100644 --- a/matlab/TCV/tcv_help_parameters.m +++ b/matlab/TCV/tcv_help_parameters.m @@ -39,6 +39,7 @@ help_struct_all.cocos = ['cocos value desired in output, uses eqdsk_cocos_transf 'is wanted. See O. Sauter et al Comput. Phys. Commun. 184 (2013) 293']; help_struct_all.nrz_out = 'Nb of radial and vertical points in output eqdsk, default is [129,129], set to [-1,-1] to get original meshes'; help_struct_all.edge = '0 (default), 1 to get edge Thomson values'; +help_struct_all.ec_inputs = '0 (default), 1 to get characterics of gyrotrons connected to each launcher: active, freq, power'; help_struct_all.fit = '0, no fit profiles, 1 (default) if fit profiles desired as well, relevant for _rho profiles. See also fit_type'; help_struct_all.fit_type = 'provenance of fitted profiles ''conf'' (default) from conf nodes, ''avg'' or ''local'' for resp. proffit: nodes'; help_struct_all.trialindx = 'value of trialindx desired to get a specific one when relevant, otherwise gets ok_trialindx, that is 1 usually'; diff --git a/matlab/gdat.m b/matlab/gdat.m index e21551bfb14986490b743ed75d0a0fe12fa88cdb..99271c743677156ce27598a06bda6a42cf7e88a1 100644 --- a/matlab/gdat.m +++ b/matlab/gdat.m @@ -190,14 +190,18 @@ try % treat multiple shot numbers if nargin > 0 && isnumeric(shot) args_in = args; - for i=1:numel(shot) - args{1} = shot(i); - [gdat_data_i,gdat_params,error_status(i),varargout] = feval(['gdat_' lower(machine_eff)],args{:}); - gdat_data_i.gdat_params.machine = lower(gdat_data_i.gdat_params.machine); - gdat_data(i) = gdat_data_i; + if ~isempty(shot) + for i=1:numel(shot) + args{1} = shot(i); + [gdat_data_i,gdat_params,error_status(i),varargout_gdat] = feval(['gdat_' lower(machine_eff)],args{:}); + gdat_data_i.gdat_params.machine = lower(gdat_data_i.gdat_params.machine); + gdat_data(i) = gdat_data_i; + end + else + [gdat_data,gdat_params,error_status,varargout_gdat] = feval(['gdat_' lower(machine_eff)],args{:}); end else - [gdat_data,gdat_params,error_status,varargout] = feval(['gdat_' lower(machine_eff)],args{:}); + [gdat_data,gdat_params,error_status,varargout_gdat] = feval(['gdat_' lower(machine_eff)],args{:}); % because data request can be an actual detailed tree related signal, upper and lower case need to be kept, but other places remain with lower case when case insensitive % needed since some substructure have machine name like mapping_for gdat_data.gdat_params.machine = lower(gdat_data.gdat_params.machine);