diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m index f63188553a2438b53e41bb21dd9a95cccad3d434..8ce621c5708f9a2b75df0b45afb5920ee67795b5 100644 --- a/matlab/TCV/gdat_tcv.m +++ b/matlab/TCV/gdat_tcv.m @@ -3303,6 +3303,13 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'rtc'} % load all real-time memory signals for various nodes + if ~isfield(gdat_data.gdat_params,'source') + gdat_data.gdat_params.source = {'Actuator_state','plasma_state','samone_out'}; + else + if ischar(gdat_data.gdat_params.source) || isstring(gdat_data.gdat_params.source) + gdat_data.gdat_params.source = {char(gdat_data.gdat_params.source)}; + end + end %Get the data from mds and fill the data structure defined by %define_simulink_signals @@ -3315,7 +3322,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') error('no path for get_scd_mems') end - aa = get_scd_mems(shot); + aa = get_scd_mems(shot,gdat_data.gdat_params.source); if isstruct(aa) scd_names = fieldnames(aa); for i=1:length(scd_names) diff --git a/matlab/TCV/tcv_help_parameters.m b/matlab/TCV/tcv_help_parameters.m index f864a08468e84d120646871535122a4e2c54b2e4..d5aae64ee63a7901ada13849abc97a3d92f1b173 100644 --- a/matlab/TCV/tcv_help_parameters.m +++ b/matlab/TCV/tcv_help_parameters.m @@ -47,7 +47,7 @@ help_struct_all.source = sprintf('%s\n','cxrs: [1 2 3] (default systems);', ... 'sxr: main source: ''MPX'' (default) or ''XTOMO'', case insensitive', ... 'mhd request: ''23'':23 LFS/HFS (default), ''23full'': 23cm sector 3 and 11, ''0'':z=0 LFS/HFS, ''0full'': 0cm sector 3 and 11', ... 'powers: ohmic in any case + ''ec'', ''nbi'', ''rad'' ', ... - 'rtc: defined, all, adcs', ... + 'rtc: defines which pattern(s) to search for (default: {''Actuator_state'',''plasma_state'',''samone_out''}, empty to have all', ... 'transp: source provides the netcdf file', ... 'icds: ''ec'', ''nbi'' ', ... 'ids_names: for request ''ids'' like magnetics, equilibrium, etc', ... @@ -69,6 +69,7 @@ help_struct_all.max_adcs = 'rtc: source=''adcs'' maximum nb of adc channels load 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.rtc = 'load data from mems saved by SCD system (if on for that shot), source defines what to search for'; %help_struct_all. = ''; if ~exist('parameter_list') || isempty(parameter_list) diff --git a/matlab/TCV_IMAS/tcv_get_ids_core_sources.m b/matlab/TCV_IMAS/tcv_get_ids_core_sources.m index 6f630945d23ad81bdf831e41bc201d4ec6e3602f..6256bafbceffc2b7449422bbd0feb0a3efe5a04d 100644 --- a/matlab/TCV_IMAS/tcv_get_ids_core_sources.m +++ b/matlab/TCV_IMAS/tcv_get_ids_core_sources.m @@ -380,61 +380,64 @@ if ~isempty(ec_gdat.ec.data) % if EC data available, fill sources end %% NBI. same tgrid for NBI1 and NBI2 - check_nbi = [~isempty(powers_gdat.nbi1.data),~isempty(powers_gdat.nbi2.data)]; active_nbi = find(check_nbi==1); nb_nbi = numel(check_nbi); nbi_names = {'nbi1','nbi2'}; -if numel(active_nbi)>0 - % get tgrid (same for NBI1 & 2 if both active) from active_nbi(1) - nbi_powers_tgrid = powers_gdat.(nbi_names{active_nbi(1)}).t; - % find times where NBI is on to define time grid with extra time slice just - % before/after NBI power and at start/end of shot - itime_nbi = find((powers_gdat.(nbi_names{active_nbi(1)}).data>0)); - if nbi_powers_tgrid(itime_nbi(end))>=ohm_tgrid(end) - i_time_end = iround(nbi_powers_tgrid,ohm_tgrid(end)); - nbi_tgrid_out = [ohm_tgrid(1),nbi_powers_tgrid(itime_nbi(1)-1:i_time_end)']; - else - nbi_tgrid_out = [ohm_tgrid(1),nbi_powers_tgrid(itime_nbi(1)-1:itime_nbi(end)+1)',ohm_tgrid(end)]; - end - nt_nbi_out = numel(nbi_tgrid_out); - - % Setup source structs for active nbi from template - main_desc = 'Source from Neutral Beam Injection'; - id_nbi.index = 2; id_nbi.name = 'nbi'; - for i_nbi = active_nbi - id_nbi.description = sprintf('NBI%i %s',i_nbi,main_desc); - ids_core_sources.source{last_index+i_nbi} = source_template; - ids_core_sources.source{last_index+i_nbi}.identifier = id_nbi; - ids_core_sources.source{last_index+i_nbi}.profiles_1d(1:nt_nbi_out) = {profiles_template}; - ids_core_sources.source{last_index+i_nbi}.global_quantities(1:nt_nbi_out) = {globals_template}; - end +% Setup source structs for active nbi from template +main_desc = 'Source from Neutral Beam Injection'; +id_nbi.index = 2; id_nbi.name = 'nbi'; - disp('Loading of current & power densities from ASTRA not implemented yet.') - disp('Checking if ASTRA run available on partition /Lac8_D:') - [~,hostname] = unix('hostname'); - if strcmp(hostname,'lac8.epfl.ch') - unix(sprintf('ls /Lac8_D/ASTRA/ | grep ''%i'' && echo File for shotnumber exists! || echo File for shotnumber does not exist!',shot)); - else - unix(sprintf('ssh $(whoami)@lac8 "ls /Lac8_D/ASTRA/ | grep ''%i'' && echo File for shotnumber exists! || echo File for shotnumber does not exist! && exit"',shot)); - end +disp('Loading of current & power densities from ASTRA not implemented yet.') +disp('Checking if ASTRA run available on partition /Lac8_D:') +[~,hostname] = unix('hostname'); +if strcmp(hostname,'lac8.epfl.ch') + unix(sprintf('ls /Lac8_D/ASTRA/ | grep ''%i'' && echo File for shotnumber exists! || echo File for shotnumber does not exist!',shot)); +else + unix(sprintf('ssh $(whoami)@lac8 "ls /Lac8_D/ASTRA/ | grep ''%i'' && echo File for shotnumber exists! || echo File for shotnumber does not exist! && exit"',shot)); +end +if numel(active_nbi)>0 for i_nbi = active_nbi - p_nbi_injected_tmp = interpos(nbi_powers_tgrid,powers_gdat.(nbi_names{i_nbi}).data,nbi_tgrid_out); - for ii = 1:nt_nbi_out - % globals - ids_core_sources.source{last_index+i_nbi}.global_quantities{ii}.time = nbi_tgrid_out(ii); - ids_core_sources.source{last_index+i_nbi}.global_quantities{ii}.power = p_nbi_injected_tmp(ii); + % get tgrid (same for NBI1 & 2 if both active) from active_nbi(1) + nbi_powers_tgrid = powers_gdat.(nbi_names{i_nbi}).t; + % find times where NBI is on to define time grid with extra time slice just + % before/after NBI power and at start/end of shot + itime_nbi = find((powers_gdat.(nbi_names{i_nbi}).data>0)); + if ~isempty(itime_nbi) + if nbi_powers_tgrid(itime_nbi(end))>=ohm_tgrid(end) + i_time_end = iround(nbi_powers_tgrid,ohm_tgrid(end)); + nbi_tgrid_out = [ohm_tgrid(1),nbi_powers_tgrid(itime_nbi(1)-1:i_time_end)']; + else + nbi_tgrid_out = [ohm_tgrid(1),nbi_powers_tgrid(itime_nbi(1)-1:itime_nbi(end)+1)',ohm_tgrid(end)]; + end + nt_nbi_out = numel(nbi_tgrid_out); + + % Setup source structs for active nbi from template + id_nbi.description = sprintf('NBI%i %s',i_nbi,main_desc); + ids_core_sources.source{last_index+i_nbi} = source_template; + ids_core_sources.source{last_index+i_nbi}.identifier = id_nbi; + ids_core_sources.source{last_index+i_nbi}.profiles_1d(1:nt_nbi_out) = {profiles_template}; + ids_core_sources.source{last_index+i_nbi}.global_quantities(1:nt_nbi_out) = {globals_template}; + + p_nbi_injected_tmp = interpos(nbi_powers_tgrid,powers_gdat.(nbi_names{i_nbi}).data,nbi_tgrid_out); + for ii = 1:nt_nbi_out + % globals + ids_core_sources.source{last_index+i_nbi}.global_quantities{ii}.time = nbi_tgrid_out(ii); + ids_core_sources.source{last_index+i_nbi}.global_quantities{ii}.power = p_nbi_injected_tmp(ii); + end + else + disp('NBI power is zero for all times, skip source.') end end - + % add empty for unused NBI - if numel(ids_core_sources.source)-last_index ~= nb_nbi + if numel(ids_core_sources.source)-last_index == 1 % if 1 then add second empty source for NBI2 ids_core_sources.source{last_index+nb_nbi} = []; end - last_index = last_index+nb_nbi; + last_index = last_index+(numel(ids_core_sources.source)-last_index); end %% DNBI has it's own time grid @@ -444,29 +447,32 @@ if ~isempty(powers_gdat.dnbi) % find times where DNBI is on to define time grid with extra time slice just % before/after DNBI power and at start/end of shot itime_dnbi = find((powers_gdat.dnbi.data>0)); - if dnbi_powers_tgrid(itime_dnbi(end))>=ohm_tgrid(end) - i_time_end = iround(dnbi_powers_tgrid,ohm_tgrid(end)); - dnbi_tgrid_out = [ohm_tgrid(1),dnbi_powers_tgrid(itime_dnbi(1)-1:i_time_end)']; + if ~isempty(itime_dnbi) + if dnbi_powers_tgrid(itime_dnbi(end))>=ohm_tgrid(end) + i_time_end = iround(dnbi_powers_tgrid,ohm_tgrid(end)); + dnbi_tgrid_out = [ohm_tgrid(1),dnbi_powers_tgrid(itime_dnbi(1)-1:i_time_end)']; + else + dnbi_tgrid_out = [ohm_tgrid(1),dnbi_powers_tgrid(itime_dnbi(1)-1:itime_dnbi(end)+1)',ohm_tgrid(end)]; + end + nt_dnbi_out = numel(dnbi_tgrid_out); + + id_dnbi.description = 'DNBI Source from Neutral Beam Injection'; + id_dnbi.index = 2; id_dnbi.name = 'nbi'; + ids_core_sources.source{last_index+1} = source_template; + ids_core_sources.source{last_index+1}.identifier = id_dnbi; + ids_core_sources.source{last_index+1}.profiles_1d(1:nt_dnbi_out) = {profiles_template}; + ids_core_sources.source{last_index+1}.global_quantities(1:nt_dnbi_out) = {globals_template}; + + p_dnbi_injected = interpos(dnbi_powers_tgrid,powers_gdat.dnbi.data,dnbi_tgrid_out); + for ii = 1:nt_dnbi_out + % globals + ids_core_sources.source{last_index+1}.global_quantities{ii}.time = dnbi_tgrid_out(ii); + ids_core_sources.source{last_index+1}.global_quantities{ii}.power = p_dnbi_injected(ii); + end + last_index = last_index+1; else - dnbi_tgrid_out = [ohm_tgrid(1),dnbi_powers_tgrid(itime_dnbi(1)-1:itime_dnbi(end)+1)',ohm_tgrid(end)]; + disp('DNBI power is zero for all times, skip source.') end - nt_dnbi_out = numel(dnbi_tgrid_out); - - id_dnbi.description = 'DNBI Source from Neutral Beam Injection'; - id_dnbi.index = 2; id_dnbi.name = 'nbi'; - ids_core_sources.source{last_index+1} = source_template; - ids_core_sources.source{last_index+1}.identifier = id_dnbi; - ids_core_sources.source{last_index+1}.profiles_1d(1:nt_dnbi_out) = {profiles_template}; - ids_core_sources.source{last_index+1}.global_quantities(1:nt_dnbi_out) = {globals_template}; - - p_dnbi_injected = interpos(dnbi_powers_tgrid,powers_gdat.dnbi.data,dnbi_tgrid_out); - for ii = 1:nt_dnbi_out - % globals - ids_core_sources.source{last_index+1}.global_quantities{ii}.time = nbi_tgrid_out(ii); - ids_core_sources.source{last_index+1}.global_quantities{ii}.power = p_dnbi_injected(ii); - end - - last_index = last_index+1; end %% total