From f3a85a947623e4f148fe65e51c3ebd316920a632 Mon Sep 17 00:00:00 2001 From: Antonia Frank <antonia.frank@epfl.ch> Date: Fri, 9 Aug 2024 16:01:42 +0200 Subject: [PATCH] Make global_quantities cell arrays again --- matlab/TCV_IMAS/tcv_get_ids_core_sources.m | 53 ++++++++++------------ 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/matlab/TCV_IMAS/tcv_get_ids_core_sources.m b/matlab/TCV_IMAS/tcv_get_ids_core_sources.m index 7954fa19..a904007c 100644 --- a/matlab/TCV_IMAS/tcv_get_ids_core_sources.m +++ b/matlab/TCV_IMAS/tcv_get_ids_core_sources.m @@ -58,7 +58,7 @@ id_ohm.index = 7; id_ohm.name = 'ohmic'; ids_core_sources.source{last_index+1} = source_template; ids_core_sources.source{last_index+1}.identifier = id_ohm; ids_core_sources.source{last_index+1}.profiles_1d(1:ohm_n_t) = {profiles_template}; -ids_core_sources.source{last_index+1}.global_quantities = globals_template; +ids_core_sources.source{last_index+1}.global_quantities(1:ohm_n_t) = globals_template; ohm_data = ohm_gdat.ohm.ohm_data; % load LIUQE data to convert @@ -76,9 +76,8 @@ jpar_tilde_to_jpar_0 = R0*T.*Rm2_fs./B0'; jpar_tilde_to_jpar_0_mapped = interp1(rho_pol_norm_liu,jpar_tilde_to_jpar_0,ohm_data.cd_dens.rhopol_norm'); vol_mapped = interp1(rho_pol_norm_liu,vol,ohm_data.cd_dens.rhopol_norm'); -% profiles_1d -current_parallel_tmp = nan(1,ohm_n_t); for ii = 1:ohm_n_t + % profiles_1d ids_core_sources.source{last_index+1}.profiles_1d{ii}.time = ohm_t_grid(ii); ids_core_sources.source{last_index+1}.profiles_1d{ii}.grid.rho_pol_norm = ... ohm_data.cd_dens.rhopol_norm'; @@ -88,13 +87,12 @@ for ii = 1:ohm_n_t ids_core_sources.source{last_index+1}.profiles_1d{ii}.j_parallel = jpar_0_tmp; integrated_jpar_0_tmp = cumtrapz(vol_mapped(:,ii),jpar_0_tmp)/2/pi/R0; ids_core_sources.source{last_index+1}.profiles_1d{ii}.current_parallel_inside = integrated_jpar_0_tmp; - current_parallel_tmp(ii) = integrated_jpar_0_tmp(end); -end -% globals -ids_core_sources.source{last_index+1}.global_quantities.time = ohm_t_grid; -ids_core_sources.source{last_index+1}.global_quantities.power = powers_gdat.ohm.data; -ids_core_sources.source{last_index+1}.global_quantities.current_parallel = current_parallel_tmp; + % globals + ids_core_sources.source{last_index+1}.global_quantities{ii}.time = ohm_t_grid(ii); + ids_core_sources.source{last_index+1}.global_quantities{ii}.power = powers_gdat.ohm.data(ii); + ids_core_sources.source{last_index+1}.global_quantities{ii}.current_parallel = integrated_jpar_0_tmp(end); +end last_index = last_index+1; % add if statement to only increment if ohmic source has been added @@ -109,11 +107,10 @@ id_bs.index = 13; id_bs.name = 'bootstrap_current'; ids_core_sources.source{last_index+1} = source_template; ids_core_sources.source{last_index+1}.identifier = id_bs; ids_core_sources.source{last_index+1}.profiles_1d(1:bs_n_t) = {profiles_template}; -ids_core_sources.source{last_index+1}.global_quantities = globals_template; +ids_core_sources.source{last_index+1}.global_quantities(1:bs_n_t) = globals_template; -% profiles_1d -current_parallel_tmp = nan(1,bs_n_t); for ii = 1:bs_n_t + % profiles_1d ids_core_sources.source{last_index+1}.profiles_1d{ii}.time = bs_t_grid(ii); ids_core_sources.source{last_index+1}.profiles_1d{ii}.grid.rho_pol_norm = ... bs_data.cd_dens.rhopol_norm'; @@ -124,12 +121,11 @@ for ii = 1:bs_n_t ids_core_sources.source{last_index+1}.profiles_1d{ii}.j_parallel = jpar_0_tmp; integrated_jpar_0_tmp = cumtrapz(vol_mapped(:,ii),jpar_0_tmp)/2/pi/R0; ids_core_sources.source{last_index+1}.profiles_1d{ii}.current_parallel_inside = integrated_jpar_0_tmp; - current_parallel_tmp(ii) = integrated_jpar_0_tmp(end); -end -% globals -ids_core_sources.source{last_index+1}.global_quantities.time = bs_t_grid; -ids_core_sources.source{last_index+1}.global_quantities.current_parallel = current_parallel_tmp; + % globals + ids_core_sources.source{last_index+1}.global_quantities{ii}.time = bs_t_grid(ii); + ids_core_sources.source{last_index+1}.global_quantities{ii}.current_parallel = integrated_jpar_0_tmp(end); +end last_index = last_index+1; % add if statement to only increment if bs source has been added @@ -165,7 +161,7 @@ if ~isempty(ec_gdat.ec.data) % if EC data available, fill sources ids_core_sources.source{last_index+i_lau} = source_template; ids_core_sources.source{last_index+i_lau}.identifier = id_ec; ids_core_sources.source{last_index+i_lau}.profiles_1d(1:nt_interp) = {profiles_template}; - ids_core_sources.source{last_index+i_lau}.global_quantities = globals_template; + ids_core_sources.source{last_index+i_lau}.global_quantities(1:nt_interp) = globals_template; end % load LIUQE data to convert @@ -271,15 +267,10 @@ if ~isempty(ec_gdat.ec.data) % if EC data available, fill sources interp_cd_integrated(:,:,it) = interp_norm_cd_integrated(:,:,it).*interp_p_ec_injected(it,:); end - % fill profiles_1d with interpolated profiles + % fill the ids entries for i_lau = active_launchers - % initialize var for current_parallel and coupled power which needs to be obatined from - % integrated j// profiles and pdens last entry - current_parallel_tmp = nan(1,nt_interp); - power_coupled_tmp = nan(1,nt_interp); - for ii = 1:nt_interp - % time + % 1d_profiles ids_core_sources.source{last_index+i_lau}.profiles_1d{ii}.time = interp_tgrid(ii); % grids ids_core_sources.source{last_index+i_lau}.profiles_1d{ii}.grid.rho_tor_norm = interp_rho_tor(:,ii); @@ -290,18 +281,20 @@ if ~isempty(ec_gdat.ec.data) % if EC data available, fill sources % integrated power density ids_core_sources.source{last_index+i_lau}.profiles_1d{ii}.electrons.power_inside = ... interp_p_integrated(:,i_lau,ii); - power_coupled_tmp(ii) = interp_p_integrated(end,i_lau,ii); + power_coupled_tmp = interp_p_integrated(end,i_lau,ii); % current density ids_core_sources.source{last_index+i_lau}.profiles_1d{ii}.j_parallel = ... interp_cd_dens(:,i_lau,ii); % integrated current density ids_core_sources.source{last_index+i_lau}.profiles_1d{ii}.current_parallel_inside = ... interp_cd_integrated(:,i_lau,ii); - current_parallel_tmp(ii) = interp_cd_integrated(end,i_lau,ii); + current_parallel_tmp = interp_cd_integrated(end,i_lau,ii); + + % globals + ids_core_sources.source{last_index+i_lau}.globa_quantities{ii}.time = interp_tgrid(ii); + ids_core_sources.source{last_index+i_lau}.global_quantities{ii}.power = power_coupled_tmp; + ids_core_sources.source{last_index+i_lau}.global_quantities{ii}.current_parallel = current_parallel_tmp; end - ids_core_sources.source{last_index+i_lau}.globa_quantities.time = interp_tgrid; - ids_core_sources.source{last_index+i_lau}.global_quantities.power = power_coupled_tmp; - ids_core_sources.source{last_index+i_lau}.global_quantities.current_parallel = current_parallel_tmp; end %add empty sources for rest of unsused launchers -- GitLab